mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
Compare commits
56
Commits
v0.2.0-rc.1
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffacfb75ef | ||
|
|
bc185ec80e | ||
|
|
2cc9d8c862 | ||
|
|
b5c58d82b8 | ||
|
|
c09875c55d | ||
|
|
0c6ee50ff5 | ||
|
|
22d0abe38e | ||
|
|
a56552dd4f | ||
|
|
7874354a15 | ||
|
|
19ae9a7071 | ||
|
|
5b2786c758 | ||
|
|
e85e85d075 | ||
|
|
00e5ea59f4 | ||
|
|
1bd598c791 | ||
|
|
da68e5d67e | ||
|
|
5ad326e13c | ||
|
|
77e0f94f84 | ||
|
|
51e4c795e4 | ||
|
|
f3052e5a8e | ||
|
|
d001f7be0f | ||
|
|
592076cfda | ||
|
|
f0c7449d3b | ||
|
|
1946707e19 | ||
|
|
9f2dda910d | ||
|
|
20f97b10eb | ||
|
|
dd46dd7a0f | ||
|
|
32a3469ed2 | ||
|
|
3c7fbad7a3 | ||
|
|
a8f0517579 | ||
|
|
326660d748 | ||
|
|
de502f7840 | ||
|
|
e4b44b5994 | ||
|
|
80923fc580 | ||
|
|
376f1c2ad7 | ||
|
|
b625469ac6 | ||
|
|
962c183117 | ||
|
|
b3e614743d | ||
|
|
394869407b | ||
|
|
9acdd0c47c | ||
|
|
82f075c5bd | ||
|
|
8e04b1c86d | ||
|
|
99a0ab45bb | ||
|
|
06f72211ef | ||
|
|
336e45defb | ||
|
|
2615a1322b | ||
|
|
7b56231dda | ||
|
|
b66e5d63f8 | ||
|
|
b7178b0dc8 | ||
|
|
654ade131f | ||
|
|
6dd965b475 | ||
|
|
4499c1a926 | ||
|
|
6e36a19058 | ||
|
|
462699a491 | ||
|
|
78716806d4 | ||
|
|
7bb1a114f3 | ||
|
|
6b859825f3 |
No files matched your search
@@ -66,7 +66,7 @@ Write the arguments in the `Use` as a user types them: `PLACEHOLDER`s in capital
|
||||
A command that deletes something the user can't get back asks first, and a script must say so.
|
||||
|
||||
- **It asks unless `--force`.** devvm gc, devvm gc --caches, devvm images rm and devvm secret rm in `internal/cli`, and devvm rm and devvm rebuild in `internal/vm` and `internal/build`, go ahead at once with `--force`, and otherwise ask with `Ask` or `Confirm` and return the question's error. Where devvm can't ask, without a terminal, with `--no-input` or once the input ends, that error is the question's refusal, which shows the question and names `--force`. That refusal is a failure, exit 1, not a usage error.
|
||||
- **It takes `--force` from `addForceFlag`, which only skips the question.** devvm gc --force deletes exactly what devvm gc lists and asks about. `--force` never deletes more, never skips a safety check that isn't the question, and never answers another question.
|
||||
- **It takes `--force` from `addForceFlag`, which only skips the question.** devvm gc --force deletes exactly what devvm gc lists and asks about. The one exception is devvm's own build VMs that a killed or failed tools build left: devvm gc deletes them first without asking, as the next tools build would, because they hold nothing of the user's, and it says which it deleted. `--force` never deletes more, never skips a safety check that isn't the question, and never answers another question.
|
||||
- **Deleting more takes a flag of its own.** devvm gc deletes stale images and unused tool images, and each wider kind has its own flag: `--tool-images` for the current shared tool images no VM has, `--history` for agents' history exports, `--orphans` for what devvm keeps for VMs that their backend no longer has, `--nix-cache` for the shared Nix cache and `--caches` for Lima's own caches. A user reads what a command deletes from its flags.
|
||||
- **Skipping a step takes a flag of its own too.** devvm rm exports the agents' history first, and `--no-export` skips the export, so devvm rm --force still exports.
|
||||
- **Its question is answered by `--force`,** as `AnsweredBy("--force")` declares, so the refusal names `--force`. A question that protects work only the user can judge, such as devvm rm deleting the VM of a folder this one is inside, has no flag, and declares its refusal with `RefusedWith`, a message saying what to run instead.
|
||||
|
||||
@@ -34,8 +34,9 @@ Failures and processes:
|
||||
Changes:
|
||||
|
||||
1. **[Extend the owner, and wait for a third copy.](standards.md#extend-the-owner-and-wait-for-a-third-copy)** Find the owner first, and give a judge one owner at once.
|
||||
2. **[Mind what's already running and released.](standards.md#mind-whats-already-running-and-released)** The CHANGELOG says what a running VM keeps, and a change to state runs on every frozen fixture.
|
||||
2. **[Mind what's already running and released.](standards.md#mind-whats-already-running-and-released)** The CHANGELOG's What to do says what to run for a running VM, and a change to state runs on every frozen fixture.
|
||||
3. **[Claim only what the code does, where precision belongs.](standards.md#claim-only-what-the-code-does-where-precision-belongs)** Precise pages hold every limit, and headline pages keep their short claims.
|
||||
4. **[Add the change's changelog line by audience.](../../../docs/content/docs/contributing/maintaining.md#releasing)** A change that someone could notice adds one outcome sentence and its links to Unreleased, in the group of the people who notice it, and its full story to the release page in `releases/`.
|
||||
|
||||
Tests:
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ These rules are written in [AGENTS.md](../../../AGENTS.md) and the [Contributing
|
||||
| Rule | Written in | Guard |
|
||||
| --- | --- | --- |
|
||||
| Every release's state keeps working, and its frozen fixture is never edited | [Released state](../../../docs/content/docs/contributing/structure.md#released-state) | `TestFixtureVMStates`, `TestFixtureVMsRead`, `TestFixtureSettings`, `TestFixtureAgentStore`, `TestStateFixturesListed`, `TestFixtureScripts` and the `fixture_v*.txtar` scripts, and a review checks that a fixture's files are unchanged |
|
||||
| A change to existing state gets a Breaking entry in the CHANGELOG | [Changing what devvm does with state](../../../docs/content/docs/contributing/structure.md#changing-what-devvm-does-with-state) | review only |
|
||||
| A change to existing state gets a CHANGELOG line, a step in What to do when the user has to act on it | [Changing what devvm does with state](../../../docs/content/docs/contributing/structure.md#changing-what-devvm-does-with-state) | review only |
|
||||
| A change to the layout updates its listing, and a new layout version adds a migration | [Changing the state layout](../../../docs/content/docs/contributing/structure.md#changing-the-state-layout) | `layout.txtar`, `TestMigrations` and `TestCheckLayout` |
|
||||
| Nothing goes in a project folder: state is in devvm's data and config folders | [AGENTS.md's Rules](../../../AGENTS.md#rules) | review only, as the structure test's check of paths covers only devvm's own folders |
|
||||
| devvm never deletes a project VM on its own | [AGENTS.md's Rules](../../../AGENTS.md#rules) | the structure test's `owners` for the VM-name grammar (`vmname.IsVM`), so gc never takes a project VM for an image, and the rest is review only |
|
||||
@@ -109,5 +109,6 @@ These rules are written in [AGENTS.md](../../../AGENTS.md) and the [Contributing
|
||||
| Prose follows the docs voice | [the docs-voice skill](../docs-voice/SKILL.md) | Vale (`AIWords`, `Filler`, `QuotedCommand`) and `TestUserPageProse` in `mise run lint:docs`, and the rest is review only |
|
||||
| User pages name no repo paths, Go identifiers or message names | [Writing docs](../../../docs/content/docs/contributing/docs.md#writing-docs) | review only |
|
||||
| A devvm command line in the repo is one devvm has | [The CLI rule tests](../../../docs/content/docs/contributing/cli.md#the-cli-rule-tests) | `TestCommandLines` |
|
||||
| A change that someone could notice adds its changelog line to Unreleased, in the group of the people who notice it, as one outcome sentence and its links, and its full story to the release page in `releases/` | [Releasing](../../../docs/content/docs/contributing/maintaining.md#releasing) | `TestChangelogShape` checks each entry's groups and their order, its Highlights, its collapsed blocks, each line's words and its `details` link, and full links for issues, while the group a line goes in and its section on the release page are review only |
|
||||
| The CLI reference is generated | [The CLI reference](../../../docs/content/docs/contributing/docs.md#the-cli-reference) | `TestReferenceIsCurrent` |
|
||||
| One commit for each task, in Conventional Commits, with no tracker's IDs | [AGENTS.md's Commits and tasks](../../../AGENTS.md#commits-and-tasks) | CI's PR title job (`.github/workflows/pr-title.yml`) checks a pull request's title, its squashed commit's subject, against AGENTS.md's types, and the rest is review only |
|
||||
@@ -187,10 +187,10 @@ h := proxy.NormHost(given)
|
||||
|
||||
A user upgrades devvm with VMs running and with state from every release since 0.1.0, so a change says what happens to both:
|
||||
|
||||
- **Running VMs.** A change to what devvm runs beside a VM, such as its proxy, its port forwarder, its agent relay or its Lima config, gets a line under After you upgrade in `CHANGELOG.md`'s Unreleased section, saying what a running VM keeps until its next start and what to run to get the change at once. The new devvm still stops, lists and reads the logs of what the old one left running. What devvm does to a running VM follows the start it runs under, not the stored setting, which the user may have changed since.
|
||||
- **Released state.** A change that adds a state field runs the commands that read and write it on each frozen `testdata/v<release>/` fixture, in the same commit, and so does a command the CHANGELOG tells users to run, as [Released state](../../../docs/content/docs/contributing/structure.md#released-state) says. A change to what devvm does with existing state gets a Breaking entry in the CHANGELOG.
|
||||
- **Running VMs.** A change to what devvm runs beside a VM, such as its proxy, its port forwarder, its agent relay or its Lima config, gets a step in What to do in `CHANGELOG.md`'s Unreleased section, saying what to run to get the change at once, and its section on the release page says what a running VM keeps until its next start. The new devvm still stops, lists and reads the logs of what the old one left running. What devvm does to a running VM follows the start it runs under, not the stored setting, which the user may have changed since.
|
||||
- **Released state.** A change that adds a state field runs the commands that read and write it on each frozen `testdata/v<release>/` fixture, in the same commit, and so does a command the CHANGELOG tells users to run, as [Released state](../../../docs/content/docs/contributing/structure.md#released-state) says. A change to what devvm does with existing state gets a line in the CHANGELOG, a step in What to do when the user has to act on it.
|
||||
|
||||
The agent relay, the ssh port that moved to one of the ports browsers refuse, and the proxy that became two processes each needed an After you upgrade line that a review found missing. The ssh config's agent once followed the stored setting rather than the VM's running start, and the settings that devvm mount-cache and devvm network transparent added to `vm.json` went in without a run of either command on 0.1.0's state.
|
||||
The agent relay, the ssh port that moved to one of the ports browsers refuse, and the proxy that became two processes each needed a line on what to do after the upgrade that a review found missing. The ssh config's agent once followed the stored setting rather than the VM's running start, and the settings that devvm mount-cache and devvm network transparent added to `vm.json` went in without a run of either command on 0.1.0's state.
|
||||
|
||||
**Guard:** `TestFixtureScripts` and the `fixture_v*.txtar` scripts run today's commands on each release's state, and `TestV010ProxyConfigsStart` starts a broker and its child from 0.1.0's proxy configs. The CHANGELOG line is review only.
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ devvm's docs should read like a guide a colleague wrote: full sentences that say
|
||||
- **What it does first.** Describe the behavior, then its limits and exceptions. Use negatives for guarantees.
|
||||
- **The reader's order.** Lead a page or section with what the reader wants to do, then how, then the details and edge cases.
|
||||
- **Exact.** Keep every flag, path, command, message, number and limit. Plain wording never means vaguer wording.
|
||||
- **Present tense, current state.** Describe how devvm works now. Don't mention older behavior, what changed or what moved.
|
||||
- **Present tense, current state.** Describe how devvm works now. Don't mention older behavior, what changed or what moved. The one exception is the release pages in `docs/content/docs/releases/`, which tell each change's story, what was wrong and what changed included, as Contributing's Writing docs says.
|
||||
- **House rules.** Write commands as devvm x or in backticks, never in quotes. Never write "please", "note that" or "simply". Use sentence-case headings. Address the reader as "you".
|
||||
|
||||
## Commands first on user pages
|
||||
|
||||
@@ -41,9 +41,9 @@ jobs:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
# npm's downloads for the docs' diagrams (lint:docs runs docs:diagrams), keyed on the lock. npm ci
|
||||
# checks each package against the lock's integrity, and the Docs workflow, which publishes, keeps
|
||||
# no cache.
|
||||
@@ -67,9 +67,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# Only Go and govulncheck, cached apart from the check jobs' full set.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go go:golang.org/x/vuln/cmd/govulncheck
|
||||
cache_key_prefix: mise-v1-vuln
|
||||
# mise run would install the rest of mise.toml's tools first.
|
||||
@@ -77,6 +77,23 @@ jobs:
|
||||
env:
|
||||
MISE_TASK_RUN_AUTO_INSTALL: "false"
|
||||
|
||||
# A release builds to the same bytes twice: scripts/repro-check.sh builds
|
||||
# the commit with scripts/release.sh in the release's pinned container,
|
||||
# once under the runner's podman, as root, and once under its Docker, as
|
||||
# the runner's user, from a repository with a stray tag, then compares
|
||||
# every file and checks that every archive's files are root's. It needs
|
||||
# no mise: the container gets Go and GoReleaser from mise.lock. The
|
||||
# containers' process and memory limits need cgroups v2, with the pids
|
||||
# and memory controllers delegated to the runner's user for podman.
|
||||
repro:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
- run: scripts/repro-check.sh
|
||||
|
||||
# Without cgo, as devvm ships. On Linux the proxy's child confines every
|
||||
# thread of itself through syscall.AllThreadsSyscall, which a build with
|
||||
# cgo, such as the race detector's in the check jobs, refuses: here a
|
||||
@@ -90,9 +107,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# Only Go, cached apart from the check jobs' full set.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go
|
||||
cache_key_prefix: mise-v1-nocgo
|
||||
- run: go test -count=1 ./internal/landlock/... ./internal/proxy/...
|
||||
@@ -113,9 +130,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# Only Go and nilaway, cached apart from the other jobs' tools.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go go:go.uber.org/nilaway/cmd/nilaway
|
||||
cache_key_prefix: mise-v1-nilaway
|
||||
# scripts/nilaway.sh exits 3 on a finding the baseline hasn't, and
|
||||
|
||||
@@ -57,9 +57,9 @@ jobs:
|
||||
persist-credentials: false
|
||||
# Full history, for each page's last updated date.
|
||||
fetch-depth: 0
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go hugo node markdownlint-cli2 vale lychee
|
||||
# The workflow publishes, so no job in it reads a cache another run could have written.
|
||||
cache: false
|
||||
@@ -89,9 +89,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go hugo node
|
||||
# What's published is built from no cache.
|
||||
cache: false
|
||||
@@ -161,9 +161,9 @@ jobs:
|
||||
persist-credentials: false
|
||||
# Full history, for each page's last updated date.
|
||||
fetch-depth: 0
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
# The next step installs only what the build needs.
|
||||
install: false
|
||||
# What's published is built from no cache.
|
||||
|
||||
@@ -50,9 +50,9 @@ jobs:
|
||||
tar -xzf "$RUNNER_TEMP/$f" -C "$HOME/.local"
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
"$HOME/.local/bin/limactl" --version
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
# devvm's image keys are computed while it builds, so the cache key
|
||||
# hashes what goes into them that this checkout fixes: assets/, the
|
||||
# pinned tool lock, e2e's Ubuntu release and Lima's version. A stale
|
||||
|
||||
@@ -68,9 +68,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# Only Go, cached apart from the other workflows' tools.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go
|
||||
cache_key_prefix: mise-v1-fuzz
|
||||
# go test keeps a target's corpus in GOCACHE's fuzz folder, under the
|
||||
|
||||
+46
-22
@@ -1,7 +1,8 @@
|
||||
name: Pins
|
||||
|
||||
# scripts/bump.sh --check once a week: the pins with a newer upstream go in
|
||||
# one open issue, which closes when none is left. It reports and never bumps.
|
||||
# scripts/bump.sh --check once a week: the pins with a newer upstream, and
|
||||
# the shared tools e2e-tools waits for, go in one open issue, which closes
|
||||
# when none is left. It reports and never bumps.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "47 6 * * 1"
|
||||
@@ -26,13 +27,15 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# mise for the dev tools' newest versions; no tools, as nothing builds.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install: false
|
||||
cache: false
|
||||
- name: Check the pins
|
||||
# gh api reads the actions' releases, and mise GitHub's for the dev tools.
|
||||
# The token is for gh api, which reads the actions' releases, mise,
|
||||
# which reads GitHub's for the dev tools, and bump.sh's own calls to
|
||||
# GitHub's API.
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
@@ -48,32 +51,53 @@ jobs:
|
||||
run: |
|
||||
set -euo pipefail
|
||||
title="Pinned versions to bump"
|
||||
# Each outdated pin, under its group's [header], with only the
|
||||
# characters --check's lines use, so no upstream text can end the
|
||||
# issue's code fence (a backtick) or add markup; \133 and \135 are
|
||||
# the brackets, written so no tr reads them as a class.
|
||||
# Only the characters --check's lines use, so no upstream text can
|
||||
# end the issue's code fence (a backtick) or add markup; \047 is
|
||||
# the apostrophe, \133 and \135 the brackets, written so no tr
|
||||
# reads them as a class.
|
||||
keep='0-9A-Za-z.+~_ ()>:/,\047\133\135\n-'
|
||||
# Each outdated pin, under its group's [header].
|
||||
awk '/^\[/ { g = $0; next } index($0, " -> ") { if (g != "") print g; g = ""; print }' \
|
||||
"$RUNNER_TEMP/check.txt" | LC_ALL=C tr -cd '0-9A-Za-z.+~_ ()>:/,\133\135\n-' > "$RUNNER_TEMP/outdated.txt"
|
||||
"$RUNNER_TEMP/check.txt" | LC_ALL=C tr -cd "$keep" > "$RUNNER_TEMP/outdated.txt"
|
||||
# Each shared tool whose newest release e2e-tools waits for.
|
||||
awk 'index($0, " waiting for upstream: ")' "$RUNNER_TEMP/check.txt" |
|
||||
LC_ALL=C tr -cd "$keep" > "$RUNNER_TEMP/waiting.txt"
|
||||
number=$(gh issue list --state open --search "in:title \"$title\"" --json number,title \
|
||||
--jq "map(select(.title == \"$title\")) | .[0].number // empty")
|
||||
if [[ ! -s $RUNNER_TEMP/outdated.txt ]]; then
|
||||
if [[ ! -s $RUNNER_TEMP/outdated.txt && ! -s $RUNNER_TEMP/waiting.txt ]]; then
|
||||
if [[ -n $number ]]; then
|
||||
gh issue close "$number" --comment "Every pin is up to date: scripts/bump.sh --check lists nothing to bump."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
{
|
||||
echo "scripts/bump.sh --check found pins with a newer upstream version:"
|
||||
echo
|
||||
# Four backticks: a line from upstream can't end the block early.
|
||||
echo '````'
|
||||
cat "$RUNNER_TEMP/outdated.txt"
|
||||
echo '````'
|
||||
echo
|
||||
echo "Bump them with \`scripts/bump.sh\`, which applies every patch and minor, or \`scripts/bump.sh TOOL…\`;"
|
||||
echo "its header says which tool moves each pin, and a line marked by hand or only when named says how."
|
||||
echo "Pin bumps change images, so run the \`--from\` tier of the end-to-end tests before merging:"
|
||||
echo "see [Updating pinned versions](https://devvm.dev/docs/contributing/maintaining/#updating-pinned-versions)."
|
||||
if [[ -s $RUNNER_TEMP/outdated.txt ]]; then
|
||||
echo "scripts/bump.sh --check found pins with a newer upstream version:"
|
||||
echo
|
||||
# Four backticks: a line from upstream can't end the block early.
|
||||
echo '````'
|
||||
cat "$RUNNER_TEMP/outdated.txt"
|
||||
echo '````'
|
||||
echo
|
||||
echo "Bump them with \`scripts/bump.sh\`, which applies every patch and minor, or \`scripts/bump.sh TOOL…\`;"
|
||||
echo "its header says which tool moves each pin, and a line marked by hand or only when named says how."
|
||||
echo "Pin bumps change images, so run the \`--from\` tier of the end-to-end tests before merging:"
|
||||
echo "see [Updating pinned versions](https://devvm.dev/docs/contributing/maintaining/#updating-pinned-versions)."
|
||||
fi
|
||||
if [[ -s $RUNNER_TEMP/waiting.txt ]]; then
|
||||
[[ ! -s $RUNNER_TEMP/outdated.txt ]] || echo
|
||||
echo "## Waiting for upstream"
|
||||
echo
|
||||
echo "These shared tools' newest releases aren't published for every platform yet, so \`e2e-tools\` waits for them:"
|
||||
echo
|
||||
echo '````'
|
||||
cat "$RUNNER_TEMP/waiting.txt"
|
||||
echo '````'
|
||||
echo
|
||||
echo "While a tool waits, a plain \`scripts/bump.sh\` stops at \`e2e-tools\`, so bump the others by name."
|
||||
echo "A wait usually ends within a few days. One still here after two weeks needs a look:"
|
||||
echo "see [Updating pinned versions](https://devvm.dev/docs/contributing/maintaining/#updating-pinned-versions)."
|
||||
fi
|
||||
} > "$RUNNER_TEMP/body.md"
|
||||
if [[ -n $number ]]; then
|
||||
gh issue edit "$number" --body-file "$RUNNER_TEMP/body.md"
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
permissions:
|
||||
pull-requests: read
|
||||
steps:
|
||||
- uses: amannn/action-semantic-pull-request@2252a14e810aa9b85c2d560bd7070c802206ecf6 # v6.1.2
|
||||
- uses: amannn/action-semantic-pull-request@66e72920af32222769c386d81f89656ebcb6d6d5 # v6.1.4
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
name: Release
|
||||
|
||||
# CI's half of each devvm release. For a pushed release tag, v<version>, it checks the tag's SSH
|
||||
# signature against the signers in the release environment's variable RELEASE_TAG_SIGNERS, never a
|
||||
# list from the tagged commit, builds the release with scripts/release.sh --tag in its pinned
|
||||
# container, signs SHA256SUMS with CI's release key, the environment's secret RELEASE_CI_KEY, adds
|
||||
# a GitHub artifact attestation of every file, and hands SHA256SUMS, its signature and the files it
|
||||
# lists over as the artifact release. It publishes nothing: its token can only read the repo, and
|
||||
# the co-signer, a machine of the maintainer's, finds this run, rebuilds the release, and signs,
|
||||
# makes and publishes it only when its own build matches
|
||||
# (docs/content/docs/contributing/cosigner.md). The release environment needs the maintainer's
|
||||
# approval for each run, and only v* tags may use it (docs/content/docs/contributing/maintaining.md's
|
||||
# CI's release workflow).
|
||||
#
|
||||
# The published base's workflow, base.yml, isn't here yet: it comes with the published base, as a
|
||||
# workflow of its own beside this one, with its own environment, key and artifact, base, which the
|
||||
# co-signer already reads (cosigner.md's Bases).
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build and sign
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
environment: release
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write # the attestation's Sigstore certificate for this run
|
||||
attestations: write # the attestation's record
|
||||
steps:
|
||||
# The whole history, for the check that the tag's commit is on main.
|
||||
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
# A tag whose commit has none of the release keys stops here, before anything is installed or
|
||||
# built: its devvm couldn't check CI's and the co-signer's signatures, so it's published with
|
||||
# scripts/publish.sh --local until the keys are made. release.sh --ci checks the keys in full.
|
||||
- name: Check the release keys
|
||||
run: |
|
||||
[[ -f packaging/keys/release-ci.pub ]] || {
|
||||
echo "::error::$GITHUB_REF_NAME has no release keys in packaging/keys: make them first (docs/content/docs/contributing/github-setup.md, step 1), or publish it with scripts/publish.sh --local"
|
||||
exit 1
|
||||
}
|
||||
# The tag as it is on GitHub, its tag object and signature, whatever the checkout made of it.
|
||||
- name: Fetch the tag
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
run: git fetch --no-tags --force origin "+refs/tags/$TAG:refs/tags/$TAG"
|
||||
# Only minisign, which signs, as the pinned mise.lock has it, and no cache, as a release builds
|
||||
# from nothing a branch's run could have left.
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.14
|
||||
install_args: minisign
|
||||
cache: false
|
||||
# The tag's checks against the environment's signers, then the build, in a folder of its own
|
||||
# that holds SHA256SUMS and exactly the files it lists.
|
||||
- name: Build
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
SIGNERS: ${{ vars.RELEASE_TAG_SIGNERS }}
|
||||
DEVVM_RELEASE_RUNTIME: podman
|
||||
run: |
|
||||
set -euo pipefail
|
||||
export DEVVM_RELEASE_SIGNERS=$RUNNER_TEMP/allowed_signers
|
||||
printf '%s\n' "$SIGNERS" > "$DEVVM_RELEASE_SIGNERS"
|
||||
scripts/release.sh --ci "$TAG" "$RUNNER_TEMP/release"
|
||||
# CI's release key goes to minisign through a pipe, never a file, and the signature has to check
|
||||
# out with the tag's packaging/keys/release-ci.pub, which mustn't be a placeholder.
|
||||
- name: Sign SHA256SUMS
|
||||
env:
|
||||
TAG: ${{ github.ref_name }}
|
||||
RELEASE_CI_KEY: ${{ secrets.RELEASE_CI_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
minisign=$(mise which minisign)
|
||||
printf '%s\n' "$RELEASE_CI_KEY" | PATH="${minisign%/*}:$PATH" scripts/release.sh --ci-sign "$TAG" "$RUNNER_TEMP/release"
|
||||
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
||||
with:
|
||||
subject-checksums: ${{ runner.temp }}/release/SHA256SUMS
|
||||
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||
with:
|
||||
name: release
|
||||
path: ${{ runner.temp }}/release/
|
||||
if-no-files-found: error
|
||||
# Until the co-signer has published it, and a release waits for the maintainer while it
|
||||
# bridges from the old key: the most a public repo keeps an artifact.
|
||||
retention-days: 90
|
||||
@@ -27,9 +27,9 @@ jobs:
|
||||
with:
|
||||
persist-credentials: false
|
||||
# Only Go and govulncheck.
|
||||
- uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10
|
||||
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
|
||||
with:
|
||||
version: 2026.11.10
|
||||
version: 2026.11.14
|
||||
install_args: go go:golang.org/x/vuln/cmd/govulncheck
|
||||
cache: false
|
||||
- name: Scan main and the releases
|
||||
|
||||
+50
-2
@@ -58,11 +58,37 @@ linters:
|
||||
- github.com/devvmhq/devvm/internal/leaktest
|
||||
- github.com/devvmhq/devvm/internal/redact
|
||||
- github.com/devvmhq/devvm/internal/memnet
|
||||
# The signature checks: the standard library and BLAKE2b alone,
|
||||
# and their own test signer.
|
||||
minisign:
|
||||
list-mode: strict
|
||||
files:
|
||||
- "**/internal/minisign/**"
|
||||
allow:
|
||||
- $gostd
|
||||
- golang.org/x/crypto/blake2b
|
||||
- github.com/devvmhq/devvm/internal/minisign
|
||||
# The co-signer, a program of its own: the standard library, its
|
||||
# config's TOML and the signature checks alone, so none of devvm's
|
||||
# other code runs where release keys are.
|
||||
cosign:
|
||||
list-mode: strict
|
||||
files:
|
||||
- "**/internal/cosign/**"
|
||||
- "**/cmd/devvm-cosign/**"
|
||||
- "!$test"
|
||||
allow:
|
||||
- $gostd
|
||||
- github.com/BurntSushi/toml
|
||||
- github.com/devvmhq/devvm/internal/minisign
|
||||
- github.com/devvmhq/devvm/internal/cosign
|
||||
main:
|
||||
list-mode: strict
|
||||
files:
|
||||
- $all
|
||||
- "!$test"
|
||||
- "!**/internal/cosign/**"
|
||||
- "!**/cmd/devvm-cosign/**"
|
||||
- "!**/internal/proxy/**"
|
||||
- "!**/internal/landlock/**"
|
||||
- "!**/internal/daemon/**"
|
||||
@@ -85,8 +111,9 @@ linters:
|
||||
- golang.org/x/text
|
||||
- golang.org/x/term
|
||||
- golang.org/x/sys
|
||||
# BLAKE2b, for minisign's prehashed signatures, which devvm
|
||||
# upgrade checks (approved; nothing else of x/crypto).
|
||||
# BLAKE2b, for minisign's prehashed signatures, which
|
||||
# internal/minisign checks (approved; nothing else of
|
||||
# x/crypto, and the structure test keeps it there).
|
||||
- golang.org/x/crypto/blake2b
|
||||
tests:
|
||||
list-mode: strict
|
||||
@@ -131,6 +158,8 @@ linters:
|
||||
msg: signal processes through internal/daemon (Proc, Handle, Alive, Signal), which checks a pid is still the process it was.
|
||||
- pattern: ^http\.(Client|DefaultClient|DefaultTransport|Transport|Get|Head|Post|PostForm)$
|
||||
msg: reach the web through internal/fetch (fetch.NewClient, and its Transport to change), which sets the timeout, the redirect policy and retries.
|
||||
- pattern: ^(x509\.(UnknownAuthorityError|HostnameError|CertificateInvalidError)|tls\.CertificateVerificationError)$
|
||||
msg: ask fetch.Untrusted, fetch.BadCertificate or fetch.Unverified why a server's certificate failed, the one place that tells a missing CA from a certificate out of date or for another host, and both from any other failure to verify one.
|
||||
- pattern: ^os\.UserHomeDir$
|
||||
msg: take the home folder from paths.Dirs.Home, the one place devvm reads HOME.
|
||||
- pattern: ^os\.(WriteFile|Create|O_TRUNC)$
|
||||
@@ -191,6 +220,21 @@ linters:
|
||||
- path: ^cmd/devvm/
|
||||
linters: [forbidigo]
|
||||
text: os\.Exit|context\.(Background|TODO)
|
||||
# The co-signer is a program of its own, which imports the standard
|
||||
# library alone (depguard's cosign): it exits with its status, makes
|
||||
# its run's context and logs to the journal through its stderr; its
|
||||
# one HTTP client is github.go's, which app.go's token calls with,
|
||||
# and its lock is lock_unix.go's. Each exclusion names its file, so a
|
||||
# second client or lock elsewhere in the package still fails.
|
||||
- path: ^cmd/devvm-cosign/
|
||||
linters: [forbidigo]
|
||||
text: os\.(Exit|Stderr)|context\.(Background|TODO)
|
||||
- path: ^internal/cosign/(github|app)\.go$
|
||||
linters: [forbidigo]
|
||||
text: reach the web through internal/fetch
|
||||
- path: ^internal/cosign/lock_unix\.go$
|
||||
linters: [forbidigo]
|
||||
text: (syscall|unix)\.Flock
|
||||
# The end-to-end runner is a test, not devvm: it prints its results,
|
||||
# TestMain exits with m.Run's code, and it stops its own checks'
|
||||
# process groups and reads whether a lock's process is alive.
|
||||
@@ -243,6 +287,10 @@ linters:
|
||||
- path: ^internal/(fetch|proxy)/|_test\.go$
|
||||
linters: [forbidigo]
|
||||
text: reach the web through internal/fetch
|
||||
# fetch's error classes themselves, and tests that make those errors.
|
||||
- path: ^internal/fetch/|_test\.go$
|
||||
linters: [forbidigo]
|
||||
text: ask fetch\.Untrusted, fetch\.BadCertificate or fetch\.Unverified
|
||||
# The packages that take no Reporter show a lock's wait through the context.
|
||||
- path: ^internal/(state|trust|msg)/|_test\.go$
|
||||
linters: [forbidigo]
|
||||
|
||||
@@ -19,15 +19,25 @@ builds:
|
||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||
|
||||
# One archive per platform: the binary (its own files embedded), the README, changelog and license.
|
||||
# Every file in it has the same owner, group and mode and the commit's time on every builder, in
|
||||
# place of the defaults, which copy them from the file on disk.
|
||||
archives:
|
||||
- id: devvm
|
||||
ids: [devvm]
|
||||
formats: [tar.gz]
|
||||
name_template: devvm-{{ .Version }}-{{ .Os }}-{{ .Arch }}
|
||||
wrap_in_directory: true
|
||||
builds_info:
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
mtime: "{{ .CommitDate }}"
|
||||
files:
|
||||
- src: LICENSE
|
||||
info: &info
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
mtime: "{{ .CommitDate }}"
|
||||
- src: README.md
|
||||
info: *info
|
||||
|
||||
@@ -7,3 +7,10 @@ config:
|
||||
# does in CHANGELOG.md.
|
||||
MD024:
|
||||
siblings_only: true
|
||||
# Inline HTML: only <details> and <summary>, which collapse a changelog
|
||||
# entry's groups. markdownlint-cli2 can't set a rule for one file, so the
|
||||
# two are allowed everywhere and every other element is still refused.
|
||||
MD033:
|
||||
allowed_elements:
|
||||
- details
|
||||
- summary
|
||||
+16
-16
@@ -9,8 +9,8 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
markdownlint-cli2:
|
||||
specifier: 0.24.1
|
||||
version: 0.24.1
|
||||
specifier: 0.24.2
|
||||
version: 0.24.2
|
||||
|
||||
packages:
|
||||
|
||||
@@ -112,8 +112,8 @@ packages:
|
||||
resolution: {integrity: sha512-c8B/VNLmxRcmqqenRA9t+9IyOjf9+V6lTxPaUJLqOCONdQkWZ0ETYgX0qbtJqPsgCNusT9MZ5Jeidw8Eb9tn2g==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
[email protected]4:
|
||||
resolution: {integrity: sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==}
|
||||
[email protected]6:
|
||||
resolution: {integrity: sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==}
|
||||
engines: {node: '>= 4'}
|
||||
|
||||
[email protected]:
|
||||
@@ -171,13 +171,13 @@ packages:
|
||||
peerDependencies:
|
||||
markdownlint-cli2: '>=0.0.4'
|
||||
|
||||
[email protected].1:
|
||||
resolution: {integrity: sha512-nLhes/MIPJQLm+Gmh+3jQEnwMOaalaN0wfCD2qz1247zNZ7R3r2WDHJB191x4hcy6soKAUTybp1bFK7aJGw/WA==}
|
||||
[email protected].2:
|
||||
resolution: {integrity: sha512-bgxzhJkgR7t2puRgePHZYVqKzC90etPzxOC+9ZNATjAVJB2zs7EAolfF1inVsrkgYN+ykVIHIxk0WypG2VVLZA==}
|
||||
engines: {node: '>=22'}
|
||||
hasBin: true
|
||||
|
||||
[email protected].1:
|
||||
resolution: {integrity: sha512-Otolm9JX12iO2NG5cetlKfzGygpiLSlHuqXKxoT6HGhN5HtbxprJPicKZqqCQd88qOvUi/TEs3o1AmcYioVscA==}
|
||||
[email protected].2:
|
||||
resolution: {integrity: sha512-IhlUBVT+kHBX+u3EjEsQdFB4q0Rl0Hx+JsGsvVkonNut1/n8Kv8yXzwk0pazC9uF35JlwMZ+LxV4CQ9YNAbG8w==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
[email protected]:
|
||||
@@ -408,13 +408,13 @@ snapshots:
|
||||
dependencies:
|
||||
'@sindresorhus/merge-streams': 4.0.0
|
||||
fast-glob: 3.3.3
|
||||
ignore: 7.0.14
|
||||
ignore: 7.0.16
|
||||
is-path-inside: 4.0.0
|
||||
micromatch: 4.0.8
|
||||
slash: 5.1.0
|
||||
unicorn-magic: 0.4.1
|
||||
|
||||
[email protected]4: {}
|
||||
[email protected]6: {}
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
@@ -462,25 +462,25 @@ snapshots:
|
||||
punycode.js: 2.3.1
|
||||
uc.micro: 3.0.0
|
||||
|
||||
[email protected]([email protected].1):
|
||||
[email protected]([email protected].2):
|
||||
dependencies:
|
||||
markdownlint-cli2: 0.24.1
|
||||
markdownlint-cli2: 0.24.2
|
||||
|
||||
[email protected].1:
|
||||
[email protected].2:
|
||||
dependencies:
|
||||
globby: 16.2.4
|
||||
js-yaml: 5.5.0
|
||||
jsonc-parser: 3.3.1
|
||||
jsonpointer: 5.0.1
|
||||
markdown-it: 15.0.3
|
||||
markdownlint: 0.42.1
|
||||
markdownlint-cli2-formatter-default: 0.0.6([email protected].1)
|
||||
markdownlint: 0.42.2
|
||||
markdownlint-cli2-formatter-default: 0.0.6([email protected].2)
|
||||
micromatch: 4.0.8
|
||||
smol-toml: 1.9.1
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
[email protected].1:
|
||||
[email protected].2:
|
||||
dependencies:
|
||||
micromark: 4.0.3
|
||||
micromark-core-commonmark: 2.0.4
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
"name": "mise-npm-install",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"markdownlint-cli2": "0.24.1"
|
||||
"markdownlint-cli2": "0.24.2"
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
|
||||
| Path | What |
|
||||
| --- | --- |
|
||||
| `cmd/devvm/` | the entry point (`ui.Main`); the only `os.Exit` |
|
||||
| `cmd/devvm/` | the entry point (`ui.Main`); the only `os.Exit` but the co-signer's |
|
||||
| `cmd/devvm-cosign/`, `internal/cosign/` | the co-signer, a program of its own: stdlib, toml and `internal/minisign` only; `packaging/cosign/` its units ([The co-signer](docs/content/docs/contributing/cosigner.md)) |
|
||||
| `internal/cli/` | the command line: one file per Cobra command, the run's services (`app.go`), argument checks, help, `--json`, the CLI tests, `docgen/`; `doc.go` maps it |
|
||||
| `internal/vm/` | what each command does to a folder's VM, below the command line; `doc.go` maps the package and its owners |
|
||||
| `internal/shell/`, `internal/vmname/` | quoting for a POSIX shell; every VM's name (`vmname.VM`, parsed where it's read) and a project VM's name grammar |
|
||||
@@ -16,7 +17,8 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
| `internal/sshconfig/`, `internal/sshagent/` | the ssh config for running VMs by name; each VM's SSH agent and devvm's own |
|
||||
| `internal/build/`, `internal/image/` | building images and their records; image keys and names, and the shared tools' registry (`SharedTools`) |
|
||||
| `internal/fetch/` | every HTTP client |
|
||||
| `internal/upgrade/` | devvm upgrade; `upgradetest/` (tests only) |
|
||||
| `internal/upgrade/` | devvm upgrade; `upgradetest/` (tests only); `legacy.go`, the bridge from the old release key |
|
||||
| `internal/minisign/` | every signature check of devvm's own: minisign, each key's role and kind, two of three (`Keys`), the co-signer's signing (`SecretKey`); `minisigntest/` (tests only) |
|
||||
| `internal/from/` | `--from`'s references and digests |
|
||||
| `internal/redact/` | passwords out of logs; `Secret`, the type of every secret's value |
|
||||
| `internal/vmlog/` | every log a VM can drive (but the proxy's own): its rate, its cap while it runs, and the backend's logs, serial consoles' included |
|
||||
@@ -39,13 +41,13 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
| `internal/ports/` | a VM's ports and the one allocator of host ports |
|
||||
| `internal/paths/`, `internal/state/` | every folder and file devvm uses; `vm.json`, the layout version, files written whole |
|
||||
| `internal/settings/` | the defaults: `config.toml` over `settings.json`, each value's check |
|
||||
| `internal/platform/`, `internal/ubuntu/`, `internal/testbuild/` | build-tagged OS code; Ubuntu's cloud image (never downloads); whether this is a test build |
|
||||
| `internal/platform/`, `internal/ubuntu/`, `internal/testbuild/` | build-tagged OS code; Ubuntu's cloud image, its pin and its resumable download; whether this is a test build |
|
||||
| `assets/` | the files devvm ships, embedded (`assets.FS`) |
|
||||
| `internal/structure/` | the structure test |
|
||||
| `internal/stubtest/`, `internal/leaktest/`, `internal/memnet/` | the test stubs; the goroutine leak checks (`Main`, `Check`); the network in memory for synctest bubbles |
|
||||
| `testdata/` | CLI tests, golden fixtures, coverage baselines, each release's frozen state (`v<release>/`), `lint/` |
|
||||
| `tests/e2e/`, `tests/e2e-mise.lock` | end-to-end tests on real VMs |
|
||||
| `scripts/`, `packaging/`, `.goreleaser.yaml`, `VERSION`, `CHANGELOG.md` | pins, releases, the test tasks' scripts, the Homebrew formula, devvm upgrade's key |
|
||||
| `scripts/`, `packaging/`, `.goreleaser.yaml`, `VERSION`, `CHANGELOG.md` | pins, releases, the test tasks' scripts, the Homebrew formula, devvm upgrade's keys (`packaging/keys/`: none until the real keys are made) |
|
||||
| `install.sh` | `curl \| bash`, asking before doctor's fixes |
|
||||
| `docs/` | the docs site (Hugo + Hextra); `content/docs/cli/` is generated, never edit it |
|
||||
| `mise.toml`, `.golangci.yml`, `.vale*`, `.markdownlint-cli2.yaml`, `.github/` | tools, tasks, linters, CI and Pages |
|
||||
@@ -65,14 +67,14 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
- **devvm's own files never get a shared copy on disk:** the proxy reads them from the binary, base.yaml and scripts go on stdin, `--from`'s build writes its scripts into its own temp folder.
|
||||
- **Credentials never go into images.** Host agent history never goes into VMs.
|
||||
- **Never auto-delete project VMs:** they may hold unsaved work. Warn instead.
|
||||
- **Every release's state keeps working** until 1.0: a change to state runs its new commands on every frozen `testdata/v<release>/` fixture (never edited or regenerated) in the same commit, and a change for existing state gets a Breaking changelog entry ([Released state](docs/content/docs/contributing/structure.md#released-state)).
|
||||
- **Every release's state keeps working** until 1.0: a change to state runs its new commands on every frozen `testdata/v<release>/` fixture (never edited or regenerated) in the same commit, and a change for existing state gets a changelog line, in What to do when users must act ([Released state](docs/content/docs/contributing/structure.md#released-state)).
|
||||
- **The startup check only reports.** Never install host software without asking.
|
||||
- **Image keys hash everything that goes into an image**, the backend included; a tool image's key is in [Building tools](docs/content/docs/internals/images.md#building-tools).
|
||||
- **Pin every download** in `assets/`'s `layers/`, `features/`, `shared-tools/build.sh`, `oci/build.sh`: `<tool>_version` and `<tool>_sha256_arm64`/`_amd64` at the top, picked with the prelude's `devvm_sha`, fetched with `devvm-fetch` (`oci/build.sh`: `sha256sum`). No `curl | sh`, no "latest". Upstream-checked exceptions: shared tools (`MISE_LOCKED=1`), Ubuntu's signed `SHA256SUMS`, Lima in `install.sh`. Go checks a download's SHA-256 before use.
|
||||
- **Shared tools are read-only in VMs:** whatever writes into a tool's folder (global installs, self-updates, `corepack enable`, `rustup component add`) is redirected (`~/.npm-global`, `go_set_gobin = false`), done in `assets/shared-tools/build.sh`, or off.
|
||||
- **In-VM scripts are bash 3.2-safe and shellcheck-clean** (`assets/`, `install.sh`): guard empty arrays (`${a[@]+"${a[@]}"}`), no associative arrays. Everything else is Go.
|
||||
- **The one exception, the docs build's Node script:** `docs/render-diagrams.mjs` (`mise run docs:diagrams`) draws the site's diagrams with pele, pinned in `docs/package.json` and its lock and installed with `npm ci --ignore-scripts`; no other build script is JavaScript, and no other npm package is installed outside mise's tools.
|
||||
- **Docs:** an easy-to-follow guide in full, joined sentences, every fact kept, written with the docs-voice skill; every behavior change updates its page in the same task, and the README stays high level ([Writing docs](docs/content/docs/contributing/docs.md#writing-docs)).
|
||||
- **Docs:** an easy-to-follow guide in full, joined sentences, every fact kept, written with the docs-voice skill; every behavior change updates its page in the same task, pages describe only how devvm works now but `releases/`, the one place for history, and the README stays high level ([Writing docs](docs/content/docs/contributing/docs.md#writing-docs)).
|
||||
- **Every code change meets the codebase-standards skill** (`.agents/skills/codebase-standards/`): its checklist before committing, and its review when reviewing one.
|
||||
- **Adding or changing a command** follows the cli skill (`.agents/skills/cli/`): its checklist, then its review.
|
||||
- **Adding or changing a shared tool** updates its page and follows Contributing's checklist: `using/toolchains.md` for a toolchain ([Adding a toolchain](docs/content/docs/contributing/extending.md#adding-a-toolchain)), `using/coding-agents.md`'s Supported agents for an agent ([Adding a coding agent](docs/content/docs/contributing/extending.md#adding-a-coding-agent)).
|
||||
@@ -104,7 +106,7 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
|
||||
- **A backend implements `backend.Backend`'s four roles, declares `Caps` for every feature and returns errors, never ending the run:** [How a backend plugs in](docs/content/docs/contributing/extending.md#how-a-backend-plugs-in); a new `Feature` goes in `backend.Features` and [the feature table](docs/content/docs/internals/backends.md#the-feature-table).
|
||||
- **A missing feature fails, naming the VM and what to do; never fall back silently** ([Missing and unreviewed features](docs/content/docs/internals/backends.md#missing-and-unreviewed-features)).
|
||||
- **Every emulation is refused until reviewed:** a design note in `docs/content/docs/internals/design.md`, a threat check with the security-audit skill, and e2e checks proving the guarantee; then it's marked reviewed in `Caps`.
|
||||
- **Every emulation is refused until reviewed:** a design note in `docs/content/docs/contributing/design.md`, a threat check with the security-audit skill, and e2e checks proving the guarantee; then it's marked reviewed in `Caps`.
|
||||
- Backend-specific code stays in its package; what isn't (`.git` protection, the proxy) stays out.
|
||||
- **Lima edits only what differs:** any `limactl edit` gives the VM new ssh host keys at its next boot, so `Start` compares first and makes one edit ([What devvm sets on a VM](docs/content/docs/internals/lima.md#what-devvm-sets-on-a-vm)).
|
||||
|
||||
@@ -144,5 +146,6 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
|
||||
|
||||
- **One commit when each task is complete**, its docs and review included. Conventional Commits: `type(scope): summary`, types `feat`, `fix`, `docs`, `test`, `refactor`, `build`, `ci`, `chore`.
|
||||
- **Don't commit until the gate passes**, with whatever `mise run fmt` changed in the commit.
|
||||
- **Changelog:** a change adds its changelog line by audience (who notices) and its full story to `releases/` ([Releasing](docs/content/docs/contributing/maintaining.md#releasing)).
|
||||
- **Task IDs from any tracker never go in commit messages, code comments or docs.**
|
||||
- **AGENTS.md stays short:** one line per path or rule. Inventories (functions, messages, test names) go in the commit message, not here.
|
||||
+159
-83
@@ -4,83 +4,110 @@ What's changed on `main` since the latest release is in [Unreleased](#unreleased
|
||||
|
||||
## 0.2.0-rc.1
|
||||
|
||||
A release candidate for 0.2.0, adding to 0.1.1-rc.3. 0.2.0 takes 0.1.1's place, because its breaking changes need a new minor version. Install it with `devvm upgrade --to 0.2.0-rc.1`, the install script's `--version 0.2.0-rc.1`, or `brew install devvmhq/tap/devvm-rc`. Homebrew's `devvm` stays on 0.1.0.
|
||||
This is a release candidate for 0.2.0, and it adds to 0.1.1-rc.3. 0.2.0 takes 0.1.1's place, because its breaking changes need a new minor version. Install it with `devvm upgrade --to 0.2.0-rc.1`, the install script's `--version 0.2.0-rc.1`, or `brew install devvmhq/tap/devvm-rc`. Homebrew's `devvm` stays on 0.1.0.
|
||||
|
||||
### Breaking
|
||||
Each change below links its section on [the 0.2.0 page](https://next.devvm.dev/docs/releases/0.2.0/), which has its full story, and the commit that made it.
|
||||
|
||||
- **At most 17 VMs run at once:** each VM's ssh is now on one of the 17 ports from 1024 up that every browser refuses, so no page in your browser reaches a server in a VM through it. Root in a VM could make its ssh port answer as a web server, which got the cookies of the apps you use on `localhost`, even in a VM that forwards no ports. A start past 17 fails and names the VMs that run on those ports ([too many VMs at once](https://next.devvm.dev/docs/using/troubleshooting/#too-many-vms-at-once)).
|
||||
- **A VM that forwards every port leaves out those 17:** a server in the VM on one of them, such as an X server on 6000, reaches this machine only when you list the port with `devvm ports`, so a VM can't take the ports other VMs' ssh needs. `devvm ports` and each launch warn when a VM's list names one of them ([ports](https://next.devvm.dev/docs/using/ports-size/#ports)).
|
||||
- **A short host name no longer reaches a host through the proxy:** a tool in a VM that used a name such as `jenkins` for a host on your company's network now needs its full name, such as `jenkins.corp.example.com`, as the proxy no longer adds this machine's DNS search domain ([a name that doesn't resolve](https://next.devvm.dev/docs/using/troubleshooting/#a-name-that-doesnt-resolve)).
|
||||
- **The agent store keeps only what a seed has of Claude Code's plugins:** if you imported Claude Code's settings with devvm 0.1.0, which copied your whole `~/.claude/plugins`, the first start of any VM takes your plugins' data, and the store's other entries of that folder that are this machine's own, such as `installed_plugins.json`, out of devvm's agent store, where every VM with Claude Code could read them, and warns once, naming them. Your own `~/.claude/plugins` is left as it is. A store whose plugins folder is a link, or below one, which only a store you made yourself has, now stops every VM with Claude Code from starting until it's a folder of its own, as a VM's mount would follow the link ([Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins)).
|
||||
- **`devvm agent import` and `devvm agent save` refuse a linked store:** when a folder on the way to what they write in devvm's agent store is a link, from `~/.config/devvm/agents` down, such as `~/.config/devvm/agents/claude` linked into a dotfiles repo, they now fail and name the link before they change anything. Before, they wrote through the link and took out whatever the folder it led to held that they didn't write, which for a link to your home folder deleted your files. Make that folder one of its own, then run the command again ([devvm's agent store](https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store)).
|
||||
### Highlights
|
||||
|
||||
### After you upgrade
|
||||
- Claude Code's plugins, MCP servers' logins, claude.ai connectors and `--setup-token` login all work in a VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-a-vm)).
|
||||
- The bugs you reported are fixed, among them 24-bit color, folder names such as `x--y`, and a folder's VM after your Mac restarts ([details](https://next.devvm.dev/docs/releases/0.2.0/#fixes)).
|
||||
- Your secrets are safer from VMs: the part of each VM's proxy that reads its traffic holds only that VM's secrets, in a sandbox ([details](https://next.devvm.dev/docs/releases/0.2.0/#each-vms-proxy-runs-as-two-processes)).
|
||||
|
||||
- A VM's proxy that runs as you upgrade keeps running as one process, without a sandbox, until the VM's next launch, which starts its two processes, as it starts a proxy again for every new devvm. Until then, `devvm doctor` names each VM whose proxy an older devvm started ([the proxy runs without a sandbox](https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox)).
|
||||
- Each existing VM's ssh moves to one of the 17 ports that browsers refuse at the VM's next start, in the one change devvm makes to its Lima config, which gives the VM new ssh host keys, as any change to its Lima config does. A VM that runs as you upgrade keeps its old port until then, and devvm warns of it at each launch, so stop it with `devvm stop` in its folder, and its next start moves it ([too many VMs at once](https://next.devvm.dev/docs/using/troubleshooting/#too-many-vms-at-once)).
|
||||
- A VM whose copy of an agent's settings file had `devvm-redacted` under a name you chose, such as a plugin's marketplace, gets the whole copy at its next launch, over its own. Until then, `devvm agent save` leaves that file out and warns, so make any change to it in devvm's agent store, or launch the VM again and make the change there.
|
||||
- A VM that runs as you upgrade, with Claude Code's plugins imported by devvm 0.1.0, loses the store's entries that are this machine's own from its mount at the first start of any VM, so Claude Code there may not find the store's plugins until that VM's next launch. On a Linux host, it can keep seeing what it had read of them until its next start. If a plugin's data held a login of the plugin's own, every VM with Claude Code could read it, so sign in to that plugin again where you don't trust those VMs. Each VM gets its own `~/.claude/plugins` at its next launch, with no restart, in place of its link to the store's folder, and Claude Code started in a shell that was open before that launch finds none of the store's plugins, so start it in a new shell ([Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins)).
|
||||
- Each VM records its project folder's volume at its first launch that finds the folder. Until then, and for a VM whose folder was already gone before the upgrade, which never records one, a folder that moves while a restart gives its disk another device number still needs `devvm adopt VM`, and after a restart such a gone folder can still be called not connected ([a moved or renamed folder](https://next.devvm.dev/docs/using/vms/#a-moved-or-renamed-folder)).
|
||||
- A VM that forwards an SSH agent and runs as you upgrade keeps the agent as it was, so it can still remove, lock or add keys, until its next start, and devvm warns of it each time it opens the VM or changes its links. Run `devvm restart` in its folder to give it the relay at once ([agent forwarding](https://next.devvm.dev/docs/using/ssh/#agent-forwarding)).
|
||||
- Run `devvm update` in each existing VM's folder. The new mise and Docker change what goes into the images, so until you do, a VM made from an older image says it's outdated, and every existing VM says there are newer shared tools at the same versions. The first update or new VM builds base and each of its shared tools again, one at a time, which takes several minutes.
|
||||
### What to do
|
||||
|
||||
### Changed
|
||||
|
||||
- **Each VM's proxy runs as two processes:** `devvm _proxy` alone reads your Keychain, your agents' login files and your other files, and `devvm _proxy-child` reads the VM's network and asks `devvm _proxy` for each name's lookup and each connection, for a login's token exchange, and for each value bound to the VM as a request needs it. So the code that reads every byte a VM sends holds, besides the VM's own proxy password and CAs and your company proxy's password, only the values that the VM's own bindings name, each kept for a few minutes after it was last asked for. A new login's tokens, its refresh token among them, never reach the process that reads the VM's requests, and an error reply from an agent's token endpoint reaches the VM as it is up to 1 MiB, and gets `502` past that. A build's proxy writes its logs to a `logs/` folder of their own in its folder ([a VM's proxy](https://next.devvm.dev/docs/internals/processes/#a-vms-proxy)).
|
||||
- **On macOS, the proxy's child runs in a macOS sandbox:** `devvm _proxy-child` starts under `sandbox-exec`, with a profile that lets it write only its VM's logs and the shared Nix cache and look at your policy files, so a bug that a VM drove there couldn't read your files, reach the Keychain or connect to this machine's unix sockets, such as ssh's and Docker's. If `sandbox-exec` is missing or fails to start it, the child runs without the sandbox, so the VM keeps its network, and `devvm doctor` warns for each VM whose proxy runs that way ([the proxy runs without a sandbox](https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox)).
|
||||
- **On Linux, the proxy's child confines itself:** before it reads a byte of the VM's, `devvm _proxy-child` confines itself with Landlock and a seccomp filter, so a bug that a VM drove there could write and read only its VM's logs and the shared Nix cache, couldn't change any other file's mode, owner, attributes or times, run a program, or connect to a unix socket, such as an ssh master's, Docker's or your SSH agent's. It could still learn whether a file of yours exists, its size and when it changed. A kernel without Landlock or seccomp filters, or whose Landlock is older than ABI 6 or lacks its fix for signals between threads, confines the child only in part, and the VM keeps its network, and `devvm doctor` warns for each VM whose proxy runs that way, naming what the kernel lacks ([the proxy runs without a sandbox](https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox)).
|
||||
- **The proxy's child connects only through `devvm _proxy`:** wherever its sandbox runs, on macOS and on Linux, it refuses the child every connection of its own, so `devvm _proxy` looks up each name for it and opens each connection, once its own read of your rules and this machine's addresses allows the address. So a bug that a VM drove in the child can't reach this machine's services on `localhost`, such as your dev servers, Docker's published ports and other VMs' proxies, nor this machine's own addresses or your LAN's private addresses, unless a rule names the address, just as the VM can't. A rule such as `devvm network allow 127.0.0.1:5432` still applies from the next connection, and a company proxy on `localhost` still works, though the child reaches whatever that company proxy reaches, as the VM does. Because `devvm _proxy` looks up its names, the child reads no file below `/etc` on Linux and doesn't talk to mDNSResponder on macOS ([the child's sandbox](https://next.devvm.dev/docs/internals/network/#the-childs-sandbox)).
|
||||
- **`devvm doctor` checks every VM's state:** it reads each VM's `vm.json` and each of its sections as every command on a VM does, and warns of each VM whose state devvm can't read, naming the VM and why, the file included, once, even when it can't read the VM's folder, without changing anything. Such a VM no longer hides doctor's warnings about the other VMs' policy files, nor what `devvm network` warns of every VM ([a file devvm can't read](https://next.devvm.dev/docs/using/troubleshooting/#a-file-devvm-cant-read)).
|
||||
- **A marketplace's credential gets a warning:** when `devvm agent import` or `devvm agent save` copies a Claude Code marketplace that has a password or an access token in its clone's git config or its source in `known_marketplaces.json`, which every VM with Claude Code can read, it warns and names the marketplace, the store's file and the keys, and copies it as before ([mounts](https://next.devvm.dev/docs/using/coding-agents/#mounts)).
|
||||
- **`devvm agent import` copies at most 20,000 files, folders and links, 128 MiB, and 16 MiB in one file, of each agent's folder:** an agent's folder that holds more, such as one a VM's project inside it filled, fails the import before the store changes, naming the folder, so take out what it doesn't need and import again. An import that fails, while it reads, such as at a file that changed meanwhile, or while it puts the settings and logins in place, such as at a login it can't save, leaves the store as it was, and in the rare case that putting it back fails too, it names what it kept. The import also warns of each VM whose project folder is inside an agent's folder, such as a skill you work on in `~/.claude/skills`, or holds one, such as `~/.pi`, because that VM can change the settings the import copies for every VM, and of each VM whose state it can't read, as it can't tell where that VM's project folder is. It leaves out an agent's folder that a link in a VM's project folder leads elsewhere, and while a VM's state can't be read, it leaves out every link out of an agent's folder, and an agent's folder or login whose path leads through a link, one on the way to your home folder included unless only root can change it, naming the state, so run `devvm doctor` and import again ([importing from this machine](https://next.devvm.dev/docs/using/coding-agents/#importing-from-this-machine)).
|
||||
- **A launch warns of a project in an agent's folder:** when a VM's project folder is inside a coding agent's folder on this machine, such as `~/.claude/skills/mine`, or holds one, such as `~/.pi`, each launch of the VM warns in one line, because code in the VM can change that agent's settings on this machine ([project folders devvm refuses](https://next.devvm.dev/docs/using/settings/#project-folders-devvm-refuses)).
|
||||
- **Cursor's CLI in a VM can change less of your Cursor account:** its proxy refuses more of the methods that change your account, your team or your cloud agents, such as merging a cloud agent's pull request, forking or pinning a cloud agent, or writing to its machine, while every call the CLI itself makes passes. Do those from Cursor on your machine ([Cursor CLI login](https://next.devvm.dev/docs/using/coding-agents/#cursor-cli-login)).
|
||||
- **Pins:** mise is 2026.11.10, in base and on this machine, the docker layer's Docker is 29.10.0 and its compose 5.8.0, and Cursor's CLI is 2026.11.17-f532c45. The new mise and Docker change what goes into the images, so base, every image built on it and every shared tool that mise installs are built again once.
|
||||
- **Slow steps show a status line:** in a terminal, devvm now shows what it's waiting for while it finds the folder's VM, checks it before a start, checks its network and reads its host keys, sets it up, runs a `devcontainer.json`'s commands, looks up a folder's disk, checks Lima, deletes a VM or an image, applies the retention settings and installs an upgrade, and while `devvm ls` reads the VMs, `devvm doctor` checks this machine, `devvm agent import` reads your agents' folders and copies them into the store, and `devvm agent save` reads and compares the VM's settings. `devvm clone add`, `clone fetch`, `clone on` and `clone off`, `devvm git-protect`, `devvm stop`, a `--clone` VM's check before `devvm rm`, a history export or import, and `devvm ports` as it starts a running VM's port forwarder again show one too, and so do `devvm link` as it asks about the VMs its links lead to, `link add`, `link rm`, `link publish` and `link unpublish`, `devvm group join` and `group leave`, and `devvm rm` of a VM that others link to, as they give each running VM its changed links and check the VMs that links lead to, `devvm network learn` and `network lock` as they give a running VM's proxy its new tier, and every stop of a VM, as for `devvm restart` or a restart you agree to after changing a setting. While devvm waits for another devvm that's changing the same thing, such as a VM's state, its folders' layout, a group, an image's build or the shared tools, a status line says so, only while it waits, where before some of those waits showed nothing and others printed a line after a few seconds that stayed. Like every status line, it shows only in a terminal without `-v`, so a run with `-v`, or with its output piped, no longer prints that line ([a command fails](https://next.devvm.dev/docs/using/troubleshooting/#a-command-fails)).
|
||||
1. Run `devvm update` in each existing VM's folder, and give the first one several minutes, because it builds base and its shared tools again ([details](https://next.devvm.dev/docs/releases/0.2.0/#pins), [c9005ae](https://github.com/devvmhq/devvm/commit/c9005ae4be13f6ebe337111bdba980c3f595c7fe)).
|
||||
2. Run `devvm restart`, or `devvm stop`, in the folder of each VM that was running when you upgraded, so it gets the new ssh port, proxy and SSH agent relay, and start Claude Code there in a new shell ([too many VMs at once](https://next.devvm.dev/docs/using/troubleshooting/#too-many-vms-at-once), [the proxy runs without a sandbox](https://next.devvm.dev/docs/using/troubleshooting/#the-proxy-runs-without-a-sandbox), [agent forwarding](https://next.devvm.dev/docs/using/ssh/#agent-forwarding), [Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins), [details](https://next.devvm.dev/docs/releases/0.2.0/#at-most-17-vms-run-at-once), [details](https://next.devvm.dev/docs/releases/0.2.0/#each-vms-proxy-runs-as-two-processes), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-vm-and-its-ssh-agent), [details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-the-agent-store), [details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-a-vm), [e4ea123](https://github.com/devvmhq/devvm/commit/e4ea123927cc90022b5333ab15e38f75c69c876a), [aeea313](https://github.com/devvmhq/devvm/commit/aeea3135b27e0de898a449adb63b7742126b8ddb), [19f9900](https://github.com/devvmhq/devvm/commit/19f9900b8633108cf69b28ee7a253b08bafff70f), [7cc0dd7](https://github.com/devvmhq/devvm/commit/7cc0dd76edc858fea9afc90d71cbba8ac6f50f37), [e97db05](https://github.com/devvmhq/devvm/commit/e97db057fd93873a14b075e7d46615dc2d020ac4)).
|
||||
3. Stop one of your running VMs before you start an 18th, because at most 17 VMs run at once, and a start past 17 fails and names the VMs that are running ([too many VMs at once](https://next.devvm.dev/docs/using/troubleshooting/#too-many-vms-at-once), [details](https://next.devvm.dev/docs/releases/0.2.0/#at-most-17-vms-run-at-once), [e4ea123](https://github.com/devvmhq/devvm/commit/e4ea123927cc90022b5333ab15e38f75c69c876a)).
|
||||
4. Use a host's full name, such as `jenkins.corp.example.com`, where a tool in a VM reached it by a short name such as `jenkins`, because the proxy no longer adds this machine's DNS search domain ([a name that doesn't resolve](https://next.devvm.dev/docs/using/troubleshooting/#a-name-that-doesnt-resolve), [details](https://next.devvm.dev/docs/releases/0.2.0/#names-are-looked-up-as-theyre-written), [c872cfe](https://github.com/devvmhq/devvm/commit/c872cfe66c349533820c885b2ed11b5db617fc24)).
|
||||
5. Disconnect the claude.ai connectors you don't want VMs to use, or deny `mcp-proxy.anthropic.com` with `devvm network deny`, because with your subscription's login, code in a VM can now act through your connectors ([details](https://next.devvm.dev/docs/releases/0.2.0/#your-claudeai-connectors), [#61](https://github.com/devvmhq/devvm/issues/61), [c1db911](https://github.com/devvmhq/devvm/commit/c1db911d1ba3856299bd59b1c4d74620b7d49408)).
|
||||
6. If devvm 0.1.0 imported your Claude Code plugins, sign in again to any plugin that keeps a login of its own, because every VM with Claude Code could read that login ([Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins), [details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-the-agent-store), [details](https://next.devvm.dev/docs/releases/0.2.0/#your-plugins-data-stays-on-this-machine), [7cc0dd7](https://github.com/devvmhq/devvm/commit/7cc0dd76edc858fea9afc90d71cbba8ac6f50f37), [e97db05](https://github.com/devvmhq/devvm/commit/e97db057fd93873a14b075e7d46615dc2d020ac4)).
|
||||
7. If a folder at a VM's path is now on another volume, such as a copy of the disk or, on Linux, a rolled-back Btrfs snapshot, run `devvm adopt` there to give it that VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-folder-on-another-volume), [4ccdbf8](https://github.com/devvmhq/devvm/commit/4ccdbf8125fe4a655980e77a7454c209e98ada70)).
|
||||
8. If a folder in devvm's agent store is a link, make it a folder of its own, because `devvm agent import` and `devvm agent save` refuse it, and a VM with Claude Code refuses a linked plugins folder ([devvm's agent store](https://next.devvm.dev/docs/using/coding-agents/#devvms-agent-store), [Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-linked-agent-store-is-refused), [details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-the-agent-store), [d939d1d](https://github.com/devvmhq/devvm/commit/d939d1d870cc0216b5a3036636b13489a869b71e), [7cc0dd7](https://github.com/devvmhq/devvm/commit/7cc0dd76edc858fea9afc90d71cbba8ac6f50f37)).
|
||||
|
||||
### Fixed
|
||||
|
||||
- **A project folder devvm can't read says so:** when you, or code in a VM that mounts it, took away your read permission on a project folder, devvm said its VM was made for an earlier folder that was deleted or replaced, and offered `devvm rm` and `devvm adopt`. It now names the folder and why it can't be read, so make it readable again ([a folder made again](https://next.devvm.dev/docs/using/vms/#a-folder-made-again)).
|
||||
- **A warning no longer lands on the status line:** a warning that devvm printed during a slow step was written onto the status line's own line, and the status line's next redraw could erase a question's prompt and what you typed. A message now prints above the status line, which comes back below it, and a question, the picker and an agent's login in the VM take the status line away until they're done ([a command fails](https://next.devvm.dev/docs/using/troubleshooting/#a-command-fails)).
|
||||
- **`devvm agent login claude --setup-token` shows Claude Code's address (#57):** the login in the VM got no terminal of its own, so `claude setup-token`, which draws full-screen, showed nothing and waited. When devvm runs in a terminal, an agent's login in the VM now gets one too, as devvm's shell does, so Claude Code shows the address to open and the prompt for its code. Without a terminal, `--setup-token` warns that the login may show nothing. On a terminal, Ctrl-C now goes to the agent's login in the VM, which ends, and devvm then says that the login ended or saved nothing, and devvm puts the terminal back as it was before the login, even when a signal ends devvm itself ([Claude Code login](https://next.devvm.dev/docs/using/coding-agents/#claude-code-login)).
|
||||
- **The VM's shell gets your terminal's 24-bit color (#54):** devvm's shell in a VM, an agent's login with `devvm agent login` and `ssh` to a VM by name never got your terminal's `COLORTERM`, so programs in the VM, such as coding agents, fell back to fewer colors. devvm's shell and an agent's login now get it when it's `truecolor` or `24bit`, and no other value ([opening a VM](https://next.devvm.dev/docs/using/vms/#opening-a-vm)). The ssh config's entries now send it as your terminal has it, from the next time devvm launches or stops a VM, which writes them again, and a VM made with `--from` gets it only when its image's sshd accepts it ([ssh access by name](https://next.devvm.dev/docs/using/ssh/#ssh-access-by-name)).
|
||||
- **MCP servers' logins in a VM finish and stay (#62):** with your subscription's login, each launch and each `devvm agent login claude` wrote devvm's copy of the login over the VM's `~/.claude/.credentials.json`, where Claude Code also keeps its logins to MCP servers. So a login to an MCP server that you started with `/mcp` in a VM failed when devvm set the VM up again before it finished, such as when you ran devvm in its folder from another terminal, and one that finished was gone at the VM's next launch. devvm now replaces only the Claude login in that file and keeps the rest, so the MCP servers' logins you make in a VM stay in that VM, and they never reach this machine or another VM. With a Claude Code token, the VM's file stays as it is ([MCP servers' logins](https://next.devvm.dev/docs/using/coding-agents/#mcp-servers-logins)).
|
||||
- **Your claude.ai connectors work in a VM (#61):** with your subscription's login, Claude Code in a VM couldn't use the connectors you added in claude.ai, because the VM's proxy put the login only into requests to `api.anthropic.com`, so those to `mcp-proxy.anthropic.com`, which carries the connectors' traffic, held the login's placeholder and were refused. From each VM's next launch, the proxy puts the login into those too, below `/v1/mcp/`, so a VM with Claude Code can use every connector you added, as Claude Code on this machine can, and code in the VM can read and act through them. Disconnect the ones you don't want VMs to use, or deny `mcp-proxy.anthropic.com` with `devvm network deny` ([your claude.ai connectors](https://next.devvm.dev/docs/safety/attack-vectors/#the-network)). A Claude Code token, from `claude setup-token` or in devvm's environment, still goes only to `api.anthropic.com` ([Claude Code login](https://next.devvm.dev/docs/using/coding-agents/#claude-code-login)).
|
||||
- **A `NO_PROXY` address with a zone no longer goes direct (#59):** an IPv6 address with a zone in your company proxy's `NO_PROXY`, such as `fe80::1%eth0`, sent that address without its zone past the company proxy. Such an entry now matches nothing, as it does in Go's HTTP clients ([behind a company proxy](https://next.devvm.dev/docs/safety/network/#behind-a-company-proxy)).
|
||||
- **Claude Code's plugins work in a VM (#56):** a VM's `~/.claude/plugins` was devvm's agent store's folder, mounted read-only, so everything Claude Code writes there failed, such as a plugin's data in `${CLAUDE_PLUGIN_DATA}`, installing a plugin and updating a marketplace. Each VM's `~/.claude/plugins` is now its own folder, and the store's plugins are Claude Code's read-only seed at `~/.claude/plugins-seed`, so the store's plugins load as before, a plugin keeps its data in the VM, and a plugin you install in a VM stays in that VM until `devvm agent save` copies it into the store. The save adds plugins to the store and never takes one out, and an export of a VM's history leaves its plugins folder out. A store that devvm 0.1.0's import filled keeps only what a seed has, as Breaking above says ([Claude Code's plugins](https://next.devvm.dev/docs/using/coding-agents/#claude-codes-plugins)).
|
||||
- **devvm's own folders are refused in any case on a Mac:** devvm compared a project folder with your home folder and its own folders by name alone, so on a Mac, where a name's case doesn't count, a project at `~/.Config/devvm/layers` got a VM with read-write access to devvm's settings and layer scripts. devvm now compares the folders themselves too, and refuses such a folder as it refuses `~/.config/devvm/layers`. A VM already made in such a folder still mounts it, so delete it with `devvm rm` there. An SSH key in a folder that a VM mounts by a name in another case is refused in the same way ([project folders devvm refuses](https://next.devvm.dev/docs/using/settings/#project-folders-devvm-refuses)).
|
||||
- **A folder that moved across a restart keeps its VM:** a folder that moved while a restart gave its disk another device number wasn't recognised, so devvm made it a second VM, and the gone folder of a VM whose disk was renumbered was called not connected. Each VM now records its folder's volume, which no renumbering changes: its volume UUID on macOS, and the file system's own ID on Linux's ext4, Btrfs and ZFS. So devvm offers a moved folder its VM by its volume, inode and birth time, and calls a VM's gone folder gone, once the VM has recorded its volume, as After you upgrade says ([a moved or renamed folder](https://next.devvm.dev/docs/using/vms/#a-moved-or-renamed-folder)). A folder at the VM's own path whose disk was renumbered, but on another volume than the one recorded, such as a copy of the disk with a volume ID of its own mounted there, is another folder, so devvm gives it the VM only after `devvm adopt` ([a folder made again](https://next.devvm.dev/docs/using/vms/#a-folder-made-again)). When devvm can't read the volume at the launch after a renumbering, such as when `diskutil` doesn't answer, the volume stays to check, and each launch looks it up until it can. On Linux, where reading the volume costs nothing, every launch checks it, so a Btrfs snapshot rolled back at the folder's path, or the folder after you give its volume a new UUID, needs `devvm adopt` too.
|
||||
- **Two devvms no longer write the agent store at once:** `devvm agent import`, `devvm agent save` and a start that cleans Claude Code's plugins out of the store now take turns, so a second one waits, saying so, until the first is done, where before their files could mix or one could fail partway. A save that finds the store changed since it showed what differs saves nothing, rather than write over an import ([importing from this machine](https://next.devvm.dev/docs/using/coding-agents/#importing-from-this-machine)).
|
||||
- **A failed `devvm agent save` leaves the store as it was:** a save that failed partway, such as at a file it couldn't write in one agent's store or at the Claude Code login it saves last, left the agents it had saved before the failure saved and the rest not. It now saves all or nothing, as an import does, and in the rare case that putting the store back fails too, it names what it kept. A file in the VM where the store has a folder, or the other way round, fails the save before anything changes, naming the store's path. It also holds the lock on Claude Code's logins while it saves Claude Code's part of `~/.claude.json`, the lock a VM's proxy holds while it saves a Claude Code login made in that VM, so the two take turns, and Ctrl-C while it waits for either lock ends the wait ([saving a VM's settings](https://next.devvm.dev/docs/using/coding-agents/#saving-a-vms-settings)).
|
||||
- **`devvm agent save` has an import's bounds on depth:** a VM that sends folders nested more than 128 deep, or a path of more than 4,096 bytes, now gets nothing saved, as an import of such folders does, where before a chain of thousands of folders could keep the save busy for a long time while it held the agent store's lock ([saving a VM's settings](https://next.devvm.dev/docs/using/coding-agents/#saving-a-vms-settings)).
|
||||
- **Names that differ only in case no longer lose a file on a Mac:** when the VM, or your home folder for `devvm agent import`, had a file whose name differed from the store's only in case, such as `foo.md` where the store had `Foo.md`, `devvm agent save` and `devvm agent import` deleted the store's file and reported success, because macOS's volume reads both names as one file. They now treat the two as one file, as the volume does, so the store's file gets the new content and keeps its name, and the save's diff shows it as changed. Two names in the VM that differ only in case, such as `A.md` and `a.md`, would be one file in the store, so the save now saves nothing and names both, and so does an import of two such names from a home folder on a volume that tells case apart ([saving a VM's settings](https://next.devvm.dev/docs/using/coding-agents/#saving-a-vms-settings)).
|
||||
- **A link inside an agent's folder copies only a setting:** `devvm agent import` copied a link inside an agent's folder as the file it led to wherever that file was in the folder, so a link in `~/.claude/skills` or `~/.claude/plugins/cache` could put your history, `~/.claude/.credentials.json` or a plugin's data into the store, where every VM with the agent reads it. Such a link is now copied only when it leads to one of the settings the import copies, and any other is left out with a warning that names where it leads ([importing from this machine](https://next.devvm.dev/docs/using/coding-agents/#importing-from-this-machine)).
|
||||
- **`devvm agent import` no longer copies your plugins' data into every VM:** it copied all of `~/.claude/plugins` into the store, so every VM with Claude Code got the data that your plugins keep on this machine, which can hold their own logins. It now copies only the marketplaces, their records and the plugins' cache, and `devvm agent save` copies only those from a VM ([importing from this machine](https://next.devvm.dev/docs/using/coding-agents/#importing-from-this-machine)).
|
||||
- **An export can't put what an import leaves out into a VM:** `devvm history import` left out the agents' logins and the files devvm's setup writes by their names as an export wrote them, so an export that spelled one another way, such as `.claude/./settings.json` or `.claude//plugins`, got it into the VM's home. The import now refuses a name with a `.` or empty part, and deletes what it leaves out by its path once it's unpacked ([importing history](https://next.devvm.dev/docs/internals/agents/#importing-history)).
|
||||
- **A project folder's VM works after your Mac restarts (#60):** macOS numbers its disks' devices in the order they appear at boot, so after a restart an unchanged folder could be on a device with another number. devvm then took the folder for another one, so every command on its VM refused it as made for an earlier folder at its path, a stopped VM's start refused it as replaced, and the next check of `.git` called it replaced. A folder at the same path, with no link on it and with the same inode and birth time, is now the same folder on whichever device it's on, and its VM's next start records it on that device before it mounts it, in the one change devvm makes to its Lima config. A folder that moved after a restart, before its VM started again, isn't offered the VM, so `devvm adopt VM` moves it ([one VM per folder](https://next.devvm.dev/docs/internals/security/#one-vm-per-folder)).
|
||||
- **Names you choose in an agent's settings are no longer taken for secrets (#55):** devvm took a plugin, a marketplace or an MCP server whose name had `key`, `token`, `secret` or `passw` in it, such as `tokeneconomizer` or `secret-scanner`, for a secret, and put `devvm-redacted` in place of all its settings in the VM's copy. Claude Code then refused the VM's `settings.json` whole, so every plugin was off in the VM. devvm now knows the agents' tables of names, such as Claude Code's `extraKnownMarketplaces` and `mcpServers` and Codex's `marketplaces` and `hooks.state`, and judges only the fields under a name, so a server named `secret-scanner` keeps its command and still loses its `env` and its `apiKey`. Thanks to @jspiro for the report and @dhruv1220 for the tests' idea in #58 ([keys in settings files](https://next.devvm.dev/docs/internals/network/#keys-in-settings-files)).
|
||||
- **A folder whose name has separators in a row gets a VM (#52):** a folder named `x--y`, `foo (copy)` or `C++ stuff` failed to get one, because devvm turned each character other than a letter or digit into its own dash, and Lima refuses a name with dashes in a row. Each run of them now becomes one dash, so `foo (copy)` gets `devvm-foo-copy-<hash>`, and the state such a folder's failed VM left is replaced when you run devvm there again. Thanks to @se6a for the report ([VM names](https://next.devvm.dev/docs/internals/backends/#vm-names)).
|
||||
- **Lima's console logs no longer keep a VM's proxy password:** Lima's boot scripts write the VM's proxy settings, with the VM's own proxy password, to the VM's serial console, and Lima keeps that console in `serial.log`, `serialp.log` or `serialv.log` in the VM's folder in devvm's Lima home. devvm took the passwords out of Lima's `ha.stderr.log` only, so those logs kept the VM's password. devvm now replaces each password in them with as many `*` once the VM has started, as it does in `ha.stderr.log` ([the run log](https://next.devvm.dev/docs/internals/overview/#the-run-log)).
|
||||
- **A short name no longer reaches a denied host under your search domain:** the proxy looked names up with this machine's DNS search domain, which macOS takes from the network's settings and Linux from `/etc/resolv.conf`. So with `api.corp.example.com` denied and `**` allowing the rest, a VM could reach that host as `api`, or `api.eu.corp.example.com` as `api.eu`, when either had a public address, because no rule judged the name the search domain made. The proxy now looks each name up as it's written, so a short name such as `jenkins` no longer reaches a host through the proxy, and a tool in the VM reaches a host on your network by its full name, such as `jenkins.corp.example.com`. When a name without a dot doesn't resolve, the block says to use its full name, and a block because a name doesn't resolve no longer suggests a `devvm network allow` command, which the name's rule already gives ([a name that doesn't resolve](https://next.devvm.dev/docs/using/troubleshooting/#a-name-that-doesnt-resolve)).
|
||||
- **A VM can no longer take an SSH agent away from you or other VMs:** a VM that forwarded your agent or devvm's own could remove every key from it with `ssh-add -D`, lock it with a password of its own with `ssh-add -x`, or add keys to it, because `ssh-agent` answers every request a forwarded connection sends. Every VM that shares devvm's agent lost it then, and with your own agent, so did you. A VM now reaches its agent only through its proxy, which passes on listing keys, signing and binding a session to a host, and refuses everything else, so `ssh-add` in a VM can still list and use the keys, but not remove, lock or add them. The ssh entries for editors name the same socket, so an editor's connection gets the same agent as devvm's shell, the one the VM started with, and the entry of a VM started outside devvm, such as with `devvm limactl start`, forwards no agent. A VM that's running when you upgrade keeps the old behaviour until its next start, so restart it with `devvm restart` ([the SSH agents](https://next.devvm.dev/docs/internals/processes/#the-ssh-agents)).
|
||||
- **A VM's host keys are pinned whatever its ports:** when other programs on this machine, such as your own dev servers, held every port a VM lists, or the VM forwarded none with `devvm ports none`, a start that went no further than starting the VM, such as `devvm clone fetch` on a stopped `--clone` VM, didn't pin the VM's ssh host keys. devvm's own ssh to the VM then failed until something else pinned them, so `devvm clone fetch` and `devvm rm`'s fetch failed with `clone_fetch_failed`. devvm now pins the keys each time it starts a VM, whatever the VM forwards, and a command that finds the VM running without them pins them first ([ssh into VMs](https://next.devvm.dev/docs/internals/security/#ssh-into-vms)).
|
||||
- **A removed link's connections end with it:** `devvm link rm` used to stop a link's new connections but leave its open ones running. A target that never closed its end kept each of those connections' ssh processes on this machine, and one of the 256 connections a client's links carry at once, until the client or the target stopped. Removing a link now ends its open connections within a few seconds, and when a target starts again, the connections still open through its earlier start end too ([removing a link](https://next.devvm.dev/docs/using/links/#removing-a-link)).
|
||||
- **An agent's settings file that's one string no longer crashes `devvm agent save`:** when an agent's settings file in the VM was a single JSON string holding a placeholder, `devvm agent save` crashed. It now puts the saved value back in it. A login file on this machine that holds only `null` is now refused as not a JSON object, where saving a Codex or opencode login made in a VM failed on it ([saving a VM's settings](https://next.devvm.dev/docs/using/coding-agents/#saving-a-vms-settings)).
|
||||
- **A closed connection's ssh process ends:** when a VM never closed its end of a forwarded port's or a link's connection, that connection's ssh process stayed on this machine after the program here, or in the client, had closed its side. So a hostile VM could take all 256 connections that a forwarder or a client's links carry at once. Such an ssh process now ends once its client has closed and the VM has sent nothing for 30 seconds. A program that closes its side for writing and then waits for an answer, as `nc -N` does, keeps its connection only while the VM sends something at least every 30 seconds, the first byte included, so a slow query that takes longer than that to start answering is cut ([how it reaches the VM](https://next.devvm.dev/docs/internals/ports/#how-it-reaches-the-vm)).
|
||||
- **A forwarded port answers on `::1` too:** when this machine briefly couldn't listen on a port's IPv6 address, such as when it ran out of open files, the forwarder forwarded the port on `127.0.0.1` alone until the server in the VM restarted. A client that connects only over IPv6, such as `http://[::1]:PORT` or a tool that doesn't fall back to `127.0.0.1`, then didn't reach the VM, and another program on this machine could take `::1` on that port and get those connections instead. The forwarder now tries the port again at the VM's next report and forwards it on both addresses. A machine that denies the forwarder `::1` alone, such as through a security module, still gets its ports on `127.0.0.1`, and the forwarder's log says so ([when it can't forward](https://next.devvm.dev/docs/internals/ports/#when-it-cant-forward)).
|
||||
- **Every host is read as the proxy reads it:** a few of devvm's checks read a host in a way of their own. A name with a letter that isn't plain ASCII, such as the Kelvin sign, which Unicode's case folding turns into `k`, was taken as the ASCII name it folds into by `devvm secret set --host`, an MCP server's URL and a `NO_PROXY` entry, and `--from` took a registry's host with such a letter, or an address in brackets before a trailing dot such as `[::1].`, as one on the internet. The proxy refuses such a host, so now `devvm secret set` refuses it, an MCP server with one gets no secret, a `NO_PROXY` entry with one matches no host, `--from` doesn't take such a registry as public, and `devvm network rm` with it never removes the rule with the plain letter. The proxy also answers `400` to a host with brackets around anything but an IPv6 address, such as `[evil.com]:443`. A partial clone's warnings also read a remote's host without its trailing dot, so they name `example.com` rather than `example.com.`, and a remote at `localhost.` gets the same warning as one at `localhost` ([how the proxy reads a host](https://next.devvm.dev/docs/internals/network/#the-proxy)).
|
||||
- **A VM can't fill a Linux host with processes:** on a Linux host, each connection that a VM confined to its proxy made to the proxy started a devvm process on this machine, with no limit, so a VM that opened connections without end could start thousands of them. devvm now carries at most 256 of a VM's connections to its proxy at once, and answers any past that with `503` before it reaches the proxy. A VM that's running when you upgrade has no limit until its next start ([the QEMU wrapper](https://next.devvm.dev/docs/internals/processes/#the-qemu-wrapper-and-its-keeper)).
|
||||
- **A forwarded port answers after a burst:** when the port forwarder ran out of open files while accepting a connection, it stopped accepting connections on that port while it still listened there, so the port took connections that nothing answered until the server in the VM restarted. It now tries again shortly after, and so do a link's socket and a browser login's forward, which also carries at most 16 connections at once ([how it reaches the VM](https://next.devvm.dev/docs/internals/ports/#how-it-reaches-the-vm)).
|
||||
- **A VM's proxy lets go of what a VM leaves:** a VM's proxy counted only its tunnels toward its limit, kept idle connections open without end, kept a plain HTTP request running after its client had gone, and took 1 MiB of a request's headers inside an intercepted tunnel. It now holds at most 2048 of the VM's connections of every kind at once, where one without the VM's password doesn't count, has at most 2048 requests to hosts under way at once, closes a connection that waits 10 minutes for its next request, or that lacked the VM's password, ends a plain HTTP request a minute after its client has stopped sending and nothing has come back, takes at most 64 KiB of headers everywhere, and carries at most 100 HTTP/2 requests at once in a tunnel. A plain `ws://` WebSocket through the proxy, which got `502`, now connects. Long downloads, WebSockets and slow streams go on as long as they last ([the proxy](https://next.devvm.dev/docs/internals/network/#the-proxy)).
|
||||
- **A `NO_PROXY` entry with port 0 matches nothing:** the proxy read an entry such as `git.test:0` as `git.test` on every port, so it sent those hosts directly rather than through your company proxy, and it read `git.test:080` or `git.test:+80` as port 80, which Go's clients don't. An entry whose port no request has, or whose port isn't in plain decimal, now matches no host, as one past 65535 already didn't ([through a company proxy](https://next.devvm.dev/docs/internals/network/#through-a-company-proxy)).
|
||||
- **No false lost pin on Linux hosts:** when git on this machine replaced `.git/config` just as devvm pinned it again, the pin could fail, and devvm warned that the file lost its pin and couldn't be pinned again, then that it was pinned again, at the VM's next check. A VM's start could fail the same way. devvm now pins the file the rename left, and warns only that it was pinned again ([how a Linux host locks .git](https://next.devvm.dev/docs/internals/git-protection/#on-linux-hosts)).
|
||||
- **A stopped forwarder or link session takes its ssh with it:** devvm stopping a VM's port forwarder or link session, or a `kill` of either, could leave its ssh connection to the VM running on this machine, with its control socket in devvm's run folder. Each signal devvm sends now reaches what the process started too, either one stops its ssh before it exits, and `devvm gc --orphans` also deletes a forwarder's socket that nothing listens on ([how devvm starts them](https://next.devvm.dev/docs/internals/processes/#how-devvm-starts-them)).
|
||||
- **A name fails at once with transparent mode off:** in a VM confined to its proxy, with transparent mode off or stopped, a lookup through the system's resolver, such as `getent`'s or curl's, could wait out its timeout rather than fail at once, seen on a Linux host, because systemd-resolved's stub kept retrying a name server where nothing listened. The VM's programs now ask that name server, its own `127.0.0.1`, directly, from each VM's next launch, so workerd under `wrangler dev`, which waited about 40 seconds for each lookup on a Linux host, fails at once too, and a VM on the open tier keeps systemd-resolved's stub ([the VM's resolver](https://next.devvm.dev/docs/internals/network/#the-vms-resolver)).
|
||||
- **A Nix package is downloaded once:** when two requests for a package that wasn't in the shared Nix cache yet came close together, the second could download it again after the first had kept it, and the cache counted it twice against its cap. It now looks in the cache again before it downloads ([the shared Nix cache](https://next.devvm.dev/docs/internals/network/#the-shared-nix-cache)).
|
||||
- **A refused launch leaves a running VM running:** when `config.toml`'s proxy named a user and no `proxy` secret was saved, `devvm` in the folder of a running VM refused, as it should, but also stopped the VM, and `devvm restart` stopped it before it refused. The same happened when your CAs folder couldn't be used, or the VM's CA or secret files couldn't be readied. On a launch or a `devvm network` change, devvm now checks the company proxy, your CAs, the VM's CA and its secret files before it stops the VM's proxy, and says it left the VM and its proxy running as they were. `devvm restart` checks the company proxy and your CAs before it stops the VM. A `devvm network` change between `internet`, `allowlist` and `none` on a running VM is refused before the VM's tier changes, so its tier never says one thing while its proxy enforces another. A VM whose proxy doesn't enforce the tier the VM has now, or whose proxy is stopped for new settings and then can't start again, is still stopped, because a VM never runs on without its proxy. A `devvm network` change now stops it in that case too, where it left the VM running without its proxy ([the proxy](https://next.devvm.dev/docs/internals/network/#the-proxy)).
|
||||
- **A VM's logs are held to their caps:** root in a VM could write to its serial console, `/dev/hvc0`, without end, and Lima's console log for the VM grew until this machine's disk was full, and so could Lima's own logs for the VM until its next start. While a VM runs, its proxy now keeps the disk space each of those logs takes under 10 MiB, on a file system with holes such as APFS or ext4, moving its end to the same name with `.1` added, of up to 10 MiB more, with any password in it replaced. It also replaces the VM's proxy password as the logs grow, so a reboot inside the VM, which on Linux hosts writes it to the console's log again, can't leave it there. A VM that's running when you upgrade gets this once a devvm command starts its proxy again. The port forwarder's and the link session's logs now stay under 1 MiB while they run, not only from their next start, a link's warnings take turns with the session's other lines, the build proxy's log stays under 10 MiB as a VM's proxy's does, a run writes at most 128 MiB to its run log, and the run logs take at most 256 MiB together, though devvm never deletes the newest or one that a running devvm still writes ([Lima's hostagent](https://next.devvm.dev/docs/internals/processes/#limas-hostagent)).
|
||||
- **devvm desktop goes on after a burst:** when `devvm desktop`'s relay ran out of open files while accepting a viewer, `devvm desktop` ended with an error, and the desktop's port with it. It now tries again shortly, as the port forwarder does ([the desktop relay](https://next.devvm.dev/docs/internals/processes/#the-desktop-relay)).
|
||||
- **A VM's size that isn't a number is refused:** when a VM's state file held a size devvm couldn't read as a number, such as `"cpus": "four"` after an edit by hand, the VM started with the image's size without a word. devvm now refuses to start the VM or show its size, names the value, and says to set it again with `devvm size`. `--cpus`, `--memory`, `--disk`, `config.toml` and `devvm size -g` also refuse a number too big for devvm to read, which for a disk reached Lima as infinity ([size](https://next.devvm.dev/docs/using/ports-size/#size)).
|
||||
- `devvm agent login claude --setup-token` now shows Claude Code's address and the prompt for its code, and Ctrl-C ends an agent's login ([details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-setup-token-login), [details](https://next.devvm.dev/docs/releases/0.2.0/#ctrl-c-in-an-agents-login), [#57](https://github.com/devvmhq/devvm/issues/57), [6965efc](https://github.com/devvmhq/devvm/commit/6965efcc0a97f7f6334f00d0530007ecf459972c)).
|
||||
- Programs in a VM, such as coding agents, now get your terminal's 24-bit color in devvm's shell, `devvm agent login` and `ssh` to a VM by name ([details](https://next.devvm.dev/docs/releases/0.2.0/#24-bit-color-in-a-vm), [#54](https://github.com/devvmhq/devvm/issues/54), [947decb](https://github.com/devvmhq/devvm/commit/947decb301c609cb8eba59a92fa6fa2c373945a4)).
|
||||
- A login to an MCP server that you make in a VM now finishes and stays in that VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#mcp-servers-logins), [#62](https://github.com/devvmhq/devvm/issues/62), [ea3037b](https://github.com/devvmhq/devvm/commit/ea3037bc157903525be51c83aedfd72c37da3cbb)).
|
||||
- A plugin in a VM now keeps its data, and you can install plugins and update marketplaces there ([details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-plugins-in-a-vm), [#56](https://github.com/devvmhq/devvm/issues/56), [e97db05](https://github.com/devvmhq/devvm/commit/e97db057fd93873a14b075e7d46615dc2d020ac4)).
|
||||
- A project folder keeps its VM after your Mac restarts, though a folder that moved before its VM started again needs `devvm adopt VM` ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-project-folder-after-your-mac-restarts), [#60](https://github.com/devvmhq/devvm/issues/60), [2c0a894](https://github.com/devvmhq/devvm/commit/2c0a894a1cb7347f3d6ebbcb3c39390d07ab4ed8)).
|
||||
- A plugin, marketplace or MCP server with a name such as `secret-scanner` no longer gets its settings redacted in a VM, so Claude Code stops refusing the VM's `settings.json` from the VM's next launch. Thanks to @jspiro for the report and @dhruv1220 for the tests' idea in [#58](https://github.com/devvmhq/devvm/pull/58) ([details](https://next.devvm.dev/docs/releases/0.2.0/#names-you-choose-in-an-agents-settings), [#55](https://github.com/devvmhq/devvm/issues/55), [f384829](https://github.com/devvmhq/devvm/commit/f3848294d8e1095f115ae13e224697484b38c47c)).
|
||||
- A folder whose name has separators in a row, such as `x--y`, `foo (copy)` or `C++ stuff`, now gets a VM when you run devvm there again. Thanks to @se6a for the report ([details](https://next.devvm.dev/docs/releases/0.2.0/#folder-names-with-separators-in-a-row), [#52](https://github.com/devvmhq/devvm/issues/52), [ba5613e](https://github.com/devvmhq/devvm/commit/ba5613e1ed9bc1c2592f1fa1af81a6e89f97f513)).
|
||||
- A warning now prints above the status line, so the status line no longer erases a question's prompt or what you typed ([details](https://next.devvm.dev/docs/releases/0.2.0/#warnings-and-the-status-line), [2b176c9](https://github.com/devvmhq/devvm/commit/2b176c92b3a4e44f83df5a94d8abc710ff5e8097)).
|
||||
- A plain `ws://` WebSocket now connects through the proxy, where it used to get `502` ([details](https://next.devvm.dev/docs/releases/0.2.0/#plain-websockets), [f37c70a](https://github.com/devvmhq/devvm/commit/f37c70a5cd9ea6dcb3f86ffcb6346bba0ee65136)).
|
||||
|
||||
<details><summary>If you use Claude Code and devvm's agent store</summary>
|
||||
|
||||
- devvm now warns when `devvm agent import` or `devvm agent save` copies a marketplace holding a credential, when a project folder is inside or holds an agent's folder, and when an import leaves out a link ([details](https://next.devvm.dev/docs/releases/0.2.0/#credentials-in-a-copied-marketplace), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-project-in-an-agents-folder), [details](https://next.devvm.dev/docs/releases/0.2.0/#links-inside-an-agents-folder), [c9d0fdb](https://github.com/devvmhq/devvm/commit/c9d0fdb270c3b348291d64333e12e4cef7856f07), [c901b92](https://github.com/devvmhq/devvm/commit/c901b920efb08d6fdf2edbaa7cfd15b1941f83ab), [d939d1d](https://github.com/devvmhq/devvm/commit/d939d1d870cc0216b5a3036636b13489a869b71e)).
|
||||
- A failed `devvm agent import` or `devvm agent save` now leaves the agent store as it was, and two of these commands at once, or a save and a VM's new Claude Code login, take turns ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-failed-import-changes-nothing), [details](https://next.devvm.dev/docs/releases/0.2.0/#two-devvms-at-the-agent-store), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-failed-save-changes-nothing), [details](https://next.devvm.dev/docs/releases/0.2.0/#devvm-agent-save-and-a-new-claude-code-login), [3101c85](https://github.com/devvmhq/devvm/commit/3101c85260b2b5f872c0e85c0287d2d08e13bbe1), [b04a1a9](https://github.com/devvmhq/devvm/commit/b04a1a9f1217cbf8069738b42d2072d4d84c53bd), [f80fd2d](https://github.com/devvmhq/devvm/commit/f80fd2df6031e1bb3ac86e5ec7d410cac0551104)).
|
||||
- On a Mac, `devvm agent save` and `devvm agent import` no longer delete a store file whose name differs from yours only in case, such as `Foo.md` ([details](https://next.devvm.dev/docs/releases/0.2.0/#names-that-differ-only-in-case), [888078c](https://github.com/devvmhq/devvm/commit/888078c9cd830a68b04665a5d3217d041624aefb)).
|
||||
- `devvm agent import` fails on an agent's folder past 20,000 entries, 128 MiB or 16 MiB in one file, and `devvm agent save` saves nothing past folders 128 deep or paths of 4,096 bytes ([details](https://next.devvm.dev/docs/releases/0.2.0/#devvm-agent-imports-bounds), [details](https://next.devvm.dev/docs/releases/0.2.0/#how-deep-a-save-goes), [c901b92](https://github.com/devvmhq/devvm/commit/c901b920efb08d6fdf2edbaa7cfd15b1941f83ab), [888078c](https://github.com/devvmhq/devvm/commit/888078c9cd830a68b04665a5d3217d041624aefb)).
|
||||
- While devvm can't read a VM's state, `devvm agent import` follows no links and warns, so run `devvm doctor` and import again ([details](https://next.devvm.dev/docs/releases/0.2.0/#an-import-while-a-vms-state-cant-be-read), [b04a1a9](https://github.com/devvmhq/devvm/commit/b04a1a9f1217cbf8069738b42d2072d4d84c53bd)).
|
||||
- `devvm agent save` no longer crashes on an agent's settings file that's a single JSON string ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-settings-file-thats-one-string), [1ecd1fa](https://github.com/devvmhq/devvm/commit/1ecd1faa735c32521c193b1b7ab710a2aea10906)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use Cursor</summary>
|
||||
|
||||
- Cursor's CLI in a VM can no longer make some changes to your account, team or cloud agents, such as merging a cloud agent's pull request, so make those from Cursor on your machine ([details](https://next.devvm.dev/docs/releases/0.2.0/#cursors-cli-and-your-cursor-account), [872c2e2](https://github.com/devvmhq/devvm/commit/872c2e23c0c4edc28d690ce13a028d6b8b140d31)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use a company proxy</summary>
|
||||
|
||||
- A launch, a `devvm network` change or a `devvm restart` that devvm refuses, such as for a missing `proxy` secret, now leaves a running VM running ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-refused-launch), [4a4aabe](https://github.com/devvmhq/devvm/commit/4a4aabe9a8dd4d85f08b8dbeaf4b3c0ec9aaf3a5)).
|
||||
- A `NO_PROXY` entry with an IPv6 zone, or with a port that's 0 or isn't plain decimal, now matches no host ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-no_proxy-address-with-a-zone), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-no_proxy-entrys-port), [#59](https://github.com/devvmhq/devvm/issues/59), [8afdec7](https://github.com/devvmhq/devvm/commit/8afdec7de4bc2fbb5fb02a2f92f7918eae4dd5c4), [a7cc125](https://github.com/devvmhq/devvm/commit/a7cc12521e8d5361a87f179348c3cedff42bac1d)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use links or forwarded ports</summary>
|
||||
|
||||
- A VM that forwards every port leaves out the 17 ports that VMs' ssh uses, so list a server's port on one of them, such as an X server's 6000, with `devvm ports` ([ports](https://next.devvm.dev/docs/using/ports-size/#ports), [details](https://next.devvm.dev/docs/releases/0.2.0/#at-most-17-vms-run-at-once), [e4ea123](https://github.com/devvmhq/devvm/commit/e4ea123927cc90022b5333ab15e38f75c69c876a)).
|
||||
- `devvm link rm` now ends a link's open connections within seconds, and a stopped port forwarder or link session no longer leaves its ssh running ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-removed-links-connections), [details](https://next.devvm.dev/docs/releases/0.2.0/#stopped-forwarders-and-link-sessions), [c63f9a3](https://github.com/devvmhq/devvm/commit/c63f9a3340c507430108eb9e806b189f09346fdf), [90a64a4](https://github.com/devvmhq/devvm/commit/90a64a44d192dde1b413992925abba61bc41a6e5)).
|
||||
- A forwarded port's or a link's connection now ends once its client has closed and the VM has sent nothing for 30 seconds, which can cut `nc -N` in front of a slow query ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-closed-connections-ssh-process), [c63f9a3](https://github.com/devvmhq/devvm/commit/c63f9a3340c507430108eb9e806b189f09346fdf)).
|
||||
- After this machine briefly runs out of open files, forwarded ports keep answering on both `::1` and `127.0.0.1`, and `devvm desktop` keeps running ([details](https://next.devvm.dev/docs/releases/0.2.0/#forwarded-ports-over-ipv6), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-forwarder-after-a-burst), [details](https://next.devvm.dev/docs/releases/0.2.0/#devvm-desktop-after-a-burst), [608ab43](https://github.com/devvmhq/devvm/commit/608ab43714354833cca7fb96f8ab89c53ef7f49d), [f37c70a](https://github.com/devvmhq/devvm/commit/f37c70a5cd9ea6dcb3f86ffcb6346bba0ee65136), [df1d76b](https://github.com/devvmhq/devvm/commit/df1d76bbd9421a62901f424224dc2c64adf24ee6)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use --clone</summary>
|
||||
|
||||
- `devvm clone fetch` and `devvm rm`'s fetch no longer fail with `clone_fetch_failed` on a VM that forwards no ports ([details](https://next.devvm.dev/docs/releases/0.2.0/#host-keys-whatever-a-vms-ports), [c1cf96e](https://github.com/devvmhq/devvm/commit/c1cf96e4b6c757d17519c6796fbb6e49dd75d5f6)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use SSH agent forwarding</summary>
|
||||
|
||||
- `ssh-add` in a VM can still list and use your SSH agent's keys, but it can no longer remove, lock or add them ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-vm-and-its-ssh-agent), [19f9900](https://github.com/devvmhq/devvm/commit/19f9900b8633108cf69b28ee7a253b08bafff70f)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use a Linux host</summary>
|
||||
|
||||
- devvm no longer warns that `.git/config` lost its pin when git replaces the file just as devvm pins it ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-pin-that-meets-gits-rename-on-linux), [90a64a4](https://github.com/devvmhq/devvm/commit/90a64a44d192dde1b413992925abba61bc41a6e5)).
|
||||
- In a VM confined to its proxy with transparent mode off, a lookup now fails at once from the VM's next launch, instead of waiting, as `wrangler dev` did for about 40 seconds ([details](https://next.devvm.dev/docs/releases/0.2.0/#lookups-with-transparent-mode-off), [63bb1ff](https://github.com/devvmhq/devvm/commit/63bb1ff9a8d9cec29400628acd2efbb75e99b8bf)).
|
||||
- When a VM's proxy can't get its whole sandbox, such as on a kernel whose Landlock is older than ABI 6, the VM keeps its network and `devvm doctor` warns, naming what's missing ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-child-without-its-whole-sandbox), [941c63c](https://github.com/devvmhq/devvm/commit/941c63c696b2315329028049b21fa70cdb1b2a0d)).
|
||||
|
||||
</details>
|
||||
<details><summary>Security hardening: a VM that tries to attack your machine can now do much less</summary>
|
||||
|
||||
- Each VM's proxy now runs as two processes, and the one that reads the VM's network holds only that VM's secrets and can't read your files, reach the Keychain or connect to local services ([details](https://next.devvm.dev/docs/releases/0.2.0/#each-vms-proxy-runs-as-two-processes), [details](https://next.devvm.dev/docs/releases/0.2.0/#the-childs-sandbox-on-macos), [details](https://next.devvm.dev/docs/releases/0.2.0/#the-childs-sandbox-on-linux), [details](https://next.devvm.dev/docs/releases/0.2.0/#the-child-connects-only-through-devvm-_proxy), [aeea313](https://github.com/devvmhq/devvm/commit/aeea3135b27e0de898a449adb63b7742126b8ddb), [941c63c](https://github.com/devvmhq/devvm/commit/941c63c696b2315329028049b21fa70cdb1b2a0d), [1793353](https://github.com/devvmhq/devvm/commit/1793353dd920a48cf4964b788a665c50cc208147), [3da3843](https://github.com/devvmhq/devvm/commit/3da38436a7f598dfe59711b0f64589e966bcb915)).
|
||||
- On a Mac, devvm refuses a project in its own folders whatever the case of their names, such as `~/.Config/devvm/layers`, so delete a VM already made there with `devvm rm` ([details](https://next.devvm.dev/docs/releases/0.2.0/#devvms-own-folders-in-another-case), [c41ca82](https://github.com/devvmhq/devvm/commit/c41ca82f6e98c2f41ce469de607ae0403c0ab4fc)).
|
||||
- `devvm history import` refuses an export with a name such as `.claude/./settings.json`, so an export can't put an agent's login or devvm's setup files into a VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-history-exports-names), [e97db05](https://github.com/devvmhq/devvm/commit/e97db057fd93873a14b075e7d46615dc2d020ac4)).
|
||||
- A VM can't fill a Linux host with processes, because devvm carries at most 256 of its connections to the proxy at once ([details](https://next.devvm.dev/docs/releases/0.2.0/#connections-to-the-proxy-on-linux-hosts), [f37c70a](https://github.com/devvmhq/devvm/commit/f37c70a5cd9ea6dcb3f86ffcb6346bba0ee65136)).
|
||||
- A VM's proxy holds at most 2,048 of its connections, closes one that waits 10 minutes for its next request, and takes at most 64 KiB of headers ([details](https://next.devvm.dev/docs/releases/0.2.0/#what-a-vms-proxy-holds), [f37c70a](https://github.com/devvmhq/devvm/commit/f37c70a5cd9ea6dcb3f86ffcb6346bba0ee65136)).
|
||||
- A `devvm network` change never leaves a VM running without its proxy ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-vm-never-runs-without-its-proxy), [4a4aabe](https://github.com/devvmhq/devvm/commit/4a4aabe9a8dd4d85f08b8dbeaf4b3c0ec9aaf3a5)).
|
||||
- While a VM runs, Lima's console log and Lima's own logs for it each stay under 10 MiB, plus one older file of up to 10 MiB, so a VM can't fill your disk ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-vms-logs-and-their-caps), [9c74dac](https://github.com/devvmhq/devvm/commit/9c74dac11ea6100f3a583dd79fe3380b45573fab)).
|
||||
- While they run, the port forwarder's and link session's logs stay under 1 MiB and the build proxy's under 10 MiB, and the run logs take at most 256 MiB together ([details](https://next.devvm.dev/docs/releases/0.2.0/#devvms-other-logs), [9c74dac](https://github.com/devvmhq/devvm/commit/9c74dac11ea6100f3a583dd79fe3380b45573fab)).
|
||||
- Lima's console logs no longer keep a VM's proxy password ([details](https://next.devvm.dev/docs/releases/0.2.0/#passwords-in-limas-console-logs), [4d40958](https://github.com/devvmhq/devvm/commit/4d409589bbd0050c29deb4110b35326abcb9e7ba)).
|
||||
- devvm now reads every host as the proxy does, so `devvm secret set`, `NO_PROXY`, MCP servers' URLs and `--from` no longer take a host with a letter such as the Kelvin sign as plain ASCII ([details](https://next.devvm.dev/docs/releases/0.2.0/#every-host-in-one-form), [4e92549](https://github.com/devvmhq/devvm/commit/4e925492ca22a58aab631675de76d3ca497251d6)).
|
||||
|
||||
</details>
|
||||
<details><summary>Internal changes</summary>
|
||||
|
||||
- `devvm doctor` now warns once of each VM whose state devvm can't read, naming the VM, the file and why, and it changes nothing ([details](https://next.devvm.dev/docs/releases/0.2.0/#devvm-doctor-checks-every-vms-state), [5924a37](https://github.com/devvmhq/devvm/commit/5924a373f07a6c550d9696d6332e546559d9650f)).
|
||||
- mise is 2026.11.10 in base and on this machine, the docker layer has Docker 29.10.0 and compose 5.8.0, and Cursor's CLI is 2026.11.17-f532c45 ([details](https://next.devvm.dev/docs/releases/0.2.0/#pins), [c9005ae](https://github.com/devvmhq/devvm/commit/c9005ae4be13f6ebe337111bdba980c3f595c7fe), [01e837a](https://github.com/devvmhq/devvm/commit/01e837a164a2d751339e07197fe264b3e3804959)).
|
||||
- In a terminal, a status line now says what devvm waits for during its slow steps and while another devvm changes the same thing ([details](https://next.devvm.dev/docs/releases/0.2.0/#status-lines-for-slow-steps), [details](https://next.devvm.dev/docs/releases/0.2.0/#status-lines-while-devvm-waits), [2b176c9](https://github.com/devvmhq/devvm/commit/2b176c92b3a4e44f83df5a94d8abc710ff5e8097), [cb7177b](https://github.com/devvmhq/devvm/commit/cb7177b32c3f40c38848c8c5740073e245f79eca)).
|
||||
- When devvm can't read a project folder, it names the folder and why, where it used to say the VM was made for an earlier folder ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-project-folder-devvm-cant-read), [cb7177b](https://github.com/devvmhq/devvm/commit/cb7177b32c3f40c38848c8c5740073e245f79eca)).
|
||||
- A folder that moved while a restart renumbered its disk keeps its VM, once the VM has recorded its folder's volume at a launch ([a moved or renamed folder](https://next.devvm.dev/docs/using/vms/#a-moved-or-renamed-folder), [details](https://next.devvm.dev/docs/releases/0.2.0/#a-folder-moved-across-a-restart), [ba510ee](https://github.com/devvmhq/devvm/commit/ba510eec1f55a7cd656050eabe14c5b52ba5ed38)).
|
||||
- The shared Nix cache downloads each package once, even when two requests for it come close together ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-nix-package-downloaded-twice), [90a64a4](https://github.com/devvmhq/devvm/commit/90a64a44d192dde1b413992925abba61bc41a6e5)).
|
||||
- devvm now refuses a VM's size that isn't a number, naming it, where the VM used to start with the image's size, so set it again with `devvm size` ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-size-that-isnt-a-number), [0b85f5f](https://github.com/devvmhq/devvm/commit/0b85f5f557a8b7a6b83f89533746c7bac3ecb7b2)).
|
||||
|
||||
</details>
|
||||
|
||||
## 0.1.1-rc.3
|
||||
|
||||
@@ -98,8 +125,8 @@ A release candidate for 0.1.1, adding to 0.1.1-rc.2. Install it with `devvm upgr
|
||||
|
||||
### New
|
||||
|
||||
- **Cursor (#44, thanks to @barnesoir):** `--agents cursor` gives a VM Cursor's CLI, as `cursor-agent` or `agent`, and `devvm agent login cursor` logs it in from a browser on any machine, with the login kept on this machine ([Cursor CLI login](https://next.devvm.dev/docs/using/coding-agents/#cursor-cli-login)). `devvm cursor` opens the folder's VM in the Cursor editor, as `devvm code` does in VS Code. Recent Cursor runs its Agent in the VM with your Cursor sign-in in memory, so `devvm cursor` warns unless your Cursor settings send Agent's requests through the app on this machine, and you should open only VMs you trust with it ([Cursor's Agent](https://next.devvm.dev/docs/using/ssh/#cursors-agent)).
|
||||
- **`devvm paste` (#38, thanks to @DustyPolk):** sends the image, PDF or file you copied on this machine into the running VM and puts its path in the VM on your clipboard, so you can paste it into a coding agent. A copied file goes only after you say yes, and `devvm paste rm` deletes what it sent ([pasting images](https://next.devvm.dev/docs/using/coding-agents/#pasting-images)).
|
||||
- **Cursor ([#44](https://github.com/devvmhq/devvm/pull/44), thanks to @barnesoir):** `--agents cursor` gives a VM Cursor's CLI, as `cursor-agent` or `agent`, and `devvm agent login cursor` logs it in from a browser on any machine, with the login kept on this machine ([Cursor CLI login](https://next.devvm.dev/docs/using/coding-agents/#cursor-cli-login)). `devvm cursor` opens the folder's VM in the Cursor editor, as `devvm code` does in VS Code. Recent Cursor runs its Agent in the VM with your Cursor sign-in in memory, so `devvm cursor` warns unless your Cursor settings send Agent's requests through the app on this machine, and you should open only VMs you trust with it ([Cursor's Agent](https://next.devvm.dev/docs/using/ssh/#cursors-agent)).
|
||||
- **`devvm paste` ([#38](https://github.com/devvmhq/devvm/pull/38), thanks to @DustyPolk):** sends the image, PDF or file you copied on this machine into the running VM and puts its path in the VM on your clipboard, so you can paste it into a coding agent. A copied file goes only after you say yes, and `devvm paste rm` deletes what it sent ([pasting images](https://next.devvm.dev/docs/using/coding-agents/#pasting-images)).
|
||||
- **`devvm agent import` can follow your dotfiles' links:** a link out of an agent's folder, such as `~/.claude/skills/x` into a dotfiles repo, is copied when you say yes in a terminal, when you pass `--follow-links`, or when it leads into a folder that `config.toml`'s `follow-links` names, such as `["~/dotfiles"]`. The store gets copies, never links, and devvm never follows a link to your home folder, its own folders, places that hold secrets, such as `~/.ssh`, or an agent's logins or history ([links out of an agent's folder](https://next.devvm.dev/docs/using/coding-agents/#links-out-of-an-agents-folder)).
|
||||
- **`--clone` copies your repo as it is here:** the VM's clone gets every branch, tag and remote-tracking branch, a detached HEAD, what you've staged and what you haven't, a rebase, merge or other operation in progress, and your stash. It also gets your remotes without credentials, the repo's hooks and its own settings, your initialised submodules, each with a clone of its own, and the Git LFS objects your checked-out files point to, as every VM now has `git-lfs`. A partial clone is copied with the objects it has, and the VM's git fetches the rest from its remote. Untracked and ignored files, such as `.env`, and credential helpers stay on this machine, and devvm names anything it leaves out that you'd expect in the VM. Because `origin` is real in the VM, code there that may use your GitHub token can push to it, which a network rule can stop ([what's copied](https://next.devvm.dev/docs/using/clone/#whats-copied), [the settings](https://next.devvm.dev/docs/using/clone/#the-settings), [submodules](https://next.devvm.dev/docs/using/clone/#submodules), [a partial clone](https://next.devvm.dev/docs/using/clone/#a-partial-clone), [Git LFS](https://next.devvm.dev/docs/using/clone/#git-lfs)).
|
||||
- **All of a `--clone` VM's work comes back:** `devvm clone fetch` also saves commits that only the VM's detached HEAD has as `saved/devvm/HEAD` and the VM's stash entries as `saved/devvm/stash-N`, and it brings back each submodule's branches and the LFS objects the VM's work points to, without `git-lfs` on this machine. `devvm rm` and `devvm clone off` check all of these and ask before any of them goes ([deleting the VM](https://next.devvm.dev/docs/using/clone/#deleting-the-vm)).
|
||||
@@ -115,7 +142,7 @@ A release candidate for 0.1.1, adding to 0.1.1-rc.2. Install it with `devvm upgr
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`--clone` of a shallow or SHA-256 repo (#40):** a repo from `git clone --depth 1` or one that uses SHA-256 failed after devvm made the VM. Both work now, and a VM whose copy failed gets its clone the next time you run devvm in its folder. Thanks to @Josuesp1620 for the report and @dhruv1220 for finding the cause in #42 ([a copy that didn't finish](https://next.devvm.dev/docs/using/clone/#a-copy-that-didnt-finish)).
|
||||
- **`--clone` of a shallow or SHA-256 repo ([#40](https://github.com/devvmhq/devvm/issues/40)):** a repo from `git clone --depth 1` or one that uses SHA-256 failed after devvm made the VM. Both work now, and a VM whose copy failed gets its clone the next time you run devvm in its folder. Thanks to @Josuesp1620 for the report and @dhruv1220 for finding the cause in [#42](https://github.com/devvmhq/devvm/pull/42) ([a copy that didn't finish](https://next.devvm.dev/docs/using/clone/#a-copy-that-didnt-finish)).
|
||||
- **A stopped VM no longer keeps its listed ports from other VMs:** only a running VM holds a port. When the first VM starts again, devvm and `devvm ports` say that the other VM has the port, and the first VM takes it back within about 20 seconds of the other one stopping. Meanwhile, both VMs' apps share that port's site data and service workers in your browser ([two VMs and one port](https://next.devvm.dev/docs/using/ports-size/#two-vms-and-one-port)).
|
||||
- **`devvm ports` says why a listed port isn't forwarded,** such as the forwarder's limit of 256 ports or Linux refusing a port below 1024, instead of always blaming a program on this machine ([a listed port isn't forwarded](https://next.devvm.dev/docs/using/troubleshooting/#a-listed-port-isnt-forwarded)). When a port's forward ends, so do its connections ([how it reaches the VM](https://next.devvm.dev/docs/internals/ports/#how-it-reaches-the-vm)).
|
||||
- **A name that doesn't resolve says why:** a block now says whether this machine's DNS has no address for the name or didn't answer in time, and after a failure that may pass, the proxy asks once more before it blocks the name ([log files](https://next.devvm.dev/docs/internals/network/#log-files)).
|
||||
@@ -137,31 +164,31 @@ A release candidate for 0.1.1, adding to 0.1.1-rc.1. Install it with `devvm upgr
|
||||
|
||||
### New
|
||||
|
||||
- **Transparent mode (#35), on by default:** on every tier but open, tools that ignore the proxy settings, such as `wrangler dev`, static Go binaries and containers, reach the VM's proxy and its allowlist anyway. A VM made before needs `devvm update` first, and `devvm network transparent off` turns it off for a VM ([what it covers](https://next.devvm.dev/docs/safety/network/#tools-that-ignore-the-proxy)).
|
||||
- **Folders of repos with `--clone` (#3):** one VM gets a clone of each repo you pick, at the same paths. `devvm clone fetch` brings back every repo's work, and `devvm clone add PATH` adds one ([folders of repos](https://next.devvm.dev/docs/using/clone/#folders-of-repos)).
|
||||
- **Transparent mode ([#35](https://github.com/devvmhq/devvm/issues/35)), on by default:** on every tier but open, tools that ignore the proxy settings, such as `wrangler dev`, static Go binaries and containers, reach the VM's proxy and its allowlist anyway. A VM made before needs `devvm update` first, and `devvm network transparent off` turns it off for a VM ([what it covers](https://next.devvm.dev/docs/safety/network/#tools-that-ignore-the-proxy)).
|
||||
- **Folders of repos with `--clone` ([#3](https://github.com/devvmhq/devvm/issues/3)):** one VM gets a clone of each repo you pick, at the same paths. `devvm clone fetch` brings back every repo's work, and `devvm clone add PATH` adds one ([folders of repos](https://next.devvm.dev/docs/using/clone/#folders-of-repos)).
|
||||
- **Rules by HTTP method and path:** `--method` and `--path` on `devvm network allow`, `deny` and `rm`, such as `devvm network deny api.github.com --method POST,PUT,PATCH,DELETE`.
|
||||
- **Your own secrets:** `devvm secret set NAME --host HOST --env VARIABLE`, then `devvm secret use NAME`. The VM only ever sees a placeholder, and `--method` and `--path` limit where the real value goes.
|
||||
- **Learning a VM's hosts (#17):** `--network learn`, then `devvm network lock` to keep the hosts you choose.
|
||||
- **`.git` protection on Linux (#4, #20):** `.git` is locked read-only around QEMU, without root. Where a host can't, such as Ubuntu with AppArmor, devvm watches `.git`, warns at each launch, and names what changed.
|
||||
- **Nested repos (#3):** a VM protects the `.git` of each repo up to 4 folders down. `devvm doctor` suggests `safe.bareRepository explicit`.
|
||||
- **pi and more providers (#23, #31, #32):** pi is a fourth agent, and Gemini, Groq, Mistral, xAI and DeepSeek keys stay on this machine.
|
||||
- **Prereleases on Homebrew (#19):** `brew install devvmhq/tap/devvm-rc`.
|
||||
- **Learning a VM's hosts ([#17](https://github.com/devvmhq/devvm/issues/17)):** `--network learn`, then `devvm network lock` to keep the hosts you choose.
|
||||
- **`.git` protection on Linux ([#4](https://github.com/devvmhq/devvm/issues/4), [#20](https://github.com/devvmhq/devvm/pull/20)):** `.git` is locked read-only around QEMU, without root. Where a host can't, such as Ubuntu with AppArmor, devvm watches `.git`, warns at each launch, and names what changed.
|
||||
- **Nested repos ([#3](https://github.com/devvmhq/devvm/issues/3)):** a VM protects the `.git` of each repo up to 4 folders down. `devvm doctor` suggests `safe.bareRepository explicit`.
|
||||
- **pi and more providers ([#23](https://github.com/devvmhq/devvm/pull/23), [#31](https://github.com/devvmhq/devvm/pull/31), [#32](https://github.com/devvmhq/devvm/pull/32)):** pi is a fourth agent, and Gemini, Groq, Mistral, xAI and DeepSeek keys stay on this machine.
|
||||
- **Prereleases on Homebrew ([#19](https://github.com/devvmhq/devvm/pull/19)):** `brew install devvmhq/tap/devvm-rc`.
|
||||
|
||||
### Changed
|
||||
|
||||
- **The 9p cache on Linux (#36):** Lima's default cache could write files to this machine empty or cut short, and made SQLite and Gradle fail. New Linux VMs use `none`, and `devvm mount-cache none` switches existing ones. Under `none`, keep SQLite WAL databases and other files that programs map for writing on the VM's own disk, or use `--clone`. macOS doesn't change.
|
||||
- **The 9p cache on Linux ([#36](https://github.com/devvmhq/devvm/issues/36)):** Lima's default cache could write files to this machine empty or cut short, and made SQLite and Gradle fail. New Linux VMs use `none`, and `devvm mount-cache none` switches existing ones. Under `none`, keep SQLite WAL databases and other files that programs map for writing on the VM's own disk, or use `--clone`. macOS doesn't change.
|
||||
- **A `--clone` VM in a folder another VM mounts** is refused, and `devvm rm` asks before deleting one made earlier.
|
||||
- **Logins:** a VM's copy of Codex's and Claude Code's login files keeps only the fields devvm knows. opencode, like pi, gets no key devvm doesn't bind, unless you list the provider in `config.toml`'s `[pass-keys]` (#30).
|
||||
- **Logins:** a VM's copy of Codex's and Claude Code's login files keeps only the fields devvm knows. opencode, like pi, gets no key devvm doesn't bind, unless you list the provider in `config.toml`'s `[pass-keys]` ([#30](https://github.com/devvmhq/devvm/pull/30)).
|
||||
- **Warnings** print once per command.
|
||||
- **Nix** is 2.35.5.
|
||||
|
||||
### Removed
|
||||
|
||||
- **`devvm git-protect strict` (#37):** it couldn't keep git on this machine out of submodules the VM adds, so it's a usage error now. Strict VMs become `on`, and devvm takes out the `diff.ignoreSubmodules = all` it set, keeping a value of your own ([VMs that were strict](https://next.devvm.dev/docs/safety/git-protection/#vms-that-were-strict)).
|
||||
- **`devvm git-protect strict` ([#37](https://github.com/devvmhq/devvm/issues/37)):** it couldn't keep git on this machine out of submodules the VM adds, so it's a usage error now. Strict VMs become `on`, and devvm takes out the `diff.ignoreSubmodules = all` it set, keeping a value of your own ([VMs that were strict](https://next.devvm.dev/docs/safety/git-protection/#vms-that-were-strict)).
|
||||
|
||||
### Fixed
|
||||
|
||||
- opencode's history copy with SQLite 3.54 (#26), a NUL byte in an ssh socket's path (#25), a build VM reusing its clone's ssh port, a login saved for an agent the VM lacks (#27), and `.git` protection locking a folder that only looks like a git folder (#28).
|
||||
- opencode's history copy with SQLite 3.54 ([#26](https://github.com/devvmhq/devvm/pull/26)), a NUL byte in an ssh socket's path ([#25](https://github.com/devvmhq/devvm/pull/25)), a build VM reusing its clone's ssh port, a login saved for an agent the VM lacks ([#27](https://github.com/devvmhq/devvm/pull/27)), and `.git` protection locking a folder that only looks like a git folder ([#28](https://github.com/devvmhq/devvm/pull/28)).
|
||||
|
||||
## 0.1.1-rc.1
|
||||
|
||||
@@ -192,3 +219,52 @@ The first release of devvm, which gives each project folder an isolated VM of it
|
||||
## Unreleased
|
||||
|
||||
These changes are on `main` and go out in the next release.
|
||||
|
||||
### Highlights
|
||||
|
||||
- A first run is about a quarter faster: shared tool images build side by side and the tools resolve while base builds, and it downloads about 210 MB less ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-faster-first-run)).
|
||||
- A first run now survives a network that cuts or stalls connections: each download is tried again, and Ubuntu's cloud image and base's and layers' downloads go on from where they stopped ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-first-run-on-a-bad-network)).
|
||||
- devvm keeps Ubuntu's cloud image in its own folder, so Lima's cache no longer grows with each release, and `devvm space` and `devvm gc --caches` show and free it ([details](https://next.devvm.dev/docs/releases/0.2.0/#ubuntus-cloud-image-in-devvms-folder)).
|
||||
|
||||
### What to do
|
||||
|
||||
1. Run `devvm update` in each existing VM's folder, and give the first one several minutes, because it builds base, its shared tools, and each layer and `--from` base your VMs use again, and a `--from` base pulls its container image again ([details](https://next.devvm.dev/docs/releases/0.2.0/#pins-since-020-rc1), [a faster first run](https://next.devvm.dev/docs/releases/0.2.0/#a-faster-first-run)).
|
||||
2. If you pair machines with opencode and an export that devvm wrote holds `.local/state/opencode/machine/home-key`, replace that key and pair again in the VM it came from and in each VM you imported it into, because every machine paired with that VM trusts the key ([history](https://next.devvm.dev/docs/using/coding-agents/#history), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)).
|
||||
3. If you ran `devvm agent import` or `devvm agent save` for opencode, restart each running VM that has opencode with `devvm restart`, because its service took the password `devvm-redacted`, which every VM had. If this machine's opencode has remote access on, run `opencode service set remote false` and then `opencode service set remote true` on this machine, because your VMs got its route ([opencode's service](https://next.devvm.dev/docs/using/coding-agents/#opencodes-service), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-service-settings-in-vms)).
|
||||
4. If a script runs `devvm rm`, or a remake with `--clean-home`, on a VM with opencode, give it `--no-worktree-check` where losing the uncommitted changes in opencode's worktrees is fine, because without a terminal devvm now refuses when they have some, and `devvm rm VM` refuses a stopped VM whose folder is gone unless you give it ([opencode's worktrees](https://next.devvm.dev/docs/using/coding-agents/#opencodes-worktrees), [details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-worktrees-before-a-vm-goes)).
|
||||
5. Behind a company proxy, check that it lets cloud-images.ubuntu.com through, because Ubuntu's cloud image now downloads through it, where Lima's download went around it ([details](https://next.devvm.dev/docs/releases/0.2.0/#ubuntus-cloud-image-in-devvms-folder)).
|
||||
6. Optionally, run `devvm gc --caches` once to free the copy that Lima's cache holds of the release your current base was built from, 3.3 GB on a Mac and 862 MB on Linux, unless the installed Lima's own templates use that release, which most do today. `limactl prune` frees the rest, your own downloads included ([details](https://next.devvm.dev/docs/releases/0.2.0/#ubuntus-cloud-image-in-devvms-folder)).
|
||||
|
||||
### Fixed
|
||||
|
||||
- When devvm can't take base's packages out of its build VM, the run log now says why ([details](https://next.devvm.dev/docs/releases/0.2.0/#bases-packages-that-dont-come-out)).
|
||||
- A first run no longer fails while a shared tool's newest release lacks a platform's download, such as Node 24.23.0's musl builds, because devvm uses that tool's newest older version with every download again ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-tool-release-without-every-download)).
|
||||
|
||||
<details><summary>If you use opencode</summary>
|
||||
|
||||
- `devvm history export` and `devvm history import` now leave out opencode 2.4's machine key and paired machines, its service's password and its terminals' access tokens, which a VM made again still keeps ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-machine-key-in-history-exports)).
|
||||
- Each VM's opencode service now has a password of its own, which `opencode service get password` shows in the VM, and this machine's service settings and remote route never reach devvm's agent store or a VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-service-settings-in-vms)).
|
||||
- `devvm rm`, and a remake with `--clean-home`, show the uncommitted changes in opencode's worktrees, which an export leaves out, and ask before they go ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-worktrees-before-a-vm-goes)).
|
||||
- `devvm agent save` no longer refuses a VM whose `~/.config/opencode` holds a `bun.lock` or another file the store doesn't keep, which stays in the VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-lock-files-in-a-save)).
|
||||
|
||||
</details>
|
||||
<details><summary>If you use --clone</summary>
|
||||
|
||||
- `devvm rm` and `devvm clone off` now stop a `--clone` VM's clone check after 2 minutes or 8 MiB and keep the VM, where a VM that never finished answering kept them waiting until Ctrl+C ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-clone-check-that-never-ends)).
|
||||
|
||||
</details>
|
||||
<details><summary>Security hardening: a VM can no longer be started unconfined past devvm's checks, and its history export can no longer have opencode run commands unasked in the VM you import it into</summary>
|
||||
|
||||
- `devvm history export` and `devvm history import` leave out opencode's automations, approvals, allow rules, resumable turns, project commands, git repositories and approved plugins, so make again any automation you want in the new VM ([details](https://next.devvm.dev/docs/releases/0.2.0/#opencodes-automations-and-permissions-in-history)).
|
||||
- devvm's shell or command in a VM that just shut itself down now fails, where Lima asked whether to start the VM, yes by default, and started it unconfined and past devvm's checks ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-stopped-vms-shell)).
|
||||
|
||||
</details>
|
||||
<details><summary>Internal changes</summary>
|
||||
|
||||
- mise is 2026.11.14 in base and on this machine, the nix layer has Nix 2.36.0, and the docker layer has buildx 0.39.1 and its model plugin 1.2.10 ([details](https://next.devvm.dev/docs/releases/0.2.0/#pins-since-020-rc1)).
|
||||
- A release now builds to the same bytes on any machine, in one pinned container, so two builders can check each other's archives ([details](https://next.devvm.dev/docs/releases/0.2.0/#reproducible-release-builds)).
|
||||
- devvm upgrade and the install script can check a release against two of three new release keys once those keys are made, and the install script refuses a release's files signed for another version ([details](https://next.devvm.dev/docs/releases/0.2.0/#releases-signed-by-two-of-three-keys)).
|
||||
- A co-signer, a machine of the maintainer's, can now rebuild each release CI hands over and sign and publish it only when both builds match ([details](https://next.devvm.dev/docs/releases/0.2.0/#a-co-signer-for-releases)).
|
||||
- Releases can now be built and signed by GitHub's CI and published by the co-signer, each with both signatures, a GitHub attestation and the old key's signature, which devvm 0.1 and 0.2 check ([details](https://next.devvm.dev/docs/releases/0.2.0/#releases-through-ci-and-the-co-signer)).
|
||||
|
||||
</details>
|
||||
@@ -34,6 +34,24 @@ Each release is signed with devvm's minisign key, `RWSjzFsn7ETaijKJ2y7F4DtZobXmy
|
||||
- **Tested on** Apple silicon Macs and on Linux on arm64 and x86_64, but not yet on Intel Macs.
|
||||
- [Installing](https://devvm.dev/docs/getting-started/install/) has the full list of requirements and the install script's options, and [Upgrading and uninstalling](https://devvm.dev/docs/using/upgrading/) covers what comes later.
|
||||
|
||||
### Trying the release candidate
|
||||
|
||||
devvm 0.2.0-rc.1 is out to try before 0.2.0, and [its release notes](https://github.com/devvmhq/devvm/releases/tag/v0.2.0-rc.1) list what changes for your VMs when you upgrade. With Homebrew, install `devvm-rc`, the formula for prereleases, after uninstalling `devvm` if Homebrew installed it:
|
||||
|
||||
```sh
|
||||
brew uninstall devvm
|
||||
brew trust --formula devvmhq/tap/devvm-rc
|
||||
brew install devvmhq/tap/devvm-rc
|
||||
```
|
||||
|
||||
Without Homebrew, run the release candidate's own install script:
|
||||
|
||||
```sh
|
||||
curl -fsSL https://github.com/devvmhq/devvm/releases/download/v0.2.0-rc.1/install.sh | bash
|
||||
```
|
||||
|
||||
When the install script installed the devvm you have, `devvm upgrade --to 0.2.0-rc.1` installs it too. [Trying a prerelease](https://next.devvm.dev/docs/using/upgrading/#trying-a-prerelease) covers moving on to the release and going back.
|
||||
|
||||
## Quick start
|
||||
|
||||
```sh
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ Each release's `SHA256SUMS` lists the checksums of its archives and of its `inst
|
||||
RWSjzFsn7ETaijKJ2y7F4DtZobXmyv+LmdclJwZP/KmAkLUwOCzWF/2b
|
||||
```
|
||||
|
||||
The install script checks the signature when minisign is installed. The script and the key in it come from the same release, though, so that check can't catch a release that someone replaced whole. Homebrew's checksum can, because it's kept in a separate repository, and so can your own check with the key above, because it doesn't come from the release. [The signature and what it trusts](https://devvm.dev/docs/internals/install/#the-signature-and-what-it-trusts) has the details.
|
||||
Once devvm has its three release keys, which aren't made yet, devvm upgrade and the install script also accept a `SHA256SUMS` that two of them signed, each in its own `SHA256SUMS.<role>.minisig`, with the trusted comment `devvm-release <version>`. Until then they check the key above alone. The install script checks the signatures when minisign is installed. The script and the keys in it come from the same release, though, so that check can't catch a release that someone replaced whole. Homebrew's checksum can, because it's kept in a separate repository, and so can your own check with the key above, because it doesn't come from the release. [The signature and what it trusts](https://devvm.dev/docs/internals/install/#the-signature-and-what-it-trusts) has the details.
|
||||
|
||||
To check a release by hand, run these in the folder with its files:
|
||||
|
||||
|
||||
@@ -39,5 +39,6 @@ rm -rf "$tmp"
|
||||
eza --version
|
||||
|
||||
# The pages download at build time; a failure leaves tldr without pages until `tldr --update`.
|
||||
tldr --update || echo "cli-tools: couldn't download tldr pages; run 'tldr --update' in the VM" >&2
|
||||
# tldr has no timeout of its own, so a stalled download gives up after a minute.
|
||||
timeout 60 tldr --update || echo "cli-tools: couldn't download tldr pages; run 'tldr --update' in the VM" >&2
|
||||
echo 'eval "$(zoxide init bash)"' > ~/.bashrc.d/zoxide.sh
|
||||
@@ -6,8 +6,15 @@ omb_commit=94c2977eda06f230aafa9628fcd869123f01896b
|
||||
|
||||
# Its own installer, from the pinned commit and cloning from it (OSH_REPOSITORY), so nothing comes
|
||||
# from master. Replaces ~/.bashrc (backed up first); re-add the ~/.bashrc.d loader afterwards.
|
||||
# A clone that fails, or stays slower than 1 KB/s for 30 s, is tried again, five tries in all.
|
||||
tmp=$(mktemp -d)
|
||||
git clone -q https://github.com/ohmybash/oh-my-bash "$tmp/omb"
|
||||
for try in 1 2 3 4 5; do
|
||||
GIT_HTTP_LOW_SPEED_LIMIT=1024 GIT_HTTP_LOW_SPEED_TIME=30 \
|
||||
git clone -q https://github.com/ohmybash/oh-my-bash "$tmp/omb" && break
|
||||
rm -rf "$tmp/omb"
|
||||
(( try < 5 )) || { echo "omb.sh: cloning oh-my-bash failed $try times" >&2; exit 1; }
|
||||
sleep $(( try * 2 ))
|
||||
done
|
||||
git -C "$tmp/omb" checkout -q -B pinned "$omb_commit"
|
||||
OSH_REPOSITORY="$tmp/omb" bash "$tmp/omb/tools/install.sh" --unattended
|
||||
rm -rf "$tmp"
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package assets
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// devvmFetch is devvm-fetch as base.sh installs it, written into a
|
||||
// folder of the test's own, with a sleep there that waits for nothing, so
|
||||
// its tries don't wait on the real clock.
|
||||
func devvmFetch(t *testing.T) (script, bin string) {
|
||||
t.Helper()
|
||||
for _, tool := range []string{"curl", "sha256sum"} {
|
||||
if _, err := exec.LookPath(tool); err != nil {
|
||||
t.Skipf("no %s: devvm-fetch runs it", tool)
|
||||
}
|
||||
}
|
||||
body := heredoc(t, "sudo tee /usr/local/bin/devvm-fetch >/dev/null <<'SH'", "SH")
|
||||
dir := t.TempDir()
|
||||
script = filepath.Join(dir, "devvm-fetch")
|
||||
must(t, os.WriteFile(script, []byte(body+"\n"), 0o600))
|
||||
bin = filepath.Join(dir, "bin")
|
||||
must(t, os.Mkdir(bin, 0o700))
|
||||
must(t, os.WriteFile(filepath.Join(bin, "sleep"), []byte("#!/bin/sh\nexit 0\n"), 0o700)) //nolint:gosec // a program: the script runs it
|
||||
return script, bin
|
||||
}
|
||||
|
||||
// fetchServer serves body as a file server does (Range), going wrong on
|
||||
// its first requests as fail says, and records each request's Range:
|
||||
// "cut" sends a quarter of the body then drops the connection, "500"
|
||||
// answers that, "whole" sends the whole body (200) whatever range it was
|
||||
// asked for, and "other" serves another file of the same length.
|
||||
type fetchServer struct {
|
||||
body, other []byte
|
||||
fail []string
|
||||
|
||||
mu sync.Mutex
|
||||
ranges []string
|
||||
}
|
||||
|
||||
func (f *fetchServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
f.mu.Lock()
|
||||
n := len(f.ranges)
|
||||
f.ranges = append(f.ranges, r.Header.Get("Range"))
|
||||
f.mu.Unlock()
|
||||
how := ""
|
||||
if n < len(f.fail) {
|
||||
how = f.fail[n]
|
||||
}
|
||||
switch how {
|
||||
case "500":
|
||||
http.Error(w, "no", http.StatusInternalServerError)
|
||||
case "redirect":
|
||||
http.Redirect(w, r, "http://"+r.Host+r.URL.Path, http.StatusFound) //nolint:gosec // G710: the test's own server, sending curl back to itself over http
|
||||
case "whole":
|
||||
_, _ = w.Write(f.body)
|
||||
case "other":
|
||||
http.ServeContent(w, r, "f", time.Time{}, bytes.NewReader(f.other))
|
||||
case "cut":
|
||||
cw := &quarterWriter{ResponseWriter: w, left: len(f.body) / 4}
|
||||
http.ServeContent(cw, r, "f", time.Time{}, bytes.NewReader(f.body))
|
||||
panic(http.ErrAbortHandler) // drops the connection
|
||||
default:
|
||||
http.ServeContent(w, r, "f", time.Time{}, bytes.NewReader(f.body))
|
||||
}
|
||||
}
|
||||
|
||||
// quarterWriter writes no more than left bytes of a body, flushed.
|
||||
type quarterWriter struct {
|
||||
http.ResponseWriter
|
||||
left int
|
||||
}
|
||||
|
||||
func (q *quarterWriter) Write(b []byte) (int, error) {
|
||||
n := min(len(b), q.left)
|
||||
q.left -= n
|
||||
n, err := q.ResponseWriter.Write(b[:n])
|
||||
if fl, ok := q.ResponseWriter.(http.Flusher); ok {
|
||||
fl.Flush()
|
||||
}
|
||||
if err == nil && n < len(b) {
|
||||
panic(http.ErrAbortHandler)
|
||||
}
|
||||
return n, err
|
||||
}
|
||||
|
||||
// devvm-fetch keeps only a file whose checksum is the one asked for: it
|
||||
// resumes a download that was cut from where it stopped, starts again from
|
||||
// nothing when the server won't resume (curl's 33) or a resume joined two
|
||||
// files (the server changed it), and fails after five tries that failed.
|
||||
func TestDevvmFetchTries(t *testing.T) {
|
||||
script, bin := devvmFetch(t)
|
||||
body := bytes.Repeat([]byte("0123456789abcdef"), 4096)
|
||||
other := bytes.Repeat([]byte("fedcba9876543210"), 4096)
|
||||
sum := sha256.Sum256(body)
|
||||
quarter := "bytes=" + strconv.Itoa(len(body)/4) + "-"
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
fail []string
|
||||
want bool
|
||||
wantRanges []string
|
||||
}{
|
||||
{name: "whole", want: true, wantRanges: []string{""}},
|
||||
{name: "cut", fail: []string{"cut"}, want: true, wantRanges: []string{"", quarter}},
|
||||
{name: "a range answered whole", fail: []string{"cut", "whole"}, want: true, wantRanges: []string{"", quarter, ""}},
|
||||
{name: "the file changed", fail: []string{"cut", "other"}, want: true, wantRanges: []string{"", quarter, ""}},
|
||||
{name: "five failures", fail: []string{"500", "500", "500", "500", "500"}, wantRanges: []string{"", "", "", "", ""}},
|
||||
// A redirect goes only to https, as devvm's own downloads do.
|
||||
{name: "a redirect to http", fail: []string{"redirect", "redirect", "redirect", "redirect", "redirect"}, wantRanges: []string{"", "", "", "", ""}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
f := &fetchServer{body: body, other: other, fail: tc.fail}
|
||||
srv := httptest.NewServer(f)
|
||||
defer srv.Close()
|
||||
out := filepath.Join(t.TempDir(), "f")
|
||||
cmd := exec.CommandContext(t.Context(), "sh", script, srv.URL+"/f", hex.EncodeToString(sum[:]), out) //nolint:gosec // G204: devvm's own embedded script, with the test's arguments
|
||||
cmd.Env = []string{"PATH=" + bin + string(os.PathListSeparator) + os.Getenv("PATH"), "HOME=" + t.TempDir()}
|
||||
msgs, err := cmd.CombinedOutput()
|
||||
if (err == nil) != tc.want {
|
||||
t.Fatalf("devvm-fetch: %v, want success %v:\n%s", err, tc.want, msgs)
|
||||
}
|
||||
f.mu.Lock()
|
||||
got := f.ranges
|
||||
f.mu.Unlock()
|
||||
if !slices.Equal(got, tc.wantRanges) {
|
||||
t.Errorf("ranges asked: %q, want %q\n%s", got, tc.wantRanges, msgs)
|
||||
}
|
||||
data, rerr := os.ReadFile(out) //nolint:gosec // the test's own temp folder
|
||||
switch {
|
||||
case tc.want && !bytes.Equal(data, body):
|
||||
t.Errorf("the file: %d bytes, %v", len(data), rerr)
|
||||
case !tc.want && rerr == nil:
|
||||
t.Error("a failed download left its file")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
+27
-1
@@ -1,6 +1,9 @@
|
||||
#!/bin/bash
|
||||
# Runs inside a project VM on every devvm launch, from a staging dir the host sends over:
|
||||
# home/ agents' settings files and logins (but Claude Code's) from devvm's store, copied into ~
|
||||
# machine-own what is each machine's own in the agents' folders, such as opencode's service.json,
|
||||
# a pattern relative to ~ per line; a copy that an earlier devvm gave the VM, holding
|
||||
# DEVVM_REDACTED, is taken out (clean_machine_own)
|
||||
# links agents' settings folders from devvm's store, two lines each: the path relative to
|
||||
# ~, then the folder's path, where it's mounted read-only; linked into ~
|
||||
# claude.json the store's .claude.json's settings, account state and MCP servers (never its API key
|
||||
@@ -22,7 +25,9 @@
|
||||
# proxy's reserved target; transparent.sh), DEVVM_RESOLVER (on a confined VM, the
|
||||
# one name server its programs ask, past systemd-resolved; empty for the system's
|
||||
# own), and DEVVM_PASTE_DIR (the folder devvm
|
||||
# paste writes to, config.toml's paste-dir: made here, the user's own, mode 700)
|
||||
# paste writes to, config.toml's paste-dir: made here, the user's own, mode 700),
|
||||
# and DEVVM_REDACTED (what the VM's copies of the agents' settings hold in place of
|
||||
# a secret)
|
||||
# transparent.sh devvm-transparent: transparent mode, for tools that ignore the proxy settings
|
||||
# tools the VM's shared tool images, "FILE TOOL VERSION" lines; tools.sh mounts them
|
||||
# tool-alias.toml the [tool_alias] table of devvm's shared-tools/mise.toml: the backend each
|
||||
@@ -212,6 +217,27 @@ git config --global --get-all safe.directory | grep -qx '\*' || git config --glo
|
||||
|
||||
[[ -d "$s/home" ]] && cp -a "$s/home/." ~/
|
||||
|
||||
# clean_machine_own LIST: of the files that LIST's lines match, patterns relative to ~ of what is
|
||||
# each machine's own in the agents' folders, such as opencode's service.json with its service's
|
||||
# password, take out each regular file that holds DEVVM_REDACTED. That's a copy of this machine's
|
||||
# that an earlier devvm gave the VM, which every VM had with the same password, so the VM's agent
|
||||
# makes its own instead. The VM's own files, links and folders stay.
|
||||
clean_machine_own() {
|
||||
local p f
|
||||
[[ -n ${DEVVM_REDACTED:-} && -f $1 ]] || return 0
|
||||
while IFS= read -r p; do
|
||||
[[ -n $p ]] || continue
|
||||
# shellcheck disable=SC2231 # each line is a pattern, which the loop expands
|
||||
for f in ~/$p; do
|
||||
if [[ -f $f && ! -L $f ]] && grep -qF -- "$DEVVM_REDACTED" "$f"; then
|
||||
rm -f "$f" || { echo "devvm: $f, a copy of this machine's settings, can't be taken out, so delete it yourself" >&2; return 1; }
|
||||
echo "devvm: took out $f, a copy of this machine's settings, so the VM's agent makes its own" >&2
|
||||
fi
|
||||
done
|
||||
done < "$1"
|
||||
}
|
||||
clean_machine_own "$s/machine-own"
|
||||
|
||||
# The agents' folders that are the VM's own, the store's being their seed, such as Claude Code's
|
||||
# plugins: a link to the store's, as a VM from before has, becomes a folder.
|
||||
while IFS= read -r rel; do
|
||||
|
||||
+15
-4
@@ -10,17 +10,27 @@
|
||||
# the InRelease files and package lists apt used, which devvm checks again
|
||||
# neither a --from image's own sources, as they are
|
||||
# Both end with the image's own sources, no package lists and an empty apt cache, so a first build
|
||||
# and a replay make the same image. A source that doesn't answer exits 75 at once: no retries.
|
||||
# and a replay make the same image. A source that doesn't answer exits 75 at once: no retries. Once
|
||||
# a source has answered, the packages' downloads are tried again after a failure, three times.
|
||||
set -euo pipefail
|
||||
dir=/var/cache/devvm/packages archives=/var/cache/apt/archives lists=/var/lib/apt/lists
|
||||
command -v apt-get >/dev/null || exit 0 # Alpine (--from alpine): apk, not pinned
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
aside=/etc/apt/devvm-sources
|
||||
|
||||
# build_conf RETRIES: the build's apt settings, with RETRIES tries again of a failed download, each
|
||||
# after a longer wait (apt's own backoff). Package lists kept as they're signed, uncompressed, for
|
||||
# record to give back. Only the lists apt installs from: no translations, AppStream components or
|
||||
# command-not-found metadata, a third of what an update fetches, which the image keeps none of.
|
||||
build_conf() {
|
||||
printf 'Acquire::Retries "%s";\nAcquire::http::Timeout "30";\nAcquire::https::Timeout "30";\nAcquire::GzipIndexes "false";\n' \
|
||||
"$1" > /etc/apt/apt.conf.d/50devvm-build
|
||||
printf 'Acquire::Languages "none";\nAcquire::IndexTargets::deb::DEP-11::DefaultEnabled "false";\nAcquire::IndexTargets::deb::CNF::DefaultEnabled "false";\n' \
|
||||
>> /etc/apt/apt.conf.d/50devvm-build
|
||||
}
|
||||
|
||||
begin() {
|
||||
# Package lists kept as they're signed, uncompressed, for record to give back.
|
||||
printf 'Acquire::Retries "0";\nAcquire::http::Timeout "30";\nAcquire::https::Timeout "30";\nAcquire::GzipIndexes "false";\n' \
|
||||
> /etc/apt/apt.conf.d/50devvm-build
|
||||
build_conf 0
|
||||
if [[ -f $dir/in/Packages ]]; then
|
||||
# The host checked each file against the SHA-256 recorded for it, and Packages lists those.
|
||||
sources_aside
|
||||
@@ -45,6 +55,7 @@ begin() {
|
||||
echo "devvm: no package source answered (above)" >&2
|
||||
exit 75
|
||||
fi
|
||||
build_conf 3
|
||||
}
|
||||
|
||||
# mirrored FROM TO writes FROM, a deb822 sources file, to TO with each archive's URI the list
|
||||
|
||||
+42
-12
@@ -4,11 +4,11 @@
|
||||
set -euxo pipefail
|
||||
: "${devvm_arch:?}" "${devvm_libc:?}" # devvm's prelude (prelude.sh) comes before this script
|
||||
# Pinned downloads (scripts/bump.sh updates them).
|
||||
mise_version=2026.11.10
|
||||
mise_sha256_arm64=86ef275d541c5243cd20b1c0fcd16810e5f3601113d8db09278d0608617a3833
|
||||
mise_sha256_amd64=b603a4f48563fc379a794d9ea2cf9f709ed276c9141068604cb0c59fa3e674a9
|
||||
mise_sha256_arm64_musl=d33f9febe2bfd13213f7fe23ba43fffe133b37737d970680c2aeba66366ff9c2
|
||||
mise_sha256_amd64_musl=ae1f7752483862f46f6eb0ffa58d3bdec8d5af8da78d98b0df477466747cba2b
|
||||
mise_version=2026.11.14
|
||||
mise_sha256_arm64=6afd537b39e2b1fe6594d4448318293d7e8c85469cbb51a6a01b28a6f26fbaf5
|
||||
mise_sha256_amd64=42a3ff51c24b4315d679a07bbc598e299dda12fea0dfc0d6f90a543495834831
|
||||
mise_sha256_arm64_musl=bf73525892d7942b881b885867bb028cab98ed528356c4490364eb1001ef9deb
|
||||
mise_sha256_amd64_musl=86a5c3d8cf3d62b45a10ddd6afe8225bada9423e517ec8df7d589aa7d02c171d
|
||||
git_lfs_version=3.8.1
|
||||
git_lfs_sha256_arm64=67895dd77b63329796bc5efdd47b57f218e1f7b98717ebaf936a8238dbcaec0f
|
||||
git_lfs_sha256_amd64=e72cf723a4a660438862282e8aecf3885fc8123e88bfcad534cf6b941a354b75
|
||||
@@ -42,15 +42,42 @@ fi
|
||||
|
||||
# devvm-fetch URL SHA256 OUT: every layer downloads through this, so an image only ever contains
|
||||
# files whose checksums are pinned in devvm's scripts. A SHA-512 (128 hex digits) is checked as one:
|
||||
# the shared tools' build gets the .NET SDK's from the tools lock.
|
||||
# the shared tools' build gets the .NET SDK's from the tools lock. A try that fails for any reason, a
|
||||
# dropped connection or one slower than 1 KB/s for 30 s included, is tried again from where it
|
||||
# stopped (-C -), five tries in all: curl's own --retry starts again from nothing. A server that
|
||||
# can't resume (33, 36) starts it again from nothing, and so does a download that doesn't check out,
|
||||
# once: a resume may have joined two files, when the server's has changed. A redirect goes only to
|
||||
# https, so no try or resume moves to plain http.
|
||||
sudo tee /usr/local/bin/devvm-fetch >/dev/null <<'SH'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
url=$1 want=$2 out=$3
|
||||
curl -fsSL --retry 3 -o "$out" "$url"
|
||||
sum=sha256sum
|
||||
[ "${#want}" -ne 128 ] || sum=sha512sum
|
||||
got=$("$sum" "$out" | cut -d' ' -f1)
|
||||
checksum() { "$sum" "$out" | cut -d' ' -f1; }
|
||||
# fetch: one download into $out from nothing, each failed try tried again from where it stopped.
|
||||
fetch() {
|
||||
rm -f "$out"
|
||||
n=1
|
||||
until curl -fsSL --proto-redir =https --connect-timeout 20 --speed-limit 1024 --speed-time 30 -C - -o "$out" "$url"; do
|
||||
code=$?
|
||||
# All of it came, and only the end of the answer went wrong.
|
||||
[ ! -f "$out" ] || [ "$(checksum)" != "$want" ] || break
|
||||
[ "$n" -lt 5 ] || { echo "devvm-fetch: $url failed $n times, the last with curl's exit $code" >&2; exit 1; }
|
||||
case $code in 33|36) rm -f "$out" ;; esac
|
||||
have=$(wc -c 2>/dev/null < "$out" | tr -d ' ')
|
||||
echo "devvm-fetch: $url failed (curl's exit $code); trying again from byte ${have:-0}" >&2
|
||||
sleep $((n * 2))
|
||||
n=$((n + 1))
|
||||
done
|
||||
}
|
||||
fetch
|
||||
got=$(checksum)
|
||||
if [ "$got" != "$want" ]; then
|
||||
echo "devvm-fetch: $url doesn't match its checksum; fetching it again from nothing" >&2
|
||||
fetch
|
||||
got=$(checksum)
|
||||
fi
|
||||
if [ "$got" != "$want" ]; then
|
||||
rm -f "$out"
|
||||
printf 'devvm-fetch: checksum mismatch for %s\n expected %s\n got %s\n' "$url" "$want" "$got" >&2
|
||||
@@ -90,11 +117,14 @@ grep -qs bashrc.d ~/.bashrc || echo 'for f in ~/.bashrc.d/*.sh; do [ -r "$f" ] &
|
||||
# /opt/devvm/tools by devvm-tools (guest/tools.sh). Each VM's tools and versions are in
|
||||
# /etc/mise/config.toml (written by guest/sync.sh); the user's own mise config and a project's version
|
||||
# files (.nvmrc, .python-version, ...) come first, and versions that aren't shared install into the VM.
|
||||
# mise names amd64 x64, and its musl builds end -musl.
|
||||
# mise names amd64 x64, and its musl builds end -musl. Its .tar.gz is a third of its binary's size.
|
||||
m=${devvm_arch/amd64/x64}; [[ $devvm_libc == gnu ]] || m+=-musl
|
||||
devvm-fetch "https://github.com/jdx/mise/releases/download/v$mise_version/mise-v$mise_version-linux-$m" "$(devvm_sha mise)" /tmp/mise
|
||||
sudo install -m 755 /tmp/mise /usr/local/bin/mise
|
||||
rm /tmp/mise
|
||||
t=$(mktemp -d)
|
||||
devvm-fetch "https://github.com/jdx/mise/releases/download/v$mise_version/mise-v$mise_version-linux-$m.tar.gz" \
|
||||
"$(devvm_sha mise)" "$t/mise.tar.gz"
|
||||
tar -xzf "$t/mise.tar.gz" -C "$t" mise/bin/mise
|
||||
sudo install -m 755 "$t/mise/bin/mise" /usr/local/bin/mise
|
||||
rm -rf "$t"
|
||||
|
||||
# git-lfs: a --clone VM's clone of a repo that uses Git LFS gets the repo's LFS objects, and git there
|
||||
# checks out each LFS file's content through git-lfs's filter, which the copy sets in that clone's own
|
||||
|
||||
@@ -7,9 +7,9 @@ set -euxo pipefail
|
||||
# are pinned by version.
|
||||
docker_version=29.10.0
|
||||
containerd_version=2.4.2
|
||||
buildx_version=0.39.0
|
||||
buildx_version=0.39.1
|
||||
compose_version=5.8.0
|
||||
model_version=1.2.9
|
||||
model_version=1.2.10
|
||||
docker_gpg_sha256=1500c1f56fa9e26b9b8f42452a553675796ade0807cdce11975eb98170b3a570
|
||||
|
||||
# Alpine (--from alpine): Docker is Alpine's own package, from the release's repositories, which have
|
||||
|
||||
@@ -7,9 +7,9 @@ set -euxo pipefail
|
||||
: "${devvm_arch:?}" "${devvm_libc:?}" # devvm's prelude (prelude.sh) comes before this script
|
||||
# Pinned downloads (scripts/bump.sh updates them). Nix's release tarball, with its own installer;
|
||||
# nix-direnv is one script, the same on every architecture.
|
||||
nix_version=2.35.6
|
||||
nix_sha256_arm64=1f177b572baadf8c09750028f047fe943a3615a34f3e4a43927367a1e0120801
|
||||
nix_sha256_amd64=b12ab64a291e41846b9da37b7f56eafa7683deaa267bafb2ed43440ab2f45f13
|
||||
nix_version=2.36.0
|
||||
nix_sha256_arm64=ee696971de946d311699f6dd639cccc8c6734aec9a061b8e205de0ce6515e5ae
|
||||
nix_sha256_amd64=c4d1aed088f62aa729823cffa3269e880de6ce6102fecb8909f2821eedb2f2eb
|
||||
direnv_version=2.38.2
|
||||
direnv_sha256_arm64=ec2a32dbe2f19dd085bd9315a1b4ea88b55ec288aa7eabe8723490baf466cb23
|
||||
direnv_sha256_amd64=148820a187930d36ca6a204504e5cdb30d8396cd1a97e64c3b3f10d793c11247
|
||||
|
||||
+3
-2
@@ -25,11 +25,12 @@ crane_sha256_amd64=0ab7a1d6932a213aed964ce97666c3077fe691c8606413674a8b3e0b9ec4c
|
||||
|
||||
die() { echo "devvm: $*" >&2; exit 1; }
|
||||
|
||||
# crane, checked against its pinned checksum, into ./crane. Its releases name amd64 x86_64.
|
||||
# crane, checked against its pinned checksum, into ./crane. Its releases name amd64 x86_64. Any
|
||||
# failure, a dropped connection or one slower than 1 KB/s for 30 s included, is tried again.
|
||||
fetch_crane() {
|
||||
local sum
|
||||
sum=$(devvm_sha crane)
|
||||
curl -fsSL --retry 3 -o crane.tar.gz \
|
||||
curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 --connect-timeout 20 --speed-limit 1024 --speed-time 30 -o crane.tar.gz \
|
||||
"https://github.com/google/go-containerregistry/releases/download/v$crane_version/go-containerregistry_Linux_${devvm_arch/amd64/x86_64}.tar.gz"
|
||||
echo "$sum crane.tar.gz" | sha256sum -c --quiet - >/dev/null || die "crane's download doesn't match its pinned checksum"
|
||||
tar -xzf crane.tar.gz crane
|
||||
|
||||
@@ -65,7 +65,9 @@ tool=$1 version=$2 file=$3
|
||||
wait_share
|
||||
sudo rm -rf "$work"; sudo mkdir -p "$work"; sudo chown "$USER" "$work"
|
||||
cd "$share/.build"
|
||||
export MISE_LOCKED=1 MISE_TRUSTED_CONFIG_PATHS="$share/.build" MISE_YES=1
|
||||
# Six retries of a download, each try at most 30 s without bytes (mise's own timeout): mise's 3 end
|
||||
# within a two-minute stall, as it tries again on the connection that stalled.
|
||||
export MISE_LOCKED=1 MISE_TRUSTED_CONFIG_PATHS="$share/.build" MISE_YES=1 MISE_HTTP_RETRIES=6
|
||||
|
||||
if [[ $tool == rust ]]; then
|
||||
# The toolchain as rustup lays it out, plus rustup itself for the VM to install (it links the
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Command devvm-cosign is the co-signer of devvm's releases and bases: a
|
||||
// program of its own, on a machine of the maintainer's, that rebuilds
|
||||
// each build CI hands over, signs it only when its own build matches, and
|
||||
// makes and publishes its release once two of the three keys signed it.
|
||||
// It reads its keys from systemd's credentials. Its code is in
|
||||
// internal/cosign; packaging/cosign has its systemd units and install
|
||||
// script.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/devvmhq/devvm/internal/cosign"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// The run's own context, ended by systemd's stop (TERM) or Ctrl+C,
|
||||
// which ends a build and its container through release.sh's traps.
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
code := cosign.Main(ctx, os.Args[1:], cosign.Env{Credentials: os.Getenv("CREDENTIALS_DIRECTORY")}, os.Stderr)
|
||||
stop()
|
||||
os.Exit(code)
|
||||
}
|
||||
@@ -3,11 +3,12 @@ title: Docs
|
||||
explainer: The guides, in the order you'll need them
|
||||
---
|
||||
|
||||
The docs are in the order you'll need them: getting devvm running, using it day to day, staying safe, choosing a backend and comparing devvm with other tools, then every command, how devvm works and how to change it.
|
||||
The docs are in the order you'll need them: getting devvm running, using it day to day, what changed in each release, staying safe, choosing a backend and comparing devvm with other tools, then every command, how devvm works and how to change it.
|
||||
|
||||
{{< cards >}}
|
||||
{{< section-card path="getting-started" >}}Installing devvm, making your first VM, and the commands you use most.{{< /section-card >}}
|
||||
{{< section-card path="using" >}}Images and toolchains, ports and size, coding agents, editors, settings, and what to do when something fails.{{< /section-card >}}
|
||||
{{< section-card path="releases" >}}Each release's changes in full: what was wrong, what changed and what to do.{{< /section-card >}}
|
||||
{{< section-card path="safety" >}}The habits that keep you safe, network tiers, `.git` protection, and what devvm does about each attack.{{< /section-card >}}
|
||||
{{< section-card path="backends" >}}What runs the VMs: Lima.{{< /section-card >}}
|
||||
{{< section-card path="compared" >}}How devvm differs from Docker Sandboxes, other VM and OS sandboxes, and hosted ones.{{< /section-card >}}
|
||||
|
||||
@@ -122,7 +122,13 @@ SQLite's default journal works in the project folder. WAL mode doesn't, because
|
||||
|
||||
## Cleaning up
|
||||
|
||||
`devvm gc` deletes devvm's stale and unfinished Lima images and the shared tools that no VM has and that aren't current, and it leaves your VMs as they are. `devvm images rm` deletes an image that's current, except on Linux hosts one whose disk VMs use ([cleaning up](../using/images.md#cleaning-up)). Lima also keeps a download cache of its own, which holds Ubuntu's cloud images that devvm's builds downloaded, and which your own Lima VMs share. `devvm gc --caches` deletes the cloud images that devvm downloads and that no image of devvm's names, after listing them and asking, and devvm never runs `limactl prune`, which empties the whole cache ([what devvm keeps](../using/space.md#lima)).
|
||||
`devvm gc` deletes devvm's stale and unfinished Lima images and the shared tools that no VM has and that aren't current, and it leaves your VMs as they are. `devvm images rm` deletes an image that's current, except on Linux hosts one whose disk VMs use ([cleaning up](../using/images.md#cleaning-up)).
|
||||
|
||||
```sh
|
||||
devvm gc --caches # free the cloud images nothing of devvm's needs, after asking
|
||||
```
|
||||
|
||||
devvm keeps Ubuntu's cloud images in its own folder and gives Lima that file, so its builds add nothing to Lima's own download cache, which your own Lima VMs share. That cache can still hold the cloud images that earlier releases of devvm had Lima download. `devvm gc --caches` deletes devvm's own copies that no image of devvm's needs, and the entries in Lima's cache that an image record of devvm's names once devvm has its own copy, unless one of Lima's own templates uses that image. devvm never runs `limactl prune`, which empties the whole cache ([what devvm keeps](../using/space.md#lima)).
|
||||
|
||||
## Limits
|
||||
|
||||
|
||||
Generated
+10
-9
@@ -26,15 +26,16 @@ devvm clone [on|off] [flags]
|
||||
## Options
|
||||
|
||||
```text
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for clone
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--json print it as one JSON object, for scripts
|
||||
--no-clone-check don't check a --clone VM's clone for unfetched commits and uncommitted changes first, which are lost
|
||||
--no-export don't export the agents' history first
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
--repos LIST the repos a --clone VM of a folder of repos gets: all, none or a LIST of their paths, such as frontend,backend (default: a picker in a terminal)
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for clone
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--json print it as one JSON object, for scripts
|
||||
--no-clone-check don't check a --clone VM's clone for unfetched commits and uncommitted changes first, which are lost
|
||||
--no-export don't export the agents' history first
|
||||
--no-worktree-check with --clean-home, don't check the agents' worktrees in the VM for uncommitted changes first, which are lost
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
--repos LIST the repos a --clone VM of a folder of repos gets: all, none or a LIST of their paths, such as frontend,backend (default: a picker in a terminal)
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
Generated
+1
-1
@@ -7,7 +7,7 @@ Delete stale images, unused tools, old files and the Nix cache over its cap
|
||||
|
||||
## Synopsis
|
||||
|
||||
Delete the stale and unfinished images, the shared tools devvm images lists as unused, the files devvm itself no longer needs, and the shared Nix cache's least recently used files while it's over its cap, after listing them and asking in a terminal without --no-input. Its flags delete more, such as --tool-images for the current shared tool images no VM has. gc never deletes a VM.
|
||||
Delete the stale and unfinished images, the shared tools devvm images lists as unused, the files devvm itself no longer needs, and the shared Nix cache's least recently used files while it's over its cap, after listing them and asking in a terminal without --no-input, and the build VMs that a killed tools build left, at once. Its flags delete more, such as --tool-images for the current shared tool images no VM has. gc never deletes a VM of yours.
|
||||
|
||||
```text
|
||||
devvm gc [--tool-images [TOOL...]] [flags]
|
||||
|
||||
Generated
+7
-6
@@ -25,12 +25,13 @@ devvm layer add LAYER... [flags]
|
||||
## Options
|
||||
|
||||
```text
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for add
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for add
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--no-worktree-check with --clean-home, don't check the agents' worktrees in the VM for uncommitted changes first, which are lost
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
Generated
+7
-6
@@ -25,12 +25,13 @@ devvm layer rm LAYER... [flags]
|
||||
## Options
|
||||
|
||||
```text
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for rm
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for rm
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--no-worktree-check with --clean-home, don't check the agents' worktrees in the VM for uncommitted changes first, which are lost
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
Generated
+9
-7
@@ -7,7 +7,7 @@ Delete this folder's VM, or a VM whose folder is gone
|
||||
|
||||
## Synopsis
|
||||
|
||||
Delete this folder's VM and what devvm keeps for it, or the VM you name when its folder is gone, after asking in a terminal without --no-input, which --force never answers when its folder is on a disk that isn't connected. When its image has an agent, devvm first exports the agents' history, unless you give --no-export. A --clone VM's work that this repo hasn't fetched is offered for fetching first, unless you give --no-clone-check.
|
||||
Delete this folder's VM and what devvm keeps for it, or the VM you name when its folder is gone, after asking in a terminal without --no-input, which --force never answers when its folder is on a disk that isn't connected. When its image has an agent, devvm first exports the agents' history, unless you give --no-export. A --clone VM's work that this repo hasn't fetched is offered for fetching first, unless you give --no-clone-check, and devvm shows the uncommitted changes in the agents' worktrees and asks before they go, unless you give --no-worktree-check.
|
||||
|
||||
```text
|
||||
devvm rm [VM] [flags]
|
||||
@@ -20,18 +20,20 @@ devvm rm [VM] [flags]
|
||||
devvm rm --force # delete it without asking, as a script must
|
||||
devvm rm --no-export # delete it without exporting the agents' history
|
||||
devvm rm --no-clone-check # delete a --clone VM without checking its clone, losing its unfetched work
|
||||
devvm rm --no-worktree-check # delete it without checking the agents' worktrees, losing their uncommitted changes
|
||||
devvm rm devvm-web-71a99b1076d92c # delete a VM whose folder is gone, by its name as devvm ls lists it
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
```text
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for rm
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-clone-check don't check a --clone VM's clone for unfetched commits and uncommitted changes first, which are lost
|
||||
--no-export don't export the agents' history first
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for rm
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-clone-check don't check a --clone VM's clone for unfetched commits and uncommitted changes first, which are lost
|
||||
--no-export don't export the agents' history first
|
||||
--no-worktree-check don't check the agents' worktrees in the VM for uncommitted changes first, which are lost
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
Generated
+7
-6
@@ -24,12 +24,13 @@ devvm update [flags]
|
||||
## Options
|
||||
|
||||
```text
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for update
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
--clean-home give the VM the image's home folder instead of keeping its own
|
||||
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
|
||||
-h, --help help for update
|
||||
--here use this folder's own VM, never that of a folder it's inside
|
||||
--no-export don't export the agents' history first
|
||||
--no-worktree-check with --clean-home, don't check the agents' worktrees in the VM for uncommitted changes first, which are lost
|
||||
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
||||
@@ -4,7 +4,7 @@ explainer: Build devvm, run its tests and follow its rules
|
||||
weight: 100
|
||||
---
|
||||
|
||||
The rules for working in the repo, for people and coding agents alike, are in [AGENTS.md](https://github.com/devvmhq/devvm/blob/main/AGENTS.md). The [codebase-standards skill](https://github.com/devvmhq/devvm/blob/main/.agents/skills/codebase-standards/SKILL.md) turns what reviews of devvm's code kept finding into a short checklist for a commit and a review, says how new code matches the code already there, and lists what guards each rule.
|
||||
The rules for working in the repo, for people and coding agents alike, are in [AGENTS.md](https://github.com/devvmhq/devvm/blob/main/AGENTS.md). The [codebase-standards skill](https://github.com/devvmhq/devvm/blob/main/.agents/skills/codebase-standards/SKILL.md) turns what reviews of devvm's code kept finding into a short checklist for a commit and a review, says how new code matches the code already there, and lists what guards each rule. Why devvm is built the way it is, what was tried and dropped, and what's still open are in the [design notes](design.md), with each emulation's threat check and the tests that prove it.
|
||||
|
||||
## Building from source
|
||||
|
||||
@@ -35,7 +35,7 @@ mise installs every tool at the version pinned in `mise.toml`, checked against `
|
||||
| gotestsum | running the tests |
|
||||
| govulncheck | checking dependencies for known vulnerabilities |
|
||||
| nilaway | finding where a nil value may be dereferenced |
|
||||
| goreleaser | release builds ([Maintaining](maintaining.md#releasing)) |
|
||||
| goreleaser | release builds, which run in their container with the GoReleaser download that `mise.lock` pins ([Reproducible releases](maintaining.md#reproducible-releases)) |
|
||||
| hugo | the docs site |
|
||||
| vale, markdownlint-cli2, lychee | linting the docs |
|
||||
| node | running markdownlint-cli2, and drawing the docs site's diagrams with pele, which `docs/package.json` pins ([diagrams](docs.md#writing-docs)) |
|
||||
@@ -58,7 +58,7 @@ Run the tasks with `mise run <task>`:
|
||||
| `nilaway:linux` | runs `nilaway` on the code as built for Linux, as CI's job does, from any system, and must pass before a push to `main` |
|
||||
| `deadcode` | lists functions nothing calls outside the tests: only `backendtest`'s, `stubtest`'s, `upgradetest`'s, `msg.IDOf`, `msg.NamesOf`, `msg.Recorder` and `msg.Fake`, which the tests use, and anything else it lists gets a caller or goes |
|
||||
| `cli-docs` | generates the CLI reference |
|
||||
| `docs:diagrams` | installs pele with `npm ci` and draws the docs site's diagrams, which every build of the site needs first; it's skipped when no page, the script or pele's pins changed, reinstalls pele only when the lock changed and draws only the diagrams that changed ([diagrams](docs.md#writing-docs)) |
|
||||
| `docs:diagrams` | installs pele with `npm ci` and draws the docs site's diagrams, which every build of the site needs first. mise skips it when no page, the script or pele's pins changed, and it reinstalls pele only when the lock changed and draws only the diagrams that changed ([diagrams](docs.md#writing-docs)) |
|
||||
| `docs` | generates the CLI reference and draws the diagrams, then serves the docs site |
|
||||
| `e2e` | runs the end-to-end tests against real VMs |
|
||||
|
||||
@@ -66,7 +66,7 @@ Run the tasks with `mise run <task>`:
|
||||
|
||||
Before and after every change, `mise run fmt && mise run lint && mise run test` must pass. Before a push to `main`, `mise run nilaway:linux` must pass as well, because CI's `nilaway` job only warns, so a new finding hides in a green run ([Nil checks](#nil-checks)).
|
||||
|
||||
CI runs `lint` and `test` on macOS and Linux, and `vuln` and `nilaway` in jobs of their own. Its `nocgo` job runs `internal/landlock`'s and `internal/proxy`'s tests on Linux with `CGO_ENABLED=0`, as devvm ships, because the test tasks turn cgo on for the race detector, and with cgo the proxy's child can't confine every thread of itself (`syscall.AllThreadsSyscall`), so only that job runs a child under Landlock and the seccomp filter. A weekly workflow also scans `main` and the binaries of the latest releases ([Known vulnerabilities](maintaining.md#known-vulnerabilities)). A change that touches only the docs and Markdown files skips them: the Docs workflow runs `lint:docs` and builds the site instead, and on every push to `main` it deploys next.devvm.dev ([the docs sites](maintaining.md#the-docs-sites)).
|
||||
CI runs `lint` and `test` on macOS and Linux, and `vuln` and `nilaway` in jobs of their own. Its `nocgo` job runs `internal/landlock`'s and `internal/proxy`'s tests on Linux with `CGO_ENABLED=0`, as devvm ships. The test tasks turn cgo on for the race detector, and with cgo the proxy's child can't confine every thread of itself (`syscall.AllThreadsSyscall`), so only that job runs a child under Landlock and the seccomp filter. Its `repro` job builds the release twice, under podman and under Docker, and checks that both builds made the same bytes and that every archive's files are root's ([Reproducible releases](maintaining.md#reproducible-releases)). A weekly workflow also scans `main` and the binaries of the latest releases ([Known vulnerabilities](maintaining.md#known-vulnerabilities)). A change that touches only the docs and Markdown files skips them: the Docs workflow runs `lint:docs` and builds the site instead, and on every push to `main` it deploys next.devvm.dev ([the docs sites](maintaining.md#the-docs-sites)).
|
||||
|
||||
### Nil checks
|
||||
|
||||
@@ -76,13 +76,13 @@ mise run nilaway # where a nil value may reach a dereference in devvm's code,
|
||||
|
||||
nilaway follows nil values across functions and packages and reports each place one may be dereferenced: a field read, a method call, an index or a slice. It reads only the packages under `github.com/devvmhq/devvm`, and it leaves out the tests and their helpers, `internal/stubtest` and `internal/backend/backendtest`, because a nil panic there fails a test. It checks the code as built for the system it runs on, so the files that build only for macOS or only for Linux need a run on each.
|
||||
|
||||
Its findings include false positives, so the findings already triaged as false positives are in `testdata/nilaway-baseline.txt`, and `scripts/nilaway.sh`, which the task runs, prints every finding and then the ones the baseline hasn't. A finding's key in the baseline is its file and its trace without line or column numbers, so moving code doesn't make a triaged finding new. The baseline has a line for each finding, so when two findings share a key, such as two unchecked `os.Stat` results in one file, the key is there twice, and a third finding with that key is new.
|
||||
Its findings include false positives, so the ones already triaged as false positives are in `testdata/nilaway-baseline.txt`. `scripts/nilaway.sh`, which the task runs, prints every finding and then the ones the baseline doesn't have. A finding's key in the baseline is its file and its trace without line or column numbers, so moving code doesn't make a triaged finding new. The baseline has a line for each finding, so when two findings share a key, such as two unchecked `os.Stat` results in one file, the key is there twice, and a third finding with that key is new.
|
||||
|
||||
The script exits with status 3 when there's a new finding. It exits with status 1 when nilaway can't run, when nilaway's output has a finding the script can't read, and when a baseline line is stale or isn't a group and a key, so a change in nilaway's output can't leave the check comparing nothing. `TestNilawayBaseline` in `internal/structure` checks each of these with a stand-in nilaway.
|
||||
|
||||
The task isn't part of `lint`, and it never fails CI: CI's `nilaway` job warns on the run when there's a new finding and lists the new and stale ones, then every finding, in the run's summary. The job fails when the script exits with status 1, and even then it blocks nothing.
|
||||
The task isn't part of `lint`, and it never fails CI. When there's a new finding, CI's `nilaway` job warns on the run and lists the new and stale findings, then every finding, in the run's summary. The job fails when the script exits with status 1, and even then it blocks nothing.
|
||||
|
||||
A warning in a green run is easy to miss, and a finding's key is its code path, so code that only moved can read as new. So before a push to `main`, `mise run nilaway:linux` must pass: it runs the same script with `GOOS=linux`, so nilaway checks the code as built for Linux, as CI's job does, even on a Mac, and the files that build only for Linux are checked too. A new finding or a stale baseline line fails it, and gets a fix or a baseline change before the push.
|
||||
A warning in a green run is easy to miss, and a finding's key is its code path, so code that only moved can read as new. So before a push to `main`, `mise run nilaway:linux` must pass. It runs the same script with `GOOS=linux`, so nilaway checks the code as built for Linux, as CI's job does, even on a Mac, and it also checks the files that build only for Linux. A new finding or a stale baseline line fails it, and gets a fix or a baseline change before the push.
|
||||
|
||||
Each finding starts with the place a nil value is dereferenced and then traces where it came from, one line for each step. A new finding that is a real bug gets a fix and a test that would have panicked without it. A false positive goes into the baseline as the key the script prints after `new:`, one line for each time it's printed, with one of the baseline's groups in front:
|
||||
|
||||
@@ -100,7 +100,7 @@ golangci-lint enforces most of the [Go conventions](#go-conventions) in `.golang
|
||||
| Rule | Enforces |
|
||||
| --- | --- |
|
||||
| forbidigo | only `internal/ui` prints (`fmt.Print*`, `os.Stdout`, `os.Stderr`); only `cmd/devvm` calls `os.Exit`; only `internal/ui` and `cmd/devvm` make a context (`context.Background`, `context.TODO`), every other function takes its caller's; only `internal/platform` reads the host's CPUs, memory and free space, which the rest reads through `platform.Host`; only `internal/cli` calls `testbuild.On`; only `internal/daemon` and `internal/platform` signal a process by its pid (`os.FindProcess`, `syscall.Kill`, `unix.Kill`, `os.Process`'s `Kill` and `Signal`); only `internal/fetch` makes an HTTP client or a transport (`http.Client`, `http.DefaultClient`, `http.Transport`, `http.DefaultTransport`, `http.Get` and the like), which the rest names as `fetch.Client`; nothing calls `os.UserHomeDir`, because the home folder is `paths.Dirs.Home`; only `internal/state` calls `os.WriteFile` or `os.Create` or opens a file with `os.O_TRUNC`, and the rest writes a file whole through `state.WriteFile`, or `state.WriteFileMode` for a mode other than 600; nothing but `daemon.Ready` changes devvm's own environment (`os.Setenv`, `os.Unsetenv`, `os.Clearenv` and `syscall`'s), and a command gets its own through its `Env`; only the code that must use a secret's value calls `redact.Secret`'s `Reveal`, each call with a `nolint` saying why ([Secrets in the code](structure.md#secrets-in-the-code)) |
|
||||
| depguard | the allowed modules, which are cobra, pflag, cobra's `doc` package for the CLI reference, go-i18n, BurntSushi's toml, `golang.org/x/text`, `x/term` and `x/sys`, and only the `blake2b` package of `x/crypto`, for minisign's prehashed signatures; the tests may also use go-internal. Nothing imports a module that cobra's `doc` package uses but isn't on the list. `internal/proxy`, `internal/daemon`, `internal/safefile`, `internal/vmname` and `internal/redact` use only the standard library and each other, and their tests may use `internal/leaktest` and `internal/memnet`, which use only the standard library too |
|
||||
| depguard | the allowed modules, which are cobra, pflag, cobra's `doc` package for the CLI reference, go-i18n, BurntSushi's toml, `golang.org/x/text`, `x/term` and `x/sys`, and only the `blake2b` package of `x/crypto`, for minisign's prehashed signatures; the tests may also use go-internal. Nothing imports a module that cobra's `doc` package uses but isn't on the list. `internal/proxy`, `internal/daemon`, `internal/safefile`, `internal/vmname` and `internal/redact` use only the standard library and each other, and their tests may use `internal/leaktest` and `internal/memnet`, which use only the standard library too. `internal/minisign` uses only the standard library and `blake2b`, and its tests its own `minisigntest` |
|
||||
| nolintlint | every `//nolint` names its linters and says why, and is still needed |
|
||||
| reassign | no package reassigns another package's variables, tests included |
|
||||
| revive | at most 100 statements or 160 lines a function (`function-length`), and a cognitive complexity of 75 (`cognitive-complexity`) |
|
||||
@@ -108,14 +108,14 @@ golangci-lint enforces most of the [Go conventions](#go-conventions) in `.golang
|
||||
| nilnesserr | a function that checks an error and then returns a different error that is always nil, which reports success for a failure |
|
||||
| durationcheck | two `time.Duration` values multiplied together, which gives nanoseconds squared instead of a duration |
|
||||
| canonicalheader | an HTTP header named other than its canonical form, such as `WWW-Authenticate` or `X-Request-ID` |
|
||||
| errchkjson | a JSON encoding's error is checked when the value could fail to encode (it holds an `any`, a float, a channel or a custom marshaler), and dropped as `_` when errchkjson proves it can't fail, so a value that changes type gets its check back; a struct with no exported fields, which encodes as `{}`, is reported too. The tests may drop the error of a value they built or decoded themselves |
|
||||
| forcetypeassert | a type assertion without its `ok`, which panics on any other type; the tests are exempt, because a panic there fails the run and names the line |
|
||||
| errchkjson | a JSON encoding's error is checked when the value could fail to encode (it holds an `any`, a float, a channel or a custom marshaler), and dropped as `_` when errchkjson proves it can't fail, so a value that changes type gets its check back. It also reports a struct with no exported fields, which encodes as `{}`. The tests may drop the error of a value they built or decoded themselves |
|
||||
| forcetypeassert | a type assertion without its `ok`, which panics on any other type. The tests are exempt, because a panic there fails the run and names the line |
|
||||
| contextcheck | a function given a context that calls one making a context of its own, instead of passing its caller's along |
|
||||
| gochecksumtype | a type switch on a sum type names every type in it, even when the switch has a `default` |
|
||||
|
||||
A function passes its caller's context along, even to work that must outlive it. Work that many requests share, such as a lookup whose value is cached for all of them, uses `context.WithTimeout(context.WithoutCancel(ctx), …)`, which keeps the caller's values and drops its cancel, so no one request's end stops it. A fresh context is the exception, for code with no caller's context to take, such as a cleanup that outlives a canceled run or the proxy's own start, and it takes `//nolint:forbidigo // <why>`. contextcheck can't follow a request's own context through `httputil.ReverseProxy`'s `Rewrite`, and it doesn't count `context.WithoutCancel` alone as deriving one, so those few places take `//nolint:contextcheck // <why>`.
|
||||
|
||||
A sum type is an interface whose implementations are a closed set: it has an unexported method, so only its own package can add one, and its doc comment ends with a `//sumtype:decl` line. gochecksumtype then fails any type switch on it that leaves out one of its types, as exhaustive does for a switch on an enum's constants. The login file formats (`format` in `internal/agentlogin`) are one. A new interface with a fixed list of implementations, which code switches on by type, is declared the same way.
|
||||
A sum type is an interface whose implementations are a closed set. It has an unexported method, so only its own package can add one, and its doc comment ends with a `//sumtype:decl` line. gochecksumtype then fails any type switch on it that leaves out one of its types, as exhaustive does for a switch on an enum's constants. The login file formats (`format` in `internal/agentlogin`) are one. A new interface with a fixed list of implementations, which code switches on by type, is declared the same way.
|
||||
|
||||
`testdata/lint/forbidigo.go` breaks each forbidigo rule once, on a line that ends in `// want forbidigo`. `mise run lint:code` lints it with forbidigo alone and fails unless forbidigo reports exactly those lines, so a rule whose pattern stops matching fails there. A new rule gets its line in the file. `./...` leaves `testdata` out, so the file never fails the lint run of the code itself.
|
||||
|
||||
@@ -125,6 +125,6 @@ The linters above check most of these, and the structure test checks others ([th
|
||||
|
||||
- **One binary, no C.** devvm builds with `CGO_ENABLED=0`, which `mise.toml` and `.goreleaser.yaml` set, and only the test tasks turn cgo on, for the race detector. `internal/proxy` and `internal/daemon` build only on unix systems for now, because they use `syscall.Kill`, `Setsid` and `Flock`.
|
||||
- **External tools are commands, never linked.** devvm runs `limactl`, `docker`, `security`, `git`, `chflags` and the other tools it needs as commands, and it uses the standard library where that does the job rather than shelling out. A string that goes into a shell is quoted with `shell.Quote`.
|
||||
- **Code for one system goes behind build tags** in `internal/platform`, in files named `*_darwin.go`, `*_linux.go` and `*_other.go`. The exceptions are packages that the proxy imports, which can't import `internal/platform`, so each keeps its own few such files: `internal/safefile`'s flags, `internal/daemon`'s `spawn_*.go`, `internal/proxy`'s socketpair, `touch_*.go` and `confineself_*.go`, and `internal/landlock`, the proxy's child's confinement on Linux.
|
||||
- **Code for one system goes behind build tags** in `internal/platform`, in files named `*_darwin.go`, `*_linux.go` and `*_other.go`. The exceptions are the packages that the proxy imports, which can't import `internal/platform`, so each one keeps its own few such files: `internal/safefile`'s flags, `internal/daemon`'s `spawn_*.go`, `internal/proxy`'s socketpair, `touch_*.go` and `confineself_*.go`, and `internal/landlock`, the proxy's child's confinement on Linux.
|
||||
- **Test seams are fields** that a test sets, such as `Host`, `Exec`, `Runner`, `OS` and `Reporter`, and never package variables, which reassign keeps any package from setting in another. `internal/proxy`'s seams are fields of its `server`, which each test makes.
|
||||
- **A new dependency needs the maintainers' yes** before it goes on depguard's list.
|
||||
@@ -24,7 +24,7 @@ devvm runs every external command through the UI's `LoggedCmd(ctx, step, cmd)`,
|
||||
|
||||
### Status lines
|
||||
|
||||
Any work that can take noticeable time runs under a status line, so that the user sees what devvm is waiting for. That's a host command, host git, a command in a VM, a backend's own commands, such as `limactl list`, a request over the network, a walk of a folder the user owns, a lookup of a folder's disk with macOS's `diskutil`, and a wait for a lock, a timeout or another process. A logged command shows its step on its own, and other slow work shows one with the Reporter's `Status`, whose label is a message in `locales/en.toml`, a lowercase phrase in `-ing`, such as `reading_vms`, with a `description` that says what runs under it:
|
||||
Any work that can take noticeable time runs under a status line, so that the user sees what devvm is waiting for. Such work is a host command, host git, a command in a VM, a backend's own commands, such as `limactl list`, a request over the network, a walk of a folder the user owns, a lookup of a folder's disk with macOS's `diskutil`, and a wait for a lock, a timeout or another process. A logged command shows its step on its own. Other slow work shows one with the Reporter's `Status`, whose label is a message in `locales/en.toml`: a lowercase phrase in `-ing`, such as `reading_vms`, with a `description` that says what runs under it. For example:
|
||||
|
||||
```go
|
||||
func ListAll(ctx context.Context, e *Env) ([]Listed, []Known, error) {
|
||||
@@ -32,13 +32,13 @@ func ListAll(ctx context.Context, e *Env) ([]Listed, []Known, error) {
|
||||
inv, err := ReadInventory(ctx, e.Dirs, e.Registry, AllBackends)
|
||||
```
|
||||
|
||||
The status line shows only in a terminal, without `-v` and until the run is interrupted, as nothing would clear one started after that. The UI keeps status lines as a stack: a logged command or a `Status` inside another shows its own line until it ends, and then the outer one is drawn again, so a phase can show one line around steps that show their own. A message said under a status line, whether `Info`, `Warn`, `Note` or data on `Stdout()`, clears the line, prints, and draws the line again below it, so a warning never lands on the status line. A question, the picker and `ui.Terminal`, which a command in the VM that draws on the terminal gets, hold the status line until they're done, so its redraw never goes over a prompt or what the user types.
|
||||
The status line shows only in a terminal, without `-v` and until the run is interrupted, because nothing would clear one started after that. The UI keeps status lines as a stack. A logged command or a `Status` inside another shows its own line until it ends, and then the UI draws the outer one again, so a phase can show one line around steps that show their own. A message said under a status line, whether `Info`, `Warn`, `Note` or data on `Stdout()`, clears the line, prints, and draws the line again below it, so a warning never lands on the status line. A question, the picker and `ui.Terminal`, which a command in the VM that draws on the terminal gets, hold the status line until they're done, so its redraw never goes over a prompt or what the user types.
|
||||
|
||||
A wait for a lock that another devvm holds shows a status line only while it waits, never when the lock is free: `platform.LockFile`, `platform.LockFileShared` and `platform.LockDir` take a `platform.Waiting`, which they call once they find the lock held and whose end they call once the wait ends, and `msg.Waiting(status, label)` makes one from a Reporter's `Status` and a label, such as `vm_state_waiting`. Only `internal/state`, for a VM's lock or the layout's, and `internal/trust`, which take no Reporter, take the run's `Status` from the context (`msg.StatusOf`), which the run's root sets (`msg.WithStatus`), and forbidigo keeps it to them; the layout's migration shows `layout_migrating` while it runs. An agent's login file, whose lock is its folder's (`platform.LockDir`), which the proxy holds while it refreshes the login, takes its wait as `agentlogin.File`'s `Waiting` (`agent_login_waiting`), and its wait ends with the caller's context, as every lock's does. Only a lock that never waits, such as one on a file just made, passes `platform.NoWait`, which shows nothing and which the structure test's `status-lines` rule holds to `statusSites`, as it does a `nil`. `msg.Waiting` with no status, as in a process with no UI, gives a wait that shows nothing, never `nil`, and a test build's locks panic on a `nil` one (`platform.CheckWaiting`, which the root's run calls in every test build), so the CLI tests and the end-to-end tests catch one the rule can't see, such as a zero `agentlogin.File`'s, though not a `msg.Waiting` given a nil status, which is review only. A forbidigo rule refuses `syscall.Flock` and `unix.Flock` outside `internal/platform`, the proxy's log rotation, the stubs and tests, so every lock goes through `internal/platform`'s.
|
||||
A wait for a lock that another devvm holds shows a status line only while it waits, never when the lock is free. `platform.LockFile`, `platform.LockFileShared` and `platform.LockDir` take a `platform.Waiting`, which they call once they find the lock held, and they call its end once the wait ends. `msg.Waiting(status, label)` makes one from a Reporter's `Status` and a label, such as `vm_state_waiting`. `internal/state`, for a VM's lock or the layout's, and `internal/trust` take no Reporter, so they alone take the run's `Status` from the context (`msg.StatusOf`), which the run's root sets (`msg.WithStatus`), and forbidigo keeps it to them. The layout's migration shows `layout_migrating` while it runs. An agent's login file is locked by its folder's lock (`platform.LockDir`), which the proxy holds while it refreshes the login, so it takes its wait as `agentlogin.File`'s `Waiting` (`agent_login_waiting`), and its wait ends with the caller's context, as every lock's does. Only a lock that never waits, such as one on a file just made, passes `platform.NoWait`, which shows nothing, and the structure test's `status-lines` rule holds it to `statusSites`, as it does a `nil`. `msg.Waiting` with no status, as in a process with no UI, gives a wait that shows nothing, never `nil`. A test build's locks panic on a `nil` one (`platform.CheckWaiting`, which the root's run calls in every test build), so the CLI tests and the end-to-end tests catch one that the rule can't see, such as a zero `agentlogin.File`'s. They don't catch a `msg.Waiting` given a nil status, which only a review finds. A forbidigo rule refuses `syscall.Flock` and `unix.Flock` outside `internal/platform`, the proxy's log rotation, the stubs and tests, so every lock goes through `internal/platform`'s.
|
||||
|
||||
Work that takes the terminal never runs under a status line, as its redraw would go over what it shows: a VM's shell, `ssh-add` asking for a key's passphrase (`checkAgent`, `Agent.Ensure`) and an agent's login in the VM. A launch shows its status lines around those steps rather than across them. A background process, such as the proxy, a forwarder or a link session, has no terminal and shows none.
|
||||
Work that takes the terminal never runs under a status line, because its redraw would go over what the work shows. That work is a VM's shell, `ssh-add` asking for a key's passphrase (`checkAgent`, `Agent.Ensure`) and an agent's login in the VM. A launch shows its status lines around those steps rather than across them. A background process, such as the proxy, a forwarder or a link session, has no terminal and shows none.
|
||||
|
||||
Tests check the label rather than a terminal. A `msg.Fake` gives each status line's label, and each logged command's step, to its `OnStatus`, and `Showing` returns the one showing, so a seam that the slow work goes through records what showed meanwhile, as `TestAgentImportStatus` does with the `Opencode` and `ExcludeFromBackup` seams, and a `backendtest.Fake` gives each call to its `OnCall`. `TestLaunchStatusLines` runs a new, a running and a stopped VM's launch and fails on any backend call made with no status line showing, but the shell's, which takes the terminal, and `Running`'s, which reads the VM's pid files, and `TestCommandStatusLines` does the same for the commands that show, list, change, export, stop and delete a running or a stopped VM, devvm network lock's picker, devvm restart, the restart that devvm mount-cache asks for, and links and a group with a second VM that runs, stops and goes, included. It answers their questions in a terminal through the `msg.Fake`, checks that the picker and the restart are asked, and fails on a question asked under a status line, or a proxy or link session started with none. `testProxy` runs each link session as a sleep that says each of its links is carried, as its links change. `TestVMLockWaits`, `TestCheckLayoutWaits` and each lock's own test check a wait's status line. `TestSSHAddOffStatusLine` fails on an `ssh-add` that runs under one, on the user's agent or devvm's own, and `chflagsCalls` fails a clone test on a lock or unlock of `.git` with none. The structure test's `status-lines` rule fails on a function that does slow work by name, a host command, host git, a walk of a folder, a volume's lookup, a request through `internal/fetch`, a wait for a lock that shows nothing or a backend's command outside a step, and shows no status line of its own, unless `statusSites` lists it with why, such as the status line of the caller it runs under ([The structure test](structure.md#the-structure-test)).
|
||||
Tests check the label rather than a terminal. A `msg.Fake` gives each status line's label, and each logged command's step, to its `OnStatus`, and `Showing` returns the one showing. So a seam that the slow work goes through records what showed meanwhile, as `TestAgentImportStatus` does with the `Opencode` and `ExcludeFromBackup` seams, and a `backendtest.Fake` gives each call to its `OnCall`. `TestLaunchStatusLines` runs a new, a running and a stopped VM's launch and fails on any backend call made with no status line showing, except the shell's, which takes the terminal, and `Running`'s, which reads the VM's pid files. `TestCommandStatusLines` does the same for the commands that show, list, change, export, stop and delete a running or a stopped VM, including devvm network lock's picker, devvm restart, the restart that devvm mount-cache asks for, links, and a group with a second VM that runs, stops and goes. It answers their questions in a terminal through the `msg.Fake`, checks that the picker and the restart are asked, and fails on a question asked under a status line, or a proxy or link session started with none. `testProxy` runs each link session as a sleep that says each of its links is carried, as its links change. `TestVMLockWaits`, `TestCheckLayoutWaits` and each lock's own test check a wait's status line. `TestSSHAddOffStatusLine` fails on an `ssh-add` that runs under one, on the user's agent or devvm's own, and `chflagsCalls` fails a clone test on a lock or unlock of `.git` with none. The structure test's `status-lines` rule fails on a function that does slow work it knows by name and shows no status line of its own. That slow work is a host command, host git, a walk of a folder, a volume's lookup, a request through `internal/fetch`, a wait for a lock that shows nothing, or a backend's command outside a step. The rule passes a function when `statusSites` lists it with why, such as the status line of the caller it runs under ([The structure test](structure.md#the-structure-test)).
|
||||
|
||||
## Command arguments
|
||||
|
||||
@@ -88,7 +88,7 @@ other = "{{.count}} current shared tool images no VM has ({{.size}}): {{.tools}}
|
||||
|
||||
- **The ID** is the table's name, in snake_case.
|
||||
- **`other`** is the text: a Go template whose fields are snake_case (`{{.vm_name}}`). Only plain fields are allowed, no logic.
|
||||
- **Fields' types:** the generator makes each field a `string` parameter of the message's function, but `count`, which is an `int`, and `vm` and `vm_name`, which are `vmname.VM`. A field that may hold something other than a VM's name, such as an image's name or a VM's name as the user typed it, is named `what` or `name` instead.
|
||||
- **Fields' types:** the generator makes each field a `string` parameter of the message's function, except `count`, which is an `int`, and `vm` and `vm_name`, which are `vmname.VM`. A field that may hold something other than a VM's name, such as an image's name or a VM's name as the user typed it, is named `what` or `name` instead.
|
||||
- **`one`** is the text for a count of 1, when the wording changes with the count. Both texts then take `{{.count}}`.
|
||||
- **`description`** is an optional note for translators.
|
||||
- **Nothing else:** the generator refuses keys go-i18n doesn't know, nested tables, plural forms English doesn't use (`zero`, `two`, `few`, `many`) and `leftDelim`/`rightDelim`.
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
---
|
||||
title: The co-signer
|
||||
explainer: Set up devvm-cosign, the second builder, which signs and publishes releases
|
||||
weight: 3
|
||||
---
|
||||
|
||||
The co-signer, `devvm-cosign`, is the second of the two builders that sign each devvm release and each published base. It runs on a Linux machine of the maintainer's, and a systemd timer starts it every hour. CI builds each release and hands its files and its signature over as a workflow artifact, because CI's token can only read the repo. Each run, the co-signer downloads what CI handed over, rebuilds it with its own copy of devvm, and signs the manifest only when its build matches CI's byte for byte. Then it makes the GitHub release itself, uploads CI's files and both signatures, and publishes the release once two of the three keys signed it, then updates the Homebrew tap. CI can't make or publish a release, so only the co-signer, and the maintainer by hand, can, and the co-signer raises an alert for any release published since its state began that it didn't make, whatever its tag. Its code is `cmd/devvm-cosign` and `internal/cosign`, and its systemd units and install script are in `packaging/cosign`.
|
||||
|
||||
Releases go through CI and the co-signer once GitHub is set up for them, as [Setting up GitHub for releases](github-setup.md) lists, and until then `scripts/publish.sh --local` publishes them from the maintainer's machine, as [Releasing](maintaining.md#releasing) describes.
|
||||
|
||||
## What CI hands over
|
||||
|
||||
CI's release workflow, `.github/workflows/release.yml` by default (`release_workflow` in the config), runs for each pushed release tag, and uploads one artifact named `release`. The artifact holds `SHA256SUMS`, CI's signature of it, `SHA256SUMS.ci.minisig`, and every file `SHA256SUMS` lists, and nothing else, side by side, with no folders. The base workflow, `.github/workflows/base.yml` by default, uploads one artifact named `base` in the same way, with `base-index.json`, `base-index.json.ci.minisig` and the files the index lists.
|
||||
|
||||
The co-signer reads the workflow's successful runs of this repo's own, never a fork's, through the Actions API. For a release, it takes each tag's newest run that the tag's push started, and for a base, the newest run on `main`. What a run hands over isn't trusted for being CI's: CI's key has to have signed the manifest, and the co-signer's own build has to match it.
|
||||
|
||||
## What a run does
|
||||
|
||||
For each release CI handed over that the co-signer hasn't published, oldest version first, though a run builds only one release or base, and the next waits for the next run:
|
||||
|
||||
1. **Its version is newer** than every release the co-signer has signed, or it's one it signed already, with the same `SHA256SUMS`, because the run that signed it stopped before publishing. An older version, or a second `SHA256SUMS` for a version it signed, is refused, because that's an old or another release replayed, and an older version is an alert until you ack it.
|
||||
2. **CI's artifact checks out.** The co-signer downloads the artifact into `/var/lib/devvm-cosign/stage/`, which no build can write, checked against GitHub's digest of it, and unzips it there, taking only plain files with names a manifest can list, each written new and hashed as it's written, within the artifact's limits. It checks `SHA256SUMS.ci.minisig` with CI's release key and the trusted comment `devvm-release <version>`, exactly, through `internal/minisign`'s `Keys.CheckRole`. The artifact has to hold exactly the files `SHA256SUMS` lists, each with its SHA-256, and nothing else. Before the build, the co-signer deletes those files from the stage and keeps only `SHA256SUMS` and CI's signature, so none of CI's files is on disk while its own build runs, and nothing can have the build copy CI's bytes in place of its own unless it has them from CI itself.
|
||||
3. **Its tag checks out.** The co-signer clones its own devvm checkout, which is at the commit its config pins, into `/var/lib/devvm-cosign/src/`, where no build's container can reach it, fetches the tag and `main` from GitHub, and checks the tag's SSH signature against the tag signers its config pins, never a list read from GitHub or from the tag's commit. The tag's commit has to be on `main`, and it has to be the commit CI's run built, and the co-signer records the tag object's ID. Before anything of the tag's runs, the co-signer reads two files from the tag's commit: the Homebrew formulas' template, `packaging/homebrew/devvm.rb`, and `CHANGELOG.md`.
|
||||
4. **Its own build matches.** The co-signer runs its clone's `scripts/release.sh --tag <tag>`, with its temporary files in `/var/lib/devvm-cosign-build/work/`, the one folder its containers write, and its finished files copied to a folder of `src/`, where the co-signer reads them, which checks the tag again with git and the same signers, and builds the release in its pinned container. No code of the tag's runs outside that container, though the tag does choose the container's image and its Go and GoReleaser downloads, each pinned by its hash, so a tag that a pinned signer signed is what the co-signer trusts ([Reproducible releases](maintaining.md#reproducible-releases)). git and `release.sh` run with an environment of their own, the machine's `PATH`, `HOME`, locale and container runtime's variables alone, and no git config but the command line's, so a repository's own config runs no hook or fsmonitor, and git reaches files and HTTPS alone.
|
||||
5. **On a match, it signs.** Every file that `SHA256SUMS` lists has to have the same SHA-256 in both builds, and the two `SHA256SUMS` have to be the same bytes. The co-signer renders the tap's formulas itself, from the tag's template and the signed `SHA256SUMS`, as `release.sh`'s `formula` function does, and its build's formulas have to be the same bytes, so neither builder's container decides what Homebrew installs. It keeps the formulas and the release notes, the tag's `CHANGELOG.md` entry for the version, in `kept/<version>/`, and records their SHA-256s and the version as signed in its state. Then it signs `SHA256SUMS` with its own key and the trusted comment `devvm-release <version>`.
|
||||
6. **On a mismatch, it signs nothing.** It writes a report to `/var/lib/devvm-cosign/reports/<tag>-<time>.txt`, with each file that differs and both builds' SHA-256s, files nothing publicly, and records the `SHA256SUMS` as refused, so it isn't built or downloaded again. Every run fails until you clear it, as [Refusals and alerts](#refusals-and-alerts) says. A build that fails rather than differs, such as one cut short by a full disk or a download that failed, is built again at the next run, but the third failure in a row refuses it in the same way, with a report that holds the last failure. A build that keeps failing would otherwise take every run's one build, and hold up each newer release and base behind it. A build stopped with its run, at its time limit or by `systemctl stop`, isn't counted.
|
||||
7. **It makes the release.** The co-signer downloads CI's artifact again, checked as before, with the same `SHA256SUMS`. It makes a draft release of the tag, titled `devvm <version>`, with the notes it kept, as a prerelease for a version such as `0.3.0-rc.1`. It uploads `SHA256SUMS`, both signatures and CI's files from the stage, hashing each file as it's sent, so a file that changed on disk after its check is deleted again rather than published. An asset it didn't upload, such as a half-finished upload's, is deleted, and one with the bytes it should have, by size and GitHub's digest, is kept, so a run that stops can run again.
|
||||
8. **It checks the draft, then publishes.** The draft's signatures have to pass `Keys.Check`, so two of CI's, its own and the recovery key's. While releases bridge from the old release key, it waits until you upload `SHA256SUMS.minisig` to the draft, with `scripts/publish.sh --sign-legacy`, and checks it with that key and the trusted comment `devvm <version>`, because devvm 0.1 and 0.2 check only that key, so while the bridge lasts, that key alone still signs a release for them. Each run fails while it waits, so you hear that the draft is waiting for you. Then it reads the draft again: its tag, title and notes have to be the ones it wrote, and its assets exactly the ones it uploaded, by GitHub's ID, size and digest, with nothing added. The tag has to name the same tag object its rebuild checked, so a tag deleted or pushed again while the draft waited isn't published. Only then does it publish the release, as GitHub's latest release unless it's a prerelease or older than a release it published, which happens when the old key signs a newer release's draft first.
|
||||
9. **It checks the release again.** When the published release differs from what it checked, the co-signer raises an alert and stops there, without updating the tap. devvm and the install script refuse a file that doesn't match `SHA256SUMS`, and Homebrew one that doesn't match its formula, but compare the files by hand. With immutable releases on, the fix is a newer release.
|
||||
10. **Then the tap.** It commits the formulas it kept, each checked against the SHA-256 its state recorded, to the tap's `Formula/devvm.rb` and `Formula/devvm-rc.rb`, with GitHub's contents API, as `scripts/publish.sh` does: `devvm.rb` only for a release, not a prerelease, and each only when the tap's formula is for an older version. A tap formula for a version newer than any the co-signer signed isn't one it wrote, so that's an alert. A run that stopped after publishing finishes the tap on the next run, without building again.
|
||||
|
||||
Before any of that, the co-signer looks at each published release it hasn't finished. Its own draft, published without it seeing the answer, such as when GitHub's answer to the publish was lost, is checked as a published release: its `SHA256SUMS` has to be the one it signed, both signatures and every file have to check out, downloaded, and its title and notes have to be its own. Only then does the co-signer finish the tap, and otherwise it raises an alert. `init` records the highest release ID GitHub showed, and the drafts there were then, and GitHub's IDs only go up, so any other release published since, whatever its tag or version, is an alert too. Each run also reads GitHub's latest release, the one `/releases/latest/download/` serves to the install script, wherever the list puts it. `init` records which release that was, and the latest has to stay that one or become one the co-signer published: an older release made the latest again, such as one with a known flaw, is an alert, by `latest:<tag>#<ID>`, and so is the one `init` saw, or one of the co-signer's own, once it's older than a release the co-signer published.
|
||||
|
||||
Each step that fails is logged, and the run goes on to the next release, then exits 1. A run that stops at any step can run again safely, and since an Ed25519 signature of the same bytes and comment is always the same, a signature made again is the one the first run would have made.
|
||||
|
||||
### Refusals and alerts
|
||||
|
||||
A refused build and an alert each fail every run, exit 1, until you deal with them, so the journal and the notify command keep saying so:
|
||||
|
||||
```sh
|
||||
journalctl -u 'devvm-cosign@*' # what each run did, and why it failed
|
||||
sudo -u devvm-cosign devvm-cosign retry v0.3.0 # build CI's v0.3.0 again, though it didn't match before
|
||||
sudo -u devvm-cosign devvm-cosign ack v0.3.0 # clear v0.3.0's alert, once you've dealt with it
|
||||
```
|
||||
|
||||
- **A refusal** is a rebuild that didn't match CI's, or one that failed three times in a row. Read its report, and find out why, such as a full disk or a download cut short on the co-signer, or a build that isn't reproducible. A new CI build of the same tag gives the same `SHA256SUMS`, because builds are reproducible, so it stays refused. Once the cause is fixed, `devvm-cosign retry <tag>` lets the next run rebuild it once more. The co-signer never retries a refusal on its own. Once a newer release is signed, a refused older one can't be signed any more, because versions only go up, so a retry of it raises the older-version alert, and its fix is a newer release.
|
||||
- **An alert** is something wrong that the co-signer can't fix: a release someone else published, one of its own whose published files differ from what it checked, an older version CI handed over, a tap formula it didn't write, or an older release made GitHub's latest. Find out what happened and fix it by hand, such as by deleting a release that isn't CI's and the co-signer's build, then ack it with what the alert names: the tag for its own release or base, `<tag>#<ID>` for a release someone else published, so another release of that tag is alerted on again, `tap:<formula>@<version>` for a tap formula, and `latest:<tag>#<ID>` for the latest release. After an ack, the next run checks its own release again, and raises the alert again if it still differs, and it leaves the rest alone.
|
||||
- **A draft the co-signer didn't make**, for a tag CI handed over, stops that release every run. A run that stopped between making a draft and recording it leaves one too. Delete it by hand, and the next run makes its own.
|
||||
|
||||
Both commands take the state's lock and fail at once when a run holds it, so run one again then. Neither reads a key file.
|
||||
|
||||
**The notify command**, `notify` in the config, is how you hear of a run that failed: a program and its arguments. Every unit of the co-signer's that fails, a run killed at its time limit or one whose config won't load included, starts `devvm-cosign-failed.service` (`OnFailure=`), which runs `devvm-cosign failed`. That runs the notify command with a line saying a run failed and the last run's record, which says when it started and what failed, or that it never finished, on its standard input, at most 64 KiB, with an environment of its own, `PATH`, `LANG` and `DEVVM_COSIGN_EVENT=failed` alone, in `/`, for a minute at most, so it gets none of the co-signer's credentials. Use a script that posts over HTTPS, such as `curl` to ntfy: a local mail server's `sendmail` doesn't work under the units' `NoNewPrivileges`. A co-signer that's down sends nothing, so a release tag that's still not published a day on is the sign to look at it.
|
||||
|
||||
### Bases
|
||||
|
||||
A base is a release of its own, `base-<serial>`, whose manifest is `base-index.json` and whose trusted comment is `devvm-base <format> <serial> <expiry>`, with each of those the same as the index's fields. The co-signer checks a base CI handed over as it checks a release, with the base keys, and with these differences:
|
||||
|
||||
- **Only CI's newest base counts,** as each base replaces the last. A run that the co-signer has published is never downloaded again.
|
||||
- **The serial only goes up,** and the index has to be in date. Its expiry is the last day devvm takes it, in UTC, and it may be at most 31 days ahead.
|
||||
- **The snapshot can't be old.** An index whose Ubuntu snapshot is more than 60 days old (`max_snapshot_days` in `[base]`) is refused, whether or not it needs a rebuild. The expiry alone can't keep users off an old base, because the co-signer re-signs an unchanged base with a new serial and expiry, so whoever holds CI's base key could otherwise keep users on one snapshot, missing every update since, for as long as they sign. Ubuntu's archive changes every day, so a base that's two months old has missed security updates.
|
||||
- **An unchanged base is signed without a rebuild.** The co-signer records the SHA-256 of every base file that a rebuild of its own matched, and the last index it signed. A base that's that index again, with a new serial and expiry, and whose files are all ones it has checked, is re-signed at once, which keeps the published base inside its 30 days while nothing changes. Any other index is rebuilt, so an older base's files can't come back with a new serial.
|
||||
- **Its release** is made at the index's commit, titled `devvm's base <serial>`, with notes the co-signer writes from the index, and it's never GitHub's latest release, which stays devvm's newest release.
|
||||
- **No rebuild yet.** Bases are built from the signing design's fifth phase on, and until then a base with a file the co-signer hasn't checked isn't signed, and its log says why. `BaseBuilder` is the seam for that build.
|
||||
|
||||
Without base keys in the config, the co-signer leaves bases alone.
|
||||
|
||||
## Its files
|
||||
|
||||
| File | What |
|
||||
| --- | --- |
|
||||
| `/usr/local/bin/devvm-cosign` | the program, built from a release tag the maintainer checked |
|
||||
| `/etc/devvm-cosign/config.toml` | everything it trusts and signs with, root's, readable by its group, `devvm-cosign` |
|
||||
| `/etc/devvm-cosign/*.key`, `app.pem` | its minisign secret keys and the GitHub App's private key, root's, mode 0600, which reach the service as systemd's credentials |
|
||||
| `/var/lib/devvm-cosign/state.json` | what it signed, made, published, refused and alerted on |
|
||||
| `/var/lib/devvm-cosign/kept/<version>/` | each signed release's formulas and notes, which it renders and checks before publishing |
|
||||
| `/var/lib/devvm-cosign/reports/` | the reports of rebuilds that didn't match |
|
||||
| `/var/lib/devvm-cosign/stage/`, `src/` | CI's artifacts, unzipped, and each build's clone of the checkout, which `release.sh` runs from, and its finished files, both emptied at the start of each run |
|
||||
| `/var/lib/devvm-cosign/cache/` | `release.sh`'s downloads, which only it, on the host, reads |
|
||||
| `/var/lib/devvm-cosign/last-failure.txt` | the last run's record for the notify command: when it started, and what failed or that it never finished; removed when a run succeeds |
|
||||
| `/var/lib/devvm-cosign-build/` | the build folder, the one the builds' containers write: `release.sh`'s temporary files in `work/`, and rootless podman's config, images and containers, all deleted each time the podman service starts |
|
||||
|
||||
The config:
|
||||
|
||||
```toml
|
||||
repo = "devvmhq/devvm"
|
||||
tap = "devvmhq/homebrew-tap"
|
||||
# The SSH public keys whose signed tags it builds, as their .pub files have them.
|
||||
tag_signers = ["ssh-ed25519 AAAA… cj@mini"]
|
||||
# podman or docker, for release.sh; podman by default.
|
||||
runtime = "podman"
|
||||
# Run after each run that failed, with what failed on its stdin; none by default.
|
||||
notify = ["/usr/local/bin/devvm-cosign-notify"]
|
||||
|
||||
# devvm's checkout that the release.sh it builds with is from: a release tag you checked.
|
||||
[devvm]
|
||||
checkout = "/opt/devvm-cosign/devvm"
|
||||
commit = "<the tag's commit, all 40 characters>"
|
||||
|
||||
[release]
|
||||
secret_key = "/etc/devvm-cosign/release.key"
|
||||
keys = { ci = "RW…", cosign = "RW…", recovery = "RW…" }
|
||||
# While releases bridge from the old release key: packaging/minisign.pub's key.
|
||||
legacy_key = "RW…"
|
||||
|
||||
# Optional, until bases are published.
|
||||
[base]
|
||||
secret_key = "/etc/devvm-cosign/base.key"
|
||||
keys = { ci = "RW…", cosign = "RW…", recovery = "RW…" }
|
||||
|
||||
[app]
|
||||
id = "<the app's client ID or app ID>"
|
||||
installation = 12345678
|
||||
private_key = "/etc/devvm-cosign/app.pem"
|
||||
```
|
||||
|
||||
- **The keys** are each kind's three public keys, the same as `packaging/keys`' `<kind>-<role>.pub`, and the secret key's public half has to be the `cosign` key, or the config is refused. A config with a key it doesn't know is refused too.
|
||||
- **The key files** are read from systemd's credentials folder, `$CREDENTIALS_DIRECTORY`, when the service runs, by the name each path in the config ends with, so those names have to be the units' credential names: `release.key`, `app.pem` and `base.key`. Run by hand, outside the units, they're read from where the config says. Each has to be a regular file that only its owner can read, mode 0600 or 0400, or the config is refused, but for a credential, which systemd makes root's, mode 0440, with an ACL for the service's user, in a folder only that service sees, and which only has to be unreadable by others.
|
||||
- **`git_url`, `api_url` and `uploads_url`** default to `https://github.com/<repo>.git`, `https://api.github.com` and `https://uploads.github.com`, and each has to be HTTPS. **`state_dir`** defaults to `/var/lib/devvm-cosign` and **`build_dir`** to `/var/lib/devvm-cosign-build`, and neither may be in the other, so the podman service's unit can hide the state folder whole. The units name both folders, so change them only with the units changed to match.
|
||||
- **`release_workflow`** and `[base]`'s **`workflow`** are the workflow files' names, `release.yml` and `base.yml` by default, and `[base]`'s **`max_snapshot_days`** is from 1 to 365, 60 by default.
|
||||
- **The tap** has to be under the same owner as the repo, as the app's one installation covers both.
|
||||
|
||||
`state.json` records, for releases and for bases, the newest version or serial it signed, the SHA-256 of each manifest it signed and of each it refused with how often it was retried, how many of a manifest's builds in a row failed, the draft releases it made, what it published, each alert and how often it was acked, the CI runs it signed, the SHA-256 of each file it kept, each release's tag object, and each base file a rebuild matched, and the highest release ID GitHub showed and its latest release when `init` wrote it. It's written whole, through a temp file that's synced and renamed, and the folder is synced after, and a write that would record less than the file on disk, such as an older version or a dropped draft, is refused. At the start of each run the co-signer also compares it with GitHub: when a release or base, a draft or published, has a signature that checks out with the co-signer's key and is newer than the state's newest, which a state it wrote never is, the state was restored from an old backup or replaced, and the run stops before signing anything, so restore the newest backup. Only one run runs at a time, through a lock in the state folder.
|
||||
|
||||
GitHub lists releases and runs newest first, so the co-signer reads them a page at a time until a page holds only ones it's finished with: published, and either from before its state began, its own and finished, or someone else's that it has alerted on. Years of releases and bases never make it read more. Ten pages it hasn't finished with are an error, never a list cut short.
|
||||
|
||||
## Setting it up
|
||||
|
||||
The co-signer runs on any Linux machine with systemd, about 4 cores and 20 GB free, podman (or Docker), git, bash, curl and `ssh-keygen`. Nothing reaches it from outside: it calls GitHub's API, fetches from GitHub, and its builds download Go, GoReleaser and Go's modules.
|
||||
|
||||
1. **Install what it runs,** such as `sudo dnf install podman git curl openssh-clients` on Fedora or `sudo apt install podman git curl openssh-client` on Debian or Ubuntu, and [mise](https://mise.jdx.dev), for the Go the tag pins.
|
||||
2. **Register qemu-user with binfmt,** once, on an x86_64 machine, so it can rebuild arm64's base: `sudo dnf install qemu-user-static` on Fedora, or `sudo apt install qemu-user-static binfmt-support` on Debian or Ubuntu, then check that `/proc/sys/fs/binfmt_misc/qemu-aarch64` exists. Releases don't need it, because Go cross-compiles them, and an arm64 machine doesn't need it at all.
|
||||
3. **Check out devvm at a release tag** and build the co-signer from it, with the Go that the tag's `mise.lock` pins:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/devvmhq/devvm.git ~/devvm-cosign && cd ~/devvm-cosign
|
||||
git tag -v v<version> # signed by your key: compare its fingerprint
|
||||
git checkout v<version>
|
||||
mise trust && mise install go # the Go the tag's mise.lock pins
|
||||
CGO_ENABLED=0 mise exec -- go build -trimpath -o /tmp/devvm-cosign ./cmd/devvm-cosign # outside the checkout, which must stay clean
|
||||
sudo packaging/cosign/install.sh /tmp/devvm-cosign
|
||||
sudo mkdir -p /opt/devvm-cosign && sudo mv ~/devvm-cosign /opt/devvm-cosign/devvm
|
||||
sudo chown -R root:root /opt/devvm-cosign/devvm # the checkout config.toml names, root's
|
||||
```
|
||||
|
||||
`install.sh` installs the program and the systemd units, makes the user `devvm-cosign` with 65536 subordinate IDs for rootless podman, above every other user's range so no two users' containers share an ID, and makes `/etc/devvm-cosign`, `/var/lib/devvm-cosign` and `/var/lib/devvm-cosign-build` with the folders the units need. It installs no package and starts nothing, and it warns when there's no `qemu-aarch64` handler.
|
||||
4. **Write the config and copy the keys** into `/etc/devvm-cosign`: the config root's, readable by the co-signer's group, and each key file root's alone, `sudo chown root:devvm-cosign /etc/devvm-cosign/config.toml && sudo chmod 640 /etc/devvm-cosign/config.toml && sudo chown root:root /etc/devvm-cosign/*.key /etc/devvm-cosign/app.pem && sudo chmod 600 /etc/devvm-cosign/*.key /etc/devvm-cosign/app.pem`. With a base key, run `install.sh` again, which then installs the drop-in that loads it.
|
||||
5. **Check it, write its first state and start the timer:**
|
||||
|
||||
```sh
|
||||
sudo systemctl start devvm-cosign@check # the config, the keys and the checkout, offline
|
||||
sudo systemctl start devvm-cosign@init # state.json, from the newest release and base published
|
||||
journalctl -u devvm-cosign@check -u devvm-cosign@init
|
||||
sudo systemctl enable --now devvm-cosign.timer
|
||||
```
|
||||
|
||||
`init` writes the first `state.json` from what GitHub has published, so the co-signer signs only newer releases and bases and alerts on any release published after it, and it refuses to replace a state there is.
|
||||
|
||||
The units:
|
||||
|
||||
- **`[email protected]`** runs `devvm-cosign <instance>` as `devvm-cosign`, once per start: `devvm-cosign@run` for the timer, and `@check` and `@init` for setting up. It loads the release key and the app's key as systemd's credentials (`LoadCredential=`), and the base key through the drop-in `devvm-cosign-base.conf`, because a credential that isn't there fails the service. It runs with `NoNewPrivileges`, `ProtectSystem=strict`, `/var/lib/devvm-cosign` and `/var/lib/devvm-cosign-build` its only writable folders, `ProtectHome`, a private `/tmp`, a PID namespace of its own, no capabilities, and a 3-hour limit, and when it fails it starts `devvm-cosign-failed.service`.
|
||||
- **`devvm-cosign.timer`** starts `devvm-cosign@run` hourly, and at boot for a run the machine was off for.
|
||||
- **`devvm-cosign-podman.service`** is the rootless podman service, as the same user, that the builds' containers run in, through `CONTAINER_HOST`. podman can't map a user namespace for its containers under `NoNewPrivileges`, because `newuidmap` gets its privilege from a file capability, so the containers run in this service, which has no `NoNewPrivileges` and whose cgroup is delegated to the user, so `release.sh`'s process and memory limits apply. Its `HOME` is the build folder, where podman keeps its config and storage. Each time it starts, it deletes the user's `libpod*` files in `/dev/shm`, podman's locks, which outlive the service, then everything in the build folder, its images and containers with `podman system reset`, so each run pulls its build's image again, and a start that fails starts `devvm-cosign-failed.service`. A start fails when a build left files the co-signer's user can't delete, and until root deletes them, `sudo rm -rf /var/lib/devvm-cosign-build/*`, no run starts. It runs only while a run needs it (`StopWhenUnneeded=`).
|
||||
- **`devvm-cosign-failed.service`** runs `devvm-cosign failed`, which runs the notify command, and reads no key.
|
||||
|
||||
### What a build's container can reach
|
||||
|
||||
The builds' containers run as the same user as the co-signer, because rootless podman maps a container's root to it, and they have no capabilities and no network, but for the one that downloads Go's modules, and run only code from a tag a pinned signer signed. A process that escapes a container lands in the podman service, and the units keep these from it:
|
||||
|
||||
- **The keys and the config.** The keys are root's, and the co-signer gets them only as credentials, in a folder of its own service's while it runs. The podman service sees neither `/etc/devvm-cosign` nor any service's credentials (`InaccessiblePaths=`).
|
||||
- **The co-signer's processes.** The podman service and the run's service each have a PID namespace of their own (`PrivatePIDs=`), so an escaped process can't see the co-signer, `release.sh` or git, nor reach their files through `/proc/<pid>/root`. `devvm-cosign` also makes itself non-dumpable when it starts, so no other process of its user can read its memory, where the keys and the GitHub token are, or trace it, though the programs it starts are dumpable.
|
||||
- **The state and what the co-signer runs.** The podman service can't see `/var/lib/devvm-cosign` at all: the state, the kept formulas, CI's staged files, the download cache, the clone whose `release.sh` and git config the co-signer runs, and the folder `release.sh` copies the finished build to, which the co-signer reads. It writes only the build folder. The co-signer runs nothing from there, and the one thing `release.sh` reads from it once a container has run is the build's output, which it copies to that private folder: a link there can only change what the co-signer compares, and none of CI's files is on disk then, so a build it changed differs from CI's and is refused. That holds unless CI is compromised too: whoever controls CI knows its files' bytes, so an escape that downloads them into the build counts as the co-signer's compromise, and both builders are then compromised, which two of three keys can't stop.
|
||||
- **Later builds.** Each run builds once, and the podman service runs only while the run does, so a process that escaped a build is gone before the next build's `release.sh` and git run. Each start of the service deletes the user's podman files in `/dev/shm` and the whole build folder, podman's config and images with it, so nothing a build left behind, such as a lock, a link or a config pointing podman at another runtime, reaches the next.
|
||||
|
||||
What's still shared is the user and the machine. An escaped process can slow the build it's in, or change it, which then doesn't match CI's, and use the machine's network while that run lasts. An escape through the kernel, rather than podman or crun, gets past all of it, so keep the machine for the co-signer alone. Running podman as a build user of its own would take away the shared user, though that isn't set up yet.
|
||||
|
||||
With Docker instead, set `runtime = "docker"`, drop `CONTAINER_HOST` and the podman unit from the service, and add `devvm-cosign` to the `docker` group. Membership of that group is as good as root on the machine, so podman is the better choice.
|
||||
|
||||
### Making its keys
|
||||
|
||||
The co-signer's keys are minisign keys with no password, because nobody is there to type one, so the machine's disk is what protects them:
|
||||
|
||||
```sh
|
||||
sudo minisign -G -W -p release-cosign.pub -s /etc/devvm-cosign/release.key
|
||||
sudo minisign -G -W -p base-cosign.pub -s /etc/devvm-cosign/base.key
|
||||
```
|
||||
|
||||
Commit each public key to `packaging/keys/<kind>-cosign.pub`, and copy the release key into `install.sh`'s `release_cosign_key` line ([Release keys](maintaining.md#release-keys)). Keep an encrypted copy of each secret key offline, such as on a USB drive kept apart, and never on a machine you develop on, because that machine and CI would then hold two of the three keys.
|
||||
|
||||
### The GitHub App
|
||||
|
||||
The co-signer calls GitHub with a GitHub App's installation token, never a personal token. Each run signs a JSON Web Token with the app's private key (RS256, issued a minute in the past and valid for nine minutes), trades it for an installation token, which lasts an hour, and asks for that token to reach only `devvm` and the tap, with Contents read and write and Actions read, and nothing else. The app's actor isn't the maintainer, so it has none of the maintainer's bypasses of rulesets.
|
||||
|
||||
[Setting up GitHub for releases](github-setup.md#2-the-github-app) has the clicks and the commands that check them.
|
||||
|
||||
1. Create the app under the account that owns devvm, with no webhook, and the repository permissions Contents: read and write, Actions: read, and Metadata: read, which GitHub adds.
|
||||
2. Install it on `devvm` and `homebrew-tap` alone, and note the installation's ID, the number at the end of its settings page's URL.
|
||||
3. Generate a private key, and copy the `.pem` file to `/etc/devvm-cosign/app.pem`.
|
||||
4. Let the app through the tap's ruleset, as a bypass for its `main`, or the co-signer can't update the formulas, and every run fails.
|
||||
|
||||
Every GitHub call goes through `Client` in `internal/cosign/github.go` and `actions.go`: listing releases, reading one, making a draft, uploading, deleting and downloading an asset, publishing, reading and writing the tap's files, and listing a workflow's runs and a run's artifacts and downloading one. A download redirects to GitHub's storage, and the token is never sent to a host other than the one it called.
|
||||
|
||||
## Moving it to another machine
|
||||
|
||||
Set up the new machine as above, with the same config and keys, then stop the old one's timer (`sudo systemctl disable --now devvm-cosign.timer`) and copy its `/var/lib/devvm-cosign` whole, but for `stage/`, `src/` and `cache/`, which the new machine makes again, as it does the build folder, `/var/lib/devvm-cosign-build`, which isn't copied. `state.json` alone isn't enough, because a release signed on the old machine and not yet in the tap needs its `kept/` files. Two machines with the same keys must never run at once, because each would publish.
|
||||
|
||||
A lost machine, or a co-signer key you no longer trust, needs new keys instead: make them on the new machine, then publish a release that embeds the new public key, signed by CI and the recovery key, which are two of three without the old key. From that release on, devvm checks the new key.
|
||||
|
||||
## Its tests
|
||||
|
||||
`internal/cosign`'s tests run the co-signer against a fake GitHub in memory (`fakegithub_test.go`), which checks each call's token and the app's JWT, serves workflow runs and their artifacts, makes drafts, serves downloads from a storage server of its own, and can fail a call, leave a half-finished upload, lose a publish's answer, or swap an asset. The rebuild is a stub in most tests, and `build_test.go` runs `ReleaseBuild` with real git repositories and a stub `release.sh`. The cases include a rebuild that doesn't match and its retry, a build that keeps failing, an older release made the latest, a formula of the build's own, a bad CI signature, an artifact with a file too many or too few, a zip with a link, a folder or a size that lies, a tag signed by an unpinned key, an older version replayed, a file swapped before or as it's published, a release someone else published, a failure mid-upload and its retry, the release list past ten pages, a base on an old snapshot, and a state that would go backwards, and the parsers of outside input have fuzz tests.
|
||||
@@ -1,24 +1,26 @@
|
||||
---
|
||||
title: Design notes
|
||||
explainer: Why devvm is built this way, and what's open
|
||||
weight: 12
|
||||
weight: 8
|
||||
aliases:
|
||||
- /docs/internals/design/
|
||||
---
|
||||
|
||||
For contributors: why devvm is built the way it is, what was tried and dropped, and what's still open. How each part works is on its own page, and [Contributing](../contributing/_index.md) has the repo's layout and rules. Why devvm is written in Go is under [Why Go](processes.md#why-go), with the processes it runs.
|
||||
For contributors: why devvm is built the way it is, what was tried and dropped, and what's still open. How each part works is on its own page in [How it works](../internals/_index.md), and the rest of [Contributing](_index.md) has the repo's layout and rules. Why devvm is written in Go is under [Why Go](../internals/processes.md#why-go), with the processes it runs.
|
||||
|
||||
## Emulated features
|
||||
|
||||
When devvm builds a backend feature from other parts of the backend, the feature is [emulated](backends.md#features), and it gets a note here before its review. The note says what the feature is built from, the guarantee it keeps, what could break it, and which end-to-end checks prove it. The threat check comes next, and only then is the feature marked reviewed. Every feature Lima has is native except its ports, which devvm's forwarder emulates ([below](#ports-on-lima)).
|
||||
When devvm builds a backend feature from other parts of the backend, the feature is [emulated](../internals/backends.md#features), and it gets a note here before its review. The note says what the feature is built from, the guarantee it keeps, what could break it, and which end-to-end checks prove it. The threat check comes next, and only then is the feature marked reviewed. Every feature Lima has is native except its ports, which devvm's forwarder emulates ([below](#ports-on-lima)).
|
||||
|
||||
### ssh into VMs
|
||||
|
||||
ssh for editors is native on Lima, so it isn't an emulation, but its sessions keep a guarantee of devvm's own: ssh and editors reach a VM by name through the entries devvm writes ([security model](security.md#ssh-into-vms)), and a session gives the VM no way out it doesn't already have, on a confined tier nothing past its proxy, whatever the VM runs as sshd.
|
||||
ssh for editors is native on Lima, so it isn't an emulation, but its sessions keep a guarantee of devvm's own: ssh and editors reach a VM by name through the entries devvm writes ([security model](../internals/security.md#ssh-into-vms)), and a session gives the VM no way out it doesn't already have, on a confined tier nothing past its proxy, whatever the VM runs as sshd.
|
||||
|
||||
**What keeps a session from carrying the VM out.** An ssh session can carry the VM's traffic only through channels the host's ssh asks for: remote forwards (`-R`, `RemoteForward`, a remote SOCKS forward), X11, a tunnel and the agent; OpenSSH's client refuses a channel the server opens unasked. Root in the VM runs whatever sshd it likes, so the guarantee is the host's ssh's: devvm's entry (first in `~/.ssh/config`, so its options win over a `Host *`) sets `ForwardX11 no`, `ForwardX11Trusted no`, `Tunnel no`, `PermitRemoteOpen none` (so devvm needs OpenSSH 8.7 or newer; no `IgnoreUnknown` for older ones, as its first value wins and would replace a user's `Host *` one, such as macOS's for `UseKeychain`), `ForwardAgent` as the agent choice the VM's current start was made with says, `AddKeysToAgent no` (no key of the host's lands in an agent the session forwards), `ProxyJump none` and `ProxyCommand none` (no hop through something else), `UpdateHostKeys no` (the VM can't add host keys; devvm reads them itself) and `HashKnownHosts no`. A `RemoteForward` can't be turned off without refusing `ssh -R` on the command line too, so it isn't (Not covered). VS Code's Remote-SSH uses local and dynamic forwards (`-L`, `-D`) and is unaffected. Then sshd's own settings, a defence for an honest VM (`assets/layers/base.sh`, `/etc/ssh/sshd_config.d/00-devvm.conf`, first so it wins; Lima's own forwards are local; it applies only where the image's `sshd_config` includes `sshd_config.d`, as Ubuntu's and Debian's do, so for some `--from` images not at all, which only an honest VM's defence loses):
|
||||
|
||||
- **Local forwarding** (`-L`, `-D`, `-W`) is allowed: the VM itself connects, from its own network, which its tier confines like any other connection of the VM's (checked). VS Code's Remote-SSH reaches its server this way.
|
||||
- **Remote forwards bind only `127.77.0.0/16`,** the range devvm keeps for links between VMs, and remote socket forwards are refused. A remote forward makes the host connect on the VM's behalf, so one the host's ssh asked for by mistake could reach anything the host reaches, its loopback services and sockets (`docker.sock`, agents) included, around the VM's confinement. `GatewayPorts clientspecified` binds the address a request names, and `PermitListen 127.77.*:*` matches that address as text, so a request for `localhost` (ssh's default), `127.0.0.1`, `0.0.0.0` or `::1` is refused. Only devvm on the host asks for a forward in that range, always by number. X11 and tunnels are refused too.
|
||||
- **Agent forwarding** is allowed: the entry decides it from the SSH agent choice the VM's current start was made with (`ForwardAgent` and `IdentityAgent` naming the VM's proxy's relay of that agent, yours or devvm's own, which passes on only listing keys, signing and `[email protected]`, so the VM can't remove, lock or add the agent's keys: [the SSH agents](processes.md#the-ssh-agents)); refusing it would break `devvm ssh-agent on` in editors.
|
||||
- **Agent forwarding** is allowed: the entry decides it from the SSH agent choice the VM's current start was made with (`ForwardAgent` and `IdentityAgent` naming the VM's proxy's relay of that agent, yours or devvm's own, which passes on only listing keys, signing and `[email protected]`, so the VM can't remove, lock or add the agent's keys, as [the SSH agents](../internals/processes.md#the-ssh-agents) says). Refusing it would break `devvm ssh-agent on` in editors.
|
||||
|
||||
These settings guard against the host's ssh asking for a forward that devvm's entry doesn't pin (a `RemoteForward` under `Host *`, `ssh -R`), and only while root in the VM leaves sshd as it is. They're a safeguard for an honest VM, and the boundary is the host's ssh, which accepts a channel only for a forward it asked for.
|
||||
|
||||
@@ -38,11 +40,11 @@ These settings guard against the host's ssh asking for a forward that devvm's en
|
||||
**What it's built from:**
|
||||
|
||||
- **Lima's forwards off.** Each VM's `portForwards` holds three ignore rules, each for every guest port and protocol (`any`, which is TCP and UDP). They're on `127.0.0.1`, which Lima also matches for `::1`, on `0.0.0.0` and on `::`, which together match servers on all addresses. They come ahead of Lima's own last rule, which forwards everything. `CreateVM` sets them with `limactl clone --set`. `Start` sets them only where `limactl list` shows other rules, because an edit gives the VM new host keys at its next boot. Lima's ssh is its VM driver's forward (`ssh.localPort`), not a rule, so the ignore rules leave it alone, and they cover the guest's own ssh port like any other.
|
||||
- **The sandbox's binds (macOS, confined tiers).** The hostagent of a confined VM runs under a Seatbelt profile ([confinement](lima.md#confinement)) that denies every network bind but two kinds. It may bind the VM's ssh port over TCP, which devvm chooses and records in the VM's state (the `ports` section's `host.ssh`), and unix sockets in the VM's Lima folder, which hold the hostagent's own socket (`ha.sock`), the VM's network (`default_ep.sock`, `default_fd.sock`) and ssh's control socket. Seatbelt matches a bind by its port alone, on any address, even when the rule names `localhost`, and it can't allow an ephemeral bind (port 0) without allowing every port. It matches a unix socket by its path with links resolved, so a link in the Lima folder doesn't let the hostagent bind a socket elsewhere. Lima's host resolver binds two ephemeral ports for its DNS server, so a confined VM starts with the resolver off and `127.0.0.1` as its DNS server, as on Linux, where nothing listens and lookups fail at once. The hostagent reaches the guest agent over vsock, which needs no bind. This list comes from starting a VM under a profile that reported every bind, then under one that denied the rest: Lima logs a forward it's refused (`failed to listen`) and carries on, while a refused resolver ends the start.
|
||||
- **The sandbox's binds (macOS, confined tiers).** The hostagent of a confined VM runs under a Seatbelt profile ([confinement](../internals/lima.md#confinement)) that denies every network bind but two kinds. It may bind the VM's ssh port over TCP, which devvm chooses and records in the VM's state (the `ports` section's `host.ssh`), and unix sockets in the VM's Lima folder, which hold the hostagent's own socket (`ha.sock`), the VM's network (`default_ep.sock`, `default_fd.sock`) and ssh's control socket. Seatbelt matches a bind by its port alone, on any address, even when the rule names `localhost`, and it can't allow an ephemeral bind (port 0) without allowing every port. It matches a unix socket by its path with links resolved, so a link in the Lima folder doesn't let the hostagent bind a socket elsewhere. Lima's host resolver binds two ephemeral ports for its DNS server, so a confined VM starts with the resolver off and `127.0.0.1` as its DNS server, as on Linux, where nothing listens and lookups fail at once. The hostagent reaches the guest agent over vsock, which needs no bind. This list comes from starting a VM under a profile that reported every bind, then under one that denied the rest: Lima logs a forward it's refused (`failed to listen`) and carries on, while a refused resolver ends the start.
|
||||
- **Which ports.** Which ports each VM forwards, all, none or a list, is in its state (`ports.forward`), and the backend never hears of them: neither `Start`'s `Want` nor any other call of the backend's has them. `vmssh.Forwards.Start`, the one owner of the forwarder, reads them from the VM's state each time it starts one, after a start of the VM and when `devvm ports` changes a running VM's ports, without editing Lima's config. A stopped VM's change is its state's alone, because its next start reads it. When the VM lists ports, the forwarder forwards those less the ports a program on the host has, which the owner leaves out with a `ports_taken` warning. When none is left, no forwarder runs.
|
||||
- **A forwarder per VM, on the host.** The forwarder is `vmssh.Forwarder`, which isn't a backend's. Its owner, `vmssh.Forwards`, runs it detached as `devvm _ports`, one per VM, for project VMs alone, because only a project VM's start goes through it, and builds' starts don't. The owner starts it once the backend's `Start` returns, and again on a running VM when its ports change, each after stopping any forwarder the VM had, which ends the connections open through it. devvm finds that one by its pid file, which it checks against the process's arguments, as it does for the proxy. It sends that forwarder SIGTERM and kills it if it hasn't ended within 2 s, so its ports are free before devvm asks which listed ports a host program has. devvm holds a lock of the VM's own (`ports.lock`, beside its pid file `ports.pid` in the VM's run folder) from stopping the old forwarder until the new one has started, so two devvm runs at once, such as a start and `devvm ports`, leave one forwarder, the one its pid file names. The owner waits up to 10 s for the forwarder to say it forwards while it runs. The forwarder says so in a status file of its own beside its pid file (`ports.status`), which holds its pid and which devvm removes before each start. If it doesn't, devvm warns with `ports_forward_failed`, naming its log, and leaves it to keep trying while the VM runs on.
|
||||
- **Reaching the VM.** The forwarder makes one ssh connection, a master (`ssh -F none -M -S <socket>`), to the VM's sshd on Lima's ssh port on the host's loopback. Lima's `SSH` gives the port with the user and the key, the first `IdentityFile` of Lima's ssh config, and devvm refuses that target unless the config names `127.0.0.1` (`vmssh.FromTarget`, the check links and the ssh config use too). It logs in as Lima's user with Lima's key alone (`IdentitiesOnly`, `IdentityAgent=none`), `_config/user` in devvm's Lima home, which every VM there authorizes, and never with the user's agent. The master reads none of the user's configuration and forwards nothing either way, with `ClearAllForwardings`, `PermitRemoteOpen none`, `ProxyCommand none`, and no agent, X11 or tunnel. The VM's sshd allows local forwarding, and remote forwards only to `127.77.0.0/16` for [links](#links-between-vms) (`base.sh`), and `-W` is local forwarding. Its control socket is in `~/.local/share/devvm/run` (mode 700) and is named by a hash of the VM's name, because a socket's path has fewer than 104 characters. When the connection is lost, the forwarder closes its forwards and makes the connection again every 2 s while the lifeline holds.
|
||||
- **What listens.** The master's session runs `ports.sh` (`assets/guest/ports.sh`) as the VM's user (`sh -s`). It prints the local addresses of the VM's listening TCP sockets, which are the state `0A` lines of `/proc/net/tcp` and `tcp6`, whenever they change and every 10 s regardless, so it ends soon after the connection does. The forwarder treats the report as untrusted. A line over 128 bytes or a report over 4096 lines ends the connection, and anything that isn't a hex address and port is skipped. Reports are applied at least 500 ms apart, and one that comes sooner waits, holding up the VM's ssh channel with it, so the VM can't make the forwarder bind, dial and read devvm's state at its own pace. The VM can make the forwarder write to its log, with ports coming and going and with the session's stderr, so the log takes 200 writes at once and then one every 10 s. Each write is at most 512 bytes, without control characters but newlines and tabs, C1 included, and the log is rotated before it passes 1 MiB, its end kept in `ports.log.1`. A forwarded port's connections go to `127.0.0.1` for a server on all IPv4 addresses or on that address, and to `::1` for a server on all IPv6 addresses or on that address. A server on another `127.x` address alone gets its connections there. Servers on other addresses alone aren't forwarded.
|
||||
- **What listens.** The master's session runs `ports.sh` (`assets/guest/ports.sh`) as the VM's user (`sh -s`). It prints the local addresses of the VM's listening TCP sockets, which are the state `0A` lines of `/proc/net/tcp` and `tcp6`, whenever they change and every 10 s regardless, so it ends soon after the connection does. The forwarder treats the report as untrusted. A line over 128 bytes or a report over 4096 lines ends the connection, and anything that isn't a hex address and port is skipped. Reports are applied at least 500 ms apart, and one that comes sooner waits, holding up the VM's ssh channel with it, so the VM can't make the forwarder bind, dial and read devvm's state at its own pace. The VM can make the forwarder write to its log, with ports coming and going and with the session's stderr, so the log takes 200 writes at once and then one every 10 s. Each write is at most 512 bytes, without control characters other than newlines and tabs, C1 included, and the log is rotated before it passes 1 MiB, its end kept in `ports.log.1`. A forwarded port's connections go to `127.0.0.1` for a server on all IPv4 addresses or on that address, and to `::1` for a server on all IPv6 addresses or on that address. A server on another `127.x` address alone gets its connections there. Servers on other addresses alone aren't forwarded.
|
||||
- **How many.** With every port, the forwarder takes ports from 1024 up, because the ports below are the host's system services. With listed ports, it takes those alone (`-only`), a listed port below 1024 included, because the user asked for it, and a bind the host refuses is logged. Either way the forwarder takes at most 256 ports at once (`vmssh.MaxForwards`). It records why it couldn't take each port in `ports.forwarded`, by the bind's error: in use (`EADDRINUSE`), past its limit, or refused (`EACCES` or `EPERM`, such as below 1024 on Linux), and `devvm ports` warns each with its own message (`ports_taken`, `ports_limit`, `ports_refused`). Any other error, such as `EMFILE`, `ENOBUFS` or `EADDRNOTAVAIL`, says nothing about the port, so it's logged, not recorded, and the port is tried again at the next report, the log's limit capping the repeats. A port past the limit is tried again at the next report once the forwarder forwards fewer. A record from before the reasons, whose third line holds every port it couldn't take, is read as giving no reason, so it warns of none rather than call a refused port in use. It reads the reserved ports (below) again with each report, and while it can't read them, it takes no new port and keeps those it has. A port it has that has since become reserved, such as one another VM's start has chosen, is given up at that report, though the VM still listens on it, and also within 10 s on the host's own clock (`Forwarder.Recheck`), whether or not the VM reports, so a VM that holds its session open and stays silent can't keep it. A reserved port the VM listens on waits and is tried again at each report until it's no longer reserved. A port that a host program has, or that the host refused, is tried again only once the VM's server on it goes and comes back.
|
||||
- **Listening.** The forwarder listens on `127.0.0.1` and `::1`, or on IPv4 alone on a host without IPv6, which a bind on `::1` reports as `EADDRNOTAVAIL`, `EAFNOSUPPORT` or `EPROTONOSUPPORT`. `EACCES` or `EPERM` on `::1` alone, with `127.0.0.1` bound, also gives IPv4 alone, with a line in the log, because that's a host denying IPv6 rather than a port it refuses. Any other error on `::1` closes the port's `127.0.0.1` listener and counts as that bind's error would on `127.0.0.1`, recorded or tried again at the next report as the bullet above says, so a passing error such as `EMFILE` never leaves a forward on IPv4 alone until its port is opened again. It binds without `SO_REUSEADDR` (`platform.ListenExclusive`). With that option, which Go and Lima set, macOS lets a socket take `127.0.0.1:PORT` while a program has `*:PORT`, and that program's loopback connections go with it. Without the option, the bind is refused when another program has the port on any address. This was checked on macOS for a program on `0.0.0.0`, on `::` (IPv4 and IPv6 at once, as Node's and Go's servers listen), on IPv6 alone and on `127.0.0.1`, each with and without `SO_REUSEADDR` of its own. A port held only by ended connections (`TIME_WAIT`, with nothing answering on it) is taken as usual, so a server that restarts gets its forward back. When a bind is refused, the forwarder dials the port and takes it only if the dial is refused. A full backlog times out, which counts as taken. A port the forwarder took on `127.0.0.1` but finds in use on `::1` is given up, so `localhost` never reaches two programs. On Linux, `SO_REUSEADDR` stays on. Linux refuses that bind with the option too while another socket listens on the port, and without it, the forwarder's own ended connections (`TIME_WAIT`) would keep anyone from listening on the port for a minute, its next forwarder included.
|
||||
- **Each connection.** Each forwarded connection is a channel of the master's (`ssh -S <socket> -W HOST:PORT`), with one process per connection and at most 256 at once. The VM's sshd opens it to the VM's own loopback from inside the VM. The channel's ssh has the master's options. If the master is gone, ssh connects on its own, and it then reaches the VM's sshd the same way, never the host's. Each relay's ssh runs with a context of its own, which closing its forward cancels, so the ssh is killed with the forward even when the VM never ends its channel. `pipeSSH`, which carries every relay of the forwarder's, the link sessions' and a login's callback, also cancels that context once the client on the host has closed its side and the VM has sent nothing for 30 seconds (`relayGrace`), and once the client can take nothing more and the ssh hasn't exited within 30 seconds. Each write of the VM's bytes to the client starts the grace again once it's done, and the grace doesn't run while that write waits for the client, so a client that closes for writing alone and waits still gets an answer the VM keeps sending, however slowly it reads. The VM must send something at least every 30 seconds, its first byte included, so a client that half-closes and waits longer than that for a first byte, such as `nc -N` in front of a slow query, is cut. The timer (`graceTimer`) runs only once the client's side has closed, or once the copy to the client has ended, with a write that failed or the VM's EOF, and a relay that ends stops it for good, so the client's goroutine, which can outlive the relay, never starts it again. The relay's own context, its owner's, also closes the client's connection when it ends, so a write that waits on a client that stopped reading ends with its forward, its link or `LoopbackForward.Close`.
|
||||
@@ -62,9 +64,9 @@ These settings guard against the host's ssh asking for a forward that devvm's en
|
||||
- **A guest port bound around the rules:** ruled out on macOS on a confined tier. Lima forwards a port only by binding it on the host, and the sandbox refuses every port but the ssh port. End to end, with Lima's own rule put back for one start inside the sandbox, Lima tries the guest's TCP and UDP ports, is refused (`operation not permitted`), and has no port but its ssh port, while devvm's forwarder forwards the TCP port.
|
||||
- **The ssh port on every address:** listed. Seatbelt allows the ssh port on any address, so a Lima that bound it on `0.0.0.0` would put the VM's sshd on the network, where it still takes only keys. Lima binds it on `127.0.0.1`, and the end-to-end checks look at the hostagent's listeners. The rule allows the port over TCP alone, so the guest's UDP server on that port number can't get a forward from it; checked end to end.
|
||||
- **A program holding a stopped VM's ssh port:** ruled out, but for a race. A start looks for the recorded port with a bind on `127.0.0.1` and `::1` as well as a connection, so a program that has the port on any address, even one that accepts no connections, gives the VM a new port. Only a program that takes the port between that check and Lima's bind, a few seconds later, gets Lima's ssh, which is listed under not covered below. End to end, a VM whose port a host program holds starts on a new one, recorded, and the program keeps its own.
|
||||
- **Two VMs choosing the same ssh port:** confirmed, fixed. Without a lock, two devvm commands making VMs at once could each choose the same port from the ports other VMs record, and the second VM's Lima would wait on a port that the first one's has. devvm chooses and records a port while it holds the claims lock, `run/claims.lock` in its data folder, after the VM's own lock ([locks](overview.md#locks)).
|
||||
- **Two VMs choosing the same ssh port:** confirmed, fixed. Without a lock, two devvm commands making VMs at once could each choose the same port from the ports other VMs record, and the second VM's Lima would wait on a port that the first one's has. devvm chooses and records a port while it holds the claims lock, `run/claims.lock` in its data folder, after the VM's own lock ([locks](../internals/overview.md#locks)).
|
||||
- **A build VM's ssh port:** confirmed, fixed. A port that Lima picked at a build's start would be one that no VM's state records, so another VM forwarding every port could take it in the window before Lima binds it, and Lima's ssh would then run the build's scripts in that VM. The fix: devvm chooses every build VM's ssh port, on macOS and Linux, under the claims lock, and records it in `run/build-ports/<name>`, which every forwarder reserves, until the build VM's start returns. A record that a killed devvm leaves is deleted the first time devvm chooses a port once the record is 15 minutes old, because no process holds its lock, and until then it keeps the port from any VM while the start that the killed devvm left may still bind it. Builds carry no credentials, an image is the build VM's own disk, and a tool build writes its images through a folder that only its own VM mounts, so even a VM that reached a build's ssh another way could break that build but couldn't learn a secret from it or choose what an image or a tool image holds. It's unit-tested on both systems, and the CLI tests check that a build's start sets the port.
|
||||
- **A browser reaching a VM's ssh port:** confirmed, fixed. Lima listens on the ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as `http://localhost:PORT`, by a link or by a VM that opens URLs, would reach a server the VM controls with the cookies of the apps you use on `localhost`, even in a VM that forwards no ports. The fix: every VM's ssh port, and every build VM's, is one of the Fetch standard's bad ports from 1024 up that Chromium's `kRestrictedPorts` blocks too (`ports.SSHPorts`, 17 of them: Chromium lacks 4190 and 6679, which headless Chrome 157 loads), to which every browser engine refuses every request, navigations and WebSockets included, chosen by the one allocator (`ports.Allocator.SSH` and `Build`, through `freeSSH`), whose other ports never take one, and a proxy or desktop port an older devvm chose there moves at the VM's next start. No forwarder takes one unless its VM lists it (`ports.Reserved`), so a guest forwarding every port can't fill them, and a stopped VM's listed ports don't keep them from a start. That allows at most 17 running VMs, and a start past that fails with `ports_ssh_limit` or `ports_ssh_limit_all`, naming the VMs whose ports are in use, or `ports_ssh_limit_others`. An older devvm's VM moves onto the list at its next start, in the start's one `limactl edit`, and each launch warns of a running VM still on an old port (`ports_ssh_old`). A start holds its port, kept or new, for a minute (`run/ports.ssh-hold` in the VM's folder), as a stopped VM's port it keeps would otherwise look free to another start in the window before Lima binds it. The hold is time-limited, so a backend that takes over a minute to bind can lose the port to another start and fail, and its next start gets another. It's unit-tested (`TestSSHPorts`, `TestSSH`, `TestSSHHolds`, `TestSSHListed`, `TestOffList`, `TestBuild`, `TestReserved`, `TestStartBuildSSHPort`, `TestPrepareRestartsTheProxy`, `TestDesktopListener`), checked by the CLI tests (`ssh_ports`, the frozen 0.1.0 fixture's launches), and end to end each VM's ssh port is on the list.
|
||||
- **A browser reaching a VM's ssh port:** confirmed, fixed. Lima listens on the ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as `http://localhost:PORT`, by a link or by a VM that opens URLs, would reach a server the VM controls with the cookies of the apps you use on `localhost`, even in a VM that forwards no ports. The fix is that every VM's ssh port, and every build VM's, is one of the Fetch standard's bad ports from 1024 up that Chromium's `kRestrictedPorts` also blocks (`ports.SSHPorts`, 17 of them, because Chromium lacks 4190 and 6679, which headless Chrome 157 loads). Every browser engine refuses every request to these ports, navigations and WebSockets included. The one allocator chooses them (`ports.Allocator.SSH` and `Build`, through `freeSSH`), its other ports never take one, and a proxy or desktop port that an older devvm chose there moves at the VM's next start. No forwarder takes one unless its VM lists it (`ports.Reserved`), so a guest forwarding every port can't fill them, and a stopped VM's listed ports don't keep them from a start. That allows at most 17 running VMs, and a start past that fails with `ports_ssh_limit` or `ports_ssh_limit_all`, naming the VMs whose ports are in use, or `ports_ssh_limit_others`. An older devvm's VM moves onto the list at its next start, in the start's one `limactl edit`, and each launch warns of a running VM still on an old port (`ports_ssh_old`). A start holds its port, kept or new, for a minute (`run/ports.ssh-hold` in the VM's folder), because a stopped VM's port that it keeps would otherwise look free to another start in the window before Lima binds it. The hold is time-limited, so a backend that takes over a minute to bind can lose the port to another start and fail, and its next start gets another. It's unit-tested (`TestSSHPorts`, `TestSSH`, `TestSSHHolds`, `TestSSHListed`, `TestOffList`, `TestBuild`, `TestReserved`, `TestStartBuildSSHPort`, `TestPrepareRestartsTheProxy`, `TestDesktopListener`), checked by the CLI tests (`ssh_ports`, the frozen 0.1.0 fixture's launches), and end to end each VM's ssh port is on the list.
|
||||
- **What a failed start or create leaves:** ruled out. A VM whose create fails, other than by an interrupt, keeps its state, and with it its recorded port, until `devvm rm` deletes it, so the port stays reserved and nothing else takes it. `devvm rm` deletes the state, which frees the port.
|
||||
- **Unix sockets:** ruled out as a way out. The hostagent binds them only in the VM's Lima folder, which only Lima's own commands and devvm use.
|
||||
- **DNS around the proxy:** ruled out. With Lima's resolver off, the guest's DNS server is `127.0.0.1`, which [transparent mode](#transparent-mode)'s dnsmasq answers inside the VM with one stand-in address and no upstream, or nothing answers when it's off, and Lima's network's DNS address and the host's address on it answer nothing even when root asks them directly with transparent mode stopped, because the sandbox denies the hostagent the host's DNS service and every connection but the proxy's; checked end to end, with transparent mode stopped and running.
|
||||
@@ -81,9 +83,9 @@ These settings guard against the host's ssh asking for a forward that devvm's en
|
||||
- **A tier's confinement:** ruled out. Listed ports take fewer ports than every port, never more, and every connection still starts on the host.
|
||||
- **Another VM takes a stopped or restarting VM's listed port:** mitigated. Only a running VM holds a port, so while VM V is stopped, another VM E may forward V's listed port, and a hostile E could then try to keep it, such as by forwarding every port and holding its ssh session open without reporting again. Three things stop that. First, the host decides when a port is given up: every forwarder closes each forward whose port is now reserved within 10 s on its own clock, whatever its VM reports, so E gives V's port up once V runs and lists it. Closing a forward also closes every connection it accepted that's still open, so a browser's keep-alive connection to `localhost:5173`, opened while E had the port, ends then too, and the browser's later requests, with V's cookies, never reach E over it. Second, V's start, a change of its ports and `devvm ports` warn with `ports_held` and name E in `held_by`, whether E lists the port or forwards every port, so V never waits silently. Third, V's listed ports stay reserved while devvm holds V's `ports.lock`, from stopping V's old forwarder until its new one runs, so no other VM takes them in that window. A stale `ports.forwarded` can't hold a port either: devvm removes it under that lock before each start, each forwarder writes an empty one when it starts, and a record counts only while its pid is the VM's running forwarder.
|
||||
- **A relay the VM holds open:** confirmed, fixed. Closing a forward closed the connections it had accepted, but each connection's ssh (`-W`) waits for the VM's sshd to end its channel, so a hostile VM that ignored the EOF kept that ssh process, and one of the forwarder's 256 relays, until the forwarder ended. Up to 256 such ssh processes could pile up on the host for each VM, and the VM's forwards would then refuse every new connection. Each relay now runs with a context of its own, which closing its forward cancels, under the forwarder's lock as the close already runs, so the ssh is killed (`exec.CommandContext`), and a relay that ends by itself releases its context. Unit-tested with an ssh stand-in that never exits on its own: the relay ends, its process is gone and its slot is free once the forward closes (`TestForwarderEndsStuckRelay`), with no goroutine or file descriptor left under `-race`.
|
||||
- **A relay the VM holds open after its client has gone:** mitigated. While a forward lasts, a VM that ignores EOF would keep each relay whose client on the host had closed, its ssh process and one of the 256, so a hostile VM could fill the forwarder's relays with connections a browser had already closed. Each relay's ssh is killed once its client has closed and the VM has sent nothing for 30 seconds, or 30 seconds after the client can take nothing more, so a VM keeps such a relay only by sending to it, and only for as long as the client keeps its side open for reading. The grace doesn't run while a write waits for a slow client, so a client that stops reading holds the relay and its ssh itself, as it could by staying open, until it reads again, closes, or the relay's forward or link goes. Unit-tested with an ssh stand-in that never exits: a closed client's relay and a half-closed one's both end after the grace when the stand-in is silent, and one the stand-in keeps talking to goes on past it, while a fully closed client's relay, and one whose writes to its client fail, end within the grace however much the stand-in sends. A half-closed client that doesn't read for many graces still gets all of the stand-in's answer after and a relay whose write waits on a client that stopped reading ends when its context does (`TestPipeSSHGrace`, `TestPipeSSHGraceWriteError`, `TestPipeSSHGraceSlowClient`, `TestRelayGrace`, `TestRelayGraceWriteError`, `TestRelayGraceSlowClient`, `TestRelayCancelEndsBlockedWrite`, `TestGraceTimer`). The price is a client that half-closes and waits more than 30 seconds for an answer's first byte, which is cut.
|
||||
- **A forward on IPv4 alone:** ruled out but for a host without IPv6 or one that denies it. A bind on `::1` that fails with an error that says nothing of the port, such as `EMFILE` or `ENOBUFS`, closes the port's `127.0.0.1` listener, is logged, and has the port tried again at the next report, so `localhost` never reaches the VM on one address and another program, or nothing, on the other. Only `EADDRNOTAVAIL`, `EAFNOSUPPORT` and `EPROTONOSUPPORT`, a host without IPv6, give IPv4 alone, and so do `EACCES` and `EPERM` on `::1` alone, logged, as a security module that denies IPv6 sockets would otherwise stop every forward. On such a host, a program that the module lets use IPv6 could still take `::1` on a forwarded port, and `localhost` would then reach it there, which is listed rather than refused because the alternative is no forwarding at all. Unit-tested with each error on `::1` (`TestForwarderIPv6Failures`).
|
||||
- **A forward's listener out of files:** confirmed, fixed. The loop that accepts a forward's connections ended at any error, `EMFILE` included, while its listener stayed open, so a burst that ran the forwarder out of open files left that port taking connections that nothing answered until the forward went. It now 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 (`daemon.AcceptRetry`), as the link session, a login's forward and the proxy's SSH agent relay do, and a login's forward also carries at most 16 connections at once, an ssh process each (`TestAcceptRetry`, `TestForwarderAcceptRetries`, `TestLinksAcceptRetries`, `TestForwardLoopbackLimit`).
|
||||
- **A relay the VM holds open after its client has gone:** mitigated. While a forward lasts, a VM that ignores EOF would keep each relay whose client on the host had closed, its ssh process and one of the 256, so a hostile VM could fill the forwarder's relays with connections a browser had already closed. Each relay's ssh is killed once its client has closed and the VM has sent nothing for 30 seconds, or 30 seconds after the client can take nothing more, so a VM keeps such a relay only by sending to it, and only for as long as the client keeps its side open for reading. The grace doesn't run while a write waits for a slow client, so a client that stops reading holds the relay and its ssh itself, as it could by staying open, until it reads again, closes, or the relay's forward or link goes. Unit-tested with an ssh stand-in that never exits: a closed client's relay and a half-closed one's both end after the grace when the stand-in is silent, and one the stand-in keeps talking to goes on past it, while a fully closed client's relay, and one whose writes to its client fail, end within the grace however much the stand-in sends. A half-closed client that doesn't read for many graces still gets all of the stand-in's answer afterwards, and a relay whose write waits on a client that stopped reading ends when its context does (`TestPipeSSHGrace`, `TestPipeSSHGraceWriteError`, `TestPipeSSHGraceSlowClient`, `TestRelayGrace`, `TestRelayGraceWriteError`, `TestRelayGraceSlowClient`, `TestRelayCancelEndsBlockedWrite`, `TestGraceTimer`). The price is a client that half-closes and waits more than 30 seconds for an answer's first byte, which is cut.
|
||||
- **A forward on IPv4 alone:** ruled out except on a host without IPv6 or one that denies it. A bind on `::1` that fails with an error that says nothing of the port, such as `EMFILE` or `ENOBUFS`, closes the port's `127.0.0.1` listener, is logged, and has the port tried again at the next report, so `localhost` never reaches the VM on one address and another program, or nothing, on the other. Only `EADDRNOTAVAIL`, `EAFNOSUPPORT` and `EPROTONOSUPPORT`, a host without IPv6, give IPv4 alone, and so do `EACCES` and `EPERM` on `::1` alone, logged, as a security module that denies IPv6 sockets would otherwise stop every forward. On such a host, a program that the module lets use IPv6 could still take `::1` on a forwarded port, and `localhost` would then reach it there, which is listed rather than refused because the alternative is no forwarding at all. Unit-tested with each error on `::1` (`TestForwarderIPv6Failures`).
|
||||
- **A forward's listener out of files:** confirmed, fixed. The loop that accepts a forward's connections ended at any error, `EMFILE` included, while its listener stayed open, so a burst that ran the forwarder out of open files left that port taking connections that nothing answered until the forward went. The fix is that 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 (`daemon.AcceptRetry`), as the link session, a login's forward and the proxy's SSH agent relay do. A login's forward also carries at most 16 connections at once, an ssh process each (`TestAcceptRetry`, `TestForwarderAcceptRetries`, `TestLinksAcceptRetries`, `TestForwardLoopbackLimit`).
|
||||
- **Channels the VM never closes in the master:** listed. A hostile VM that never sends CLOSE for a killed relay's channel can leave small channel entries, with no file descriptor, in the forwarder's ssh master. At most 256 relays run at once, which bounds them, and no code change is needed.
|
||||
|
||||
**Not covered:**
|
||||
@@ -184,7 +186,7 @@ A VM's network is one of four tiers, `open`, `internet`, `allowlist` and `none`,
|
||||
|
||||
## Rules by method and path
|
||||
|
||||
A rule can narrow a host name to some of its requests, by method, by path or both ([how to use them](../safety/network.md#rules-by-method-and-path), [how the proxy judges them](network.md#requests-by-method-and-path)), and a secret of yours can go in for some methods alone. The design keeps two things: a request that a deny names doesn't reach its host by any spelling of its method or its path that the threat check below covers, and an allow lets through only what it names, as every server would read it. What it leaves open, such as a form's `_method` field and methods outside the list, is listed there.
|
||||
A rule can narrow a host name to some of its requests, by method, by path or both ([how to use them](../safety/network.md#rules-by-method-and-path), [how the proxy judges them](../internals/network.md#requests-by-method-and-path)), and a secret of yours can go in for some methods alone. The design keeps two things: a request that a deny names doesn't reach its host by any spelling of its method or its path that the threat check below covers, and an allow lets through only what it names, as every server would read it. What it leaves open, such as a form's `_method` field and methods outside the list, is listed there.
|
||||
|
||||
**What it's built from:** the policy files' one line per rule, with the methods and then the path after the host (`proxy.parseRule`), `--method` and `--path` on devvm network allow, deny and rm (`netpolicy.Rule`), the proxy's interception with the VM's CA, which the secrets already use, and one matcher, `proxy.match` in `internal/proxy/request.go`, for rules and for secrets' bindings, whose path check (`plainPath`) is the one that custom secrets' `--path` had.
|
||||
|
||||
@@ -226,7 +228,7 @@ A rule can narrow a host name to some of its requests, by method, by path or bot
|
||||
|
||||
## Transparent mode
|
||||
|
||||
A confined VM's tools that ignore the proxy settings, such as workerd under `wrangler dev`, a static Go binary or a container made through Docker's API, reach the VM's proxy by the names they look up ([how](network.md#tools-that-skip-the-proxy)). The design keeps three things: no DNS query and no connection leaves the VM but through its proxy, the host the proxy judges is the host it dials, and nothing new listens on the host or takes part in the backends.
|
||||
A confined VM's tools that ignore the proxy settings, such as workerd under `wrangler dev`, a static Go binary or a container made through Docker's API, reach the VM's proxy by the names they look up ([how](../internals/network.md#tools-that-skip-the-proxy)). The design keeps three things: no DNS query and no connection leaves the VM but through its proxy, the host the proxy judges is the host it dials, and nothing new listens on the host or takes part in the backends.
|
||||
|
||||
**What it's built from:** `internal/proxy/transparent.go`: the reserved target `TransparentHost` (`transparent.devvm.proxy`), the stand-in address `SentinelAddr` (`198.18.0.1`, in benchmarking's `198.18.0.0/15`, which clients such as workerd's kj count as public and the floor counts as internal), `transparent`'s `serve`, `tls`, `handler` and `refusePage`, `sniHost`, and `policy.transparentPorts` behind `/transparent/ports`. `routeFor` is the order every connection is judged in, `CONNECT`'s and the transparent path's alike, and `carry` is the one tunnel, its SNI check included. `Event.Via` is `dns` for the path's events (`withVia` for its requests). In the guest, `assets/guest/transparent.sh` is `devvm-transparent`, its ruleset (`render`), its slots and its service, set up by `sync.sh` when `netpolicy.TransparentAddr` gives the setup the stand-in address: the VM runs confined (`backend.NetProxy`) and its mode is on (`netpolicy.TransparentOf`: the VM's `net.transparent`, else `config.toml`'s `transparent-proxy`, else on). `layers/base.sh` installs dnsmasq, socat and nftables, which changes base's key.
|
||||
|
||||
@@ -247,8 +249,8 @@ A confined VM's tools that ignore the proxy settings, such as workerd under `wra
|
||||
- **Naming one host and reaching another:** ruled out. The host is the SNI's, or each request's `Host`, and the proxy dials that host by name after `routeFor` judged it, then checks the replayed ClientHello's SNI again (`carry`). An interception's leaf names the SNI host alone, and every request whose `Host` or `:authority` differs gets `421` (`TestTransparentIntercept`). Domain fronting and ECH's outer name are what `CONNECT` with the password reaches already.
|
||||
- **Secrets on the wrong host, or in plain HTTP:** ruled out. Interception is chosen from the SNI host alone, on 443, and a plain request is always forwarded as `http://`, which never gets a secret (`TestTransparentHTTP`).
|
||||
- **SNI and Host shapes:** ruled out. No SNI, an address, a trailing dot, two names, a ClientHello split across records or cut short, a name `HostOK` refuses and a name under `devvm.proxy` are refused before the policy (`TestTransparentSNI`, `FuzzTransparent`). A name with anything but printable ASCII is refused before its case is folded, so the Kelvin sign never becomes `k`, and the same holds for `CONNECT`'s target and its SNI check (`TestHostsNotASCII`).
|
||||
- **Holding the proxy's memory or slots:** fixed. A transparent connection counts toward the 1024 tunnels and gets 10 seconds for its first bytes. A ClientHello record longer than 16 KiB and 256 bytes is never read, and on every tunnel a ClientHello that has started must arrive whole within 10 seconds (`TestTunnelHelloDeadline`, `TestPeekClientHelloCap`). The `403` page's TLS connection and an intercepted tunnel took 1 MiB of a request's headers, where the proxy's own listener takes 64 KiB. Every connection that the proxy serves HTTP on now takes 64 KiB, and HTTP/2 inside one asks for at most 100 requests at once, where Go's default is 250, each a request upstream (`serveOne`, `TestServeOneHeaderLimit`, `TestServeOneStreamsLimit`).
|
||||
- **Requests left running, and idle connections:** fixed. A plain HTTP request, the transparent path's included, went on after its client had gone, because the proxy can't tell that from a half-close, so a VM could leave requests waiting on a host that never answers, past the connections it holds. Once its client stops sending, a request ends after a minute with nothing to pass on, while an answer that keeps coming still reaches a client that half-closed. A connection to the proxy waits at most 10 minutes between requests, and one without the password is closed after its `407`. Only tunnels counted toward a limit, so the proxy now holds at most 2048 connections of every kind at once, a request that outlives its client included, as `net/http` closes its connection only once the handler returns (`maxConns`). A connection counts from its first request with the password, and the ones that haven't sent it wait in a pool of 128 where a new one closes the oldest (`maxWaiting`), so an open VM that reaches another VM's proxy port can't take that VM's room by holding connections through their 30 seconds for headers. Tunnels' HTTP/2 streams were bounded only for each tunnel, and every request upstream is a connection of its own, so 1024 tunnels could open about 100,000 connections to hosts: the proxy has at most 2048 requests upstream at once (`maxRequests`). Each limit's line in `proxy.log` comes once a minute at most (`everyMinute`). A plain `ws://` upgrade got `502`, as the request's writer hid the hijack it needs, and gets its `101` now (`TestPlainHTTPEndsWithClient`, `TestProxyConnectionBounds`, `TestProxyConnectionLimit`, `TestProxyWaitingConnections`, `TestUpstreamRequestLimit`, `TestPlainWebSocket`).
|
||||
- **Holding the proxy's memory or slots:** fixed. A transparent connection counts toward the 1024 tunnels and gets 10 seconds for its first bytes. A ClientHello record longer than 16 KiB and 256 bytes is never read, and on every tunnel a ClientHello that has started must arrive whole within 10 seconds (`TestTunnelHelloDeadline`, `TestPeekClientHelloCap`). The `403` page's TLS connection and an intercepted tunnel took 1 MiB of a request's headers, where the proxy's own listener takes 64 KiB. With the fix, every connection that the proxy serves HTTP on takes 64 KiB, and HTTP/2 inside one asks for at most 100 requests at once, where Go's default is 250, each a request upstream (`serveOne`, `TestServeOneHeaderLimit`, `TestServeOneStreamsLimit`).
|
||||
- **Requests left running, and idle connections:** fixed. A plain HTTP request, the transparent path's included, went on after its client had gone, because the proxy can't tell that from a half-close, so a VM could leave requests waiting on a host that never answers, past the connections it holds. Once its client stops sending, a request ends after a minute with nothing to pass on, while an answer that keeps coming still reaches a client that half-closed. A connection to the proxy waits at most 10 minutes between requests, and one without the password is closed after its `407`. Only tunnels counted toward a limit, so the fix holds the proxy to at most 2048 connections of every kind at once, a request that outlives its client included, as `net/http` closes its connection only once the handler returns (`maxConns`). A connection counts from its first request with the password, and the ones that haven't sent it wait in a pool of 128 where a new one closes the oldest (`maxWaiting`), so an open VM that reaches another VM's proxy port can't take that VM's room by holding connections through their 30 seconds for headers. Tunnels' HTTP/2 streams were bounded only for each tunnel, and every request upstream is a connection of its own, so 1024 tunnels could open about 100,000 connections to hosts. The proxy has at most 2048 requests upstream at once (`maxRequests`). Each limit's line in `proxy.log` comes once a minute at most (`everyMinute`). A plain `ws://` upgrade got `502`, because the request's writer hid the hijack it needs, and with the fix it gets its `101` (`TestPlainHTTPEndsWithClient`, `TestProxyConnectionBounds`, `TestProxyConnectionLimit`, `TestProxyWaitingConnections`, `TestUpstreamRequestLimit`, `TestPlainWebSocket`).
|
||||
- **A flood of connections to another VM's proxy:** listed. Connections without the password wait in their own pool, so holding them can't take a VM's room, but an open VM or a program on this machine that opens connections as fast as the host accepts them fills the kernel's accept queue, and the VM's own connections wait in it with them, or are evicted from the pool before their first request arrives. That slows the VM's proxy for as long as the flood lasts, and ends with it.
|
||||
- **A ClientHello sent a byte, then late:** fixed, found in review. The deadline first made a record header that didn't come whole read as "not TLS", so a tunnel that sent `0x16`, waited past it, then sent a ClientHello naming another host was carried unchecked, which the SNI check had refused before. A stream whose first byte is `0x16` is TLS from then on: a header that doesn't come whole, or whose version byte isn't 3, is refused, and the far end gets nothing (`TestTunnelHelloStall`, `FuzzClientHello`).
|
||||
- **A split ClientHello on an address's tunnel:** fixed, found in review, older than transparent mode. A tunnel to an address may carry no server name, and a ClientHello that didn't parse read as one without a name, so one split across two records, naming another host in the second, went on unchecked. Only a ClientHello that parsed whole counts now: one that doesn't is refused, on every tunnel (`TestTunnelAddressSplitHello`).
|
||||
@@ -272,7 +274,7 @@ A confined VM's tools that ignore the proxy settings, such as workerd under `wra
|
||||
|
||||
## A company proxy
|
||||
|
||||
Behind a company proxy, nothing reaches the internet without going through it, so each VM's proxy goes through it too ([how](network.md#through-a-company-proxy)), and each build goes through a proxy of devvm's for the build alone, which goes through it. The design keeps two things: the proxy still decides every request by the name the VM asked for, and the company proxy's password reaches nothing of a VM's or a build's.
|
||||
Behind a company proxy, nothing reaches the internet without going through it, so each VM's proxy goes through it too ([how](../internals/network.md#through-a-company-proxy)), and each build goes through a proxy of devvm's for the build alone, which goes through it. The design keeps two things: the proxy still decides every request by the name the VM asked for, and the company proxy's password reaches nothing of a VM's or a build's.
|
||||
|
||||
**What it's built from:** the host's `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY`, read from devvm's environment (`backend.ReadHostProxy`) when a VM's proxy starts, or `config.toml`'s `[proxy]` when the environment sets neither proxy (`settings.HostProxy`), checked (`HostProxy.Upstream`: only `http://` proxies), and written into the proxy's config, `proxy.json` in the VM's run folder, `vms/<hash>/run/` (mode 600), as `upstream` (`internal/proxy/upstream.go`). `config.toml` is a file people copy and keep with their dotfiles, so it never holds the password: its URL names the user, and the password is the `proxy` secret (`proxy.UpstreamSecret`), in the Keychain or devvm's secrets folder, which the proxy looks up through `IO.Secret` as it starts (`upstreamPassword`), so no file of devvm's holds it either. It's a host-only secret (`secrets.Secret.HostOnly`): no VM is ever bound to it. The proxy opens its own `CONNECT` through the company proxy, by name, with `Proxy-Authorization: Basic` from the URL, for tunnels and for the TLS connections it makes to put secrets in, which check the server against the system's roots and the user's CAs. Plain HTTP goes to the company proxy in absolute form. A change to the settings starts the VM's proxy again at devvm's next run, and an old proxy that won't stop fails the start (`proxy_stop_failed`) rather than run on with its old settings.
|
||||
|
||||
@@ -280,7 +282,7 @@ Behind a company proxy, nothing reaches the internet without going through it, s
|
||||
|
||||
- An address the VM asks for is judged as before, and `localhost`, `*.localhost` and loopback and unspecified addresses never go upstream, so the floor refuses them as before unless a rule names them. A host whose last label is all digits or starts with `0x` (`127.1`, `2130706433`, `0x7f000001`) is refused as no host name (`hostOK`), because a company proxy that reads it as `inet_aton` does would reach an address the floor never judged.
|
||||
- A name is refused when this machine's resolver answers with any internal or denied address (`floorUpstream`). The proxy looks it up absolute, as it does for a direct connection (`egress.lookupName`), so this machine's DNS search domain never turns `api` into `api.corp.example.com`, a name that no rule judged. A name this machine can't resolve within three seconds goes upstream unjudged only when the policy names it, as itself or under `*.domain` (`policy.byName`). When only `**` allows it, the proxy refuses it (`errUnresolved`), because `**` would otherwise send the company proxy any name the VM makes up, and the company proxy may resolve such a name to its own network's hosts.
|
||||
- The company proxy may still resolve a name differently, or later, than this machine did (DNS rebinding between the two lookups). It may also add its own search domain to any name it's sent, before or after it tries the name as written, depending on its resolver: a Kubernetes pod's resolver uses `ndots:5`, so it tries the search domain first for any name with fewer than five dots. So a name that a rule names, such as `jenkins`, may reach `jenkins.corp.example.com` through it, and a name that resolves here may reach another under the company's search domain there. A VM that controls a name under an allowed domain can choose the unjudged path: its name server can fail, or answer after the proxy's three seconds, and then answer the company proxy with an internal address.
|
||||
- The company proxy may still resolve a name differently, or later, than this machine did (DNS rebinding between the two lookups). It may also add its own search domain to any name it's sent, before or after it tries the name as written, depending on its resolver. A Kubernetes pod's resolver, for example, uses `ndots:5`, so it tries the search domain first for any name with fewer than five dots. So a name that a rule names, such as `jenkins`, may reach `jenkins.corp.example.com` through it, and a name that resolves here may reach another under the company's search domain there. A VM that controls a name under an allowed domain can choose the unjudged path: its name server can fail, or answer after the proxy's three seconds, and then answer the company proxy with an internal address.
|
||||
- So under a name the policy lists, a VM reaches whatever the company proxy reaches: its company's internal hosts, and the company proxy's own host, including this machine's loopback when the company proxy runs on this machine (a local proxy that a VPN client runs, for example). Address denies apply only to the addresses this machine resolves. The allowlist stays the limit: a name the VM's policy doesn't allow never reaches the company proxy.
|
||||
- The proxy reads at most 64 KiB of the company proxy's answer to `CONNECT` (`maxConnectReply`), so an answer whose headers never end fails the request instead of filling memory.
|
||||
- The company proxy sees every allowed host name and port, and with a CA in the user's CA folder, it reads TLS too, as it does for this machine.
|
||||
@@ -304,7 +306,7 @@ The build's policy is `**` alone, so on its own the build's proxy would refuse e
|
||||
|
||||
## One form of a host
|
||||
|
||||
Every check that judges or compares a host reads it in one form, `proxy.NormHost`'s, so a deny, a binding, a risk or a warning can never hold for one spelling of a host and miss another. A host of printable ASCII is lowercased, in ASCII alone, and loses its one trailing dot, unless it's an address, whose dot can only be its IPv6 zone's. Any other host stays as it is, its case and its dots too, and `HostOK` refuses it, because Unicode's case folding turns some letters into ASCII ones, such as the Kelvin sign into `k`. A host with two trailing dots or more keeps them all, which `HostOK` refuses, so `NormHost` gives the same host however many times it runs, and a caller that reads a host again can't turn `evil.test..` into `evil.test`. A matcher takes a `proxy.Host`, which only `NormHost` makes, and the structure test refuses another copy ([the checks on owners](../contributing/structure.md#the-checks-on-owners)).
|
||||
Every check that judges or compares a host reads it in one form, `proxy.NormHost`'s, so a deny, a binding, a risk or a warning can never hold for one spelling of a host and miss another. `NormHost` lowercases a host of printable ASCII, in ASCII alone, and drops its one trailing dot, unless the host is an address, whose dot can only be its IPv6 zone's. Any other host keeps its case and its dots, and `HostOK` refuses it, because Unicode's case folding turns some letters into ASCII ones, such as the Kelvin sign into `k`. A host with two trailing dots or more keeps them all, which `HostOK` refuses, so `NormHost` gives the same host however many times it runs, and a caller that reads a host again can't turn `evil.test..` into `evil.test`. A matcher takes a `proxy.Host`, which only `NormHost` makes, and the structure test refuses another copy ([the checks on owners](structure.md#the-checks-on-owners)).
|
||||
|
||||
**The shapes each reader meets.** Each reader has a differential fuzz target (`FuzzHostSites` in `internal/proxy`, and one beside each reader elsewhere), which checks it against a frozen copy of the readers that each folded and trimmed a host its own way, and allows only these differences:
|
||||
|
||||
@@ -314,7 +316,7 @@ Every check that judges or compares a host reads it in one form, `proxy.NormHost
|
||||
- **Brackets** hold only an IPv6 address, one pair of them, as in a rule, so `HostOK` and `Host.Addr` take an address bare or as `[::1]`, never with a stray bracket, and `NormHost` keeps a dot after a bracket (`[::1].`), so that's no address either. A request for `[evil.com]:443`, `[1.2.3.4]:443`, `1.2.3.4]` or `[[::1]]` gets `400`, where `net.SplitHostPort` or a trim took the brackets off and the name or address in them was judged. An SNI in brackets is refused as no host name rather than as an address.
|
||||
- **An IPv6 address whose zone ends in a dot** keeps it, so `::1%.` is the zoned address it is, where the copy dropped the dot and left `::1%`, an empty zone, which is no address. The proxy answers `400` to both, and an address with a zone is never the internet's (`proxy.Public`), so a promisor remote at one counts as private and `--from`'s registry at one isn't public.
|
||||
- **A host with a stray bracket around an address is an address**, so an MCP server there (`https://1.2.3.4]/`, whose hostname Go's URL parser gives as `1.2.3.4]`) gets no binding.
|
||||
- **A line that isn't a rule**, which devvm network rm and its duplicate check compare as text, is the same as another in ASCII letters' case and one trailing dot alone, so a Kelvin sign typed for a `k` never names the rule with the `k`, such as the deny `!kubernetes.io`.
|
||||
- **A line that isn't a rule**, which devvm network rm and its duplicate check compare as text, matches another line only when the two differ in nothing but the case of ASCII letters and one trailing dot, so a Kelvin sign typed for a `k` never names the rule with the `k`, such as the deny `!kubernetes.io`.
|
||||
- **An SNI's trailing dot** on the transparent path is dropped, as a request's is. `crypto/tls` refuses such a ClientHello, so none reaches it.
|
||||
- **A `NO_PROXY` name that isn't ASCII** matches no host, so the Kelvin sign's `kubernetes.io` doesn't send `kubernetes.io` directly, and the request goes through the company proxy.
|
||||
- **A `NO_PROXY` entry with port `0`**, which no request has, sends nothing directly, as one with a port past `65535` doesn't, where the copy read `git.test:0` as `git.test` on every port (found by `FuzzNoProxy`). Neither does an entry whose port isn't in plain decimal, such as `git.test:080` or `git.test:+80`, which Go's clients match against no request, where the copy read it as port 80.
|
||||
@@ -325,7 +327,7 @@ Every check that judges or compares a host reads it in one form, `proxy.NormHost
|
||||
|
||||
## The desktop
|
||||
|
||||
`devvm desktop` shows a VM's desktop on this machine with VNC, and keeps two things: no one on this machine or the network reaches the desktop without the VM's password, and the desktop gives the VM no new way out. Both hold whatever the VM's own server does, because root in the VM can replace it ([how](desktop.md)).
|
||||
`devvm desktop` shows a VM's desktop on this machine with VNC, and keeps two things: no one on this machine or the network reaches the desktop without the VM's password, and the desktop gives the VM no new way out. Both hold whatever the VM's own server does, because root in the VM can replace it ([how](../internals/desktop.md)).
|
||||
|
||||
**What it's built from:** the built-in `desktop` layer (`assets/layers/desktop.sh`): Xfce and TigerVNC's `Xvnc` from the distribution's archive, and `/usr/local/bin/devvm-desktop`, which starts `Xvnc` on a socket of the VM's user's own (`/run/devvm-desktop/vnc.sock`, mode 600 in a 700 folder), with no TCP port and no password, then an Xfce session. On this machine, `internal/desktop`'s `Relay`, which `devvm desktop` runs (`internal/vm/desktop.go`): a listener on `127.0.0.1` alone (`platform.ListenLoopback`, without address reuse), on the port the VM's state records (the `ports` section's `host.desktop`, chosen by `ports.Allocator` and among `ports.Used`), and for each viewer that passes its check, an `ssh -W` channel to the socket through devvm's ssh config's entry for the VM. Only a VM made with the layer has the desktop (`image.DesktopLayer`), because it adds about 370 MB to an image, so `base` and the VMs without it stay that much smaller.
|
||||
|
||||
@@ -337,7 +339,7 @@ Every check that judges or compares a host reads it in one form, `proxy.NormHost
|
||||
|
||||
**The clipboard:** off unless `--clipboard`. Without it, `Xvnc` starts with `AcceptCutText`, `SendCutText`, `SetPrimary` and `SendPrimary` off, and the relay drops every `ClientCutText` from the viewer, extended clipboard ones too (`internal/desktop/filter.go`). It reads the viewer's messages by their lengths (RFC 6143's and the extensions TigerVNC offers: fences, continuous updates, desktop size, xvp, GII, QEMU's key and audio events) and ends the connection on a type it doesn't know, so nothing it can't read reaches the VM. The other way, from the VM to the viewer, isn't read: following the server's `ServerCutText` would mean decoding every screen update's encoding. A VM whose server was changed can send its clipboard to the viewer, so Screen Sharing's Use Shared Clipboard setting is what keeps it off this machine then.
|
||||
|
||||
**The local proxy, for browsers:** Chrome, Chromium and Firefox ignore the password in the VM's `HTTP_PROXY` and ask for it on every site, so the desktop's session uses `devvm-local-proxy` instead ([how](desktop.md#the-local-proxy)), which the guest setup writes (`assets/guest/sync.sh`) and `socat` serves. It gives no program a power it lacked, because the password it adds is the one the VM's environment already holds, and every program in the VM can read it there. What it must not do is hand the password to anything outside the VM, or send it anywhere but the VM's proxy:
|
||||
**The local proxy, for browsers:** Chrome, Chromium and Firefox ignore the password in the VM's `HTTP_PROXY` and ask for it on every site, so the desktop's session uses `devvm-local-proxy` instead ([how](../internals/desktop.md#the-local-proxy)), which the guest setup writes (`assets/guest/sync.sh`) and `socat` serves. It gives no program a power it lacked, because the password it adds is the one the VM's environment already holds, and every program in the VM can read it there. What it must not do is hand the password to anything outside the VM, or send it anywhere but the VM's proxy:
|
||||
|
||||
- **Where it listens:** `127.0.77.1:3128` (`proxy.LocalProxyAddr`, `proxy.LocalProxyPort`), on the VM's loopback alone (`bind=`), taking connections from `127.0.0.0/8` alone (`range=`). The port forwarder never forwards a server on that address (`vmssh`'s `dialAddr`, `proxy.IsLocalProxyAddr`), so a VM that forwards every port doesn't put a proxy that needs no password on this machine's `localhost`, where other users and programs would reach the VM's proxy, and its secrets, without the password.
|
||||
- **Where the password goes:** only to the VM's proxy, whose address is written into the script with the password, never to an address a request names. It's in the one `Proxy-Authorization` header the local proxy adds, after it drops the client's, and devvm's proxy removes that header before it forwards a request. A `CONNECT`'s tunnel carries nothing of the local proxy's after its head.
|
||||
@@ -393,13 +395,13 @@ The CLI tests (`testdata/script/paste.txtar`, `paste_rm.txtar`) drive the rest a
|
||||
|
||||
## Base's image and packages
|
||||
|
||||
base starts from the newest Ubuntu cloud image on each machine, and its packages are the newest when each key of base first builds, so devvm's own files pin neither and need no bumps ([how](images.md#ubuntus-cloud-image), [packages](images.md#bases-packages)). What it trusts, and where:
|
||||
base starts from the newest Ubuntu cloud image on each machine, and its packages are the newest when each key of base first builds, so devvm's own files pin neither and need no bumps ([how](../internals/images.md#ubuntus-cloud-image), [packages](../internals/images.md#bases-packages)). What it trusts, and where:
|
||||
|
||||
- **The image:** Ubuntu's cloud image key alone, pinned in devvm's files. devvm checks the release's `SHA256SUMS` signature itself, in Go, so a host without `gpgv` checks it too, and a bad signature is refused, never passed over for an older release. The listing that names the newest release is unsigned, so a server or network that can change it can only hold devvm back to an older signed release, over HTTPS. The signed `SHA256SUMS` names files, not its release, so such a server could also serve an older release's files under a newer release's name, which devvm then records as the pin; that holds base back the same way, and it makes the package check's date stricter, not looser. The pinned SHA-256 then decides every later download.
|
||||
- **The packages:** Ubuntu's archive key, through apt in the build VM, which holds nothing but Ubuntu's image and devvm's own scripts while it records. A mirror only serves files, and apt checks each against the archive key, so `ubuntu-mirror` can't install a package Ubuntu didn't publish. Ubuntu's `InRelease` files carry no `Valid-Until`, and the build VM has no lists before, so a stale or hostile mirror, or anyone on an `http://` path to one, can serve an older signed state of the archive. devvm refuses one older than the archive state the pinned cloud image was built from, naming the mirror (`packages_stale_mirror`, `packages_stale` without one): every pocket but the release's must be dated no more than a day before the image's release, and the release pocket no earlier than Ubuntu's release day (`Release.Stale`). So a recorded state is never older than the pinned image. A mirror that fell behind after the pinned release still gets recorded, so freshness past the pin's date rests on the mirror, and on HTTPS for Ubuntu's own.
|
||||
- **The cache:** a first build records what its own apt checked, and devvm checks it again on this machine before it keeps anything. The build hands back the `InRelease` files and package lists apt used, and devvm verifies each `InRelease` with Ubuntu's archive key, pinned in its files, in Go (`pgp.go`'s clearsigned messages). Each list must be one a verified `InRelease` gives the SHA-256 and size of, and each package one a list gives the SHA-256 of, so the recording VM can't add a package Ubuntu didn't publish, even with root, and the set keeps the archive's own entry for each package. devvm keeps each file under its own SHA-256 and each key's set once. What comes back from the VM is checked for shape, hashes and size (at most 20,000 entries and 16 GiB of packages, 2 GiB of lists) before anything is kept, so a build VM can't put a file under another file's name, change another key's set, or write outside the cache. A key's set is never written again, so a later build can't change it either. The recording VM can't record an older version than apt would install either: the build must hand back `resolute-updates`' and `resolute-security`'s `InRelease` files with lists for the recorded packages' architectures, and every non-empty list that each `InRelease` it hands back gives for the recorded packages' architectures, and devvm refuses a package that the release pocket, `-updates` or `-security` lists a newer version of, ordered as `dpkg --compare-versions` orders them (`packages_lists_missing`, `packages_not_newest`). apt in the build takes phased updates too, so the newest version is what it installs. A replay checks each file's SHA-256 on this machine before it sends it, and apt in the VM checks it again against the set's entry. Replays trust apt's entries as recorded (`trusted=yes` on a local repository of files devvm checked), because the archive's signature covers the archive's lists, not a set of packages taken from them.
|
||||
- **What it doesn't stop:** anything with root in the recording VM before `apt.sh end` (a feature's script, a compromised pinned download) chooses which of Ubuntu's signed packages get recorded, because the host checks that each package is the archive's and the newest that the lists handed back have, not that apt chose it. It can record a package base doesn't ask for, or one from `-backports`, but never one from `-proposed`. It can also hand back an older signed state of `-updates` and `-security` than the archive's newest, dated as early as a day before the pinned image's release, which the stale check allows, and record the newest versions of that state. Every later build of that key replays what it recorded, as the same image would. It can also change the image itself, which the image's key doesn't cover. `devvm rebuild base` records anew. Packages for `--from` bases and for layers come from their sources as they are, unpinned.
|
||||
- **Breakage from upstream:** users now build from images and packages that e2e hasn't run. If the newest image doesn't boot, a first build tries the release before it ([how](images.md#ubuntus-cloud-image)), which covers a release whose kernel Lima can't start, but not packages that break base.sh or a VM later. A scheduled build of base from the newest image and packages, on CI or the test machines, should catch a break before users do; it isn't built yet.
|
||||
- **Breakage from upstream:** users now build from images and packages that e2e hasn't run. If the newest image doesn't boot, a first build tries the release before it ([how](../internals/images.md#ubuntus-cloud-image)), which covers a release whose kernel Lima can't start, but not packages that break base.sh or a VM later. A scheduled build of base from the newest image and packages, on CI or the test machines, should catch a break before users do; it isn't built yet.
|
||||
|
||||
## Shared tools
|
||||
|
||||
@@ -408,14 +410,14 @@ Each tool version is one compressed EROFS image, loop-mounted read-only in each
|
||||
- **Measured (macOS):** ten tools take 0.85 GB as images (1.5 GB installed), once for every VM and mix. Start times from an image match a local disk warm (`node -e 0` 13 ms vs 14 ms, `claude --version` 3 ms), and are 10–30 ms slower cold. Mounting five images takes 0.15 s; VM start is unchanged.
|
||||
- **Why images, not a shared folder:** tools run from a virtiofs folder were about 3× slower warm (`node -e 0` 38 ms, `claude --version` 30 ms), the Mac's case-insensitive disk collided 33 file names in Python's terminfo, and mise's version links failed in a read-only folder.
|
||||
- **Why not per-tool layers:** an image chain for every mix of languages and agents repeats each agent's files in every mix.
|
||||
- **Where they build:** a tool image is shared by every VM whose tools need its key, and its build runs whatever runs as root in its build VM, so the key alone can't keep one VM's base out of another VM's tools. A glibc tool image therefore always builds in a clone of devvm's own Ubuntu base, on every backend, even for a VM on a `--from` Debian or Ubuntu image, whose code would otherwise run as root in the build of images that Ubuntu VMs then mount. `--from` VMs mount those images, because the tools are their projects' own prebuilt releases, which run on any glibc new enough, and devvm still refuses a tool that needs a newer glibc than the image has ([shared tools and glibc](../using/from.md#shared-tools-and-glibc)). A musl tool image can only build on Alpine, so it builds in the VM's own `--from` base, and its key hashes that base's digest, so it's only ever another VM's on the same container image. Before it builds, devvm checks the base's record against what the images are for, and refuses any other base (`tools_wrong_base`, [building tools](images.md#building-tools)). The cost is a build of devvm's own base for a `--from` VM's first glibc tools when it isn't built yet.
|
||||
- **A VM for each tool:** a tool's installer runs as root in its build VM, and a tool image's key hashes only its own tool's inputs, so tools built together in one VM could write into each other's images: through a shared work folder, a process left running until the next tool's `mkfs.erofs`, or root replacing `mise` or `mkfs.erofs` itself. A fresh folder for each tool and killing its processes wouldn't stop root, so each tool builds in a VM of its own, with an output folder of its own, and only that tool's image leaves it ([building tools](images.md#building-tools)). Measured on Fedora 43 (bare-metal x86_64, Lima with QEMU and KVM), building node, pnpm and bun took about 16 s in one VM and about 34 s in three, the same in two runs each, so each extra tool costs about 9 s, once for each tool version.
|
||||
- **Why a tool that doesn't mount fails the launch:** mise would otherwise download the same version into the VM on first use, which gives that VM a private copy, a download nobody asked for, and one that the VM's tier may block, all without a word ([how](images.md#the-share)).
|
||||
- **Instead of Nix:** Nix and NixOS were weighed as the way to deliver the shared tools and rejected, because NixOS breaks prebuilt binaries, and a Nix hidden under the tools shows through in read-only-store errors. The [`nix` layer](images.md#the-nix-layer) is separate, and you choose it. It gives a project that uses Nix a Nix of its own in its VM, with its own store and daemon, and the shared tools stay as they are beside it.
|
||||
- **Where they build:** a tool image is shared by every VM whose tools need its key, and its build runs whatever runs as root in its build VM, so the key alone can't keep one VM's base out of another VM's tools. A glibc tool image therefore always builds in a clone of devvm's own Ubuntu base, on every backend, even for a VM on a `--from` Debian or Ubuntu image, whose code would otherwise run as root in the build of images that Ubuntu VMs then mount. `--from` VMs mount those images, because the tools are their projects' own prebuilt releases, which run on any glibc new enough, and devvm still refuses a tool that needs a newer glibc than the image has ([shared tools and glibc](../using/from.md#shared-tools-and-glibc)). A musl tool image can only build on Alpine, so it builds in the VM's own `--from` base, and its key hashes that base's digest, so it's only ever another VM's on the same container image. Before it builds, devvm checks the base's record against what the images are for, and refuses any other base (`tools_wrong_base`, [building tools](../internals/images.md#building-tools)). The cost is a build of devvm's own base for a `--from` VM's first glibc tools when it isn't built yet.
|
||||
- **A VM for each tool:** a tool's installer runs as root in its build VM, and a tool image's key hashes only its own tool's inputs, so tools built together in one VM could write into each other's images: through a shared work folder, a process left running until the next tool's `mkfs.erofs`, or root replacing `mise` or `mkfs.erofs` itself. A fresh folder for each tool and killing its processes wouldn't stop root, so each tool builds in a VM of its own, with an output folder of its own, and only that tool's image leaves it ([building tools](../internals/images.md#building-tools)). Measured on Fedora 43 (bare-metal x86_64, Lima with QEMU and KVM), building node, pnpm and bun took about 16 s in one VM and about 34 s in three, the same in two runs each, so each extra tool costs about 9 s, once for each tool version.
|
||||
- **Why a tool that doesn't mount fails the launch:** mise would otherwise download the same version into the VM on first use, which gives that VM a private copy, a download nobody asked for, and one that the VM's tier may block, all without a word ([how](../internals/images.md#the-share)).
|
||||
- **Instead of Nix:** Nix and NixOS were weighed as the way to deliver the shared tools and rejected, because NixOS breaks prebuilt binaries, and a Nix hidden under the tools shows through in read-only-store errors. The [`nix` layer](../internals/images.md#the-nix-layer) is separate, and you choose it. It gives a project that uses Nix a Nix of its own in its VM, with its own store and daemon, and the shared tools stay as they are beside it.
|
||||
|
||||
## The shared Nix cache
|
||||
|
||||
VMs with the nix layer share their downloads from cache.nixos.org through a cache that only the host fills ([how](network.md#the-shared-nix-cache)). It's the first thing that VMs share, so the design keeps two things: each VM's Nix store stays its own, and no VM can change what another VM gets.
|
||||
VMs with the nix layer share their downloads from cache.nixos.org through a cache that only the host fills ([how](../internals/network.md#the-shared-nix-cache)). It's the first thing that VMs share, so the design keeps two things: each VM's Nix store stays its own, and no VM can change what another VM gets.
|
||||
|
||||
**Why a cache the host fills, not a shared store:** one store, or one daemon, shared between VMs is what Nix's own store vulnerabilities break. CVE-2026-110450 (the daemon's store corrupted through `repair`), CVE-2026-39860 and the CVE-2024-27297 family (a fixed-output derivation that changes its output after Nix registered it) each let a client of the daemon change paths in its store, and in a shared store, every other VM would then trust those paths. A VM's own builds are worse: a path a VM built has no signature that another VM could check, short of a key that trusts that VM, and then every VM trusts every other. A binary cache keeps the trust where Nix already has it. Each VM's Nix fetches from the cache as from cache.nixos.org, checks cache.nixos.org's signature and the `NarHash` itself, and adds the path to its own store, so the cache only saves downloads.
|
||||
|
||||
@@ -458,7 +460,7 @@ VMs with the nix layer share their downloads from cache.nixos.org through a cach
|
||||
|
||||
## A CA per VM
|
||||
|
||||
To put a secret in, a VM's proxy shows the VM certificates from a CA that the VM trusts, and inside the VM that CA vouches for any site. So each VM has CAs of its own, and the design keeps two things: a CA's key never leaves this machine, and no VM's proxy can make a certificate that another VM accepts ([how](network.md#the-vms-ca)).
|
||||
To put a secret in, a VM's proxy shows the VM certificates from a CA that the VM trusts, and inside the VM that CA vouches for any site. So each VM has CAs of its own, and the design keeps two things: a CA's key never leaves this machine, and no VM's proxy can make a certificate that another VM accepts ([how](../internals/network.md#the-vms-ca)).
|
||||
|
||||
**What it's built from:** `trust.InitCA`, at each launch, whatever the VM's tier, readies the VM's current CA and its next one in `vms/<hash>/run/ca/` (`paths.VM.CA`): ECDSA P-256, 30 days and an hour each, the next one starting a week and an hour before the current one ends. The proxy's config names the four files (`ca`, `ca_key`, `ca_next`, `ca_next_key`) and their certificates' SHA-256 (`ca_sha256`, `ca_next_sha256`), so a replaced CA starts the proxy again. The proxy signs with the next CA from an hour after its start (`ca.signer`), and the VM's setup installs both certificates, `devvm-proxy.crt` and `devvm-proxy-next.crt`, so the switch needs neither a launch nor a new proxy. The guest never fetches a CA: its trust comes only from the setup that devvm sends over ssh at each launch.
|
||||
|
||||
@@ -500,7 +502,7 @@ A link lets a program in one VM, the client, reach a TCP service in another VM,
|
||||
- **Low ports.** At each start, the setup sets `net.ipv4.ip_unprivileged_port_start` to `0` where it's `1024`, which is on Lima's Alpine VMs, so sshd can listen on a link's port below 1024 for the VM's user. Lima's Ubuntu and Debian VMs already have `0`, so devvm leaves it there.
|
||||
- **The link session.** For each running client with links, a hidden command, `devvm _links`, runs on the host as one detached process. It keeps an ssh connection of its own to the client, never the forwarder's master, with the options of `internal/vmssh`: `-F none`, `BatchMode`, the VM's key alone (`IdentitiesOnly`, `IdentityAgent=none`), its pinned host key, `ForwardAgent=no`, `ForwardX11=no`, `Tunnel=no`, `PermitRemoteOpen=none`, `PermitLocalCommand=no` and `ProxyJump=none`. It starts that connection as a master with `ClearAllForwardings=yes`, so the master asks for nothing at first, and adds each link with `ssh -O forward -R 127.77.x.y:PORT:<socket>` and removes it with `ssh -O cancel`, at its start and while the client runs. A cancel keeps the connections that are open, and the master ending drops them. Each link is its own `-O forward`, never `ExitOnForwardFailure` for all of them, so a link whose address a program in the client already holds fails alone, with an error naming the link (`link_port_taken`).
|
||||
- **The sockets.** Each link's forward ends at a unix socket on the host, mode 600 in devvm's run folder `~/.local/share/devvm/run` (mode 700), named by a hash of the client, the address and the port, because a socket's path has fewer than 104 characters. The masters' control sockets are in the same folder, named by a hash of the client, and for a master to a target, of the target and its start too. A stale socket at the path is replaced, anything else there is refused, and the socket goes when its link or the process ends.
|
||||
- **Each connection.** When a program in the client connects to a link's address, the client's sshd opens a channel to the host for the forward, and the host's ssh connects it to that link's socket. `devvm _links` then reads the links state again and checks that the link still exists, that the target's ID matches, that the port is published, that the tier rule holds, that the target runs as its backend says, and, for a client on a confined tier, that the target's tier is enforced as it runs. The connections to one target share what its backend says of its run, which is whether it runs, its start and its ssh: one lookup is in flight for each target, and its answer is reused for one second (`linkRunFor`), so a burst of 256 connections asks the backend once rather than once for each. A connection that closes while its lookup runs finds the target stopped, but that lookup isn't kept: the connections waiting on it look again, so they get the target's real answer. A target that stops is noticed within that second, and the connection's other checks, the tier's as the target runs included, are made for each connection. That tier check asks the backend again, and a stopped VM never runs confined, so for a client on a confined tier it notices at once that the target stopped. When the backend then says the target no longer runs on the start that was looked up, the connection is refused as `link_target_stopped`, not as `unenforced`. It then carries the connection with `ssh -S <master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT` through a master to the target that it keeps, one per target, with the target's key and pinned host key. The target's sshd connects to the target's own loopback. When the master is gone, `-S` alone would make a connection of its own, and `ProxyCommand=/usr/bin/false` makes that connection fail, so a channel goes through the master or nowhere. A target's master ends when the target stops, and the next one reads the target's known hosts again, because a VM whose Lima config changed gets new host keys when it boots. Each relay's ssh (`-W`) waits for the target's sshd to end its channel, so each runs with a context of its own (`vmssh.relayConns`, which the port forwarder's forwards use too): the link's removal and its master's replacement close its connection and cancel that context under the session's lock, which kills the ssh (`exec.CommandContext`), and a relay that ends by itself releases its context. So a removed link's open connections end with it, and a target that never ends a channel can't keep the relay's ssh process, or one of the 256, past either. A link whose address and port lead to another target at the next sync, as a link removed and another added within one second would, cuts the old target's connections and starts a new set for the new one, and a connection accepted before that change is cut with the old set. While a link lasts, the relay's grace (`pipeSSH`, as for [the forwarder](#ports-on-lima)) kills an ssh whose client in the client VM has closed and whose target has sent nothing for 30 seconds. devvm never starts the target. At most 256 connections are carried at once, and the next one is refused and logged. A link's socket holds 128 connections waiting to be accepted on macOS, and the process accepts nothing while it starts an ssh, so its accept loop only accepts, and hands a burst on whole once 5 ms pass with nothing more waiting, the first has waited 50 ms, or 257 wait. Another goroutine then carries or refuses each connection in it, logging each refusal before it closes the connection, while the loop goes on accepting the next burst, and the loop waits for that goroutine only once 257 of the next burst wait. So every connection in a burst is carried or refused with `link_limit`, and none is refused by the socket unlogged.
|
||||
- **Each connection.** When a program in the client connects to a link's address, the client's sshd opens a channel to the host for the forward, and the host's ssh connects it to that link's socket. `devvm _links` then reads the links state again and checks that the link still exists, that the target's ID matches, that the port is published, that the tier rule holds, that the target runs as its backend says, and, for a client on a confined tier, that the target's tier is enforced as it runs. The connections to one target share what its backend says of its run, which is whether it runs, its start and its ssh. One lookup is in flight for each target, and its answer is reused for one second (`linkRunFor`), so a burst of 256 connections asks the backend once rather than once for each. A connection that closes while its lookup runs finds the target stopped, but that lookup isn't kept, and the connections waiting on it look again, so they get the target's real answer. A target that stops is noticed within that second, and the connection's other checks, the tier's as the target runs included, are made for each connection. That tier check asks the backend again, and a stopped VM never runs confined, so for a client on a confined tier it notices at once that the target stopped. When the backend then says the target no longer runs on the start that was looked up, the connection is refused as `link_target_stopped`, not as `unenforced`. It then carries the connection with `ssh -S <master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT` through a master to the target that it keeps, one per target, with the target's key and pinned host key. The target's sshd connects to the target's own loopback. When the master is gone, `-S` alone would make a connection of its own, and `ProxyCommand=/usr/bin/false` makes that connection fail, so a channel goes through the master or nowhere. A target's master ends when the target stops, and the next one reads the target's known hosts again, because a VM whose Lima config changed gets new host keys when it boots. Each relay's ssh (`-W`) waits for the target's sshd to end its channel, so each runs with a context of its own (`vmssh.relayConns`, which the port forwarder's forwards also use). The link's removal and its master's replacement close its connection and cancel that context under the session's lock, which kills the ssh (`exec.CommandContext`), and a relay that ends by itself releases its context. So a removed link's open connections end with it, and a target that never ends a channel can't keep the relay's ssh process, or one of the 256, past either. A link whose address and port lead to another target at the next sync, as a link removed and another added within one second would, cuts the old target's connections and starts a new set for the new one, and a connection accepted before that change is cut with the old set. While a link lasts, the relay's grace (`pipeSSH`, as for [the forwarder](#ports-on-lima)) kills an ssh whose client in the client VM has closed and whose target has sent nothing for 30 seconds. devvm never starts the target. At most 256 connections are carried at once, and the next one is refused and logged. A link's socket holds 128 connections waiting to be accepted on macOS, and the process accepts nothing while it starts an ssh, so its accept loop only accepts, and hands a burst on whole once 5 ms pass with nothing more waiting, the first has waited 50 ms, or 257 wait. Another goroutine then carries or refuses each connection in it, logging each refusal before it closes the connection, while the loop goes on accepting the next burst, and the loop waits for that goroutine only once 257 of the next burst wait. So every connection in a burst is carried or refused with `link_limit`, and none is refused by the socket unlogged.
|
||||
- **The proxy's entrance.** In a client on any tier, an HTTP client that honors `HTTP_PROXY` sends `db:5432` to the VM's proxy, and the proxy is a second entrance to the same socket, so a link added while the client runs works at once without a restart. `devvm _links` writes every link the client has, carried or not, to `links.json` in the client's run folder, `vms/<hash>/run/` (mode 600, written whole) whenever they change or the file is gone, with each link's names, address, port, target and socket. A link it doesn't carry has no socket, and a session that ended leaves its list, so the proxy refuses those links (`502`, `link_refused`) instead of asking its rules, which could send `db` to a host the host's resolver or a company proxy finds by that name. devvm removes the list with the VM. devvm puts the path in the proxy's config as `links`, and its run folder, where the sockets are, as `link_sockets`, so `internal/proxy` stays standard library only, and the proxy reads the list for every request, after the VM's password and before any rule, as it does for `devvm.proxy`. It matches `CONNECT NAME:PORT` and absolute-form `GET http://NAME:PORT/` exactly, after one normalization: lower case, one trailing dot dropped, and `NAME.devvm.internal` as the list names it. It takes an entry only when the entry's socket is the one that `proxy.LinkSocket` names from devvm's run folder, this VM, the entry's address and its port, which is also the name `vmssh.Links.Socket` gives the socket. It then connects to the socket and passes the bytes as they are: no SNI check, no interception, no secret put in, even when a secret's hosts would match, and no rule asked. An absolute-form request goes over a new connection to the socket for each request, without the proxy's headers, and HTTPS in absolute form gets `400`. `devvm _links`'s checks of each connection apply to both entrances unchanged, and it logs the connection once, as `link`. A stale entry fails there, or finds no socket, which the proxy answers with `502` and logs as `link_refused` (`not carried`). The proxy also refuses any other name under `devvm.internal`, logged as a refused block, so a long name never reaches the rules. An absolute-form request to a link ends when the client gives it up, so a target that never answers can't hold the client's 256 connections. Anything else not on the list meets the floor and the rules as before, so a short name the client has no link for, before its first session lists it, is the rules' to decide.
|
||||
- **Events.** `devvm _links` writes `link`, `link_refused` (with why), `link_target_stopped` and `link_limit` events to the client's event log, in the proxy's JSON-lines format, with the link's name as the host and the target VM as `target`, so `devvm network log` shows them. Every client gets an event log for them, whatever its tier. `devvm _links` writes it with the proxy's own writer, which rotates it past 10 MiB by the proxy's rule and follows the file to its new name when the other writer rotated it, so the two writers never lose each other's lines.
|
||||
- **The forwarder skips links.** The port forwarder (`vmssh.Forwarder`) forwards a server on any loopback address of the VM's, so it would put a link's listener on the host's `127.0.0.1` and `::1`. It never forwards a listener whose address is in `127.77.0.0/16`, on any VM, so a server of the client's own on `127.0.0.1` with the same port is forwarded as usual. Lima's own forwards don't take it either, because devvm's rules ignore every port first, and Lima's fallback rule matches `127.0.0.1` and the bind addresses `0.0.0.0`, `::` and `::1` alone.
|
||||
@@ -590,7 +592,7 @@ A group is a named set of VMs that reach each other's published ports by name: y
|
||||
- **A group's links are links,** recorded in each member's links state with a mark of their own, so `devvm group leave` removes only those, and `devvm link rm` refuses them (`link_from_group`) while they still apply. Every connection of one is also checked against membership: a group's link applies only while its client and its target are in the same group (`ungrouped` otherwise), so a link that a leave cut short, or a race between two devvm commands, left behind carries nothing, and `devvm link rm` removes it. `devvm group leave` removes the leaver's own group links before it takes it out of the group, and running `devvm group join` again works out every member's links again. Each takes the client's address for that member and the member's name in the group: its folder part, or the name it joined with (`--as NAME`). devvm works out a member's group links again whenever a member joins or leaves, publishes or unpublishes a port, or adds or removes a link of its own, and it records and applies only the members whose links changed, naming the links each gains or loses (`group_links_added`, `group_links_removed`). A running member gets them at once, as `devvm link add` gives them, and a stopped one at its next start.
|
||||
- **The user's links take precedence.** A link made with `devvm link add` stays as it is: a port it links gets no group link, its name names that member's group links too, and when its name is another member's name in the group, that member's group links aren't made in that client, which is warned of (`group_link_name_clash`).
|
||||
- **Names are unique in a group.** `devvm group join` refuses a name another member has, as its name or its folder part (`group_name_taken`), and `localhost` (`group_name_host`). It also refuses a VM whose own hostname, its folder part, is another member's name, whether that's the member's folder part or the name it joined with (`group_name_hostname`), because the name would resolve to the joining VM itself, whatever name it joins as. The refusal names the fix: the other member leaves and joins again with another name, or the project goes in a folder with another name. So no member's name is another member's hostname, and `groupLinks` makes no link by such a name, or by `localhost`, all the same.
|
||||
- **Joins take turns.** Each `devvm group join` and `devvm group leave`, each publish and unpublish that works the members' links out again, and `devvm rm` of a VM hold a lock on the host, `~/.local/share/devvm/groups.lock` (`lockGroups`), from reading the members' states to writing them. A join checks the group once before it asks to widen a parent folder's VM, and again once it holds the lock, with the VM's state read again, so two VMs joining at once are checked one after the other, and the second sees the first as a member: the one tier and the names hold however the joins overlap. A devvm that waits for the lock does so under a status line (`group_waiting`). The lock is an OS lock (`flock`) on an open file, which the system lets go of when the process holding it ends, however it ends.
|
||||
- **Joins take turns.** Each `devvm group join` and `devvm group leave`, each publish and unpublish that works the members' links out again, and `devvm rm` of a VM hold a lock on the host, `~/.local/share/devvm/groups.lock` (`lockGroups`), from reading the members' states to writing them. A join checks the group once before it asks to widen a parent folder's VM, and again once it holds the lock, with the VM's state read again, so two VMs joining at once are checked one after the other, and the second sees the first as a member. So the one tier and the names hold however the joins overlap. A devvm that waits for the lock does so under a status line (`group_waiting`). The lock is an OS lock (`flock`) on an open file, which the system lets go of when the process holding it ends, however it ends.
|
||||
- **`devvm rm` of a member takes it out of its group,** after `devvm rm`'s removal of every link to it, and the group goes with its last member.
|
||||
|
||||
**What a group adds to the link threat check.** A group joins the trust of every member: code in any member can often run code in the others through the ports they publish, and then has their network, secrets and project folder. A member joining later gets that reach into every member, and they into it, without a command in their folders, so `devvm group join` says so on every join (`group_trust`). Nothing reaches more than the published ports on each member's own loopback, and the one tier keeps every member's tier whole.
|
||||
@@ -615,7 +617,7 @@ A group is a named set of VMs that reach each other's published ports by name: y
|
||||
|
||||
## Read-only paths on Linux
|
||||
|
||||
macOS locks `.git`'s hooks and config with the user-immutable flag, which Linux has only for root, so on Linux devvm makes them read-only where the VM sees them instead ([.git protection on Linux hosts](git-protection.md#on-linux-hosts)). Lima's `read-only-paths` feature is native: QEMU serves the project folder over 9p from its own mount namespace, and devvm binds each path over itself there. Landlock, a FUSE layer and a 9p server of devvm's own were ruled out: Landlock can't make paths read-only below a folder it allows writes in, and the other two would put devvm's code between the VM and every file of the project.
|
||||
macOS locks `.git`'s hooks and config with the user-immutable flag, which Linux has only for root, so on Linux devvm makes them read-only where the VM sees them instead ([.git protection on Linux hosts](../internals/git-protection.md#on-linux-hosts)). Lima's `read-only-paths` feature is native: QEMU serves the project folder over 9p from its own mount namespace, and devvm binds each path over itself there. Landlock, a FUSE layer and a 9p server of devvm's own were ruled out: Landlock can't make paths read-only below a folder it allows writes in, and the other two would put devvm's code between the VM and every file of the project.
|
||||
|
||||
**The guarantee:** while a VM whose protection is on runs, nothing in it, root included, can write, replace, remove or rename `.git`'s hooks, config and the rest of what's locked, of `.git` and of the submodules the check before its start found, or rename `.git` and those git folders. git in the VM commits as before. Nothing changes for this machine's own git, and nothing persists once QEMU ends. Where the host can't do it, the start is refused, or, for a VM made there, protection is off and devvm says so at each launch. devvm reports a VM that's on and runs without its pins, at each launch of it and at `devvm stop`. One gap is listed, not closed: a file that a git command on this machine renames over a pinned one while the VM runs is the guest's until it's pinned again, and devvm names it afterwards.
|
||||
|
||||
@@ -644,7 +646,7 @@ macOS locks `.git`'s hooks and config with the user-immutable flag, which Linux
|
||||
|
||||
## Nested repos
|
||||
|
||||
A folder often holds git repos of its own besides its submodules, such as a workspace of several repos with no repo at its top. Every one of them is in the VM's mount, so `.git` protection covers each as it covers the folder's own repo ([nested repos](git-protection.md#nested-repos)). Two other designs were weighed. Refusing such folders, or warning only, leaves the most common multi-repo layout without protection. A `--clone` of every repo keeps the VM out of the working trees altogether, which is what a [workspace clone](#workspace-clones) does for a user who doesn't need the VM to write them, so both are built.
|
||||
A folder often holds git repos of its own besides its submodules, such as a workspace of several repos with no repo at its top. Every one of them is in the VM's mount, so `.git` protection covers each as it covers the folder's own repo ([nested repos](../internals/git-protection.md#nested-repos)). Two other designs were weighed. Refusing such folders, or warning only, leaves the most common multi-repo layout without protection. A `--clone` of every repo keeps the VM out of the working trees altogether, which is what a [workspace clone](#workspace-clones) does for a user who doesn't need the VM to write them, so both are built.
|
||||
|
||||
**The guarantee:** in a VM made by this devvm, or one `devvm git-protect on` set, nothing in the VM can change the hooks and config of a nested repo that a walk of the stopped VM's folder found, with the same locks, pins and watch as the folder's own repo, and with the same reports at each check. It holds from the check that found the repo: a repo the VM makes while it runs, or a folder of its own the VM puts in a protected repo's place on Linux, is git's to use on this machine until the next stopped check names it, and what the walk can't find or the bound leaves out is named, or counted, not protected. A VM an earlier devvm made keeps protecting only its own repo until `devvm git-protect on`, because locking a repo's config breaks `git config` there, which the user didn't ask for. It's told once.
|
||||
|
||||
@@ -669,7 +671,7 @@ A folder often holds git repos of its own besides its submodules, such as a work
|
||||
|
||||
## Workspace clones
|
||||
|
||||
`devvm --clone` in a folder of repos gives one VM a clone of each repo the user picks, each at its own path, so the paths between them work as on the host ([folders of repos](../using/clone.md#folders-of-repos)). It extends the one-repo clone rather than adding a mode beside it: the clone section's `repos` lists the repos by their paths relative to the folder, and a clone of the folder's own repo, the only kind devvm 0.1.0 made, reads as one repo at `.` with its remote and seed in `made`, so its state needs no migration. Every step that a one-repo clone takes for its repo, a workspace clone takes for each: the checks of `--clone` (`checkRepoTop`, `cloneSource`, `gitprotect.OwnRepo`), a remote of its own (`freeRemote`), a copy of its branches through the VM's own command channel to that repo's path ([the copy into a clone VM](git-protection.md#the-copy-into-a-clone-vm)), and at `devvm rm` or `devvm clone off`, the check of its work and the removal of its remote. The repos are found by the walk that [`.git` protection](#nested-repos) makes (`starter.walk`), so the same depth, skipped folders and bound apply, and they're recorded once, when the VM is made or at `devvm clone add`, never at a launch.
|
||||
`devvm --clone` in a folder of repos gives one VM a clone of each repo the user picks, each at its own path, so the paths between them work as on the host ([folders of repos](../using/clone.md#folders-of-repos)). It extends the one-repo clone rather than adding a mode beside it: the clone section's `repos` lists the repos by their paths relative to the folder, and a clone of the folder's own repo, the only kind devvm 0.1.0 made, reads as one repo at `.` with its remote and seed in `made`, so its state needs no migration. Every step that a one-repo clone takes for its repo, a workspace clone takes for each: the checks of `--clone` (`checkRepoTop`, `cloneSource`, `gitprotect.OwnRepo`), a remote of its own (`freeRemote`), a copy of its branches through the VM's own command channel to that repo's path ([the copy into a clone VM](../internals/git-protection.md#the-copy-into-a-clone-vm)), and at `devvm rm` or `devvm clone off`, the check of its work and the removal of its remote. The repos are found by the walk that [`.git` protection](#nested-repos) makes (`starter.walk`), so the same depth, skipped folders and bound apply, and they're recorded once, when the VM is made or at `devvm clone add`, never at a launch.
|
||||
|
||||
Four choices keep it small. The seed copies each repo's refs as a one-repo clone's seed does, every branch, tag and remote-tracking branch, so a workspace repo behaves in the VM as a repo of its own does; the seed sends one pack for each repo, so this costs about what a clone of the repo does. A repo `--clone` can't copy is listed and left out, never fatal, so one odd repo doesn't stop the rest; the same holds for a repo whose three remote names are taken. The folder's own files outside every repo are copied once and never back, as a tar the host makes from what it reads beneath the folder, so a Makefile or a compose file works in the VM without becoming a sync. And `devvm` in one of the repos opens the folder's VM at that repo's path, because the VM has the repo there and mounts nothing of the host, so the finder's reason to pass over a parent's VM below a repo of its own, that the parent's VM can write that repo, doesn't hold; `--here` still makes the repo's own VM.
|
||||
|
||||
@@ -684,20 +686,20 @@ rm's check reads every repo at once: one script sent with the command (`cloneSta
|
||||
- **A host file through the copy:** fixed. devvm first walked the folder by paths beneath an `os.Root`, which follows a link in the middle of a path while it stays in the root, so another VM that mounts a subfolder could swap a folder there for a link to an unchosen repo, or its `.git`, as the walk reached it, and the copy took that repo's files and config (the adversarial review). The walk now opens each folder from its parent's handle and checks it's the folder it listed (`safefile.Root.OpenDir`, `TestOpenDir`), and opens each file by its own name in its folder, without following a link at its end, checked to be a regular file once open, and refused when it has another hard link, which could be any file on its disk (`OneLink`). A folder shaped like a git dir, such as a bare mirror, was copied as plain files, which the review found too; it's now left out and counted. A link is copied as a link only when its target is relative and stays in the folder, never read through. Other disks, sockets, FIFOs and devices stay on the host, and files keep their permissions without set-id bits (`TestWorkspaceFiles`). A workspace clone copies the folder's files, so devvm refuses the folders it refuses to mount, such as the home folder (`checkUnsafe`). Listed: a secret the user keeps at the folder's top, such as an `.env`, is copied as any file is, which the docs say.
|
||||
- **Host git in a folder the VM chose:** fixed. Host git runs only in the repos devvm's state records, which only devvm writes, each at a clean path below the folder, and `repos` passes over any other. The review found that only the seed checked a recorded repo again, so once another VM, or the user, removed a repo's `.git` or put another folder in its place, `devvm clone fetch` and rm's fetch wrote the VM's objects and refs into whichever repo git found there, the folder's own above it included. Every fetch into a repo, and devvm clone off's undo adding its remote again, now checks first that the folder is still the top of a repo of its own (`checkRepoTop`): `devvm clone fetch` leaves it alone and names it, and rm and devvm clone off refuse and keep the VM (the `clone_workspace` script). Every host git command goes through `hostgit`, so no hook, fsmonitor, filter or `GIT_*` of the environment runs, and the push and fetch connect to the VM alone, whatever the repo's config says (`gitSSHCommand`).
|
||||
- **Refs from the VM:** ruled out. `devvm clone fetch` fetches with `--refmap=` and one refspec, `+refs/heads/*:refs/remotes/<remote>/*`, so the VM's branches land only under that repo's remote for the VM, whose name devvm chose, and host git refuses a ref name it can't take. rm's fetch writes new `saved/` branches only, never over one (`savedPrefix`). The names devvm lists are host git's, read back, and shown through `msg.Printable`.
|
||||
- **The clone check's answer:** ruled out. devvm reads at most 8 MiB, and fails the check past that; each record must be whole, of a repo asked for, and each worktree's path clean, relative and below the folder, once, followed by its status (`TestParseCloneState`, `TestWorktreePathPins`). A VM that hides its work only loses its own work, which the docs say: devvm checks what the VM answers, not that it answers everything. A repo whose clone isn't at its path in the VM first read as having nothing to check, so a clone moved in the VM went with its work without a question (the review); it's now asked about, as uncommitted changes are (`TestCloneChangesAcrossRepos`).
|
||||
- **The clone check's answer:** ruled out. devvm reads at most 8 MiB, and fails the check past that or after 2 minutes; each record must be whole, of a repo asked for, and each worktree's path clean, relative and below the folder, once, followed by its status (`TestParseCloneState`, `TestWorktreePathPins`). A VM that hides its work only loses its own work, which the docs say: devvm checks what the VM answers, not that it answers everything. A repo whose clone isn't at its path in the VM first read as having nothing to check, so a clone moved in the VM went with its work without a question (the review); it's now asked about, as uncommitted changes are (`TestCloneChangesAcrossRepos`).
|
||||
- **The finder's carve-out:** ruled out. It applies only to a state whose clone section is on and a workspace, which never mounts the folder; a VM made again with the folder mounted clears that section first (`TestCoversRepo`, the `clone_workspace` script).
|
||||
- **A repo another VM can swap:** fixed. A VM that mounts a subfolder holding a workspace repo, or the repo itself, can swap it for a link to another repo between devvm's check and its push or fetch, which would send another repo's history into the clone VM, or write the clone's refs into another repo (the second review). devvm now refuses such a repo when it finds the repos, at `devvm clone add` and before each push and fetch, and rm's check runs no host git in it, naming the VM (`finder.mountsRepo`, `stillRepo`, the `clone_workspace_repo` script); the check and git still race for a VM that mounts it only later, which the next command names.
|
||||
- **A repo with worktrees or repos of its own:** fixed. The second review found that a repo holding a linked worktree, as the docs' `.worktrees/NAME` layout makes, or a repo below it, became a workspace: `--no-input` scripts that 0.1.0 ran now refused, the worktree was copied as a repo of its own, recording a remote in the config it shares with its repo, and the folder's own clone showed the other clones as untracked, so rm always asked. A folder that's a repo gets its own clone unless `--repos` is given, a linked worktree of a repo in the folder is never a repo of its own (`worktreeIn`), each repo's remote is chosen once the one before is added, and the folder's own clone excludes the other clones and what the host's `info/exclude` names (`repoExcludes`, `TestFindRepos`, `TestRepoExcludes`, the `clone_workspace_repo` script). A folder of repos inside another repo's working tree is refused, as its copy would take that repo's files.
|
||||
- **Work lost to a copy that didn't finish:** fixed. `devvm clone add` records a repo before its copy, and a failed copy left it recorded and unseeded, which the command then called added, and rm passed over, so a push that reached the VM without its record went unchecked. A recorded, unseeded repo is now copied again by `devvm clone add`, fetched when its remote is recorded, and checked by rm when its clone is in the VM (the `clone_workspace` script's failed add, then its retry).
|
||||
- **The verification pass:** fixed. `devvm clone add .` gave the folder's own clone no excludes, so it showed the other clones as changes and rm always asked; it now gets every other repo's and the host's. A linked worktree whose repo another VM mounts wasn't refused; devvm now checks the repo its common dir is in too (`mountingVM`). Exclude lines took a repo's folder name as a pattern, so `lib[2]` wasn't left out, and a name with a line break could write a line that left out every new folder, hiding work from rm; git's pattern characters are now escaped, each line is anchored at both ends, and a repo whose name has a character `msg.Safe` refuses, a line break among them, is refused (`TestRepoExcludes` runs real git on them). A repo another VM mounts failed rm for the whole workspace; rm now reads its clone in the VM, checks every other repo, and asks before its work goes, never running host git in it. The VM's folder never made failed the check; it now reads as every repo gone. Each repo is checked again after rm's question, before its fetch. A retry whose push had landed sent it again, which the VM refused once its branch moved on; a repo the VM has with a commit is now left as it is, and only its remote added. The branches' bound of 10,000 is for all the repos of a check together.
|
||||
- **A worktree hidden by the bound:** fixed. The clone check's script counted the worktrees outside the folder towards its 101 before leaving them out, so 101 outside ones hid a changed one inside, and rm deleted without asking, for a one-repo clone too; it counts only those inside now (`TestCloneStateScript`). The repos' branches are capped at 10,000 in all per check, as each costs host git a lookup.
|
||||
- **Cost:** listed. The walk is `.git` protection's, bounded at 100 repos; the copy at 5,000 entries and 64 MiB, each file at 10 MiB. A VM can serve a pack without end, or many branches, which `devvm clone fetch` writes into the repo until the disk is full or the user presses Ctrl+C, as `git fetch devvm` would; a cap on what host git reads from the VM's ssh isn't built. rm's read of the clone stops at 8 MiB, but a VM that writes slowly without end keeps it waiting until Ctrl+C, and `--no-clone-check` is the way out.
|
||||
- **Cost:** listed. The walk is `.git` protection's, bounded at 100 repos; the copy at 5,000 entries and 64 MiB, each file at 10 MiB. A VM can serve a pack without end, or many branches, which `devvm clone fetch` writes into the repo until the disk is full or the user presses Ctrl+C, as `git fetch devvm` would; a cap on what host git reads from the VM's ssh isn't built. The read of the clone, by rm and `devvm clone off`, shares the bounds of the read of the agents' worktrees (`answer`). devvm stops the VM's command past 8 MiB and gives up past 2 minutes, so when a VM writes without end, slowly or not, or never answers, the check fails and devvm keeps the VM, and `--no-clone-check` is the way out (`TestWorkCheckBounded`).
|
||||
|
||||
**End-to-end checks** (`tests/e2e`, the `clone` section): a folder of two repos and a file of its own gets one VM that mounts only the shared tools, with each repo's clone at its path holding every branch and the folder's file; an agent-like commit in each repo comes back with `devvm clone fetch`, listed as one branch with both repos; `devvm clone add` copies a third; rm without a terminal refuses with unfetched work in one repo, naming it, and keeps the VM; `--no-clone-check` deletes it and removes every repo's remote. Unit tests: `TestDefaultBranch`, `TestSeedTips`, `TestIsWorkspace`, `TestChooseRepos`, `TestPickRepos`, `TestFindRepos`, `TestWorkspaceFiles`, `TestCloneChangesAcrossRepos`, `TestFetchedByBranch`, `TestCloneRepos`, `TestFixtureClonesReadAsOneRepo`, `TestCoversRepo`, `TestParseCloneState`, `TestCloneStateScript`, `TestOpenDir` and `TestRepoExcludes`.
|
||||
|
||||
## A VM made again
|
||||
|
||||
`devvm layer add` and `devvm layer rm` make a VM again from a new image, and `devvm update` from its own image's new build, while keeping devvm's state for it and its home folder ([making a VM again](overview.md#making-a-vm-again)). All three use the one remake, and three choices shape it.
|
||||
`devvm layer add` and `devvm layer rm` make a VM again from a new image, and `devvm update` from its own image's new build, while keeping devvm's state for it and its home folder ([making a VM again](../internals/overview.md#making-a-vm-again)). All three use the one remake, and three choices shape it.
|
||||
|
||||
**Option B, a new disk.** The layer's script never runs in the existing VM. Running it there would run a third-party installer next to the project's files, as root, on a disk the VM's own code has changed, and the image's key would then describe a disk that no longer matches it. A new disk from the image keeps every VM a copy of an image whose key hashes everything in it. Taking a layer out works the same way, because a layer has no script that undoes it, and only a new disk from an image without the layer leaves nothing of it behind.
|
||||
|
||||
@@ -737,7 +739,7 @@ devvm puts the file into the new VM once it has started confined, as the VM's us
|
||||
|
||||
## A folder's volume
|
||||
|
||||
A VM's state records its folder's volume beside the folder's device, inode and birth time, so a folder that moved while a restart gave its disk another device number keeps its VM ([one VM per folder](security.md#one-vm-per-folder)). The volume is macOS's volume UUID, from `diskutil info -plist` for the mount point and device read from the folder opened with no link on its path, or Linux's `f_fsid` on ext4, Btrfs and ZFS, read from that open folder. It's bound to the folder's inode and birth time, so a record that an older devvm left beside another folder names no volume.
|
||||
A VM's state records its folder's volume beside the folder's device, inode and birth time, so a folder that moved while a restart gave its disk another device number keeps its VM ([one VM per folder](../internals/security.md#one-vm-per-folder)). The volume is macOS's volume UUID, from `diskutil info -plist` for the mount point and device read from the folder opened with no link on its path, or Linux's `f_fsid` on ext4, Btrfs and ZFS, read from that open folder. It's bound to the folder's inode and birth time, so a record that an older devvm left beside another folder names no volume.
|
||||
|
||||
The volume tells two disks apart that each have a folder with the same inode and birth time, which happens by chance or when a copy of a disk gets a volume ID of its own. It doesn't tell a disk from a copy that keeps the volume ID, and it isn't a secret or a signature:
|
||||
|
||||
@@ -751,18 +753,18 @@ The volume tells two disks apart that each have a folder with the same inode and
|
||||
| --- | --- | --- |
|
||||
| A folder on another volume with the same inode and birth time, at the folder's own path after a restart | A renumbered folder at its own path must be on the recorded volume when both are known (`platform.KeepsVolume`), checked when devvm finds the VM and again when the start records the new device | Unit tests (`TestKeepsVolume`, `TestRenumberedOnAnotherVolume`) |
|
||||
| A link swapped in while devvm reads the folder | The identity, owner, mount point, device and `f_fsid` come from one folder opened with no link on its path (`platform.StatFolder`), and `diskutil`'s answer must name that mount point and device | Unit tests (`TestStatFolderAndVolumeUUID`, `TestStatFolder`, `TestMovedFrom`) |
|
||||
| A `diskutil` that hangs or fails | A lookup within 1 or 5 seconds, none after one fails in a run, and a volume that can't be told records no volume and matches no moved folder, while a renumbered folder at its own path is then judged by its device, inode and birth time alone, as before volumes were recorded | Unit tests (`TestVolumeOfCache`, `TestRecordFolder`) |
|
||||
| A disk the user mounts in its place | Not held: a disk mounted at the folder's path with the folder's volume ID, inode and birth time is the folder to devvm, as it is to any program | Documented here and in [one VM per folder](security.md#one-vm-per-folder) |
|
||||
| A `diskutil` that hangs or fails | A lookup within 1 or 5 seconds, none after one fails in a run, and a volume that can't be told records no volume and matches no moved folder, while a renumbered folder at its own path is then judged by its device, inode and birth time alone, as for a state that records no volume | Unit tests (`TestVolumeOfCache`, `TestRecordFolder`) |
|
||||
| A disk the user mounts in its place | Not held, because a disk mounted at the folder's path with the folder's volume ID, inode and birth time is the folder to devvm, as it is to any program | Documented here and in [one VM per folder](../internals/security.md#one-vm-per-folder) |
|
||||
|
||||
## opencode's database in history exports
|
||||
|
||||
opencode 2 keeps its sessions and its logins in one SQLite database, `~/.local/share/opencode/opencode.db` (`opencode-<channel>.db` for another channel's build), in WAL mode. An export of agents' history goes to this machine and can go into another VM of the folder, so it must carry the sessions without the logins. Leaving the database out would lose opencode's history, and opencode's own `opencode session export` runs opencode and its server once per session, which an export before `devvm rm` can't count on. devvm copies the database in the VM with the `sqlite3` that base installs (`sqlite3` on Debian and Ubuntu, `sqlite` on Alpine), as the VM's user, in a temporary folder in `~/.cache` (`opencodeClean`):
|
||||
|
||||
1. `VACUUM INTO` copies the database as one snapshot, with what its `-wal` file holds, so a login that opencode saved last, which is still only in the WAL, is in the copy and taken out with the rest.
|
||||
2. In the copy, devvm drops every trigger, so none can put a row back, and empties the tables that hold logins: opencode 2.2's `credential` (its logins and API keys), `account` and `control_account` (its console's access and refresh tokens) and `account_state`, the `session_share` table of an earlier opencode (each share's secret), and any other table whose name has `credential`, `account`, `auth`, `secret`, `token` or `share` in it, or that has a column such as `secret`, `api_key`, `access_token` or `password`, so a table that a later opencode adds for its logins is emptied too. It also deletes the rows of the `kv` table whose key starts with `wellknown:config:`, because each holds an organization's remote config, which opencode fetched with that organization's well-known login and which can hold the organization's keys. opencode fetches the config again once it has the login.
|
||||
2. In the copy, devvm drops every trigger, so none can put a row back, and empties the tables that hold logins: opencode 2.2's `credential` (its logins and API keys), `account` and `control_account` (its console's access and refresh tokens) and `account_state`, the `session_share` table of an earlier opencode (each share's secret), and any other table whose name has `credential`, `account`, `auth`, `secret`, `token` or `share` in it, or that has a column such as `secret`, `api_key`, `access_token` or `password`, so a table that a later opencode adds for its logins is emptied too. It also deletes the rows of the `kv` table whose key starts with `wellknown:config:`, because each holds an organization's remote config, which opencode fetched with that organization's well-known login and which can hold the organization's keys. opencode fetches the config again once it has the login. It also empties what would run without asking in the VM that imports the copy (`opencodeUnattended`): opencode 2.4's `automation` table, each automation's trigger and the shell command it runs, which opencode approved once, as the automation was made, and never asks about again, its `permission` table, the requests you said always to allow in a project, its `job` table, the subagents' jobs, and its `session_inbox` table, a session's queued messages, which its service starts again when it starts (`restart.ts`), and any table whose name starts with one of those names. It sets to NULL, in every table, a column named `time_suspended`, which marks a session whose turn the service resumes on its own, and one named `commands`, a project's commands, whose start command opencode runs with `bash -lc` for each worktree it makes (`opencodeNulled`). It drops every view, as a view in an emptied table's name could show a renamed table's rows, and its check fails on any table with a generated column, which `pragma_table_info` doesn't list. Each session's own rules are the `permission` column of `session_v2`, a JSON array of rules, each with an `effect` of allow, deny or ask, so in every table with a `permission` column, its name in any case, devvm keeps only the deny and ask rules with a text action, and a value that isn't such an array becomes no rules (`opencodeAllowRules`). It writes each kept rule again from the values that `sqlite3` read, because `sqlite3` reads a key written twice by its first value and opencode's `JSON.parse` by its last, so `"effect":"deny","effect":"allow"` would otherwise stay as an allow rule for opencode. A kept rule whose resource is missing or isn't text gets `*`, which matches every resource, because opencode's rules need one. It reads that JSON only where a `CASE` has found it valid, because `sqlite3` may read both sides of an `AND` and fail on text that isn't JSON.
|
||||
3. It takes out the record of opencode's migration that imports `auth.json` (`20260805200742_import_legacy_credentials`), so the opencode that next opens the copy imports the logins that devvm's setup wrote in its own VM's `auth.json`, as it does when it first makes its database.
|
||||
4. It turns WAL off, with `secure_delete` on, and runs `VACUUM`, which writes the file again, so no free page keeps a deleted row and no `-wal` or `-journal` file is left.
|
||||
5. It checks what `sqlite3` printed, not only that it succeeded. Right after `VACUUM INTO`, the copy must have as many tables as the database, and at least one. At the end, devvm counts the triggers, the rows of each table it emptied and the `kv` rows it deleted, and each count must be `0`, so a `sqlite3` that runs nothing and prints nothing fails the check too. When a check or any step fails, the database is left out of the export and the run log says why.
|
||||
5. It checks what `sqlite3` printed, not only that it succeeded. Right after `VACUUM INTO`, the copy must have as many tables as the database, and at least one. At the end, devvm counts the triggers and views, the generated columns, the rows of each table it emptied, the values left in each column it set to NULL, the rows whose `permission` still holds anything but deny and ask rules, and the `kv` rows it deleted, and each count must be `0`, so a `sqlite3` that runs nothing and prints nothing fails the check too. When a check or any step fails, the database is left out of the export and the run log says why.
|
||||
|
||||
The export's `tar` leaves out the database and its `-wal`, `-shm` and `-journal` files as they are, matched within opencode's folder, and adds the copy at the database's path (`--transform`, which leaves symlinks' targets alone). The import does the same to an export it unpacks, in the VM, before anything reaches the home folder: it deletes the `-wal`, `-shm` and `-journal` files and any database that isn't a regular file, and puts in each database's copy, or deletes the database when the VM has no `sqlite3` or the copy fails. Each `sqlite3` runs with `trusted_schema` off, so an imported database's schema can't call the CLI's functions that write files.
|
||||
|
||||
@@ -771,7 +773,12 @@ The export's `tar` leaves out the database and its `-wal`, `-shm` and `-journal`
|
||||
- **A secret that's in a session itself,** such as a key you pasted into a prompt, stays in the session, as it does in Claude Code's and Codex's transcripts.
|
||||
- **A plugin's own storage and a remote workspace's binding stay.** opencode keeps each plugin's storage in its `kv` table, under the plugin's own prefix, and each remote workspace's binding, the record its provider needs to reconnect, in its `workspace` table. opencode's built-in plugins keep model catalogs and session records there, but a plugin you install, or a workspace provider, that keeps a token there takes it into the export.
|
||||
- **A VM without `sqlite3`,** made from an image built without it, exports and imports no opencode database, and opencode's sessions are lost from that export.
|
||||
- **A remake's home folder copy** keeps opencode's database with its logins, because it's the same VM's data going into the same folder's new VM ([the home folder's copy](#the-home-folders-copy)).
|
||||
- **opencode's own agents keep their rules.** A session keeps its agent, and a turn is checked against that agent's built-in rules too, such as `explore`'s, which allow its shell commands. With no suspended session, job or queued message, no turn starts until you send one.
|
||||
- **A host password that looks like a variable's name or a number.** Settings' copies keep a value that looks like an environment variable's name or a switch (`envName`, `plainValue`), so a service password set by hand in that form reached VMs as it was, with no `devvm-redacted` for the setup's clean-up to find; the release page says what to do.
|
||||
- **The `event` table stays as it is.** It holds the events that opencode's sessions were made from, a `session.permissions` event's rules among them, and opencode 2.4.1 writes an event into `session_v2` as it publishes it (its session projector), not when it opens a database, so the copy's rules are the ones opencode reads. A later opencode that rebuilt its sessions from that table would read the allow rules again.
|
||||
- **A remake's home folder copy** keeps opencode's database with its logins, and its home key, because it's the same VM's data going into the same folder's new VM ([the home folder's copy](#the-home-folders-copy)).
|
||||
|
||||
opencode 2.4 keeps the private Ed25519 key of its home, which every machine it pairs with `opencode machine add` trusts and which it never replaces, in a file of its own, `~/.local/state/opencode/machine/home-key`, not in the database. The database's `machine` table holds each paired machine's name and the public key it logs in to the home with, so it's the VM's own pairings, and the copy empties it with the login tables (`opencodeLogins`). The key's folder, the background service's registration (`service.json`, or `service-<channel>.json` on a channel other than latest, dev, beta or next, with the service's password, written through `<file>.<id>.tmp`, and `<file>.pty-handoff`, a terminal's handoff ticket, written through `<file>.pty-handoff.<uuid>.tmp`) and the terminals' daemons (`pty`, their sockets and access tokens) are opencode's `HistoryOwn` in the agents' registry: the export leaves them out and the import never writes them, while a remake keeps them. The registrations are patterns, `service-*.json`, `service.json.*` and `service-*.json.*`, which the export's GNU `tar --exclude` and the import's `tar --exclude` and its clean-up loop, a shell glob, all expand.
|
||||
|
||||
**Threat check** (the security-audit skill, guidance mode, with its data isolation companion):
|
||||
|
||||
@@ -781,11 +788,13 @@ The export's `tar` leaves out the database and its `-wal`, `-shm` and `-journal`
|
||||
| The WAL or journal file carrying the rows | They never go into an export, and an import deletes them | `TestHistoryExportRuns` and `TestHistoryImportCleansOpencode` |
|
||||
| An export with the logins in it reaching another VM | The import makes the same copy in the VM before anything reaches its home folder, or leaves the database out | `TestHistoryImportCleansOpencode`, with and without `sqlite3` |
|
||||
| A trigger putting a row back as it's deleted | Every trigger is dropped first, and the rows are counted after | `TestOpencodeClean` plants one |
|
||||
| A hostile VM's export running a command, or allowing one, without asking in the VM that imports it | The copy empties `automation`, `permission`, `job` and `session_inbox`, and every table whose name starts with one of those names, sets `time_suspended` and `commands` to NULL, keeps only the deny and ask rules of each `permission` column, written again, drops views and refuses generated columns; the counts after must be `0`. The export leaves out opencode's git repositories (`snapshot`, `repos`, `worktree`), and the import never writes them | `TestOpencodeCleanSchema` plants a row in each from opencode 2.4.1's schema, an allow rule, a suspended session and a project's commands; `TestOpencodeCleanSessionRules` plants rules that aren't deny or ask, a key written twice, values that aren't rules and a column in upper case; `TestOpencodeCleanHidden` a view and a generated column; `TestHistoryExportRuns` and `TestHistoryImportRuns` the git folders |
|
||||
| opencode's home key reaching this machine's export or another VM | The export leaves out its `machine` folder, `service.json`, `service-<channel>.json`, their handoff and temporary files, and `pty`, and the import never writes them, by their paths after it unpacks too; the copy of the database empties its `machine` table, the paired machines' public keys | `TestHistoryExportRuns`, `TestHistoryImportRuns` and `TestHistoryImportV010` plant them; `TestOpencodeCleanSchema` empties `machine` from opencode 2.4.1's schema; `TestHomeSkipsEveryLogin` keeps them in a remake |
|
||||
| A hostile database's schema running code in the VM | `trusted_schema` is off, and it runs as the VM's user on the VM's own files, which the export's code could reach anyway | Reviewed |
|
||||
|
||||
## Links out of an agent's folder
|
||||
|
||||
devvm's agent store reaches every VM with the agent: its folders are mounted read-only, its files are copied in at every launch, and the hooks, MCP servers' commands and plugins in it run in each of those VMs. So whatever `devvm agent import` copies is something every such VM reads and runs. A link in an agent's folder that leads out of it can lead anywhere on this machine, such as to `~/.ssh`, to another agent's login, or into a folder that a VM can write, such as a dotfiles repo that is also a devvm project. Following such links unasked would let a mistaken link put a secret into every VM, and let a VM that writes the folder a link leads into change what every other VM's agent runs. That's why the import follows no link out of an agent's folder by default, and reads each folder through itself as an `os.Root` ([how](agents.md#links-out-of-an-agents-folder)).
|
||||
devvm's agent store reaches every VM with the agent: its folders are mounted read-only, its files are copied in at every launch, and the hooks, MCP servers' commands and plugins in it run in each of those VMs. So whatever `devvm agent import` copies is something every such VM reads and runs. A link in an agent's folder that leads out of it can lead anywhere on this machine, such as to `~/.ssh`, to another agent's login, or into a folder that a VM can write, such as a dotfiles repo that is also a devvm project. Following such links unasked would let a mistaken link put a secret into every VM, and let a VM that writes the folder a link leads into change what every other VM's agent runs. That's why the import follows no link out of an agent's folder by default, and reads each folder through itself as an `os.Root` ([how](../internals/agents.md#links-out-of-an-agents-folder)).
|
||||
|
||||
Dotfiles repos keep settings as links all the same, and copying them into the store by hand is lost at the next import, so devvm follows them when you allow it, in two ways:
|
||||
|
||||
@@ -822,9 +831,9 @@ Whichever allows it, the same rules hold:
|
||||
|
||||
## Claude Code's plugins: a seed and a folder of the VM's own
|
||||
|
||||
Claude Code writes into its plugins folder whenever it runs: each plugin's data, which a plugin reaches as `${CLAUDE_PLUGIN_DATA}`, the plugins it installs, its marketplaces' copies and their updates, its MCP bundles and its records. devvm's agent store holds one plugins folder for every VM with Claude Code, mounted read-only, so if that folder were each VM's `~/.claude/plugins`, every one of those writes would fail: a plugin that keeps data would break, and no plugin could be installed in a VM. Making the store's folder writable would fix the writes, but every VM shares it, so a VM could then change the plugins, hooks and MCP servers' commands that Claude Code runs in every other VM, and keep a foothold in each of them after you delete it. That isn't an escape to this machine, but it breaks the line between VMs that the store's read-only mounts hold for every other agent folder.
|
||||
Claude Code writes into its plugins folder whenever it runs: each plugin's data, which a plugin reaches as `${CLAUDE_PLUGIN_DATA}`, the plugins it installs, its marketplaces' copies and their updates, its MCP bundles and its records. devvm's agent store holds one plugins folder for every VM with Claude Code, mounted read-only, so if that folder were each VM's `~/.claude/plugins`, every one of those writes would fail. A plugin that keeps data would break, and no plugin could be installed in a VM. Making the store's folder writable would fix the writes, but every VM shares it, so a VM could then change the plugins, hooks and MCP servers' commands that Claude Code runs in every other VM, and keep a foothold in each of them after you delete it. That isn't an escape to this machine, but it breaks the line between VMs that the store's read-only mounts hold for every other agent folder.
|
||||
|
||||
So each VM's plugins folder is its own, on its own disk, and the store's folder is Claude Code's seed, a plugins folder that Claude Code reads but never writes, which it supports for container images and CI ([how](agents.md#claude-codes-plugins)). Its two variables, `CLAUDE_CODE_PLUGIN_CACHE_DIR` and `CLAUDE_CODE_PLUGIN_SEED_DIR`, are Claude Code's own, so devvm patches nothing in Claude Code and copies nothing into the VM at a launch: the seed stays one mount that every VM reads. What a VM writes stays in that VM, and what it installed reaches the store, and every VM, only through `devvm agent save`, whose diff you read before you answer yes. The import and the save copy only the entries a seed has, the marketplaces' records, their copies and the plugins' cache, because the rest of the folder is each machine's own: each plugin's data can hold its own logins, and this machine's plugins' data in the store would reach every VM.
|
||||
So each VM's plugins folder is its own, on its own disk, and the store's folder is Claude Code's seed, a plugins folder that Claude Code reads but never writes, which it supports for container images and CI ([how](../internals/agents.md#claude-codes-plugins)). Its two variables, `CLAUDE_CODE_PLUGIN_CACHE_DIR` and `CLAUDE_CODE_PLUGIN_SEED_DIR`, are Claude Code's own, so devvm patches nothing in Claude Code and copies nothing into the VM at a launch, and the seed stays one mount that every VM reads. What a VM writes stays in that VM, and what it installed reaches the store, and every VM, only through `devvm agent save`, whose diff you read before you answer yes. The import and the save copy only the entries a seed has, the marketplaces' records, their copies and the plugins' cache, because the rest of the folder is each machine's own. Each plugin's data can hold its own logins, and this machine's plugins' data in the store would reach every VM.
|
||||
|
||||
The save never takes a plugin out of the store, because a VM's folder holds only what that VM installed, not the store's plugins, which it reads from the seed, so a plugin missing from it isn't one the VM removed. Taking out what the VM's folder lacks would empty the store of every plugin the VM didn't install itself. The VM's marketplaces' records join the store's for the same reason, and only a record whose copy is in the store's marketplaces folder joins, so the records that Claude Code made of the seed's own marketplaces stay as the store has them, and a record can't point other VMs elsewhere.
|
||||
|
||||
@@ -845,7 +854,7 @@ The save never takes a plugin out of the store, because a VM's folder holds only
|
||||
| A VM's paths in the records it saves | The records' paths to the VM's plugins folder are renamed to the store's, only a record whose copy is in the store's `marketplaces` by a clean path joins the store's, and a records file that isn't a JSON object is left out | `TestAgentSaveClaudePlugins` |
|
||||
| A name in the VM's plugins folder that the save's script would read as a pattern | It's sent rather than excluded, and devvm refuses the save | `TestAgentSaveScriptClaudePlugins` |
|
||||
| A plugin's data, or what a VM installed, reaching another VM through an export | The export and the import leave out the VM's plugins folder, and the import leaves out the seed's link | `TestClaudePluginsHistory` |
|
||||
| An export that names the VM's plugins folder another way, such as `.claude/./plugins`, past the import's excludes, now that the folder is writable | The import refuses a name with a `.`, `..` or empty part, and deletes what it leaves out by its path once unpacked; the review found it first, and it's fixed | `TestHistoryImportRuns` |
|
||||
| An export that names the VM's plugins folder another way, such as `.claude/./plugins`, past the import's excludes, as the folder is writable | The import refuses a name with a `.`, `..` or empty part, and deletes what it leaves out by its path once unpacked. The review found it first, and it's fixed | `TestHistoryImportRuns` |
|
||||
|
||||
## The 9p cache on Linux
|
||||
|
||||
@@ -873,33 +882,33 @@ On a Linux host, Lima's QEMU shares the project folder over 9p, and Lima mounts
|
||||
|
||||
## Linux hosts: overlays instead of copies
|
||||
|
||||
Lima on QEMU keeps one qcow2 disk per VM, and a clone copies it (2.0 GB for `base`). A project VM's disk is a qcow2 overlay of its image's instead ([details](lima.md#clones-and-overlays)): 196 KB new, 12 MB after booting, the same speed except fsync writes (1.8–2.5 s vs 1.2–2.1 s per GiB). Flattening one (`qemu-img rebase -b ""`) took 8 s, if it's ever needed.
|
||||
Lima on QEMU keeps one qcow2 disk per VM, and a clone copies it (2.0 GB for `base`). A project VM's disk is a qcow2 overlay of its image's instead ([details](../internals/lima.md#clones-and-overlays)): 196 KB new, 12 MB after booting, the same speed except fsync writes (1.8–2.5 s vs 1.2–2.1 s per GiB). Flattening one (`qemu-img rebase -b ""`) took 8 s, if it's ever needed.
|
||||
|
||||
## One binary
|
||||
|
||||
devvm's own files (`assets/` in the repo: `base.yaml`, `prelude.sh`, `layers/`, `features/`, `shared-tools/`, `network/`, `guest/`, `oci/`) are embedded in the binary (`assets.FS`), so devvm installs, moves and upgrades as one file and can't find a mismatched copy beside it. Code reads them from that file system; scripts reach VMs on their standard input, never by path or file mode. The binary is the only copy: no shared folder on disk holds devvm's files, because a copy there could be edited and still be used. A VM's proxy is devvm itself, so it reads its built-in policies from the binary (its config's `builtin_policies`, by name), once, and its `policies` carry only your files. `limactl create` reads `base.yaml` on its standard input (`-`). Only `--from`'s build on Lima needs a path, because its build VM mounts the conversion's scripts from `oci/` read-only (root there reads them), and none of the folder's other files, with `guest/ca.sh` beside it when you have [company CAs](network.md#a-companys-ca). It writes them into its own temporary folder, `devvm-oci.<random>`, beside `vm/` and never inside it, files 600 and folders 700, and the build's cleanup deletes the folder however the build ends. Image keys hash the embedded files, so what goes into an image is always what its key describes.
|
||||
devvm's own files (`assets/` in the repo: `base.yaml`, `prelude.sh`, `layers/`, `features/`, `shared-tools/`, `network/`, `guest/`, `oci/`) are embedded in the binary (`assets.FS`), so devvm installs, moves and upgrades as one file and can't find a mismatched copy beside it. Code reads them from that file system; scripts reach VMs on their standard input, never by path or file mode. The binary is the only copy: no shared folder on disk holds devvm's files, because a copy there could be edited and still be used. A VM's proxy is devvm itself, so it reads its built-in policies from the binary (its config's `builtin_policies`, by name), once, and its `policies` carry only your files. `limactl create` reads `base.yaml` on its standard input (`-`). Only `--from`'s build on Lima needs a path, because its build VM mounts the conversion's scripts from `oci/` read-only (root there reads them), and none of the folder's other files, with `guest/ca.sh` beside it when you have [company CAs](../internals/network.md#a-companys-ca). It writes them into its own temporary folder, `devvm-oci.<random>`, beside `vm/` and never inside it, files 600 and folders 700, and the build's cleanup deletes the folder however the build ends. Image keys hash the embedded files, so what goes into an image is always what its key describes.
|
||||
|
||||
## devvm's own Lima home
|
||||
|
||||
Lima merges `_config/default.yaml` and `override.yaml` of its home into every VM. In `~/.lima`, a `networks: [{vzNAT: true}]` there gave a confined VM a second network card with a default route around its proxy (the self-check caught it), and an extra mount went unnoticed. Hence a Lima home of devvm's own, which refuses those files and any network devvm didn't give a VM ([details](lima.md#a-lima-home-of-its-own)). The costs: plain `limactl list` doesn't show devvm's VMs, and VM names are shorter, as the path of Lima's ssh socket has fewer than 104 characters.
|
||||
Lima merges `_config/default.yaml` and `override.yaml` of its home into every VM. In `~/.lima`, a `networks: [{vzNAT: true}]` there gave a confined VM a second network card with a default route around its proxy (the self-check caught it), and an extra mount went unnoticed. Hence a Lima home of devvm's own, which refuses those files and any network devvm didn't give a VM ([details](../internals/lima.md#a-lima-home-of-its-own)). The costs: plain `limactl list` doesn't show devvm's VMs, and VM names are shorter, as the path of Lima's ssh socket has fewer than 104 characters.
|
||||
|
||||
## The state layout
|
||||
|
||||
devvm keeps its state in plain files in two folders, which [State files](overview.md#state-files) describes. The layout follows a few rules:
|
||||
devvm keeps its state in plain files in two folders, which [State files](../internals/overview.md#state-files) describes. The layout follows a few rules:
|
||||
|
||||
- **One folder per VM, keyed by identity.** A VM's folder, `vms/<hash>/`, is named by the hash that ends the VM's name, the hash of its project folder's physical path when devvm made it. The VM's name, its backend and its ssh alias are chosen once, when devvm makes the VM, and recorded in its state, so devvm finds a folder's VM by the state that records the folder, first by the path's hash, then reads the name and the backend from the state. A folder that moves keeps its VM, whose state records the new path while its name and folder stay ([a moved folder](overview.md#a-moved-folder)). A backend's limit on names, or another VM taking the same folder name, never changes which VM a folder finds. Every file devvm keeps for a VM is in its folder, so deleting a VM stops what runs for it, removes what it has outside the folder, and then deletes the folder whole, and `devvm space` and `devvm gc` count folders. A list of a VM's files, kept in each place that deletes or counts them, would drift, and one of those places would miss a file. Only sockets stay outside, in `run/` and named by hashes, because a socket's path has fewer than 104 characters.
|
||||
- **One folder per VM, keyed by identity.** A VM's folder, `vms/<hash>/`, is named by the hash that ends the VM's name, the hash of its project folder's physical path when devvm made it. The VM's name, its backend and its ssh alias are chosen once, when devvm makes the VM, and recorded in its state, so devvm finds a folder's VM by the state that records the folder, first by the path's hash, then reads the name and the backend from the state. A folder that moves keeps its VM, whose state records the new path while its name and folder stay ([a moved folder](../internals/overview.md#a-moved-folder)). A backend's limit on names, or another VM taking the same folder name, never changes which VM a folder finds. Every file devvm keeps for a VM is in its folder, so deleting a VM stops what runs for it, removes what it has outside the folder, and then deletes the folder whole, and `devvm space` and `devvm gc` count folders. A list of a VM's files, kept in each place that deletes or counts them, would drift, and one of those places would miss a file. Only sockets stay outside, in `run/` and named by hashes, because a socket's path has fewer than 104 characters.
|
||||
- **The folder says who writes a file.** `~/.config/devvm` holds what you write, and devvm never rewrites a file of yours there: it changes single lines of `policy` and keeps the rest, comments included, and it writes the folder's `version`. Everything devvm writes is in `~/.local/share/devvm`. A default comes from a flag, then `config.toml`, then `settings.json`, then devvm's own, and a command that would save a default that `config.toml` sets refuses, naming the file and the key, because the saved value would never apply.
|
||||
- **Two formats.** What you edit is TOML, read strictly, so a typo stops the command and devvm names the file and the line, rather than the key being ignored. What only devvm writes is JSON, through `encoding/json`, and devvm ignores fields it doesn't know, so a newer devvm's additions don't stop an older one. A change that an older devvm would read wrongly goes through the layout version instead.
|
||||
- **One section per package.** `vm.json` has the core fields every VM has, and each package that keeps something of a VM's owns one section of it, with its own type, so `internal/state` imports none of them. Each section keeps what you asked for apart from what devvm made, which sits under `made`, so a value is never stored twice under two names.
|
||||
- **The lock rule.** Each change to a VM's state holds that VM's lock, reads the file again, and writes it once, so a command's changes land together, and reads take no lock, because each write renames a whole file over the old one. A command holds at most one VM's lock at a time. A change across VMs, such as removing every link to a VM being deleted, lets go of the first VM's lock, then takes each other VM's lock in turn and reads its state again before writing it. The claims lock is taken only after a VM's own lock, never before, so no two devvms can each wait for the lock the other holds. Test builds and the tests check this order as each lock is taken (`internal/state`'s `held`): a second VM's lock, a VM's lock under the claims lock, or a lock the same goroutine holds already panics, naming both locks, before it waits. The check is per goroutine: it follows the locks each goroutine holds, by the goroutine's number, which it reads from the goroutine's stack, so two goroutines that each hold one VM's lock pass, and a goroutine that a change starts while it holds a lock isn't checked against that lock. A release build checks nothing.
|
||||
- **A layout version.** Each folder records its layout version in `version`. A newer devvm that changes the layout raises it and adds a migration from the version before, an older layout is migrated before a command runs, and a newer one is refused, because this devvm would read it wrongly. `testdata/script/layout.txtar` lists every file and folder a confined VM, a port, a link and a secret leaves, so a change to the layout changes a listing and fails the test until someone decides whether it needs a new version ([changing the state layout](../contributing/structure.md#changing-the-state-layout)).
|
||||
- **The lock rule.** Each change to a VM's state holds that VM's lock, reads the file again, and writes it once, so a command's changes land together, and reads take no lock, because each write renames a whole file over the old one. A command holds at most one VM's lock at a time. A change across VMs, such as removing every link to a VM being deleted, lets go of the first VM's lock, then takes each other VM's lock in turn and reads its state again before writing it. The claims lock is taken only after a VM's own lock, never before, so no two devvms can each wait for the lock the other holds. Test builds and the tests check this order as each lock is taken (`internal/state`'s `held`): a second VM's lock, a VM's lock under the claims lock, or a lock the same goroutine holds already panics, naming both locks, before it waits. The check is per goroutine. It follows the locks each goroutine holds, by the goroutine's number, which it reads from the goroutine's stack, so two goroutines that each hold one VM's lock pass, and a goroutine that a change starts while it holds a lock isn't checked against that lock. A release build checks nothing.
|
||||
- **A layout version.** Each folder records its layout version in `version`. A newer devvm that changes the layout raises it and adds a migration from the version before, an older layout is migrated before a command runs, and a newer one is refused, because this devvm would read it wrongly. `testdata/script/layout.txtar` lists every file and folder a confined VM, a port, a link and a secret leaves, so a change to the layout changes a listing and fails the test until someone decides whether it needs a new version ([changing the state layout](structure.md#changing-the-state-layout)).
|
||||
- **devvm's own files stay in the binary,** as [one binary](#one-binary) describes, so neither folder holds a copy of `assets/`.
|
||||
|
||||
**Why not a database.** SQLite or bbolt would give transactions, but either one is a new dependency, and devvm builds without cgo, so SQLite would mean a large pure-Go port. State would also stop being files that you can read with `cat` or `jq`, back up, and check by hand. Files written whole and renamed into place, with an OS file lock for each VM, give what devvm needs: one writer to a VM at a time, and readers that never see half a file.
|
||||
|
||||
## Where secret values live
|
||||
|
||||
devvm handles values that let whoever holds them act as you or as a VM: a VM's proxy password, a build proxy's, the company proxy's password, the secrets you save and the keys and tokens in agents' login files. Each one lives in a few places, and only there: the Keychain or the secret's file in `~/.local/share/devvm/secrets/`, the proxy's `proxy.json`, the VM's `vm.json` for its proxy password, the agent store's login files, the proxy's memory for the values it caches, and the VM's own proxy settings for its password, which the VM must send. In devvm's code, each such value is a `redact.Secret` from the moment it's read until the place it's used, but for the two that **Not covered** names ([secrets in the code](../contributing/structure.md#secrets-in-the-code)).
|
||||
devvm handles values that let whoever holds them act as you or as a VM: a VM's proxy password, a build proxy's, the company proxy's password, the secrets you save and the keys and tokens in agents' login files. Each one lives in a few places, and only there: the Keychain or the secret's file in `~/.local/share/devvm/secrets/`, the proxy's `proxy.json`, the VM's `vm.json` for its proxy password, the agent store's login files, the proxy's memory for the values it caches, and the VM's own proxy settings for its password, which the VM must send. In devvm's code, each such value is a `redact.Secret` from the moment it's read until the place it's used, except for the two that **Not covered** names ([secrets in the code](structure.md#secrets-in-the-code)).
|
||||
|
||||
- **Printing never shows the value.** `String`, `GoString` and `Format` write `<redacted>` for every verb, so a `%v` of a struct in an error, a log line in the proxy's own log or a line of devvm's run log can't hold it. `fmt` can't call `Format` on a value in an unexported field, and prints such a field as it is, so the value is behind a pointer, and the field shows only its address. The run log's own redaction, `redact.String`, still takes proxy keys and URL passwords out of the output of the commands devvm runs, which no type can reach.
|
||||
- **Encoding fails rather than writing a stand-in.** `MarshalJSON` and `MarshalText` return `redact.ErrEncode`. A `MarshalJSON` that wrote `<redacted>` would look safe, but a struct written to the file that should hold the value, such as `proxy.json` or `vm.json`, would then lose it, and a VM would lose its proxy or you your login, with no error. A file that holds a value has a wire type of its own instead, which writes the value as a string, so the two kinds of file can't be confused.
|
||||
@@ -915,9 +924,9 @@ The wire types keep each file's bytes as they were, so a frozen release's `proxy
|
||||
|
||||
## The proxy's broker
|
||||
|
||||
A VM's proxy reads every byte the VM sends out, and it runs as you, with your Keychain, your files and every socket of yours. A bug in it that a VM could drive, such as a parser that a crafted request takes over or a path that leads out of its folder, would reach all of that. So `devvm _proxy` is split in two: a broker, which keeps what only the host should do and stays unconfined, and a child, which reads the VM's network and can be confined. The design keeps four things: a child that a VM takes over holds nothing of this machine's beyond what it held for that VM, it can't make the broker act for another VM, another secret or another file, it connects to no address that the VM's rules and the floor refuse, such as this machine's loopback, but for what a company proxy reaches for it, and the VM's connections stay the child's: of each request, only the host name it looks up and the address it connects to cross to the broker, which opens the connection and hands it to the child, so no byte the connection carries passes through the broker, and of a request's own bytes, only a login's token exchange reaches it, as captures in the broker below describe. [Processes](processes.md#a-vms-proxy) describes the two processes as they run, and this note is their design, with its threat check. On macOS the child runs under Seatbelt, and on Linux it confines itself with Landlock and a seccomp filter ([the child's sandbox](network.md#the-childs-sandbox)), and on both its sandbox refuses it every connection of its own, so the broker looks up each name and opens each connection that the child asks for, once its own policy and floor allow the address.
|
||||
A VM's proxy reads every byte the VM sends out, and it runs as you, with your Keychain, your files and every socket of yours. A bug in it that a VM could drive, such as a parser that a crafted request takes over or a path that leads out of its folder, would reach all of that. So `devvm _proxy` is split in two: a broker, which keeps what only the host should do and stays unconfined, and a child, which reads the VM's network and can be confined. The design keeps four things. A child that a VM takes over holds nothing of this machine's beyond what it held for that VM. It can't make the broker act for another VM, another secret or another file. It connects to no address that the VM's rules and the floor refuse, such as this machine's loopback, except for what a company proxy reaches for it. And the VM's connections stay the child's. Of each request, only the host name it looks up and the address it connects to cross to the broker, which opens the connection and hands it to the child, so no byte that the connection carries passes through the broker. Of a request's own bytes, only a login's token exchange reaches the broker, as captures in the broker below describe. [Processes](../internals/processes.md#a-vms-proxy) describes the two processes as they run, and this note is their design, with its threat check. On macOS the child runs under Seatbelt, and on Linux it confines itself with Landlock and a seccomp filter ([the child's sandbox](../internals/network.md#the-childs-sandbox)), and on both its sandbox refuses it every connection of its own, so the broker looks up each name and opens each connection that the child asks for, once its own policy and floor allow the address.
|
||||
|
||||
**Why a broker, and not values handed over at the start:** the proxy looks each bound value up when a request needs it, in the Keychain, devvm's secrets folder or an agent's login file, which it refreshes on the host when it's due ([how the proxy puts them in](network.md#how-the-proxy-puts-them-in)). A login's value changes with each refresh, and the proxy keeps it for 30 seconds, and any other value for 5 minutes. The proxy also saves the logins that a VM makes, and writes the VM's bindings again. Values handed over once would be stale within the minute, and the child would need to write the store of logins. So the broker runs beside the child for as long as it does, and answers its questions.
|
||||
**Why a broker, and not values handed over at the start:** the proxy looks each bound value up when a request needs it, in the Keychain, devvm's secrets folder or an agent's login file, which it refreshes on the host when it's due ([how the proxy puts them in](../internals/network.md#how-the-proxy-puts-them-in)). A login's value changes with each refresh, and the proxy keeps it for 30 seconds, and any other value for 5 minutes. The proxy also saves the logins that a VM makes, and writes the VM's bindings again. Values handed over once would be stale within the minute, and the child would need to write the store of logins. So the broker runs beside the child for as long as it does, and answers its questions.
|
||||
|
||||
**What runs where:**
|
||||
|
||||
@@ -937,14 +946,14 @@ A VM's proxy reads every byte the VM sends out, and it runs as you, with your Ke
|
||||
| `proxy.json`, the CAs' files, the lifeline, the status file and the pid file | broker | the child gets what it needs of them over the socket, so it needs no read of the VM's run folder |
|
||||
| The files that change while the proxy runs: the policy files, the bindings file and the links' list | the child looks at them, the broker reads them | below |
|
||||
|
||||
**The files that change.** The proxy reads each of these files again when its modification time, size or inode changes, which it checks with a `stat` on every request. The child keeps that check, because Landlock leaves `stat` unrestricted and Seatbelt can allow it alone (`file-read-metadata`), and asks the broker for the file only when it has changed. The broker reads the file with the same checks as the proxy does now, its owner, its mode, at most 1 MiB, and a symbolic link followed or refused as each file allows, and returns its bytes with the stamp of the file it read. The child parses them as it does now and keeps that stamp, so a change still applies to the next request, and an unchanged file costs no hop. Both write `proxy.log`, each line saying which side wrote it. A rotation takes the file's lock and checks its size again, as the event log's does, so the two writers rotate it once, and the broker reads, copies and empties the file through the descriptor it was given, never by its path.
|
||||
**The files that change.** The proxy reads each of these files again when its modification time, size or inode changes, which it checks with a `stat` on every request. The child keeps that check, because Landlock leaves `stat` unrestricted and Seatbelt can allow it alone (`file-read-metadata`), and asks the broker for the file only when it has changed. The broker reads the file with the proxy's usual checks, its owner, its mode, at most 1 MiB, and a symbolic link followed or refused as each file allows, and returns its bytes with the stamp of the file it read. The child parses them and keeps that stamp, so a change still applies to the next request, and an unchanged file costs no hop. Both write `proxy.log`, each line saying which side wrote it. A rotation takes the file's lock and checks its size again, as the event log's does, so the two writers rotate it once, and the broker reads, copies and empties the file through the descriptor it was given, never by its path.
|
||||
|
||||
**The folders the child writes are the VM's.** A child that a VM takes over can put anything in the folders it writes, so the unconfined code that later opens them reads them as it reads a file a VM can write. The child may create regular files alone there. On Linux it never gets Landlock's rights to make a link, a FIFO, a socket, a device or a folder, and the Nix cache's `nar/` folder is made before it confines itself. On macOS its profile refuses creating anything but a regular file, and hard links, which the follow-up checks there. devvm, `devvm _links`, `devvm network log`, `devvm network lock`, the port forwarder, the link session, devvm gc's trim of the Nix cache and the cache's lock open, rename, empty, change and delete files in those folders through `internal/safefile`, never following a link and taking only a regular file with one link that's yours, or through an `os.Root` of the folder. The broker makes the cache's `nar/` folder and sets both folders' modes the same way (`makeNixFolders`), deleting anything at `nar/` that isn't a folder, a link as itself, and making a folder in its place, which its log warns of, so its `chmod` never reaches a folder of yours. A confined child can't leave a link there; this is for one that runs without Landlock or Seatbelt. So a link that a child leaves where `proxy.log`, `network.jsonl`, `links.log`, `ports.log` or `nar/` was never leads devvm to your files, and a FIFO there never hangs a command. A build's child writes `events.jsonl` and `proxy.log` in a `logs/` folder of its own inside the build proxy's folder, apart from its config, its policy and its status file.
|
||||
**The folders the child writes are the VM's.** A child that a VM takes over can put anything in the folders it writes, so the unconfined code that later opens them reads them as it reads a file a VM can write. The child may create only regular files there. On Linux it never gets Landlock's rights to make a link, a FIFO, a socket, a device or a folder, and the Nix cache's `nar/` folder is made before it confines itself. On macOS its profile refuses creating anything but a regular file, and hard links, which the follow-up checks there. devvm, `devvm _links`, `devvm network log`, `devvm network lock`, the port forwarder, the link session, devvm gc's trim of the Nix cache and the cache's lock open, rename, empty, change and delete files in those folders through `internal/safefile`, never following a link and taking only a regular file with one link that's yours, or through an `os.Root` of the folder. The broker makes the cache's `nar/` folder and sets both folders' modes the same way (`makeNixFolders`), deleting anything at `nar/` that isn't a folder, a link as itself, and making a folder in its place, which its log warns of, so its `chmod` never reaches a folder of yours. A confined child can't leave a link there, so this is for one that runs without Landlock or Seatbelt. So a link that a child leaves where `proxy.log`, `network.jsonl`, `links.log`, `ports.log` or `nar/` was never leads devvm to your files, and a FIFO there never hangs a command. A build's child writes `events.jsonl` and `proxy.log` in a `logs/` folder of its own inside the build proxy's folder, apart from its config, its policy and its status file.
|
||||
|
||||
**What the child needs,** which what confines it holds it to:
|
||||
|
||||
- **Its descriptors:** standard input from the null device, `proxy.log` as its output and its error output, the socket to the broker as descriptor 3, and the VM's proxy port's listener, which the broker opened, as descriptor 4.
|
||||
- **Its environment:** `TZ`, `SSL_CERT_FILE` and `SSL_CERT_DIR` when devvm has them, so the roots it trusts on Linux are the ones the proxy trusts now, and `GODEBUG`, to which it adds `updatemaxprocs=0`, so Go's runtime doesn't read its cgroup's CPU limit again as it runs. It gets nothing else, so it never sees a token in the environment of the shell that started devvm, or the status file's name.
|
||||
- **Its environment:** `TZ`, `SSL_CERT_FILE` and `SSL_CERT_DIR` when devvm has them, so the roots it trusts on Linux are the proxy's usual ones, and `GODEBUG`, to which it adds `updatemaxprocs=0`, so Go's runtime doesn't read its cgroup's CPU limit again as it runs. It gets nothing else, so it never sees a token in the environment of the shell that started devvm, or the status file's name.
|
||||
- **Files to read and write:** the VM's logs folder, `vms/<hash>/logs/`, where it creates, appends to, reads, empties and renames its two logs and takes the event log's lock, which `devvm _links` takes too, and for a VM with the nix layer, the shared Nix cache, `cache/nix-cache/` and its `nar/` folder, where it creates, writes, reads, lists, deletes and renames regular files, from the top folder into `nar/` among them, and takes `.lock`. A build's child writes its own `logs/` folder instead.
|
||||
- **Files to look at only:** the policy files, the bindings file and the links' list, with `stat`.
|
||||
- **What the system gives it:** what a Go program reads to start, the system's roots, its time zone, and the host's own addresses. On Linux, it loads the roots and its time zone before it confines itself. On macOS, `crypto/x509` asks `trustd` through `com.apple.trustd.agent`, after CoreFoundation looks at the metadata of the program's folder for its bundle. The floor reads the host's addresses every 30 seconds (`hostAddrs`), through a netlink route socket on Linux and the route `sysctl` on macOS. It needs no resolver, because the broker looks up its names.
|
||||
@@ -965,69 +974,69 @@ The floor fails open if it reads no addresses for the host, because `hostAddrs`
|
||||
| `dial` | an address and a port, or which company proxy, `https` or `http` | a TCP connection to it, as the frame's one descriptor, or an error |
|
||||
| `cancel` | the ID of a `lookup` or a `dial` it gave up on, as the frame's own | nothing of its own: that request ends with an error |
|
||||
|
||||
Only a `lookup` and a `dial` can be cancelled, with a `cancel` frame of the request's ID, below. A value's lookup and a token exchange run to their 20 seconds whatever happens to the VM's request, as they do now, so the broker keeps a value it looked up for the next request. The child stops waiting for a reply once its request has ended, drops the reply when it comes, and holds the request's place under its type's cap until then, so it never has more under way than the broker allows, and it closes a link's or a dial's connection that it no longer wants. A reply that wouldn't fit in a frame is sent as an error instead, so no request waits for one that never comes, and the few headers a token's reply keeps are 1 KiB each at most. An error reaches the child as one of a few codes, `not_found`, `refused`, `busy`, `too_long` or `failed`, or for a `lookup`, `no_such_host`, `timeout` or `temporary`, which the child turns back into the resolver's error that its block's reason and its second try need, and the broker's own log keeps its text, which can name a lookup's or an endpoint's details. The broker's start frame has the start's deadline to be written, so a child that never reads can't hold the broker either.
|
||||
Only a `lookup` and a `dial` can be cancelled, with a `cancel` frame of the request's ID, below. A value's lookup and a token exchange run to their 20 seconds whatever happens to the VM's request, so the broker keeps a value it looked up for the next request. The child stops waiting for a reply once its request has ended, drops the reply when it comes, and holds the request's place under its type's cap until then, so it never has more under way than the broker allows, and it closes a link's or a dial's connection that it no longer wants. A reply that wouldn't fit in a frame is sent as an error instead, so no request waits for one that never comes, and the few headers a token's reply keeps are 1 KiB each at most. An error reaches the child as one of a few codes, `not_found`, `refused`, `busy`, `too_long` or `failed`, or for a `lookup`, `no_such_host`, `timeout` or `temporary`, which the child turns back into the resolver's error that its block's reason and its second try need, and the broker's own log keeps its text, which can name a lookup's or an endpoint's details. The broker's start frame has the start's deadline to be written, so a child that never reads can't hold the broker either.
|
||||
|
||||
**Bounds, and failing closed.** The broker serves one `value` at a time, as lookups go one at a time now, at most 8 `token`s at once, as `captureReads` allows, 4 `file`s, 256 `link`s, which is the link session's own cap on a client's connections, 256 `lookup`s and 1024 `dial`s, as many as the child's tunnels at once (`maxConnects`). It answers a request past its cap with an error, which a child that keeps the same caps never gets, because the broker gives a request's place back as its reply starts to go, before the child can send the next. A reply that waits for the socket keeps its place, so a child that stops reading holds no more of the broker's answers than the caps. It keeps each value it looked up for as long as the proxy keeps it now, so a child that asks again and again makes the broker look a binding up at most once in 30 seconds or 5 minutes, and on macOS run `security` that often. It keeps a failed lookup for 5 seconds, so a child can't make it run `security` or try a refresh back to back. The child keeps a value only until the broker's lookup is that old, so no value is kept longer than it is now. The broker keeps its own watch on the bindings file, the links' list and the policy files, as the proxy does now (`watched`), looking at the first two on every `value`, `link` and `token` request, and at the policy files on every `dial`, whatever the child asks, so a binding or a link that devvm takes away is gone for the next request, and a change to the bindings file drops the broker's values and its failed lookups, as it drops the proxy's values now, so a secret set right after a failure goes in at the next request. Some frames end the pair: one over 2 MiB, one that isn't JSON or has a type or a field that the version doesn't know, a second `start`, a reply to no request, a frame that carries a descriptor from the child, and a `ready` whose version or executable's SHA-256 differs. The child takes a descriptor only with a `link` or `dial` reply that says it carries one, and closes any other. For each, the broker stops the child, logs the rule the frame broke but never its bytes, and exits, and the VM has no network until devvm starts its proxy again. A request that the broker refuses, such as one for a binding that isn't in the file, gets an error instead, which the child handles as it handles a failed lookup now: no value goes in, a capture gets `502`, a link gets `link_refused`, a name that the broker can't look up gets the block it gets now, and a connection that the broker refuses or can't open gets `connect failed`.
|
||||
**Bounds, and failing closed.** The broker serves one `value` at a time, as the proxy's lookups go one at a time, at most 8 `token`s at once, as `captureReads` allows, 4 `file`s, 256 `link`s, which is the link session's own cap on a client's connections, 256 `lookup`s and 1024 `dial`s, as many as the child's tunnels at once (`maxConnects`). It answers a request past its cap with an error, which a child that keeps the same caps never gets, because the broker gives a request's place back as its reply starts to go, before the child can send the next. A reply that waits for the socket keeps its place, so a child that stops reading holds no more of the broker's answers than the caps. It keeps each value it looked up for as long as the proxy keeps it, so a child that asks again and again makes the broker look a binding up at most once in 30 seconds or 5 minutes, and on macOS run `security` that often. It keeps a failed lookup for 5 seconds, so a child can't make it run `security` or try a refresh back to back. The child keeps a value only until the broker's lookup is that old, so no value is kept longer than the broker keeps it. The broker keeps its own watch on the bindings file, the links' list and the policy files, as the proxy does (`watched`), looking at the first two on every `value`, `link` and `token` request, and at the policy files on every `dial`, whatever the child asks, so a binding or a link that devvm takes away is gone for the next request, and a change to the bindings file drops the broker's values and its failed lookups, as it drops the proxy's values, so a secret set right after a failure goes in at the next request. Some frames end the pair: one over 2 MiB, one that isn't JSON or has a type or a field that the version doesn't know, a second `start`, a reply to no request, a frame that carries a descriptor from the child, and a `ready` whose version or executable's SHA-256 differs. The child takes a descriptor only with a `link` or `dial` reply that says it carries one, and closes any other. For each, the broker stops the child, logs the rule the frame broke but never its bytes, and exits, and the VM has no network until devvm starts its proxy again. A request that the broker refuses, such as one for a binding that isn't in the file, gets an error instead, which the child handles as it handles a failed lookup. No value goes in, a capture gets `502`, a link gets `link_refused`, a name that the broker can't look up gets the block of any name that doesn't resolve, and a connection that the broker refuses or can't open gets `connect failed`.
|
||||
|
||||
**Naming nothing but its own VM's.** Every request names something in the broker's own config, which is one VM's, so the child can't reach another VM's binding, any other secret or any file:
|
||||
|
||||
- **`value`:** the broker finds the key in its own read of the bindings file that its config names, and looks the value up with its own copy of that binding, never the child's, so the binding's `id` and its methods are checked as they are now (`fits`). A key that the file doesn't hold now gets an error, the company proxy's secret's included, which no binding names.
|
||||
- **`value`:** the broker finds the key in its own read of the bindings file that its config names, and looks the value up with its own copy of that binding, never the child's, so the binding's `id` and its methods are checked as for any binding (`fits`). A key that the file doesn't hold now gets an error, the company proxy's secret's included, which no binding names.
|
||||
- **`file`:** a number in the broker's list, which is the bindings file, the links' list and the policy files in the config's order, so no path crosses the socket.
|
||||
- **`link`:** the broker finds the host and port in its own read of the links' list (`links.find`), and connects to `LinkSocket` of its run folder, its VM, the entry's address and its port, only for an address in `127.77.0.0/16`, trying a few times for a full backlog as the proxy does now.
|
||||
- **`link`:** the broker finds the host and port in its own read of the links' list (`links.find`), and connects to `LinkSocket` of its run folder, its VM, the entry's address and its port, only for an address in `127.77.0.0/16`, trying a few times for a full backlog as the proxy does.
|
||||
- **`token`:** the broker finds the endpoints in its own `captures` that the host, the path and the method match, which gives the agents, refuses a request that matches none, and puts in the VM's name itself (`Exchange.VM`).
|
||||
- **`lookup`:** the broker takes only a host name in the proxy's own form (`NormHost`, `HostOK`), with its trailing dot, and no address, and looks it up as the proxy does now, so a child learns no more than it could ask this machine's resolver.
|
||||
- **`lookup`:** the broker takes only a host name in the proxy's own form (`NormHost`, `HostOK`), with its trailing dot, and no address, and looks it up as the proxy does, so a child learns no more than it could ask this machine's resolver.
|
||||
- **`dial`:** the broker connects to an address only once its own read of the VM's policy files and its own read of the host's addresses allow it, as the floor does, and to a company proxy only at the address of its own config.
|
||||
|
||||
**Captures in the broker.** For a captured request, the child does what the proxy does now up to the request's body: it judges the host and the request by the VM's rules, intercepts it and reads the body. Then it sends the request in `token`. The broker runs `IO.Capture`'s `Request`, and sends the request to the endpoint's host from its own config, on port 443, through the company proxy when there is one, and trusting the system's roots and `upstream_cas`, as an OAuth refresh does now. It reads the reply, runs `Response` and returns what the VM gets. The broker keeps what the proxy does now with a captured request: it drops a `1xx`, refuses an upgrade, leaves gzip to Go's transport, sends the VM's headers on without the hop-by-hop ones and `Proxy-Authorization`, takes a successful reply of at most 1 MiB and returns only `keepHeaders`' headers with it. It returns an error reply as it is, up to the same 1 MiB, where the proxy now streams one through, and gives one that's longer a `502`. An error reply to a request whose body `Request` changed comes back as its OAuth error code alone (`errorReply`). The child logs the `login` event, naming the agent that the broker returned, and `guard` stays in the child, for the host's other replies. So the real tokens in an endpoint's reply, a new login's refresh token among them, and the `id_token` that `Request` puts into Codex's API-key exchange, never enter the child, and a child can't save tokens that the endpoint didn't issue.
|
||||
**Captures in the broker.** For a captured request, the child does what the proxy does for any request up to the request's body. It judges the host and the request by the VM's rules, intercepts it and reads the body. Then it sends the request in `token`. The broker runs `IO.Capture`'s `Request`, and sends the request to the endpoint's host from its own config, on port 443, through the company proxy when there is one, and trusting the system's roots and `upstream_cas`, as an OAuth refresh does. It reads the reply, runs `Response` and returns what the VM gets. The broker does what the proxy does with a captured request. It drops a `1xx`, refuses an upgrade, leaves gzip to Go's transport, sends the VM's headers on without the hop-by-hop ones and `Proxy-Authorization`, takes a successful reply of at most 1 MiB and returns only `keepHeaders`' headers with it. It returns an error reply as it is, up to the same 1 MiB, rather than streaming it through, and gives one that's longer a `502`. An error reply to a request whose body `Request` changed comes back as its OAuth error code alone (`errorReply`). The child logs the `login` event, naming the agent that the broker returned, and `guard` stays in the child, for the host's other replies. So the real tokens in an endpoint's reply, a new login's refresh token among them, and the `id_token` that `Request` puts into Codex's API-key exchange, never enter the child, and a child can't save tokens that the endpoint didn't issue.
|
||||
|
||||
**Connections through the broker.** The child judges each request as the proxy does now: the VM's rules, then the floor, which looks the name up and keeps the addresses that aren't internal or that a rule names. It asks the broker for each lookup, and then for a connection to each address it kept, one at a time, as it dials them now, or for a connection to the company proxy when one applies. The broker answers a `dial` for an address only when that address passes its own copy of the floor's check: no deny names it, and it's neither internal nor this machine's own, or a rule names it, by the broker's own read of the VM's built-in policies, its policy files, which it looks at on every `dial`, and the host's addresses, which it reads every 30 seconds, or the config says the VM is open. Then it connects over TCP, with the proxy's 15-second timeout, and hands the connection to the child as it hands a link's. So a child that a VM takes over connects to this machine's loopback, its own addresses and the private and link-local ranges only where a rule names the address, as the VM does, and it reaches the internet as it does now. Two ways stay open, as they do for the VM: a company proxy, which the child speaks to with its password and which reaches whatever it reaches, this machine's loopback included when it runs on this machine, and a host on this machine's network whose address is public, such as a neighbour's global IPv6 address, which the floor counts as the internet.
|
||||
**Connections through the broker.** The child judges each request as the proxy does, by the VM's rules, then the floor, which looks the name up and keeps the addresses that aren't internal or that a rule names. It asks the broker for each lookup, and then for a connection to each address it kept, one at a time, as the proxy dials them, or for a connection to the company proxy when one applies. The broker answers a `dial` for an address only when that address passes its own copy of the floor's check: no deny names it, and it's neither internal nor this machine's own, or a rule names it, by the broker's own read of the VM's built-in policies, its policy files, which it looks at on every `dial`, and the host's addresses, which it reads every 30 seconds, or the config says the VM is open. Then it connects over TCP, with the proxy's 15-second timeout, and hands the connection to the child as it hands a link's. So a child that a VM takes over connects to this machine's loopback, its own addresses and the private and link-local ranges only where a rule names the address, as the VM does, and it reaches the internet as the VM does. Two ways stay open, as they do for the VM: a company proxy, which the child speaks to with its password and which reaches whatever it reaches, this machine's loopback included when it runs on this machine, and a host on this machine's network whose address is public, such as a neighbour's global IPv6 address, which the floor counts as the internet.
|
||||
|
||||
- **A rule applies from the next connection,** as it does now: `devvm network allow 127.0.0.1:5432` changes the policy file, the child sees its new stamp at the next request and asks for it, and the broker's own look at the file at the `dial` that follows sees it too. A rule taken away is gone for the broker's next `dial` as well, so a connection opened as a rule goes may fail, but never one that no rule allowed. The broker also looks at its own copy of the policy files at each `file` request for one of them, so its copy is never older than what it gave the child, but in the moment between the two looks. A rule for a name, such as `localhost:5432`, judges the name, and the floor needs a rule for the address too, such as `127.0.0.1:5432`, as it does now.
|
||||
- **A rule applies from the next connection.** `devvm network allow 127.0.0.1:5432` changes the policy file, the child sees its new stamp at the next request and asks for it, and the broker's own look at the file at the `dial` that follows sees it too. A rule taken away is gone for the broker's next `dial` as well, so a connection opened as a rule goes may fail, but never one that no rule allowed. The broker also looks at its own copy of the policy files at each `file` request for one of them, so its copy is never older than what it gave the child, but in the moment between the two looks. A rule for a name, such as `localhost:5432`, judges the name, and the floor needs a rule for the address too, such as `127.0.0.1:5432`.
|
||||
- **Which addresses:** the broker judges each address as the floor does, unmapped, so an IPv4-mapped `::ffff:127.0.0.1` is `127.0.0.1`, a NAT64 or 6to4 address is judged by the IPv4 address in it, `::1` and every address in `127.0.0.0/8` are loopback, and `0.0.0.0` and `::`, which reach this machine's own services, are internal. It refuses an address with a zone, such as `fe80::1%en0`, which no rule can name, and a port outside 1 to 65535.
|
||||
- **The company proxy:** the child asks for `https`'s or `http`'s, and the broker connects to the address in its own config, by name, through the system's resolver, so a company proxy on this machine's loopback, such as a VPN client's, works as it does now, and the child can name no other address that way. The child still speaks `CONNECT` and plain HTTP to it, with its password, so the company proxy, not the broker, decides where those go.
|
||||
- **The company proxy:** the child asks for `https`'s or `http`'s, and the broker connects to the address in its own config, by name, through the system's resolver, so a company proxy on this machine's loopback, such as a VPN client's, works, and the child can name no other address that way. The child still speaks `CONNECT` and plain HTTP to it, with its password, so the company proxy, not the broker, decides where those go.
|
||||
- **The host's addresses:** the broker reads them before it starts the child, and a read that fails or finds none fails the start, as the child's own check does, and a later read that fails keeps the last good one.
|
||||
- **A request given up on:** the child sends `cancel` with a `lookup`'s or a `dial`'s ID once the VM's request has ended, or a lookup's own deadline has passed, and the broker ends that lookup or connection, answers it with an error and frees its place, so slots that a VM's abandoned requests held don't fill the caps. A `cancel` gets no answer of its own, and one for an ID that isn't under way is dropped.
|
||||
- **Lookups:** the broker looks each name up through this machine's resolver, as the proxy does now, so the child sends no DNS, and a resolver on this machine's loopback, such as systemd-resolved's `127.0.0.53` or a `dnsmasq` on `127.0.0.1`, answers the broker. The child sends no UDP at all.
|
||||
- **Lookups:** the broker looks each name up through this machine's resolver, as the proxy does, so the child sends no DNS, and a resolver on this machine's loopback, such as systemd-resolved's `127.0.0.53` or a `dnsmasq` on `127.0.0.1`, answers the broker. The child sends no UDP at all.
|
||||
- **What doesn't change:** the open tier's broker allows every address, as the floor does there. Transparent mode's connections, the Nix cache's fetches and the connections that put a value in go through the same `dial`. A link's connection is the broker's already, through its `link` request, and a capture's token request is the broker's own.
|
||||
- **The sandboxes:** on macOS the child's profile allows no network out at all, neither TCP nor UDP to any address, nor any unix socket, and Seatbelt checks every `connect` and every send with an address, while writes on a connection it accepted or was handed need no rule. On Linux, Landlock from ABI 4 refuses every TCP `connect`, and from ABI 10 every UDP bind and send, as the child's ruleset handles those rights and allows no port, and the seccomp filter refuses the child every socket but a netlink route socket, `connect` and `socketpair` outright, and `MSG_FASTOPEN` on `sendto`, `sendmsg` and `sendmmsg`, because TCP Fast Open connects a socket as it sends, and the listener, once a `shutdown` has closed it, is a TCP socket that could connect again. A filter reads only a call's arguments, never what they point to, and these checks need nothing else, so no other thread of the child can change what the filter checked.
|
||||
- **Without the sandbox:** a child that runs unconfined, or on a Linux kernel without seccomp filters, still asks the broker for every connection, but nothing stops a child that a VM took over from connecting itself, so its confinement says so (`partial` with `no-seccomp`, or `none`), and devvm doctor warns of it, as it does now.
|
||||
- **Without the sandbox:** a child that runs unconfined, or on a Linux kernel without seccomp filters, still asks the broker for every connection, but nothing stops a child that a VM took over from connecting itself, so its confinement says so (`partial` with `no-seccomp`, or `none`), and devvm doctor warns of it.
|
||||
|
||||
**The `Secret` type on the socket.** The frames are the third kind of file that holds values, after `proxy.json` and `vm.json`, so they get wire types of their own, as those files have ([where secret values live](#where-secret-values-live)). The start's password, the company proxy's password, the CAs' keys, and a `value` or `token` reply's value each cross as a string in a wire struct. Only the protocol's encoder fills that string, with `Reveal` and its `//nolint:forbidigo` on the line, and the decoder makes it a `redact.Secret` at once. Nothing logs a frame, and an error names only its type and the rule it broke. The company proxy's URLs from the environment cross as strings, as they are in `proxy.json`.
|
||||
|
||||
**The start:**
|
||||
|
||||
1. devvm starts the broker as it starts the proxy now, `devvm _proxy -config FILE`, detached, with its output in `proxy.log`, and waits up to 5 seconds for its status file.
|
||||
1. devvm starts the broker as it starts the proxy, `devvm _proxy -config FILE`, detached, with its output in `proxy.log`, and waits up to 5 seconds for its status file.
|
||||
2. The broker reads the config, looks up the company proxy's password when the config names the `proxy` secret, reads the CAs' files, listens on the VM's proxy port, starts the agent's relay and the keeping of the backend's logs, and makes the socketpair.
|
||||
3. It starts the child, devvm's own binary with the arguments `_proxy-child -for FILE`, through `daemon.Spawn`, which gains the descriptors to pass (`ExtraFiles`) and an environment that its caller chooses. On Linux it runs `/proc/self/exe`, which is its own file even once an upgrade has replaced the file at its path. `-for` names the config only so the child can be told apart, and the child never opens it. Once the child runs, the broker closes its own copies of the listener and of the child's end of the socketpair.
|
||||
4. It sends `start`, which also says how the broker started the child, under Seatbelt or unconfined and why. The child checks the executable's SHA-256 against its own, makes its server from the start, opens its logs and the Nix cache, loads the system's roots and its time zone, checks that it can read the host's addresses, confines itself where its platform does that in the process, checks that the confinement holds by opening its broker's config, which it must be refused, and answers `ready` with how it's confined.
|
||||
5. Within 4 seconds of its own start, the broker writes the child's pid file, `run/proxy-child.pid`, and how it's confined, `run/proxy.confined`, which devvm doctor reads only while the broker runs, and which `Proxy.Stop` removes with the pid file, and then the status file with its own pid and the address (`daemon.Ready`), which is what devvm waits for now. The status keeps the address alone, which devvm compares with the config's. When the child answers `failed`, or doesn't answer in time, the broker stops it and exits with the reason in `proxy.log`, so devvm reports `proxy_start_failed` as it does now.
|
||||
5. Within 4 seconds of its own start, the broker writes the child's pid file, `run/proxy-child.pid`, and how it's confined, `run/proxy.confined`, which devvm doctor reads only while the broker runs, and which `Proxy.Stop` removes with the pid file, and then the status file with its own pid and the address (`daemon.Ready`), which is what devvm waits for. The status keeps the address alone, which devvm compares with the config's. When the child answers `failed`, or doesn't answer in time, the broker stops it and exits with the reason in `proxy.log`, so devvm reports `proxy_start_failed`.
|
||||
|
||||
**The end.** The two end together, and neither starts the other again:
|
||||
|
||||
- **The lifeline is the broker's.** When the VM's hostagent ends, the broker closes the socket, and the child closes its listener first, then closes its connections, waits up to 5 seconds for its handlers as the proxy does now, and exits. The broker waits for it, and kills it a second past that, then removes the agent's socket and exits.
|
||||
- **`devvm stop`'s `SIGTERM`** reaches the broker through its pid file. The broker sends the child `SIGTERM` through its `daemon.Handle`, which ends it at once, as `SIGTERM` ends the proxy now, and kills it if it hasn't ended within a second, inside the 2 seconds that devvm waits before its own `SIGKILL`. So a stop ends both, and the next start finds the port free.
|
||||
- **The lifeline is the broker's.** When the VM's hostagent ends, the broker closes the socket, and the child closes its listener first, then closes its connections, waits up to 5 seconds for its handlers as the proxy does, and exits. The broker waits for it, and kills it a second past that, then removes the agent's socket and exits.
|
||||
- **`devvm stop`'s `SIGTERM`** reaches the broker through its pid file. The broker sends the child `SIGTERM` through its `daemon.Handle`, which ends it at once, as `SIGTERM` ends the proxy, and kills it if it hasn't ended within a second, inside the 2 seconds that devvm waits before its own `SIGKILL`. So a stop ends both, and the next start finds the port free.
|
||||
- **A broker that ends any other way,** `SIGKILL` included, leaves the socket closed, because nothing else holds its end, and the child reads its end, closes its listener and exits. The child reads the socket for as long as it runs, so this needs no signal. A child that a VM has taken over can ignore the socket's end, so on Linux the broker also starts the child with `PR_SET_PDEATHSIG` set to `SIGKILL`, from a goroutine that holds its thread (`runtime.LockOSThread`) until the child is reaped, because Linux ties that signal to the thread that started the child rather than its process.
|
||||
- **A child that ends,** crashed or killed, ends the broker, which logs how it ended and removes the agent's socket. Neither starts the other again, so a child that fails at once can't loop, and the VM has no network until devvm's next command starts its proxy again, as after a proxy's crash now.
|
||||
- **A child that ends,** crashed or killed, ends the broker, which logs how it ended and removes the agent's socket. Neither starts the other again, so a child that fails at once can't loop, and the VM has no network until devvm's next command starts its proxy again, as after a proxy's crash.
|
||||
|
||||
**Finding them.** The broker is the proxy as devvm knows it now: its pid file, its status file and its arguments, `_proxy -config FILE`, which `daemon.Proc` matches, stay as they are. The broker signals the child through the `daemon.Handle` that `Spawn` returned, which reaps it. devvm also finds the child as a `daemon.Proc`, by `run/proxy-child.pid` and its arguments, `_proxy-child -for` and the VM's config, so `Proxy.Stop` and `devvm gc --orphans` stop a child that outlived its broker, checking its arguments before each signal as they do for every background process. The broker writes that pid file only once the child said it's ready, after `sandbox-exec` has run it, so the arguments are already the child's own. Its arguments don't contain `_proxy -config`, so every pattern that finds a VM's proxy now finds the broker alone. The testscript runner's `pkill -f` of `_proxy -config` in the sandbox ends the brokers and so their children, and the runner also ends `_proxy-child -for` in the sandbox, in case a test killed a broker in a way that kept its child. The end-to-end checks find the child by `[_]proxy-child -for` and the config, and a check that a proxy is gone checks both.
|
||||
**Finding them.** To devvm, the broker is the proxy. Its pid file, its status file and its arguments, `_proxy -config FILE`, which `daemon.Proc` matches, stay as they are. The broker signals the child through the `daemon.Handle` that `Spawn` returned, which reaps it. devvm also finds the child as a `daemon.Proc`, by `run/proxy-child.pid` and its arguments, `_proxy-child -for` and the VM's config, so `Proxy.Stop` and `devvm gc --orphans` stop a child that outlived its broker, checking its arguments before each signal as they do for every background process. The broker writes that pid file only once the child said it's ready, after `sandbox-exec` has run it, so the arguments are already the child's own. Its arguments don't contain `_proxy -config`, so every pattern that finds a VM's proxy finds only the broker. The testscript runner's `pkill -f` of `_proxy -config` in the sandbox ends the brokers and so their children, and the runner also ends `_proxy-child -for` in the sandbox, in case a test killed a broker in a way that kept its child. The end-to-end checks find the child by `[_]proxy-child -for` and the config, and a check that a proxy is gone checks both.
|
||||
|
||||
**The build proxy** is the same broker and child, which `backend.ProxyStarter` starts and stops through its `daemon.Handle`, and which ends the child as `devvm stop` does. Its broker has no secrets, captures, links, agent or backend logs to keep, so it only looks up the `proxy` secret when `config.toml`'s company proxy names one, and follows the build VM's lifeline. Its child writes `events.jsonl` and `proxy.log` in the build proxy's `logs/` folder and reads nothing else, so the end-to-end checks that look for a build's logs look there. One way for both keeps one code path, and a build runs code that devvm trusts no more than a VM's.
|
||||
|
||||
**Upgrades.** The config doesn't change. `proxy.json` keeps its fields and `ConfigVersion` stays 1, so every release's frozen configs still read and write back byte for byte (`TestV010ProxyConfigs`), and the implementation starts a broker and its child on each of them. A proxy that a devvm before the split started runs as one process until the VM's next launch, which starts it again because its config's `devvm_sha256` differs, as every upgrade does now, so a running VM keeps its network through the upgrade. An older devvm that stops a VM's proxy after a downgrade finds the broker by the same pid file and arguments, and the child ends with it.
|
||||
**Upgrades.** The config doesn't change. `proxy.json` keeps its fields and `ConfigVersion` stays 1, so every release's frozen configs still read and write back byte for byte (`TestV010ProxyConfigs`), and the implementation starts a broker and its child on each of them. A proxy that a devvm before the split started runs as one process until the VM's next launch, which starts it again because its config's `devvm_sha256` differs, as every upgrade does, so a running VM keeps its network through the upgrade. An older devvm that stops a VM's proxy after a downgrade finds the broker by the same pid file and arguments, and the child ends with it.
|
||||
|
||||
**Confining the child.** Two follow-ups hold the child to what it needs, as listed above, and where a platform can't, the child runs unconfined, says so in `ready`, the broker logs a warning and writes it to `run/proxy.confined`, and devvm doctor warns of it for each running VM. The child says how it's confined in one line of words from a fixed set, its level, `full`, `partial` or `none`, then what confines it, and for a child that isn't fully confined, why (`proxy.Confinement`, in `internal/proxy/confine.go`), which the broker refuses unless it parses, so devvm never prints what a child wrote ([the child's sandbox](network.md#the-childs-sandbox) has the table). Both follow-ups share it, the check that the confinement holds (`checkConfined`, which opens the broker's config) and the hook where the child confines itself in the process (`confineSelf`, by platform), which on Linux calls `internal/landlock` and turns what it got into the line (`landlockConfinement`), and which `confineChild` bounds to 2 seconds (`confineWait`). The child gets the hook through `IO`'s `confine`, which `ChildMain` sets, so a test's child in the test's own process confines nothing, and a confinement that fails, rather than one the kernel can't give, fails the start. Each follow-up's start fits in the broker's 4 seconds, so a sandbox that refuses what the child needs fails the start rather than hang it, and on macOS a broker and its child under Seatbelt are ready in about 40 ms, or 350 ms for the first start of a binary that macOS hasn't run before.
|
||||
**Confining the child.** Two follow-ups hold the child to what it needs, as listed above, and where a platform can't, the child runs unconfined, says so in `ready`, the broker logs a warning and writes it to `run/proxy.confined`, and devvm doctor warns of it for each running VM. The child says how it's confined in one line of words from a fixed set, its level, `full`, `partial` or `none`, then what confines it, and for a child that isn't fully confined, why (`proxy.Confinement`, in `internal/proxy/confine.go`), which the broker refuses unless it parses, so devvm never prints what a child wrote ([the child's sandbox](../internals/network.md#the-childs-sandbox) has the table). Both follow-ups share it, the check that the confinement holds (`checkConfined`, which opens the broker's config) and the hook where the child confines itself in the process (`confineSelf`, by platform), which on Linux calls `internal/landlock` and turns what it got into the line (`landlockConfinement`), and which `confineChild` bounds to 2 seconds (`confineWait`). The child gets the hook through `IO`'s `confine`, which `ChildMain` sets, so a test's child in the test's own process confines nothing, and a confinement that fails, rather than one the kernel can't give, fails the start. Each follow-up's start fits in the broker's 4 seconds, so a sandbox that refuses what the child needs fails the start rather than hang it, and on macOS a broker and its child under Seatbelt are ready in about 40 ms, or 350 ms for the first start of a binary that macOS hasn't run before.
|
||||
|
||||
- **macOS, with Seatbelt:** the broker starts the child through `/usr/bin/sandbox-exec -p PROFILE`, with a profile that denies everything by default, so the child is confined from its first instruction, and the profile is an argument, never a file on disk. `internal/seatbelt` owns it (`ChildProfile`), with the quoting and the real paths that Lima's hostagent's profile uses too, and the broker gets it through `proxy.IO.Seatbelt`, which only `devvm _proxy` on macOS sets, because `internal/proxy` imports the standard library alone. The profile imports the system's `dyld-support.sb`, the rules that Apple keeps for starting a program, so dyld and the system's libraries in their cryptexes load as Apple changes them. It allows `exec` and reading of devvm's binary by its real path alone, which `sandbox-exec` needs to run it and the child needs for its SHA-256, and the metadata of its folder, which CoreFoundation looks at for the program's bundle before Security checks a certificate. It allows reading `/usr/lib` and `/System/Library` and the time zone, and the metadata of the links on the way, `/etc`, `/var` and `/tmp`, because a sandboxed lookup through a link needs it. It allows reading and writing in its folders, making only regular files there (`vnode-type REGULAR-FILE`), no hard link anywhere (`file-link`), no folder removed, and no change to a file's flags, ACL, owner, set-id bits or extended attributes, so the broker makes the Nix cache's folders before the child starts. It allows `file-read-metadata` alone on the watched files, on their targets when they're links, and on every link on the way to any of its files and folders (`seatbelt.Links`), the mach services `com.apple.trustd` and `com.apple.trustd.agent`, reading `sysctl` but its `kern.proc` names, and signals to itself. It allows no network out at all, to any address or unix socket, and accepting on its listener, and reading and writing the connections it accepted and those that the broker handed it, need no rule. It allows no bind, no fork, no look at another process (`process-info`, the process list), and none of the Keychain's services. The list of what the child needs came from the sandbox's own log of what it refused (`log show --predicate 'eventMessage CONTAINS "devvm("'`), and the profile leaves refused what the child does without: `com.apple.logd`, `com.apple.system.notification_center`, `com.apple.system.opendirectoryd.libinfo`, `/Library/Preferences/com.apple.networkd.plist`, `/etc/passwd`, `/dev/fd`, the interfaces' link addresses (`net.link.addr`), `AF_SYSTEM` sockets and the binds that the system's network code tries. `crypto/x509`'s checks don't need `com.apple.SecurityServer`, which the profile never allows. A watched file whose link points elsewhere after the start gets its `stat` refused, which the child takes as a file to ask the broker for at every request (`watched.get`), so a change still applies to the next request. The broker starts the child again unconfined, within the same 4 seconds, only when `sandbox-exec` failed before devvm's code ran, which the child's end shows: it ended before it answered, with `sandbox-exec`'s own exit status, 65 for a profile it refused or 71 for a program it couldn't run, or killed by `SIGABRT` or `SIGKILL`, as dyld aborts a program that the profile refuses what it needs to load, which the broker decides before its own stop of the child. A ready that names a sandbox the broker didn't start the child under breaks the protocol's rules (`Confinement.fits`). `ChildProfile` refuses a path that isn't absolute or that is the root, as resolved. A missing `sandbox-exec` starts it unconfined too. Anything else fails the start, so nothing a VM left in the child's folders can turn a confined start into an unconfined one.
|
||||
- **Linux, with Landlock:** the child sets `no_new_privs` on every thread and restricts itself (`landlock_restrict_self`, through `syscall.AllThreadsSyscall`, or with ABI 8's `TSYNC` where the kernel has it) before it reads a byte of the VM's, and the files it opened before then are its logs and the Nix cache. It keeps the rights above on its folders, to make regular files alone, binds and connects no TCP port (ABI 4), binds and sends no UDP (ABI 10), scopes abstract unix sockets and signals to itself (ABI 6), and connects to no named unix socket (ABI 9). Landlock's network rules match only ports, so they can refuse the child an address only by refusing it every connection, which is what the child needs, and the seccomp filter refuses the same on every kernel, TCP Fast Open included, which Landlock's check of `connect` doesn't see. It reads no file outside its folders, because it needs no resolver. The Nix cache renames a NAR's temporary file from its top folder into `nar/`, which Landlock allows only from ABI 2 (`REFER`), so the floor is ABI 2, unless the cache makes each temporary file in the folder that its file goes to. A child on a kernel below ABI 4 or 6 is partly confined, which it says in `ready` and devvm doctor reports. A kernel at ABI 6 or 7 without Landlock's erratum 2, which lets a process's threads signal each other across the domains each made in turn, would refuse the signals that `syscall.AllThreadsSyscall` sends each thread and hang the start, so there the child leaves signals unscoped and says so (`landlock-signals`). A kernel without Landlock, or at ABI 1, confines no files, and the child runs with the seccomp filter alone and says so (`partial seccomp no-landlock`), which devvm doctor warns of: the VM keeps its network rather than lose it on such a kernel. `internal/landlock` (`Self`) does all of it, with the standard library alone, behind its own build tags, as the proxy can't import `internal/platform`, and checks after confining that the child lists its folders and fails to list `/` and to read `/etc/hosts`.
|
||||
- **Linux, with seccomp:** no Landlock ABI can refuse the child an address, a kernel before ABI 9 can't refuse it a named unix socket, and one before ABI 4 can't refuse it a port, so the child also installs a seccomp filter on every thread (`SECCOMP_FILTER_FLAG_TSYNC`) that refuses `socket` for every family but a netlink route socket (`AF_NETLINK` with `NETLINK_ROUTE`), `socketpair`, `connect`, `listen`, `MSG_FASTOPEN` on `sendto`, `sendmsg` and `sendmmsg`, `socketcall`, and `io_uring_setup`, `io_uring_enter` and `io_uring_register`, whose operations would pass a filter of system calls. 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 can't get around it. `socketcall` is a 32-bit call alone, so the check of the architecture is what refuses it. The filter also refuses `ptrace`, `process_vm_readv`, `process_vm_writev` and `pidfd_getfd`, which Landlock restricts to the child's own domain but nothing does on a kernel without it, and which would let the child read the memory, or take the descriptors, of another process of yours, such as an ssh master. Changed in review, it refuses what Landlock doesn't restrict at any ABI: a file's mode, owner, extended attributes and times changed by its path (`chmod`, `fchmodat`, `fchmodat2`, `chown`, `lchown`, `fchownat`, the six `xattr` calls, `utime`, `utimes`, `futimesat`, and `utimensat` with a path), `truncate`, which Landlock restricts only from ABI 3, the kernel's keyrings (`add_key`, `request_key`, `keyctl`), another process's limits and scheduling (`prlimit64` on another pid, `setpriority`, `ioprio_set` and the four `sched_set` calls), watches that would tell it of files outside its folders (`inotify_init`, `inotify_init1`, `inotify_add_watch`, `fanotify_init`, `fanotify_mark`), and what the child never does: `execve` and `execveat`, `fork`, `vfork` and a `clone` that isn't a thread, a namespace (`unshare`, `setns`, a `clone` with a namespace's flag), `bpf`, `userfaultfd` and `perf_event_open`, with `clone3` refused as `ENOSYS`, as its flags are behind a pointer. The calls on a descriptor the child opened stay (`fchmod`, `fchown`, `ftruncate`, `utimensat` without a path), and the Nix cache marks a file used through its descriptor. The review's own check: the filter's interpreter, and `TestSelf` on Fedora 43 (ABI 11), Ubuntu 26.04 (ABI 8) and Debian 13 (ABI 6), where Go's runtime still starts new threads under it. The child needs none of these, as the broker looks up its names and opens its connections. Once confined, the child checks that it can't make a unix or an IPv4 socket, nor `connect` or send with `MSG_FASTOPEN` on any socket, which the filter refuses before the kernel looks at the descriptor. The filter is classic BPF written out by hand (`internal/landlock`'s `filter`), a unit test runs its bytes in an interpreter of its own for amd64 and arm64, and a test's child confines itself under it on the Linux test hosts and in CI's `nocgo` job (`TestSelf`). A kernel without seccomp leaves the filter out, and the child says so (`no-seccomp`).
|
||||
|
||||
**Performance.** The path of the VM's requests is the child's alone: no request, tunnel or byte in them crosses the socket. The child asks the broker only for a value that its cache doesn't hold, at most once for each binding in 30 seconds or 5 minutes, for a watched file after it changed, for each connection to a link, which is a new connection for each plain HTTP request to a link as it is now, for each token request, and for each lookup and each connection that a request opens upstream. Those last two add a round trip on the socketpair to each lookup and each connection, a JSON frame each way and a descriptor, which is small beside a lookup's or a TCP handshake's own time, and a kept-alive connection or a tunnel costs it once. A start costs one more process and its `exec`, and each VM's proxy takes a second Go process's memory: on an Apple silicon Mac, an idle broker and its child each take about 19 MB resident.
|
||||
**Performance.** The path of the VM's requests is the child's alone: no request, tunnel or byte in them crosses the socket. The child asks the broker only for a value that its cache doesn't hold, at most once for each binding in 30 seconds or 5 minutes, for a watched file after it changed, for each connection to a link, which is a new connection for each plain HTTP request to a link, for each token request, and for each lookup and each connection that a request opens upstream. Those last two add a round trip on the socketpair to each lookup and each connection, a JSON frame each way and a descriptor, which is small beside a lookup's or a TCP handshake's own time, and a kept-alive connection or a tunnel costs it once. A start costs one more process and its `exec`, and each VM's proxy takes a second Go process's memory: on an Apple silicon Mac, an idle broker and its child each take about 19 MB resident.
|
||||
|
||||
**Options weighed:**
|
||||
|
||||
- **Values handed to the child at the start:** ruled out, above.
|
||||
- **The child reading the changing files itself:** it would need to read the VM's run folder and devvm's config folder. Landlock keeps a rule for a file on that file itself, so a file that devvm replaces whole would lose it, and only a rule on the folder would hold. Asking the broker after a change keeps the check on each request without a hop.
|
||||
- **The broker sending changes to the child as they happen:** the broker would have to watch each file, and the standard library can only poll, so a change would wait for the next poll, where it now applies to the next request.
|
||||
- **The broker sending changes to the child as they happen:** the broker would have to watch each file, and the standard library can only poll, so a change would wait for the next poll, while with the stamp's check it applies to the next request.
|
||||
- **The broker speaking to the company proxy and handing over the tunnel:** that would keep the company proxy's password out of the child for tunnels, but the company proxy takes it with each plain HTTP request, which would put the broker on that path, parsing what the child sends. So the broker opens the TCP connection to the company proxy alone, and the child speaks to it.
|
||||
- **Seatbelt refusing `localhost:*` alone, with the broker connecting to loopback only:** Seatbelt's network filter names a host only as `*` or `localhost`, so the child would still reach this machine's own LAN addresses, where a server that listens on every address answers, such as Docker's published ports, and the LAN, and whether `localhost` covers all of `127.0.0.0/8`, `0.0.0.0` and the mapped forms is Apple's to say. A profile that allows nothing out, with the broker judging every address, holds for all of them, and keeps one way for both systems.
|
||||
- **seccomp's user notification on Linux,** with the broker as the supervisor of `connect`, `sendto` and `sendmsg`: the broker would read the address from the child's memory, which another thread of the child can change after the read, so it could never let the call go on, and would make every connection itself and put it in the child (`SECCOMP_IOCTL_NOTIF_ADDFD`), which costs what the `dial` request does. Reading the child's memory needs `ptrace`'s access, which Yama's `ptrace_scope` 2 or 3 refuses, the broker couldn't tell a TCP socket from a UDP one without taking it (`pidfd_getfd`, the same access), the listener's descriptor would have to come from the child, which the protocol refuses, and `ADDFD` needs Linux 5.9. The filter on arguments works on every kernel with seccomp filters, with no access to the child's memory.
|
||||
@@ -1040,18 +1049,18 @@ Only a `lookup` and a `dial` can be cancelled, with a `cancel` frame of the requ
|
||||
|
||||
- **The child naming another VM's binding, another secret or a file:** ruled out. Each request is a key, a number, a host and port, or an endpoint that the broker resolves in its own config and its own reads of its VM's files, and no path, VM name or binding crosses the socket.
|
||||
- **The values bound to its VM:** listed. A child that a VM takes over can ask for every value that its VM's bindings file names, such as a secret of yours, a GitHub token or an agent's access token, and use it anywhere the child reaches, while the VM itself holds only placeholders. It gets no other VM's value, no value that isn't bound to its VM, and no login's refresh token.
|
||||
- **The company proxy's password:** listed. The child holds it, as the proxy does now, because the company proxy takes it with each plain HTTP request, so a child that a VM takes over can send it anywhere it reaches.
|
||||
- **The company proxy's password:** listed. The child holds it, as the proxy does, because the company proxy takes it with each plain HTTP request, so a child that a VM takes over can send it anywhere it reaches.
|
||||
- **Its VM's password and CAs:** listed. The child holds its VM's password and both CAs' keys, which only that VM trusts, and it already sees all of that VM's traffic.
|
||||
- **A forged token reply:** ruled out. The broker gets the endpoint's reply itself, over TLS that it checks, from the host in its own config, so a child can't save tokens that the endpoint didn't issue. Listed, as now: a real exchange of a code that the VM got for an account of its own saves that account's login for every VM with the agent, as a VM can do without the proxy taken over ([logins made in a VM](network.md#logins-made-in-a-vm)).
|
||||
- **A forged token reply:** ruled out. The broker gets the endpoint's reply itself, over TLS that it checks, from the host in its own config, so a child can't save tokens that the endpoint didn't issue. Listed: a real exchange of a code that the VM got for an account of its own saves that account's login for every VM with the agent, as a VM can do without the proxy taken over ([logins made in a VM](../internals/network.md#logins-made-in-a-vm)).
|
||||
- **A binding or link that devvm took away:** changed in review. The broker read the bindings file and the links' list only when the child asked for them, which a child that a VM takes over never does, so a secret unbound or deleted, or a link removed, stayed within its reach. The broker now looks at both on every request that uses them, and drops its values when the bindings file changes.
|
||||
- **Flooding the broker:** listed. Frames have a cap, each request type has a cap on how many run at once, the broker's cache holds a lookup to once a binding in 30 seconds or 5 minutes, a failed lookup is kept for 5 seconds (changed in review, as a failure wasn't kept, so a child could make the broker run `security` or try a refresh back to back), and a frame that breaks a rule ends the pair. A child can still run up to 8 token exchanges at once with your login, one after another, as a VM can now, and make the broker write a line in `proxy.log` for each connection it refuses or can't open, which pushes older lines out of the log's rotation, as the child's own lines can.
|
||||
- **The broker's own parsing:** listed. The broker still reads bytes that a VM chooses, in four bounded places: the child's frames, at most 2 MiB each, which `encoding/json` decodes, the agent's relay's messages, at most 256 KiB each, read by their length and type alone, the backend's logs, which it scans for passwords, and a token request and its reply, at most 64 KiB and 1 MiB, which `internal/agentlogin` parses as the proxy's process does now.
|
||||
- **Flooding the broker:** listed. Frames have a cap, each request type has a cap on how many run at once, the broker's cache holds a lookup to once a binding in 30 seconds or 5 minutes, a failed lookup is kept for 5 seconds (changed in review, as a failure wasn't kept, so a child could make the broker run `security` or try a refresh back to back), and a frame that breaks a rule ends the pair. A child can still run up to 8 token exchanges at once with your login, one after another, as a VM can, and make the broker write a line in `proxy.log` for each connection it refuses or can't open, which pushes older lines out of the log's rotation, as the child's own lines can.
|
||||
- **The broker's own parsing:** listed. The broker still reads bytes that a VM chooses, in four bounded places: the child's frames, at most 2 MiB each, which `encoding/json` decodes, the agent's relay's messages, at most 256 KiB each, read by their length and type alone, the backend's logs, which it scans for passwords, and a token request and its reply, at most 64 KiB and 1 MiB, which `internal/agentlogin` parses as the proxy's process does.
|
||||
- **The network:** changed, and listed. The rules and the floor were the child's own code, and the sandboxes allowed it TCP and UDP to any address, so a child that a VM took over reached this machine's loopback, its own LAN addresses and the LAN, such as your dev servers, Docker's published ports and other VMs' proxies, whatever the rules said. A profile can't follow a rule that applies from the next connection, and Landlock and a seccomp filter can't refuse an address, so the sandboxes now refuse the child every connection of its own, and the broker, which judges each address with its own read of the policy files and the host's addresses, opens each one for it. Listed: the child still reaches any public address on the internet, as an open VM's proxy does, over TCP alone, and an address that a rule names. Changed in review, the note no longer says the LAN is out of reach: the floor counts a host on this machine's network whose address is public as the internet, such as a printer's or a NAS's global IPv6 address on most networks with IPv6, or any host on a network of public IPv4 addresses, so the child, as the VM, reaches those, and the floor counting this machine's own networks as internal is a change of its own, for the VM as much as the child. The child reaches no unix socket, so neither the ssh masters' control sockets, nor `docker.sock`, nor an SSH agent.
|
||||
- **The `dial` and `lookup` requests:** ruled out, and listed. A `dial` names an address and a port, which the broker judges as the floor does before it connects, or a company proxy of its own config, and nothing else, so a child can't make the broker connect where the floor refuses, nor reach a unix socket, nor send UDP through it. A `lookup` takes a host name alone, and the broker returns its addresses, which the child could ask this machine's resolver for, split DNS, `/etc/hosts` and `.local` names included. Listed: a child can make the broker look up any name, which carries data out in the name as a VM's own lookups through the proxy can, and hold 256 lookups and 1024 connections under way at once, each for at most its timeout, as it could hold them itself before. Changed in review: a lookup or a connection that the child gave up on held its place until its timeout, so a VM whose requests went away while DNS or IPv6 hung could fill the caps, and now the child cancels it. The broker logged a line for each failed lookup and connection, which a VM that asks for one refused address after another drives, and now it logs at most 20 a minute, then one that says it stops, as the child does for the lookups it gives up on.
|
||||
- **The connections the child holds:** changed in review, and listed. The caps count a connection only while it opens, and Go raises a process's limit on open files to its hard limit, so a child could keep every connection the broker handed it and use up this machine's ports for outgoing connections. The child now lowers its own limit, soft and hard, to 8448 files before it confines itself, four times `maxConns` and room for its logs and the Nix cache, so it holds at most that many, which a process can't raise again. Listed: that lowers the risk but doesn't remove it, as macOS gives out its outgoing ports from one range of 16,384 for every process, so a few children that VMs took over, or one on a busy machine, could still use them up.
|
||||
- **A connection connected again:** ruled out. A child holds connected TCP sockets, those it accepted and those the broker handed it, and its listener. On Linux, the filter refuses `connect`, which could otherwise disconnect a TCP socket (`AF_UNSPEC`) and connect it elsewhere, and `MSG_FASTOPEN`, which would connect the listener once a `shutdown` has closed it. On macOS, Seatbelt checks every `connect` and every `sendto` with an address against the profile, which allows none.
|
||||
- **A rule as it changes:** ruled out, and listed. The child and the broker each read the policy files when their stamp changes, and the broker looks at them at each `dial`, after the child's own look, so a rule that the child saw is one the broker sees. A rule taken away as a connection opens makes that connection fail, which fails closed. Changed in review: the broker's copy and what it gave the child were two reads, and a file that keeps its last rules when it can't be read, as a policy file does, could leave the broker's copy older than the child's, with a rule the child no longer had, so the broker now looks at its copy at each `file` request for a policy file too. Listed: a file that changes and can't be read between those two looks, which only you can make happen, still leaves the broker's copy a version behind until the file reads again.
|
||||
- **The company proxy:** listed. A child that a VM takes over can connect to the company proxy of its config, wherever it is, loopback included, and send it what it likes with the password it holds, as the proxy does now: `CONNECT` and plain HTTP to any host and port, which the company proxy, not the floor, decides on, so it reaches whatever the company proxy reaches, this machine's loopback included when the company proxy runs here. The broker speaking `CONNECT` itself would keep tunnels to the floor, but plain HTTP takes the password with each request, so the child would still hold it and reach the same through `http`'s company proxy.
|
||||
- **The company proxy:** listed. A child that a VM takes over can connect to the company proxy of its config, wherever it is, loopback included, and send it what it likes with the password it holds, as the proxy does: `CONNECT` and plain HTTP to any host and port, which the company proxy, not the floor, decides on, so it reaches whatever the company proxy reaches, this machine's loopback included when the company proxy runs here. The broker speaking `CONNECT` itself would keep tunnels to the floor, but plain HTTP takes the password with each request, so the child would still hold it and reach the same through `http`'s company proxy.
|
||||
- **Other processes' details:** changed in review. The first profile allowed every `sysctl` and `process-info`, so a child could list your processes and read their paths and arguments, a token on a command line among them. The profile now denies `process-info` for any process but the child, the process list, and `sysctl`'s `kern.proc` names. macOS answers `kern.procargs2`, a process's arguments, to a sandboxed process only for the processes of its own process group, and the child is alone in a session of its own (`daemon.Spawn`'s `Setsid`), so it's refused every other process's, its broker's included, which `TestChildProfileConfines` checks.
|
||||
- **Changing the shared folders' files:** changed in review. The first profile allowed every write in the child's folders, so a child could set a flag such as `uchg` on a file in the shared Nix cache, or remove its `nar/` folder, and stop every VM's cache and devvm gc's trim from changing it. The profile now refuses changing a file's flags, ACL, owner, set-id bits and extended attributes, and removing a folder, and leaves the mode and times, which the child changes. A child can still delete or rewrite the cache's files, as the disk's row says.
|
||||
- **The seccomp filter's way around:** changed in review. A filter of `socket` alone lets a child reach a unix socket through the 32-bit system calls (`socketcall`, or the x32 numbers) or through `io_uring`, which doesn't pass the filter, and before ABI 9 that filter is all that keeps the ssh masters' control sockets from it. The filter now kills any other architecture's calls and refuses `socketcall` and `io_uring`, on every thread.
|
||||
@@ -1066,14 +1075,14 @@ Only a `lookup` and a `dial` can be cancelled, with a `cancel` frame of the requ
|
||||
- **A child that claims more:** changed in review. The broker took any confinement the child's ready named, so a child could say `full seatbelt` when the broker had started it unconfined. The broker now refuses a ready that names a sandbox it didn't start the child under, or another than the one it did (`Confinement.fits`), which ends the pair.
|
||||
- **Other processes:** ruled out where the child is confined. Landlock scopes signals to the child (ABI 6) and lets it trace only processes in its own domain, and the profile allows signals only to itself. Listed: on a Linux kernel before ABI 6, or at ABI 6 or 7 without erratum 2, a child that a VM takes over can signal any process of yours, which devvm doctor warns of. Changed in review: Landlock's scope of signals doesn't cover a process's limits or scheduling, and a review killed another process from a fully confined child on ABI 8 by setting its `RLIMIT_CPU` to 1 with `prlimit64`, so the seccomp filter refuses `prlimit64` on any pid but the child's own (0), and `setpriority`, `ioprio_set`, `sched_setaffinity`, `sched_setscheduler`, `sched_setparam` and `sched_setattr` outright. The seccomp filter refuses `ptrace`, `process_vm_readv`, `process_vm_writev` and `pidfd_getfd` on every kernel, but on a kernel without Landlock the child can still open `/proc/<pid>/mem` and `/proc/<pid>/fd/` of another process of yours, unless the kernel's Yama restricts tracing (`ptrace_scope` 1 or more, Ubuntu's default), and so read its memory and its files. Changed in review: the broker sets itself undumpable (`PR_SET_DUMPABLE` 0), so its own memory and descriptors, which hold the VM's secrets, are root's alone there.
|
||||
- **A port of another VM's:** changed in review, and ruled out where the seccomp filter or Seatbelt holds. Before ABI 4, Landlock can't refuse the child a port, so a child could bind another VM's proxy port while that proxy starts again, and take that VM's password from its requests. The seccomp filter refuses `listen`, and now every new socket but a netlink route socket, so the child has no socket to bind, as the ones it holds are bound already, and the profile refuses a bind on macOS. Listed: without either, the child can still bind such a port, so that VM's proxy fails to start until it's free again.
|
||||
- **No confinement, or part of it:** listed. Where Landlock or Seatbelt isn't there, the child runs with the access the proxy has now, and the split then only keeps the lookups, the captures, the relay and the logs' keeping out of the code that reads the VM's network. Without the seccomp filter, or on macOS without Seatbelt, a child that a VM took over can also connect anywhere itself, loopback included. A kernel below ABI 4 or 6 confines the child in part, which `ready`, `run/proxy.confined` and devvm doctor say. Changed in review: ABI 6, 7 and 8 with the seccomp filter and scoped signals count as full, as the filter refuses every unix socket that ABI 9 would refuse by path, and every connection and datagram of the child's own, which ABI 10 would refuse only for UDP, so doctor warns of nothing that a user could close. On macOS, `sandbox-exec` is deprecated, and if macOS drops it, or it fails to start the child, the child runs unconfined, and the proxy's log and devvm doctor say so, so the VM keeps its network.
|
||||
- **No confinement, or part of it:** listed. Where Landlock or Seatbelt isn't there, the child runs with the broker's access, and the split then only keeps the lookups, the captures, the relay and the logs' keeping out of the code that reads the VM's network. Without the seccomp filter, or on macOS without Seatbelt, a child that a VM took over can also connect anywhere itself, loopback included. A kernel below ABI 4 or 6 confines the child in part, which `ready`, `run/proxy.confined` and devvm doctor say. Changed in review: ABI 6, 7 and 8 with the seccomp filter and scoped signals count as full, as the filter refuses every unix socket that ABI 9 would refuse by path, and every connection and datagram of the child's own, which ABI 10 would refuse only for UDP, so doctor warns of nothing that a user could close. On macOS, `sandbox-exec` is deprecated, and if macOS drops it, or it fails to start the child, the child runs unconfined, and the proxy's log and devvm doctor say so, so the VM keeps its network.
|
||||
- **The floor without the host's addresses:** changed in review. A confinement that refused the read of the host's addresses would have left the floor with none, and so let the VM reach this machine's own public addresses. The child's check after it confines itself needs a read that isn't empty, and a later read that fails keeps the last good one.
|
||||
- **Descriptors and the environment:** ruled out. The child inherits only its four descriptors, the socketpair is close-on-exec so no other program holds an end, the child closes any descriptor that a frame brings that it didn't ask for, and it gets only `TZ`, `SSL_CERT_FILE`, `SSL_CERT_DIR` and `GODEBUG` from the environment.
|
||||
- **The pid and status files:** ruled out. The child can't write the run folder, the status file's name isn't in its environment, and the status names the broker's pid, which `daemon.Proc` checks, so a child that a VM takes over can't make devvm signal another process. The broker writes the child's pid file, and devvm checks the child's arguments before it signals it.
|
||||
- **A child that outlives its broker, or starts again:** ruled out, changed in review. The child ends when it reads the socket's end, which a killed broker leaves because no other process holds it, and the broker ends with its child, and neither starts the other. A stop gave the broker 2 seconds and the child's close took up to 6, so a child could have kept the port and its old config as the next start began. Now `SIGTERM` ends the child within a second, and devvm finds a child that outlived its broker by its pid file and stops it. Listed: a child that a VM has taken over can ignore the socket's end and change its own arguments, which `daemon.Proc` then doesn't match, so devvm leaves it alone. On Linux `PR_SET_PDEATHSIG` kills it with its broker, but on macOS such a child outlives a broker that was killed, confined, with its VM's values and port, and the VM's next start reports its proxy's port as taken.
|
||||
- **A binary that changed under the broker:** changed in review. The protocol's version alone can't tell two builds apart, so the start and the answer carry each side's executable's SHA-256, and a child from another build fails the start, and the VM's next launch starts the pair again. On Linux the child is the broker's own file anyway.
|
||||
- **A file that changes between its stamp and its read:** ruled out. The child keeps the stamp of the file that the broker read, so a write after that read changes the stamp, and the child asks again.
|
||||
- **Memory and CPU:** listed. A child that a VM takes over can use memory and CPU without a bound, as the proxy can now.
|
||||
- **Memory and CPU:** listed. A child that a VM takes over can use memory and CPU without a bound, as the proxy can.
|
||||
|
||||
**End-to-end checks** that the implementation adds, in `network`, `link`, `nix`, `images`, `tools` and `from`: a VM's proxy runs as a broker and a child, with the child's arguments and descriptors above and no environment but the four variables. A bound secret goes in, a login is captured from the fake token endpoint, a link connects and the Nix cache fills, each through the child. `devvm stop` leaves neither process, and the next launch starts on the same port at once. A symbolic link, a FIFO and a hard link planted in the VM's logs folder and the Nix cache lead no command of devvm's, the next start or a rotation to their targets, and hang none. A broker killed with `SIGKILL` takes its child with it within a second, a child killed takes its broker and the agent's socket with it, and nothing starts again until the next launch. A build behind a company proxy goes through a broker and a child, and both are gone after the build. The two follow-ups add the checks that the confined child can't read a file in the home folder, reach the Keychain or connect to a unix socket, on each platform. On Linux, `network` checks that the VM's proxy says Landlock in `run/proxy.confined`, and that the child's `/proc` entry shows `no_new_privs` and a seccomp filter, and `TestSelf`, in `internal/landlock`, runs its test binary again as a child that confines itself, which writes, renames and lists in its folder, reads the host's addresses and writes to a TCP connection it held before, and is refused a file outside its folder, `/etc/hosts`, listing `/`, its own executable, a folder, a link and a FIFO in its folder, a unix socket that stands in for an ssh master's, a socketpair, a listen, an IPv4 and an IPv6 socket, a netlink socket of another family than routes, connecting a TCP socket it held before to a loopback server, `MSG_FASTOPEN` from its listener once a `shutdown` has closed it, from ABI 4 a bind and from ABI 6 a signal to its parent. By hand, devvm's release build ran a broker whose child was confined on Ubuntu 26.04 (AppArmor, ABI 8), Fedora 43 (SELinux, ABI 11), Debian 13 (ABI 6) and Ubuntu 26.04 on arm64, served a request, refused a blocked host and reached the Nix cache's endpoint. On macOS, `network` checks that the VM's proxy says `full seatbelt` in `run/proxy.confined`, which means the child started under `sandbox-exec` and its own check held, and `TestChildProfileConfines`, in `internal/seatbelt`, runs its test binary again under the child's profile, which writes a regular file in its folder, renames it, changes its mode, removes it, looks at its policy file, and writes to a TCP connection it was handed and to one it accepted on a listener it was handed, and is refused a link, a folder, a FIFO and a hard link there, changing a file's flags, removing a folder, reading its policy file, reading or looking at a file outside, opening the broker's config, connecting to a unix socket, connecting over TCP to a loopback server on `127.0.0.1` and `::1` or to any other address, sending UDP, running a program, listening on a port, signalling its parent and listing the processes. The broker's judgment is unit tests: a `dial` to a loopback port that no rule names is refused, `127.0.0.1` and `::1` alike, and so is one to this machine's own address, while one that a rule names connects, from the `dial` after the rule is written, and not after it's gone, and the open tier's broker connects to any. `FuzzBrokerFrames` sends the broker any `lookup` and `dial`, and checks that it looks up only a host name and connects only where its own floor allows, and the in-process tests run the whole proxy with every lookup and connection through the broker. By hand, devvm's release build ran a broker whose child was confined, and a helper under the child's profile was refused `~/.zshrc`, `~/.ssh`, `~/Library/Keychains` and the login keychain's file, `~/.local/share/devvm` and `~/.config/devvm`, running `security`, and an ssh master's control socket, and reached example.com. The fallback and its limits are unit tests (`TestStartChildSandbox`), as a broken `sandbox-exec` can't be made on a real Mac.
|
||||
|
||||
@@ -1114,7 +1123,7 @@ User-facing limits are in [Known limits](../using/limits.md), and what devvm lea
|
||||
- **Linux hosts:** the QEMU wrapper depends on the shape of Lima's `-netdev user,id=net0,…` argument. If Lima changes it, the wrapper refuses to start QEMU rather than run it unrestricted.
|
||||
- **Network tiers, not built:**
|
||||
- approving blocked hosts as they're hit.
|
||||
- **Claude Code's login is captured on a path Anthropic doesn't document.** devvm reads Claude Code's token endpoint, its client ID, its requests and replies and the `.credentials.json` format from Claude Code 2.1's bundle, and refreshes the login on the host as Claude Code would ([logins made in a VM](network.md#logins-made-in-a-vm)). A release that changes any of them can break the login in VMs, or the host's refresh, without warning. The `network` end-to-end section drives the real Claude Code's `claude auth login` against a fake endpoint, so a change to its requests fails that section, and a Claude Code token from `claude setup-token`, which Anthropic documents, stays the fallback.
|
||||
- **Claude Code's login is captured on a path Anthropic doesn't document.** devvm reads Claude Code's token endpoint, its client ID, its requests and replies and the `.credentials.json` format from Claude Code 2.1's bundle, and refreshes the login on the host as Claude Code would ([logins made in a VM](../internals/network.md#logins-made-in-a-vm)). A release that changes any of them can break the login in VMs, or the host's refresh, without warning. The `network` end-to-end section drives the real Claude Code's `claude auth login` against a fake endpoint, so a change to its requests fails that section, and a Claude Code token from `claude setup-token`, which Anthropic documents, stays the fallback.
|
||||
- **Network tiers, risks of the mechanism:**
|
||||
- `sandbox-exec` is deprecated. If Apple removes it, macOS needs another way to confine the hostagent: an egress filter upstream (gvisor-tap-vsock#609 and #631; Lima's `hostLoopback: false`, lima#5581), a user-v2 daemon of devvm's own (lima#5464), or QEMU with the Linux mechanism on macOS too (it works there, slower than `vz`). The self-check catches it breaking silently.
|
||||
- VMs started outside devvm (`limactl start`, `limactl shell` starting a stopped VM, Lima's start at login) aren't confined: devvm reports them `unenforced`. An `override.yaml` setting a dead `HTTPS_PROXY` might harden this (untested).
|
||||
@@ -8,13 +8,14 @@ weight: 7
|
||||
|
||||
The site is [Hugo](https://gohugo.io) with the [Hextra](https://imfing.github.io/hextra/) theme, built from `docs/`. Hextra is a Hugo module pinned in `docs/go.mod`; update it with `hugo mod get github.com/imfing/hextra@<version>` in `docs/`.
|
||||
|
||||
- **Pages** are Markdown files in `docs/content/docs/`, one per topic, in a folder per section of the sidebar. The sections run in the order a new user needs them: `getting-started/`, `using/`, `safety/`, `backends/`, `compared/`, `cli/`, `internals/`, then `contributing/`. Each folder's `_index.md` is the section's own page, which lists its pages. Update the page for any behavior you change, in the same change. The README stays high level: it says what devvm is and links to the pages for the rest.
|
||||
- **What goes where:** the user pages, in `getting-started/`, `using/`, `safety/`, `backends/` and `compared/`, say what devvm does, what you type and what you see, and they name no repo paths, Go identifiers or message names. How it works, in `internals/`, explains how devvm does it, for readers who want to check a claim, and it holds the mechanisms and the message names that come from them. Contributing, in `contributing/`, covers changing devvm, so repo paths, Go identifiers, version bumps, releases and tests go there. A user page links once to its How it works page where there is one.
|
||||
- **Pages** are Markdown files in `docs/content/docs/`, one per topic, in a folder per section of the sidebar. The sections run in the order a new user needs them: `getting-started/`, `using/`, `releases/`, `safety/`, `backends/`, `compared/`, `cli/`, `internals/`, then `contributing/`. Each folder's `_index.md` is the section's own page, which lists its pages. Update the page for any behavior you change, in the same change. The README stays high level: it says what devvm is and links to the pages for the rest.
|
||||
- **What goes where:** the user pages, in `getting-started/`, `using/`, `safety/`, `backends/` and `compared/`, say what devvm does, what you type and what you see, and they name no repo paths, Go identifiers or message names. How it works, in `internals/`, explains how devvm does it, for readers who want to check a claim, and it holds the mechanisms and the message names that come from them. Contributing, in `contributing/`, covers changing devvm, so repo paths, Go identifiers, version bumps, releases and tests go there, and so do the [design notes](design.md), which say why devvm is built as it is and hold each emulation's design note and threat check. A user page links once to its How it works page where there is one.
|
||||
- **Current behavior, but for releases:** every page describes how devvm works now, and none mentions older behavior, what changed or what moved, because that goes in the changelog and on the release pages. Releases, in `releases/`, is the one place the docs describe history. It has a page for each minor release, such as `releases/0.2.0.md`, which covers the release and its release candidates and is written as the release is made. Each change there has a section of its own, under Breaking changes, Changes, Fixes or Hardening, that tells its full story: what was wrong or missing, how it showed, how devvm works now, at the level of the user pages, and what you do, with links to the user or How it works pages for anything deeper. The changelog's entry links each section, as [Releasing](maintaining.md#releasing) says. These pages follow the docs voice, but they aren't user pages, so the rules for leading with a command don't apply.
|
||||
- **User pages lead with doing:** a task on a user page, in `getting-started/`, `using/`, `safety/`, `backends/` or `compared/`, shows its command, in a copyable block or numbered steps, and a short explanation follows. One paragraph of why next to its command is fine, but two or more paragraphs back to back mean the mechanism belongs on the How it works page, under a heading that the user page links to, with every fact moved rather than dropped. The docs-voice skill's [SKILL.md](https://github.com/devvmhq/devvm/blob/main/.agents/skills/docs-voice/SKILL.md) has the rule, under Commands first on user pages, with an example, and its `scan.sh -p paras` and `scan.sh -p long` list the runs and the long paragraphs.
|
||||
- **Front matter** sets `title`, shown as the page's heading, `weight`, the page's place in its section, or a section's place in the sidebar for an `_index.md`, and `explainer`, the line under the title on the page's social card, which Social cards below describes. Start the body at `##`.
|
||||
- **Links** to other pages point at their files (`[Contributing](_index.md)`), so the linters can check them.
|
||||
- **Diagrams** are Mermaid code blocks, fenced with `mermaid`, which are drawn as SVGs before Hugo builds the site, so no page loads Mermaid or any other diagram JavaScript. A diagram goes where it helps the reader follow the text, with at most one sentence to introduce it, and the text keeps every fact the diagram shows.
|
||||
- **Drawing them:** `mise run docs:diagrams` installs [pele](https://pele.run) with `npm ci --ignore-scripts`, at the version and integrity that `docs/package.json` and `docs/package-lock.json` pin, and then runs `docs/render-diagrams.mjs`. The script draws each block in `docs/content` as an SVG in `docs/.build/diagrams/`, which git ignores, with a JSON file of the diagram's size beside it. It names both for the block's key, a hash of the salt and the block's text, where the salt is a hash of pele's version and the script itself, and it writes the salt to that folder too. `mise run docs` and `mise run lint:docs` run it first, and so do the Docs workflow's builds.
|
||||
- **Diagrams** are Mermaid code blocks, fenced with `mermaid`, which a script draws as SVGs before Hugo builds the site, so no page loads Mermaid or any other diagram JavaScript. A diagram goes where it helps the reader follow the text, with at most one sentence to introduce it, and the text keeps every fact the diagram shows.
|
||||
- **Drawing them:** `mise run docs:diagrams` installs [pele](https://pele.run) with `npm ci --ignore-scripts`, at the version and integrity that `docs/package.json` and `docs/package-lock.json` pin, and then runs `docs/render-diagrams.mjs`. The script draws each block in `docs/content` as an SVG in `docs/.build/diagrams/`, which git ignores, with a JSON file of the diagram's size beside it. It names both files for the block's key, which is a hash of the salt and the block's text. The salt is a hash of pele's version and the script itself, and the script writes it to that folder too. `mise run docs` and `mise run lint:docs` run it first, and so do the Docs workflow's builds.
|
||||
- **Caching:** a run with nothing changed takes a few hundredths of a second. mise skips the task when the drawings' folder is newer than every page in `docs/content`, the script, `docs/package.json` and the lock, so the script updates the folder's time on every run. The task runs `npm ci` only when the lock's SHA-256 differs from the one it wrote to `docs/node_modules/.devvm-lock-sha256` after its last install. The script keeps every drawing that's already there, draws only the blocks it has no drawing of, and deletes the files no block's key names, so a changed diagram is drawn again on its own, and a new pele or a change to the script draws them all again. The CI workflow's check job caches npm's downloads, keyed on the lock, and the Docs workflow, which publishes, keeps no cache and draws every diagram.
|
||||
- **Putting them in pages:** `hugo.yaml` mounts that folder at `assets/diagrams`, and the render hook, `docs/layouts/_markup/render-codeblock-mermaid.html`, which takes the place of Hextra's, reads the salt, computes each block's key from it and the block's text, and puts the SVG in the page. A block without its SVG fails the build, so run `mise run docs:diagrams` again after you change a diagram, even while `mise run docs` serves the site, because the server doesn't redraw them.
|
||||
- **The theme** is in `custom.css`, which sets pele's `--pele-*` variables from the site's palette, so a diagram never sets its own colors or font. Panels are on the surface color with blue borders, lines and arrows are lime, subgraphs, lifelines and notes use the border color, and text is in Departure Mono at 14px, larger than the home page's art so labels read easily.
|
||||
@@ -75,7 +76,7 @@ The site is [Hugo](https://gohugo.io) with the [Hextra](https://imfing.github.io
|
||||
| Vale | the style rules | `.vale.ini`, `.vale/styles/devvm/` |
|
||||
| lychee (`--offline`) | links to pages and files | |
|
||||
|
||||
It also builds the site with Hugo's `--panicOnWarning`, into a temporary folder it removes, so any warning fails it. That includes a deprecation, such as a template that reads `site.Data` where Hugo wants `hugo.Data`, so a Hugo upgrade that deprecates something the templates use fails here before the feature is removed. It runs `TestExplainers` too, so a page without an explainer fails it, and `TestUserPageProse` (`internal/cli/docgen/prose_test.go`), which holds the user pages to [lead with doing](#writing-docs): it fails a run of three or more paragraphs back to back where two are over 80 words, and any paragraph or list item over 150 words. It counts words as `scan.sh` does, a code span as one word and a link by its text, and a paragraph of 40 words or fewer that ends with a colon introduces what follows, so it isn't in a run. `proseExempt` names the pages that another branch is rewriting, each with why, until that branch lands.
|
||||
It also builds the site with Hugo's `--panicOnWarning`, into a temporary folder it removes, so any warning fails it. That includes a deprecation, such as a template that reads `site.Data` where Hugo wants `hugo.Data`, so a Hugo upgrade that deprecates something the templates use fails here before the feature is removed. It runs `TestExplainers` too, so a page without an explainer fails it, and `TestUserPageProse` (`internal/cli/docgen/prose_test.go`), which holds the user pages to [lead with doing](#writing-docs): it fails a run of three or more paragraphs back to back where two are over 80 words, and any paragraph or list item over 150 words. It counts words as `scan.sh` does, a code span as one word and a link by its text, and a paragraph of 40 words or fewer that ends with a colon introduces what follows, so it isn't in a run. `proseExempt` names the pages that another branch is rewriting, each with why, until that branch lands. `TestChangelogShape` (`internal/cli/docgen/changelog_test.go`) holds `CHANGELOG.md` to the shape that [Releasing](maintaining.md#releasing) gives an entry, and `TestChangelogProblems` checks that each of its rules fails an entry that breaks it.
|
||||
|
||||
### The CLI reference
|
||||
|
||||
@@ -99,4 +100,4 @@ The tests fail when the checked-in pages are stale: `TestReferenceIsCurrent` in
|
||||
|
||||
### Building the site
|
||||
|
||||
`mise run docs` draws the diagrams, then serves the site at `http://localhost:1313/` and reloads on every change but a diagram's, which needs `mise run docs:diagrams` again. After `mise run docs:diagrams`, `mise exec -- hugo -s docs --minify` builds it into `docs/public/`, as the Docs workflow does for devvm.dev, and `mise exec -- hugo -s docs --minify --config hugo.yaml,next.yaml` builds the site as next.devvm.dev has it, with its banner and its noindex ([the docs sites](maintaining.md#the-docs-sites)).
|
||||
`mise run docs` draws the diagrams, then serves the site at `http://localhost:1313/` and reloads on every change except a diagram's, which needs `mise run docs:diagrams` again. After you run `mise run docs:diagrams`, `mise exec -- hugo -s docs --minify` builds the site into `docs/public/`, as the Docs workflow does for devvm.dev, and `mise exec -- hugo -s docs --minify --config hugo.yaml,next.yaml` builds the site as next.devvm.dev has it, with its banner and its noindex ([the docs sites](maintaining.md#the-docs-sites)).
|
||||
@@ -10,15 +10,15 @@ devvm runs every VM on Lima, but the rest of devvm reaches Lima only through the
|
||||
|
||||
- **It implements `backend.Backend`** and returns its errors instead of ending the run: a `msg.M`, or `backend.Logged(m)` once a logged command failed, so the command shows the run log's end before the message. `Backend` is the backend's `Name` and `Caps` and four roles, each an interface of its own that every backend implements in full:
|
||||
- `backend.Host` is what the backend needs of this machine and where it keeps its VMs there. `Problems` lists what the host lacks for it, and `backend.Check(ctx, b)` returns the first of them, so a backend doesn't write a check of its own. `NameMax` is the longest VM name it takes, `Location` is where its VMs live when that can change between runs (`backend.LocationOf`), and `DiskDirs` and `Floors` are the folders its disks are in and the free space it wants there (`backend.Space`). A backend whose VMs can't move returns `""` from `Location`, and one whose disks aren't on this machine returns no `DiskDirs`.
|
||||
- `backend.Images` builds images and the shared tools' images and keeps the images. `BuildImage` runs the spec's `Recipe` (`image.Recipe`, which `internal/build` puts together and `image.Input` hashes) as it is, each `image.Step` with its arguments and as root when it says so. `Origin` is the backend's own steps that base starts with, such as the Ubuntu image Lima pinned on this machine, a `--from` image's conversion, base's disk size (`backend.BaseDiskGiB`) and `base.yaml`. Base's size is `backend.BaseCPUs`, `backend.BaseMemoryGiB` and `backend.BaseDiskGiB`, never read from a backend's files. `internal/build` puts them first in base's recipe, as its `Origin`, so base's key hashes them, and `BuildImage` is given them back and runs those rather than reading its own files again. `PinOrigin` pins what base starts from on this machine, which `internal/build` asks for before it keys a build (`backend.PinFirst`): on Lima, that's the newest Ubuntu cloud image (`state.UbuntuPin`, found by `ubuntu.Finder`). A base build's `ImageSpec.Packages` sends its packages into the VM's `backend.PackagesDir` before the steps and takes them out after, which `internal/build/packages.go` records or replays and checks, and a step that exits `backend.ExitUnreachable` fails as `build_sources_unreachable`.
|
||||
- `backend.Machines` makes, starts, stops, renames and deletes VMs, lists them, and runs commands and shells in them. A stopped VM changes only at `Start`, which first checks with `backend.Validate` that it can apply the VM's `backend.Want`, such as a disk no smaller than the VM's own, and then applies what the `Want` asks where it differs from the VM. `Start` leaves a running VM as it is, and the callers, not the backend, warn that a change waits for the VM's next start. On Lima, `Start` owns the config's `env:`, `propagateProxyEnv`, `dns` and `hostResolver`, and a project VM's size, agent mounts and `forwardAgent`, which it compares with the VM's before its one edit ([what devvm sets on a VM](../internals/lima.md#what-devvm-sets-on-a-vm)). Ports are never the backend's: `vmssh.Forwards` forwards them over the backend's `SSH`. `Running` says how a VM runs now, in one `backend.Run`: the ID of its current start, whether it's confined to its proxy, and its lifeline, the file that the VM's proxy and port forwarder follow. The backend runs no port forwarder of its own, and `SSH` says how ssh, links and devvm's forwarder (`vmssh.Forwards`) reach a running VM's sshd, a target that `vmssh.FromTarget` checks. All three get it through `vmssh.Checked`, which checks the review lets the backend's ssh through, checks the target, and adds the VM's host keys for its current start, reading the record (`vmssh.ReadKeys`) or pinning the keys first (`vmssh.PinKeys`). A VM whose ssh isn't usable fails with a `*vmssh.UnusableError` and one without host keys with `vmssh.ErrNoHostKeys`, which the ssh config skips on. `Exec` passes its `backend.ExecOpts` streams on as they are, because a terminal's files must give the command a terminal in the VM, as a shell has, which an agent's login that draws full-screen needs, and any other streams are pipes (`TestExecStreamsAsGiven` on Lima).
|
||||
- `backend.Housekeeping` is what devvm space and devvm gc ask: `Usage`, `Strays`, and `DevvmCache` and `DeleteCache` for its own caches. A backend that can't tell returns none.
|
||||
- `backend.Images` builds images and the shared tools' images and keeps the images. `BuildImage` runs the spec's `Recipe` (`image.Recipe`, which `internal/build` puts together and `image.Input` hashes) as it is, each `image.Step` with its arguments and as root when it says so. `Origin` is the backend's own steps that base starts with, such as the Ubuntu image Lima pinned on this machine, a `--from` image's conversion, base's disk size (`backend.BaseDiskGiB`) and `base.yaml`. Base's size is `backend.BaseCPUs`, `backend.BaseMemoryGiB` and `backend.BaseDiskGiB`, never read from a backend's files. `internal/build` puts them first in base's recipe, as its `Origin`, so base's key hashes them, and `BuildImage` is given them back and runs those rather than reading its own files again. `PinOrigin` pins what base starts from on this machine, which `internal/build` asks for before it keys a build (`backend.PinFirst`): on Lima, that's the newest Ubuntu cloud image (`state.UbuntuPin`, found by `ubuntu.Finder`). A base build's `ImageSpec.Packages`, a `backend.Packages`, sends its packages into the VM's `backend.PackagesDir` before the steps and takes them out after, which `internal/build/packages.go` records or replays and checks, and a step that exits `backend.ExitUnreachable` fails as `build_sources_unreachable`. `DeleteToolsLeft` deletes the throwaway VMs that `BuildTools` left, such as a killed run's, and never another VM or an image, and it returns the ones it deleted, which devvm gc names. devvm gc asks for it while it holds the share's lock, so no build of this data folder's is using them, but a devvm with another data folder and the same Lima home holds a lock of its own (`DEVVM_LIMA_HOME`), so the two mustn't build tools or run gc at once. A backend whose builds leave none does nothing.
|
||||
- `backend.Machines` makes, starts, stops, renames and deletes VMs, lists them, and runs commands and shells in them. A stopped VM changes only at `Start`, which first checks with `backend.Validate` that it can apply the VM's `backend.Want`, such as a disk no smaller than the VM's own, and then applies what the `Want` asks where it differs from the VM. `Start` leaves a running VM as it is, and the callers, not the backend, warn that a change waits for the VM's next start. On Lima, `Start` owns the config's `env:`, `propagateProxyEnv`, `dns` and `hostResolver`, and a project VM's size, agent mounts and `forwardAgent`, which it compares with the VM's before its one edit ([what devvm sets on a VM](../internals/lima.md#what-devvm-sets-on-a-vm)). Ports are never the backend's: `vmssh.Forwards` forwards them over the backend's `SSH`. `Running` says how a VM runs now, in one `backend.Run`: the ID of its current start, whether it's confined to its proxy, and its lifeline, the file that the VM's proxy and port forwarder follow. The backend runs no port forwarder of its own, and `SSH` says how ssh, links and devvm's forwarder (`vmssh.Forwards`) reach a running VM's sshd, a target that `vmssh.FromTarget` checks. Every ssh of devvm's to a VM, its port forwarder's included, refuses a target that isn't on this machine's loopback, `127.0.0.1`, with `vmssh.FromTarget` ([what each backend emulates](../internals/backends.md#what-each-backend-emulates)). All three get it through `vmssh.Checked`, which checks the review lets the backend's ssh through, checks the target, and adds the VM's host keys for its current start, reading the record (`vmssh.ReadKeys`) or pinning the keys first (`vmssh.PinKeys`). A VM whose ssh isn't usable fails with a `*vmssh.UnusableError` and one without host keys with `vmssh.ErrNoHostKeys`, which the ssh config skips on. `Exec` passes its `backend.ExecOpts` streams on as they are. When they're a terminal's files, the command must get a terminal in the VM, as a shell does, because an agent's login that draws full-screen needs one, and any other streams are pipes (`TestExecStreamsAsGiven` on Lima).
|
||||
- `backend.Housekeeping` is what devvm space and devvm gc ask: `Usage`, `Strays`, and `DevvmCache` and `DeleteCache` for its own caches. A backend that can't tell returns none. devvm gc also asks `backend.Images` for `DeleteToolsLeft`, which sits beside `BuildTools`, whose VMs it deletes.
|
||||
|
||||
`backend.Forgetter` is the one role a backend may leave out, for the files it keeps for a VM besides the VM. Lima keeps none. Lima's type, `lima.Lima`, holds the backend's fields, `Name`, `Caps` and the helpers its roles share, and it embeds one type for each role, `host`, `images`, `machines` and `housekeeping`, each over the `Lima` it's part of. `backendtest.Fake` is split the same way. So no type has more methods than the structure test allows, and a new method goes on the type of its role.
|
||||
- **It declares `Caps`**, saying for each of `backend.Features` whether it has the feature natively, emulates it, or lacks it ([features](../internals/backends.md#features)). It lists every feature by hand, `None` included, and `Registry.Register` refuses `Caps` that leave one out or rate a feature better than the one `Feature.BuiltOn` says it's built on (`Caps.Check`). The callers, not the backend, decide what a VM needs, and they check it with the registry's `Review.Require(b, vm, spec.Features()...)` before they act. A feature the backend lacks fails in one line that names the VM and what to do, and devvm never falls back to something weaker. An emulation stays refused until its review passes: a design note in [the design notes](../internals/design.md), a threat check with the security-audit skill, and end-to-end checks that prove its guarantee.
|
||||
- **It declares `Caps`**, saying for each of `backend.Features` whether it has the feature natively, emulates it, or lacks it ([features](../internals/backends.md#features)). It lists every feature by hand, `None` included, and `Registry.Register` refuses `Caps` that leave one out or rate a feature better than the one `Feature.BuiltOn` says it's built on (`Caps.Check`). The callers, not the backend, decide what a VM needs, and they check it with the registry's `Review.Require(b, vm, spec.Features()...)` before they act. A feature the backend lacks fails in one line that names the VM and what to do, and devvm never falls back to something weaker. An emulation stays refused until its review passes: a design note in [the design notes](design.md), a threat check with the security-audit skill, and end-to-end checks that prove its guarantee.
|
||||
- **It's registered in `registry.New`** (`internal/backend/registry`), the only place besides `internal/cli` that imports a backend. The registry hands the backend out behind its guard, which checks every `CreateVM`, `Start`, `BuildImage` and `BuildTools` call before the backend sees it. The guard refuses a spec that needs a feature `Review.Require` would refuse, using the specs' own `Features`, and a build spec whose `ImageSpec.Validate` or `ToolsSpec.Validate` fails, such as one with a network that isn't a build's or a key that isn't one. So a caller that forgets `Require` still can't reach a backend with a feature it lacks, and the backend doesn't check those specs itself. The guard has every role's methods, its own in place of the backend's for those calls, so a guarded backend handed on as a `backend.Images` or a `backend.Machines` is still guarded. The guard's type has only `backend.Backend`'s methods, so code that looks for an optional role, such as `backend.Forgetter`, uses `backend.As` instead of a type assertion, and the structure test fails on a type assertion to a backend package's type anywhere but the guard.
|
||||
- **It names its images by key**, and an image's key hashes the backend's name, so two backends never share an image.
|
||||
- **It passes the conformance suite**, `backendtest.Conformance(t, factory)`, which checks the contract that `backend.Backend`'s documentation gives. The backend's tests call it with a factory that returns a new `backendtest.Subject` for each check, and each check runs as a subtest. The subject is the backend, holding one image, whose key is `Image`, and no VMs. `Dir` is a folder of the check's own for the folders its VMs mount, `Boots` says whether its VMs start, and `Restart` starts a running VM again outside `Start`, as a command of the user's own would. The suite checks every role's answers and the empty answers each role allows, that a VM is made, renamed and deleted as its spec says, and that a missing VM is `backend.ErrNotFound`. It also checks that `Running` gives a stopped VM its lifeline with an empty `ID`, that every start gets another `ID`, that a VM is `Confined` only while it runs on a start `Start` made with `NetProxy`, and that the registry's guard still refuses what the backend lacks when the backend is used as `backend.Images` or `backend.Machines` alone. When `Boots` is false, the checks that need a running VM are skipped with the reason, and when `Restart` is nil, so is the one that needs it. `backendtest.Fake` runs the suite in `internal/backend/backendtest`, and `TestConformance` in `internal/backend/lima` runs it on Lima twice: on the limactl stub, whose VMs start, and on real Lima's dummy instances, which can't boot, so the checks that need a running VM are left to the end-to-end tests. The real Lima run skips when limactl isn't on `PATH`. `TestConformanceFinds` checks the suite itself: each of a set of fakes that breaks the contract in one method fails the check meant to catch it.
|
||||
- **It passes the conformance suite**, `backendtest.Conformance(t, factory)`, which checks the contract that `backend.Backend`'s documentation gives. The backend's tests call it with a factory that returns a new `backendtest.Subject` for each check, and each check runs as a subtest. The subject is the backend, holding one image, whose key is `Image`, and no VMs. `Dir` is a folder of the check's own for the folders its VMs mount, `Boots` says whether its VMs start, and `Restart` starts a running VM again outside `Start`, as a command of the user's own would. The suite checks every role's answers and the empty answers each role allows, that a VM is made, renamed and deleted as its spec says, and that a missing VM is `backend.ErrNotFound`. It also checks that `Running` gives a stopped VM its lifeline with an empty `ID`, that every start gets another `ID`, that a VM is `Confined` only while it runs on a start `Start` made with `NetProxy`, and that the registry's guard still refuses what the backend lacks when the backend is used as `backend.Images` or `backend.Machines` alone. `checkProxyURL` checks what the open tier needs of every backend, which has no feature of its own ([features](../internals/backends.md#features)): a VM on the backend's own network (`NetDirect`) reaches a port on the host's loopback, and the guest's proxy settings come from the confinement (`Confinement.GuestProxy`, `ProxyURL`). When `Boots` is false, the checks that need a running VM are skipped with the reason, and when `Restart` is nil, so is the one that needs it. `backendtest.Fake` runs the suite in `internal/backend/backendtest`, and `TestConformance` in `internal/backend/lima` runs it on Lima twice: on the limactl stub, whose VMs start, and on real Lima's dummy instances, which can't boot, so the checks that need a running VM are left to the end-to-end tests. The real Lima run skips when limactl isn't on `PATH`. `TestConformanceFinds` checks the suite itself: each of a set of fakes that breaks the contract in one method fails the check meant to catch it.
|
||||
|
||||
The registry's `For` chooses a VM's backend: a VM that exists gets the one its state records in `backend=`, and a new VM gets `backend.Default`, which is `lima`. Tests set the registry's `NewVMs` to give new VMs a fake backend (`backendtest.Fake`). The command line has no way to choose a backend, so a second backend would also add one, following the [cli skill](https://github.com/devvmhq/devvm/blob/main/.agents/skills/cli/SKILL.md), together with its column in the tables that list VMs, images and caches. `--json` output already names each VM's, image's and shared tool's backend.
|
||||
|
||||
@@ -41,7 +41,7 @@ A toolchain that needs more than mise's install gets code of its own, which the
|
||||
|
||||
## Adding a coding agent
|
||||
|
||||
Each coding agent is one `agents.Def` in `internal/agents/agents.go`, and the rest of devvm reads every list of the agents and every fact of one from there: its shared tool (`image.SharedTools` makes its entry, glibc-only or not), its settings folders and files with each file's format, the folders it reads in a VM as a seed of a folder of the VM's own (its `Seeds`, Claude Code's plugins, each with the link that the VM's home puts the store's folder at and the entries that `devvm agent import` and `devvm agent save` copy, which `agents.MachineOwn` judges), the tables in those files whose keys are names you choose, such as its MCP servers' (its `Names` and `NamedValues`, which `agentlogin.Redact` doesn't judge as keys, read from the agent's own docs), the folder that `devvm agent import` copies from, its login files and their kinds, its history and what an export leaves out of it, the environment that every VM's shells get, which turns off its self-update and telemetry, the secret every VM with it uses, how `devvm agent login` logs it in (its `Login`: the command lines of its own login, with a code and for a setup token, and whether the login comes back to a forwarded port or you paste a code back; or API keys alone), whether `config.toml`'s `[pass-keys]` takes it, and its row in the docs' Supported agents table (its `Docs`). The commands' help, `--agents`, the picker, shell completion, the messages and the CLI tests' lists of the agents all come from the registry too. A new agent that works like one devvm has needs these files and nothing else:
|
||||
Each coding agent is one `agents.Def` in `internal/agents/agents.go`, and the rest of devvm reads every list of the agents and every fact of one from there: its shared tool (`image.SharedTools` makes its entry, glibc-only or not), its settings folders and files with each file's format, its `Seeds`, its `Names` and `NamedValues`, the folder that `devvm agent import` copies from, which of that folder's entries are each machine's own (its `FolderOwn`), which neither the import nor the save copies and no VM gets, its login files and their kinds, its history and what an export leaves out of it (its logins, and what's the VM's own as a machine, its `HistoryOwn`, which a VM made again keeps), where in that history it makes git worktrees, which `devvm rm` and a remake with `--clean-home` check for uncommitted changes first (its `Worktrees`), the environment that every VM's shells get, which turns off its self-update and telemetry, the secret every VM with it uses, how `devvm agent login` logs it in (its `Login`: the command lines of its own login, with a code and for a setup token, and whether the login comes back to a forwarded port or you paste a code back; or API keys alone), whether `config.toml`'s `[pass-keys]` takes it, and its row in the docs' Supported agents table (its `Docs`). Its `Seeds` are the folders it reads in a VM as a seed of a folder of the VM's own, such as Claude Code's plugins. Each one has the link that the VM's home puts the store's folder at and the entries that `devvm agent import` and `devvm agent save` copy, which `agents.MachineOwn` judges. Its `Names` and `NamedValues` are the tables in its settings files whose keys are names you choose, such as its MCP servers', which `agentlogin.Redact` doesn't judge as keys, read from the agent's own docs. The commands' help, `--agents`, the picker, shell completion, the messages and the CLI tests' lists of the agents all come from the registry too. A new agent that works like one devvm has needs these files and nothing else:
|
||||
|
||||
- `internal/agents/agents.go`: its `Def` and its name's constant.
|
||||
- `assets/shared-tools/mise.toml`: its line in `[tool_alias]`, the backend it comes from, and in `[tools]`, its version.
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
---
|
||||
title: Setting up GitHub for releases
|
||||
explainer: The GitHub settings that releases through CI and the co-signer need, once, in order
|
||||
weight: 3
|
||||
---
|
||||
|
||||
Releases go through CI and the co-signer only once GitHub is set up for them, and until then `scripts/publish.sh --local` publishes them from the maintainer's machine, as [Releasing](maintaining.md#releasing) says. This page is the setup, in the order to do it. Each step gives the clicks in GitHub's settings and, where GitHub's API can do it, the `gh api` command that does the same. Read each command before you run it, check it against GitHub's documentation, and replace each `<…>` with its value. The commands assume the repos are `devvmhq/devvm` and `devvmhq/homebrew-tap`, under the organization `devvmhq`.
|
||||
|
||||
Step 4 needs your user ID, which `gh api user --jq .id` prints, and step 7 the App ID from step 2.
|
||||
|
||||
## 1. The release keys
|
||||
|
||||
devvm checks a release with three release keys once they're built into it ([Release keys](maintaining.md#release-keys)). Until you make them, `packaging/keys` has none and `install.sh`'s three key lines are empty, so devvm and the install script check each release with the old release key alone, and `scripts/publish.sh --local` publishes it signed with that key, as before. CI's Release workflow, `scripts/publish.sh` without `--local`, `--sign-legacy` and the co-signer refuse to run without the keys, and each refusal points here. Make each key where its holder keeps it, and never two on one machine:
|
||||
|
||||
```sh
|
||||
minisign -G -W -p packaging/keys/release-ci.pub -s ci.key # CI's, with no password: step 4 puts it in GitHub
|
||||
sudo minisign -G -W -p release-cosign.pub -s /etc/devvm-cosign/release.key # on the co-signer's machine (step 3)
|
||||
minisign -G -p release-recovery.pub -s /path/on/an/offline/drive/recovery.key # the recovery key, with a password, kept offline
|
||||
```
|
||||
|
||||
Commit the three `.pub` files to `packaging/keys/` as `release-ci.pub`, `release-cosign.pub` and `release-recovery.pub`, and copy each key into `install.sh`'s `release_ci_key`, `release_cosign_key` and `release_recovery_key` lines, all in one commit, because a devvm with one or two of the keys can't upgrade. `TestReleaseKeys` checks that the keys are all three, each a different minisign key and none of them the old release key, and `TestInstallScriptKeys` checks that `install.sh`'s lines match them. `scripts/release.sh --check-tag` refuses a tag with one or two of the keys, a key marked `PLACEHOLDER` in its comment, or lines in `install.sh` that differ. The first release built with the keys still carries the old key's signature, so every devvm before it, which has no release keys, upgrades to it. Keep `ci.key` only until step 4, then delete it, because a lost CI key is replaced by a release that the other two keys sign.
|
||||
|
||||
## 2. The GitHub App
|
||||
|
||||
The co-signer calls GitHub as an app of its own, never with your GitHub token, and the app can read the repo, write releases and the tap, and read workflow runs' artifacts, and nothing else ([The GitHub App](cosigner.md#the-github-app)).
|
||||
|
||||
1. Open `https://github.com/organizations/devvmhq/settings/apps/new` (for a user account, Settings, then Developer settings, then GitHub Apps, then New GitHub App).
|
||||
2. Name it, such as `devvm-cosign`, with `https://devvm.dev` as its homepage, and clear **Webhook: Active**.
|
||||
3. Under **Repository permissions**, set **Contents** to Read and write and **Actions** to Read-only. GitHub adds **Metadata**, Read-only. Leave every other permission, and every organization and account permission, at No access.
|
||||
4. Under **Where can this GitHub App be installed?**, choose **Only on this account**, then **Create GitHub App**.
|
||||
5. Note the **App ID** and the **Client ID** at the top of its page: the config's `[app] id` takes either, and step 7 needs the App ID.
|
||||
6. Under **Private keys**, choose **Generate a private key**, and copy the `.pem` file to the co-signer's machine as `/etc/devvm-cosign/app.pem`, root's, mode 0600. Delete the downloaded copy.
|
||||
7. Choose **Install App**, then the `devvmhq` account, then **Only select repositories**, and select `devvm` and `homebrew-tap` alone. The installation's ID is the number at the end of the page's URL afterwards, `…/installations/<ID>`, which is the config's `[app] installation`.
|
||||
|
||||
Check it:
|
||||
|
||||
```sh
|
||||
gh api orgs/devvmhq/installations --jq '.installations[] | {id, app_slug, repository_selection, permissions}'
|
||||
gh api orgs/devvmhq/installations/<installation ID>/repositories --jq '.repositories[].full_name' # devvm and homebrew-tap alone
|
||||
```
|
||||
|
||||
## 3. The co-signer's machine
|
||||
|
||||
Set it up as [Setting it up](cosigner.md#setting-it-up) says, with the release key from step 1 and the app's key from step 2, then step 7 below for its notify command. Its `init` records what GitHub has published, so run `devvm-cosign@init` once the setup on this page is done and before the first release goes through it.
|
||||
|
||||
## 4. The release environment
|
||||
|
||||
CI's Release workflow runs in the environment `release`, which waits for your approval on each run and holds CI's release key and the tag signers ([CI's release workflow](maintaining.md#cis-release-workflow)). Only runs for `v*` tags may use it, and administrators can't skip the approval.
|
||||
|
||||
1. In `devvm`'s **Settings**, open **Environments**, then **New environment**, and name it `release`.
|
||||
2. Tick **Required reviewers** and add yourself. Leave **Prevent self-review** clear, because you push the tags you approve. Approve only a run for a tag you just pushed: the run is that tag's own workflow, so approving it gives CI's release key to the tag's code, and the tag's signature check runs inside it.
|
||||
3. Clear **Allow administrators to bypass configured protection rules**.
|
||||
4. Under **Deployment branches and tags**, choose **Selected branches and tags**, then **Add deployment branch or tag rule**, choose **Tag**, and enter `v*`.
|
||||
5. Under **Environment secrets**, add `RELEASE_CI_KEY`, the whole of `ci.key` from step 1, both lines, then delete `ci.key`.
|
||||
6. Under **Environment variables**, add `RELEASE_TAG_SIGNERS`: the SSH public keys that sign release tags, one per line, each after a name, as git's allowed signers file has them, such as `cj ssh-ed25519 AAAA…`. The key is the one `packaging/release-signer` pins the fingerprint of, and `git config user.signingkey` names.
|
||||
|
||||
The same with `gh`:
|
||||
|
||||
```sh
|
||||
gh api --method PUT repos/devvmhq/devvm/environments/release --input - <<'EOF'
|
||||
{
|
||||
"wait_timer": 0,
|
||||
"prevent_self_review": false,
|
||||
"can_admins_bypass": false,
|
||||
"reviewers": [{ "type": "User", "id": <your user ID> }],
|
||||
"deployment_branch_policy": { "protected_branches": false, "custom_branch_policies": true }
|
||||
}
|
||||
EOF
|
||||
gh api --method POST repos/devvmhq/devvm/environments/release/deployment-branch-policies -f name='v*' -f type=tag
|
||||
gh secret set RELEASE_CI_KEY --env release --repo devvmhq/devvm < ci.key
|
||||
printf 'cj %s\n' "$(cat ~/.ssh/<your signing key>.pub)" | gh variable set RELEASE_TAG_SIGNERS --env release --repo devvmhq/devvm
|
||||
```
|
||||
|
||||
Check it with `gh api repos/devvmhq/devvm/environments/release`: `can_admins_bypass` is false, `protection_rules` lists you as the reviewer, and `gh api repos/devvmhq/devvm/environments/release/deployment-branch-policies` lists `v*` as a tag.
|
||||
|
||||
## 5. The tag ruleset
|
||||
|
||||
Only you can create, move or delete a `v*` tag, so nobody else can start a release build, or retag a release. GitHub's rulesets take roles, teams and apps as bypasses, not a single user, so the bypass is the repository's admin role, which is you while you're the only admin. Check that first, `gh api repos/devvmhq/devvm/collaborators --jq '.[] | select(.permissions.admin) | .login'`, which lists organization owners too, and check `gh api repos/devvmhq/devvm/rulesets` for a tag ruleset there already, to edit rather than add.
|
||||
|
||||
1. In `devvm`'s **Settings**, open **Rules**, then **Rulesets**, then **New ruleset**, then **New tag ruleset**.
|
||||
2. Name it `Release tags`, and set **Enforcement status** to Active.
|
||||
3. Under **Bypass list**, add **Repository admin**, with **Always allow**.
|
||||
4. Under **Target tags**, add the pattern `v*`.
|
||||
5. Under **Tag rules**, tick **Restrict creations**, **Restrict updates**, **Restrict deletions** and **Block force pushes**, then **Create**.
|
||||
|
||||
The same with `gh`:
|
||||
|
||||
```sh
|
||||
gh api --method POST repos/devvmhq/devvm/rulesets --input - <<'EOF'
|
||||
{
|
||||
"name": "Release tags",
|
||||
"target": "tag",
|
||||
"enforcement": "active",
|
||||
"conditions": { "ref_name": { "include": ["refs/tags/v*"], "exclude": [] } },
|
||||
"rules": [{ "type": "creation" }, { "type": "update" }, { "type": "deletion" }, { "type": "non_fast_forward" }],
|
||||
"bypass_actors": [{ "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "always" }]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
`actor_id` 5 is the repository admin role.
|
||||
|
||||
## 6. Immutable releases
|
||||
|
||||
Once a release is published, nobody can change its files or move its tag, so the files the co-signer checked are the ones users download. A draft can still change, which is how the co-signer and `--sign-legacy` add their files before it's published.
|
||||
|
||||
In `devvm`'s **Settings**, under **General**, then **Releases**, tick **Enable release immutability**. With `gh`, `gh api --method PUT repos/devvmhq/devvm/immutable-releases`, and `gh api repos/devvmhq/devvm/immutable-releases` checks it.
|
||||
|
||||
## 7. The tap's ruleset
|
||||
|
||||
Only the co-signer's app writes the tap's `main`, so nobody else can point Homebrew at other archives.
|
||||
|
||||
1. In `homebrew-tap`'s **Settings**, open **Rules**, then **Rulesets**, then **New ruleset**, then **New branch ruleset**.
|
||||
2. Name it `main`, and set **Enforcement status** to Active.
|
||||
3. Under **Bypass list**, add the app from step 2, with **Always allow**.
|
||||
4. Under **Target branches**, choose **Include default branch**.
|
||||
5. Under **Branch rules**, tick **Restrict updates**, **Restrict deletions** and **Block force pushes**, then **Create**.
|
||||
|
||||
The same with `gh`, with the App ID from step 2:
|
||||
|
||||
```sh
|
||||
gh api --method POST repos/devvmhq/homebrew-tap/rulesets --input - <<'EOF'
|
||||
{
|
||||
"name": "main",
|
||||
"target": "branch",
|
||||
"enforcement": "active",
|
||||
"conditions": { "ref_name": { "include": ["~DEFAULT_BRANCH"], "exclude": [] } },
|
||||
"rules": [{ "type": "update" }, { "type": "deletion" }, { "type": "non_fast_forward" }],
|
||||
"bypass_actors": [{ "actor_id": <App ID>, "actor_type": "Integration", "bypass_mode": "always" }]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
To fix the tap by hand, turn the ruleset's enforcement off, make the change, and turn it on again, which admins can do. The co-signer raises an alert for a tap formula it didn't write.
|
||||
|
||||
## 8. Where the co-signer tells you
|
||||
|
||||
A run that fails, a refusal and an alert reach you through the config's `notify` command ([Refusals and alerts](cosigner.md#refusals-and-alerts)). A script that posts over HTTPS works under the co-signer's units, such as this one to ntfy, saved as `/usr/local/bin/devvm-cosign-notify`, root's, mode 0755, with `notify = ["/usr/local/bin/devvm-cosign-notify"]` in the config:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
# What failed comes on standard input.
|
||||
exec curl -fsS --max-time 30 -H 'Title: devvm co-signer' --data-binary @- https://ntfy.sh/<a long random topic>
|
||||
```
|
||||
|
||||
An ntfy.sh topic is readable by anyone who knows its name, so use a long random one, or a server of your own with an ntfy access token. GitHub tells you the rest: it emails you when the Release workflow waits for your approval, and when a run fails.
|
||||
|
||||
## 9. The first release through CI
|
||||
|
||||
Make it a release candidate, so a mistake costs little:
|
||||
|
||||
```sh
|
||||
git tag -s v<version> && scripts/publish.sh # push main and the tag
|
||||
gh run watch --repo devvmhq/devvm # approve the run in the Actions tab first
|
||||
scripts/publish.sh --sign-legacy # once the co-signer's draft is there
|
||||
gh release view v<version> --repo devvmhq/devvm # published, with SHA256SUMS and its three signatures
|
||||
```
|
||||
|
||||
The three signatures are CI's, the co-signer's and the old key's, `SHA256SUMS.ci.minisig`, `SHA256SUMS.cosign.minisig` and `SHA256SUMS.minisig`.
|
||||
|
||||
Then `scripts/publish.sh --local` isn't needed any more, and a release it published would be one the co-signer alerts on.
|
||||
@@ -4,7 +4,7 @@ explainer: Bump pinned versions, fix known vulnerabilities, release devvm and ru
|
||||
weight: 2
|
||||
---
|
||||
|
||||
For maintainers: version bumps and releases. Run the scripts with mise, which puts the pinned GoReleaser and minisign on `PATH`: `mise exec -- scripts/release.sh`.
|
||||
For maintainers: version bumps and releases. Run the scripts with mise, which puts the pinned minisign on `PATH`: `mise exec -- scripts/release.sh`. A release you build yourself builds in a container, so you also need podman or Docker for that, though not to push a release's tag for CI.
|
||||
|
||||
## Updating pinned versions
|
||||
|
||||
@@ -17,37 +17,43 @@ scripts/bump.sh docker pele # only these tools, with a named images or e2e t
|
||||
```
|
||||
|
||||
- `--check` prints each group's pins under its name in brackets, such as `[go]`, with each pin's current version and upstream's newest, and whether a bump would be a patch, a minor or a major, or a new digest, commit, checksum or release for a pin that isn't a version. A held pin says which version holds it, and a line that the run wouldn't apply says how to apply it. When upstream's latest is older than a pin, as when a release marker hasn't moved yet, `--check` says the pin is newer and `bump.sh` leaves it as it is.
|
||||
- With no tools named, `bump.sh` applies every patch and minor bump, and never a major, a held pin or a tool that it applies only when named. Naming an images or e2e tool applies its major too. `e2e-tools` always applies one, because users get the shared tools' new majors as well, and `assets/shared-tools/mise.toml` holds what stays.
|
||||
- It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit, an image digest), since some of the edited files run on the host, and it edits nothing unless every value is good. Then it runs the commands that finish a bump: `mise lock` for Go and the dev tools, `go get` and `go mod tidy` for the modules, `go get` and `hugo mod tidy` in `docs/` for Hextra, `npm install --ignore-scripts` in `docs/` and then `mise run docs:diagrams` for pele, and actionlint and zizmor for the workflows. If one of those fails, the pins are already edited, and it says so.
|
||||
- With no tools named, `bump.sh` applies every patch and minor bump. It never applies a major, a held pin or a tool that it applies only when named. Naming an images or e2e tool also applies its major. `e2e-tools` always applies one, because users get the shared tools' new majors as well, and `assets/shared-tools/mise.toml` holds what stays.
|
||||
- It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit, an image digest), since some of the edited files run on the host, and it edits nothing unless every value is good. Then it runs the commands that finish a bump: `mise lock` for Go and the dev tools, `go get` and `go mod tidy` for the modules, `go get` and `hugo mod tidy` in `docs/` for Hextra, `npm install --ignore-scripts` in `docs/` and then `mise run docs:diagrams` for pele, and actionlint and zizmor for the workflows. If one of those fails, the pins are already edited, and `bump.sh` says so.
|
||||
- It needs `curl` and `jq`, `mise` for Go, the dev tools, the end-to-end lock and pele, `go` to apply the modules and Hextra, and `gh` for the actions.
|
||||
- Every Monday the Pins workflow (`.github/workflows/pins.yml`) runs `scripts/bump.sh --check` and opens or updates one issue, "Pinned versions to bump", which lists the outdated pins under their groups, and closes it once none is left. It never bumps anything: you run `scripts/bump.sh`, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests) when an images or e2e pin moved, because those bumps change images.
|
||||
- `bump.sh` sends `GH_TOKEN`, or else `GITHUB_TOKEN`, when one is set, with its calls to GitHub's API and to nothing else, through a header file rather than curl's command line. Without a token, GitHub allows 60 calls an hour from one address, which a CI runner shares with other jobs, and once they're spent it refuses the rest with a `403`. A fetch that fails names its URL.
|
||||
- Every Monday the Pins workflow (`.github/workflows/pins.yml`) runs `scripts/bump.sh --check` with the workflow's token and opens or updates one issue, "Pinned versions to bump", which lists the outdated pins under their groups and the shared tools that `e2e-tools` waits for, and closes it once none is left. It never bumps anything, so you run `scripts/bump.sh`, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests) when an images or e2e pin moved, because those bumps change images.
|
||||
|
||||
The tools, by group, as `--check` prints them:
|
||||
|
||||
| Group | Tools | What they move |
|
||||
| --- | --- | --- |
|
||||
| `images` | `docker`, `nix`, `direnv`, `nix-direnv`, `mise`, `git-lfs`, `rustup`, `crane`, `omb`, `eza`, `tealdeer` | the downloads pinned in `assets/`, and devvm's host mise |
|
||||
| `images` | `docker`, `nix`, `direnv`, `nix-direnv`, `mise`, `git-lfs`, `rustup`, `crane`, `omb`, `eza`, `tealdeer` | the downloads pinned in `assets/`, and devvm's host mise, so `scripts/bump.sh nix direnv nix-direnv` moves the [nix layer](../internals/images.md#the-nix-layer)'s three pins |
|
||||
| `shared-tools` | `cursor`, only when named | Cursor's CLI in `assets/shared-tools/mise.toml`, the one shared tool pinned for users |
|
||||
| `e2e` | `e2e-tools`, `e2e-from`, `e2e-curl`, `e2e-ubuntu`, `e2e-lima` | the end-to-end tests' own pins |
|
||||
| `go` | `go`, `go-minor` only when named, `go-mods`, `deadcode` | Go, its modules and the deadcode task |
|
||||
| `dev-tools` | `dev-tools` | `mise.toml`'s tools but Go, with their `mise.lock` entries |
|
||||
| `dev-tools` | `dev-tools` | `mise.toml`'s tools except Go, with their `mise.lock` entries |
|
||||
| `ci` | `ci-mise`, `actions` | the mise the workflows install, and their actions |
|
||||
| `release` | `release-image` | the container that every release is built in |
|
||||
| `docs` | `hextra`, `pele` only when named | the docs site's theme, and pele, which draws its diagrams |
|
||||
|
||||
- `go` moves Go to its newest patch release of the minor that `go.mod` names: the `go` lines of `go.mod` and `docs/go.mod`, `mise.toml`'s `go`, and its `mise.lock` entries, from `go.dev/dl`. `--check` reports a newer minor on the `go-minor` line, and `scripts/bump.sh go-minor` moves the same files to it.
|
||||
- `go` moves Go to its newest patch release of the minor that `go.mod` names, from `go.dev/dl`. It edits the `go` lines of `go.mod` and `docs/go.mod`, `mise.toml`'s `go`, and its `mise.lock` entries. `--check` reports a newer minor on the `go-minor` line, and `scripts/bump.sh go-minor` moves the same files to it.
|
||||
- `go-mods` moves `go.mod`'s direct modules, the ones the depguard allowlist allows and the tests' own, to their newest patch or minor release from the Go module proxy, with `go get` and `go mod tidy`. The indirect ones move as `go mod tidy` needs them. A module's next major has a new path, so `--check` reports it and you move it by hand. `deadcode` moves the deadcode task's version in `mise.toml` to golang.org/x/tools' newest release.
|
||||
- `dev-tools` moves each of `mise.toml`'s tools but Go to mise's newest version of it, edits its line and runs `mise lock`, so `mise.lock` keeps every platform's checksum, and markdownlint-cli2's lock folder in `.mise/locks/` moves with it. nilaway has no releases, so its pin is a pseudo-version, and `dev-tools` moves it to the one for its newest commit.
|
||||
- `dev-tools` moves each of `mise.toml`'s tools except Go to mise's newest version of it, edits its line and runs `mise lock`, so `mise.lock` keeps every platform's checksum, and markdownlint-cli2's lock folder in `.mise/locks/` moves with it. nilaway has no releases, so its pin is a pseudo-version, which `mise latest` prints nothing for. `dev-tools` moves a Go tool pinned to a pseudo-version to its newest commit's, from the Go module proxy's `@latest` for the module that holds the tool, the longest prefix of its path that the proxy has. A tool with no newest version stops the run with an error, never a change, and so does any failed request to the proxy, except its answer that a prefix isn't a module.
|
||||
- `ci-mise` moves the `version` that the workflows give jdx/mise-action to base's mise, as the run leaves it, so `scripts/bump.sh mise ci-mise` moves both. `actions` moves each workflow's `uses:` to its newest release's tag, as the tag's commit from `gh api`, with the tag in the comment after it, and reports a newer major without applying it. An action in a folder of its repo, such as `actions/cache/restore`, moves with its repo's releases.
|
||||
- `hextra` moves the docs site's theme in `docs/go.mod`, and it reminds you to compare the copies of Hextra's files in `docs/layouts/` with the new release's. `pele` moves pele, only when named, because the diagrams need a look on the built site: it runs `npm install` in `docs/` with the exact version and no install scripts, which writes `docs/package.json` and `docs/package-lock.json`, and then draws the diagrams again with `mise run docs:diagrams`. The drawing script's self-check fails that step when the new pele no longer measures and writes its small text, such as edge labels, as the script expects ([diagrams](docs.md#writing-docs)).
|
||||
- `cursor` moves Cursor's CLI, only when named, to the release that Cursor's install script fetches, with each platform's SHA-256 computed from its download, because Cursor publishes no checksums. devvm's login and proxy code was read against the pinned release, so read the new one where that code names it, then run `e2e-tools`.
|
||||
- `release-image` moves `release_image` in `scripts/release.sh`, the container that every release is built in, to the digest of Docker Hub's newest index of `buildpack-deps:trixie-scm`. The digest is the SHA-256 of the index it fetched, which every pull checks the registry's index against, and before it records the digest, it checks that the index has a `linux/amd64` and a `linux/arm64` image, the two that builders run. Every release trusts this image, because its git, awk, tar and gzip write the release's files, so read what changed in it before you commit a bump (docker-library's `repo-info` repository lists each image's packages), and run `scripts/repro-check.sh` after it ([Reproducible releases](#reproducible-releases)).
|
||||
- `hextra` moves the docs site's theme in `docs/go.mod`, and it reminds you to compare the copies of Hextra's files in `docs/layouts/` with the new release's. `pele` moves pele only when named, because the diagrams need a look on the built site. It runs `npm install` in `docs/` with the exact version and no install scripts, which writes `docs/package.json` and `docs/package-lock.json`, and then draws the diagrams again with `mise run docs:diagrams`. The drawing script's self-check fails that step when the new pele no longer measures and writes its small text, such as edge labels, as the script expects ([diagrams](docs.md#writing-docs)).
|
||||
- `cursor` moves Cursor's CLI only when named, to the release that Cursor's install script fetches, with each platform's SHA-256 computed from its download, because Cursor publishes no checksums. devvm's login and proxy code was read against the pinned release, so read the new one where that code names it, then run `e2e-tools`.
|
||||
- A hold keeps a pin below a version, and `--check` shows the newest version beside it. Go modules and actions take Dependabot's ignore list in `.github/dependabot.yml`, which keeps pflag below 1.1.0, because pflag 1.1 prints every boolean flag with `[=true|false]` in the help. The other holds are in `bump.sh`'s `holds`, which keeps Node, the one in `mise.toml`, on its major.
|
||||
- `bump.sh`'s header lists every pin with the tool that moves it, or with `-` and the reason it's left, as `# pin` lines. `TestBumpCoversPins` in `internal/structure` finds the pins in `assets/`, `mise.toml`, both `go.mod` files, the workflows, `tests/e2e-mise.lock`, `tests/e2e`'s consts, `docs/hugo.yaml` and `docs/package.json`'s dependencies, without the network, and fails on a pin that no line covers or on a line that covers nothing, so a new pin gets a tool or a reason. The header also says why the pins outside those files are left as they are, such as the Lima that `install.sh` installs, which is the newest release checked against its `SHA256SUMS`, and the Homebrew formula, whose URLs and checksums `release.sh` fills in.
|
||||
- `bump.sh`'s header lists every pin with the tool that moves it, or with `-` and the reason it's left, as `# pin` lines. `TestBumpCoversPins` in `internal/structure` finds the pins in `assets/`, `mise.toml`, both `go.mod` files, the workflows, `tests/e2e-mise.lock`, `tests/e2e`'s consts, `scripts/release.sh`'s container, `docs/hugo.yaml` and `docs/package.json`'s dependencies, without the network, and fails on a pin that no line covers or on a line that covers nothing, so a new pin gets a tool or a reason. The header also says why the pins outside those files are left as they are, such as the Lima that `install.sh` installs, which is the newest release checked against its `SHA256SUMS`, and the Homebrew formula, whose URLs and checksums `release.sh` fills in.
|
||||
- base's Ubuntu cloud image and its apt packages have nothing to bump: devvm pins the newest image on each machine at its first build of base, and records the newest packages for each key of base at its first build ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image), [base's packages](../internals/images.md#bases-packages)). `docker` moves Docker's packages (`assets/layers/docker.sh`), read from its repository for base's Ubuntu release, and its signing key. Packages added to `assets/layers/base.sh` or `assets/features/` need no pin of their own: they change base's key, whose first build records them.
|
||||
- `mise` moves base's mise (`assets/layers/base.sh`) and devvm's host mise (`internal/tools/mise.go`) together: the host one writes the lock base's installs from. `TestMisePins` fails when their versions or Linux checksums differ, and base's mise version is in the key of each tool image mise installs, so a bump builds them again.
|
||||
- The shared tools aren't pinned for users, but for Cursor's CLI: holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests.
|
||||
- The shared tools aren't pinned for users, except Cursor's CLI. Holds go in `assets/shared-tools/mise.toml` (`node = "24"` stays on that major). `testdata/mise.lock` is a fixed lock for the tests.
|
||||
- Their backends are named in `mise.toml`'s `[tool_alias]` table, for every tool that isn't one of mise's own `core:` tools, because mise's registry can move a tool to another backend in any release ([versions](../internals/images.md#versions)). A new shared tool gets its alias there, and `TestToolBackendsNamed` fails when a tool that isn't a `core:` tool has none, or when its alias isn't the backend that `tests/e2e-mise.lock` resolved.
|
||||
- When opencode's major version changes, or a bump of `e2e-tools` moves opencode to a version that adds migrations, refresh `internal/vm/testdata/opencode-<version>.sql`, the schema of opencode's database that `TestOpencodeCleanSchema` cleans. Print it with `sqlite3 ~/.local/share/opencode/opencode.db .schema` in a VM with that opencode, after `opencode auth list` has made the database, and copy only the schema, never rows. Name the file for the version, and in the test put each new table in its list of tables that devvm empties or keeps, which the test asks for. A table or a column that holds a login also goes into `opencodeLogins` (`internal/vm/agents.go`) and the design note's [opencode's database in history exports](../internals/design.md#opencodes-database-in-history-exports).
|
||||
- `e2e-tools`, `e2e-from`, `e2e-curl` and `e2e-ubuntu` move the end-to-end tests' own pins, which keep their cached images valid between runs: `e2e-tools` resolves `tests/e2e-mise.lock` again, with devvm's pinned host mise, for both architectures' glibc and musl VMs, and refuses a tool whose download has no checksum on every platform yet; `e2e-from` moves the digests of `node:24`, `alpine:3` and `ubuntu:26.04` in `tests/e2e/from_test.go` to Docker Hub's; `e2e-curl` moves `curlImage` in `tests/e2e/transparent_test.go`, the curl image that the network checks run in containers, to curlimages/curl's newest release, by its digest; `e2e-ubuntu` moves `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go`, the dated release of Ubuntu's cloud image that e2e pins base to in place of the newest, to the newest Ubuntu lists. Ubuntu removes dated releases after a few months, and e2e's going stops its first builds of base: bump `e2e-ubuntu` before that. Run `e2e-tools` after any change to `assets/shared-tools/mise.toml`, because the end-to-end tests refuse a lock resolved from another one ([end-to-end tests](tests.md#end-to-end-tests)). `mise run test` catches it first: `TestE2ELockPins` checks the lock's first line against `mise.toml` and that it locks each of its tools, and `TestE2EUbuntuPins` checks that `e2eUbuntuRelease` is a dated release of base's Ubuntu release, which `e2e-ubuntu` lists, and that `scripts/bump.sh` and `tests/e2e` name only that release.
|
||||
- When opencode's major version changes, or a bump of `e2e-tools` moves opencode to a version that adds migrations, refresh `internal/vm/testdata/opencode-<version>.sql`, the schema of opencode's database that `TestOpencodeCleanSchema` cleans. Print it with `sqlite3 ~/.local/share/opencode/opencode.db .schema` in a VM with that opencode, after `opencode auth list` has made the database, and copy only the schema, never rows. You can also make the file from the release's `packages/core/src/database/schema.gen.ts` in opencode's repo: unwrap its SQL and add the `migration` table's line at the end, and it matches `.schema` line for line. Name the file for the version, and in the test put each new table in its list of tables that devvm empties or keeps, which the test asks for. A table or a column that holds a login also goes into `opencodeLogins` (`internal/vm/agents.go`) and the design note's [opencode's database in history exports](design.md#opencodes-database-in-history-exports).
|
||||
- `e2e-tools`, `e2e-from`, `e2e-curl` and `e2e-ubuntu` move the end-to-end tests' own pins, which keep their cached images valid between runs. `e2e-tools` resolves `tests/e2e-mise.lock` again, with devvm's pinned host mise, for both architectures' glibc and musl VMs. `e2e-from` moves the digests of `node:24`, `alpine:3` and `ubuntu:26.04` in `tests/e2e/from_test.go` to Docker Hub's. `e2e-curl` moves `curlImage` in `tests/e2e/transparent_test.go`, the curl image that the network checks run in containers, to curlimages/curl's newest release, by its digest. `e2e-ubuntu` moves `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go`, the dated release of Ubuntu's cloud image that e2e pins base to in place of the newest, to the newest Ubuntu lists. Ubuntu removes dated releases after a few months, and e2e's going stops its first builds of base: bump `e2e-ubuntu` before that. Run `e2e-tools` after any change to `assets/shared-tools/mise.toml`, because the end-to-end tests refuse a lock resolved from another one ([end-to-end tests](tests.md#end-to-end-tests)). `mise run test` catches it first: `TestE2ELockPins` checks the lock's first line against `mise.toml` and that it locks each of its tools, and `TestE2EUbuntuPins` checks that `e2eUbuntuRelease` is a dated release of base's Ubuntu release, which `e2e-ubuntu` lists, and that `scripts/bump.sh` and `tests/e2e` name only that release.
|
||||
- A shared tool's newest release isn't always published for every platform at once, as when its files are still uploading, or for a few days after a Node release until its musl builds appear. `e2e-tools` counts a version that is newer than the one in `tests/e2e-mise.lock` as unpublished on a platform when its lock entry has no download with a checksum there, or when `mise lock` stops with a `404` for that platform's download. It then names the tool, the version and the platform, and stops without editing the lock, so you try again later. When devvm resolves the shared tools for users and a lock entry has no download for a platform, it steps back to an older version ([versions](../internals/images.md#versions)), but `e2e-tools` only waits, and its next run tries the newest version again. While a tool waits, `e2e-tools` can't resolve the lock again after a change to `assets/shared-tools/mise.toml` either.
|
||||
- `--check` reports an unpublished version as waiting for upstream and goes on, so the Pins workflow still passes, and its issue lists the line under Waiting for upstream, so the issue stays open while a tool waits. `--check` still reports the other shared tools. When `mise lock` stopped on the `404`, `--check` holds that tool back, at the lock's version or left out when the lock has none, and runs `mise lock` again, so another tool's failure still stops the run. Applying `e2e-tools` prints mise's output before it stops. A `404` counts as unpublished only when it's the only error `mise lock` printed, apart from the version and `--verbose` lines that end its output, and never when mise only warned about it, and only when the download's file name names an architecture and its address holds the version of exactly one of the tools that mise resolved. A version no newer than the lock's that has no download for a platform still stops the run, because upstream published it, and so does any other failure of `mise lock`, with mise's output, such as a checksum that doesn't match, even beside a `404`, or a network error.
|
||||
- While a tool waits, a plain `scripts/bump.sh` stops at `e2e-tools` before it edits anything, so bump the other pins by name, with `scripts/bump.sh TOOL…`. A wait usually ends within a few days. When a line has been under Waiting for upstream for two weeks, look at the tool's release, because a wait that long rarely ends on its own: upstream may have renamed the download, mise's registry may build the wrong address for it, or the tool may have stopped publishing checksums. Each of these needs a fix in mise or a hold on the tool in `assets/shared-tools/mise.toml`, not more waiting.
|
||||
- `e2e-lima` moves the Lima release that CI's end-to-end workflow installs, `LIMA_VERSION` in `.github/workflows/e2e.yml`, to Lima's newest release, and `LIMA_SHA256` to its `Linux-x86_64` tarball's line in that release's `SHA256SUMS`. Lima's release notes print the SHA-256 of `SHA256SUMS` itself, so `e2e-lima` checks the downloaded file against that value first and edits nothing when they differ.
|
||||
- `assets/layers/ubuntu-cloud.gpg` is Ubuntu's cloud image signing key (fingerprint `D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81`), from keyserver.ubuntu.com. If Ubuntu changes it, pinning a new image (a first build of base, or `devvm rebuild base`) stops with `ubuntu_bad_signature`: fetch the new key, check its fingerprint against Ubuntu's announcement, and replace the file (`gpg --export FPR`).
|
||||
- `assets/layers/ubuntu-archive.gpg` is Ubuntu's archive signing key, "Ubuntu Archive Automatic Signing Key (2018)" (fingerprint `F6ECB3762474EDA9D21B7022871920D1991BC93C`), fetched from keyserver.ubuntu.com by that fingerprint, checked against the fingerprint that [Ubuntu's security team lists](https://wiki.ubuntu.com/SecurityTeam/FAQ), and exported with `gpg --export-options export-minimal --export FPR`. devvm checks the `InRelease` files of a first build of base against it (`ubuntu.ArchiveKeyring`). If Ubuntu signs the archive with a new key, that build stops with `packages_refused`: fetch the new key, check its fingerprint the same way, and replace the file. The key must be RSA, because `internal/ubuntu/pgp.go` checks only RSA signatures. Moving base to a new Ubuntu release (`ubuntu.Series`, `ubuntu.Version`) also moves `ubuntu.Released`, the day Ubuntu released it, which is the date of that release's own `InRelease` (`dists/<series>/InRelease`), because devvm refuses a release pocket dated before it.
|
||||
@@ -62,7 +68,7 @@ govulncheck checks devvm against the Go vulnerability database. `mise run vuln`
|
||||
|
||||
A binary's scan works differently from the code's. It reports the vulnerable code that the binary holds rather than the calls into it, and it can name a package that isn't linked into the binary at all. Before you release for a vulnerability that only a binary's scan found, check that the binary has it, with `go version -m BINARY` for its Go and modules and `govulncheck -mode=binary -show traces BINARY` for the code it holds.
|
||||
|
||||
The workflow keeps its findings in one issue, "Known vulnerabilities in devvm", which lists each scan's vulnerabilities with the version found and the version that fixes it, and links each one's entry in the database. It comments on the issue whenever the findings change, so a new vulnerability notifies you, and closes the issue once every scan finds nothing. When govulncheck itself fails, the job fails and leaves the issue as it is. Only a scan job with read access runs govulncheck, and a second job, the only one that can write issues, reads its findings and updates the issue, but only in a run on `main`, so a run started on another branch never closes it. The scans cover devvm's Go code alone, not the packages in the VM images, the pinned tools, Lima, or releases older than the two they scan.
|
||||
The workflow keeps its findings in one issue, "Known vulnerabilities in devvm", which lists each scan's vulnerabilities with the version found and the version that fixes it, and links each one's entry in the database. It comments on the issue whenever the findings change, so a new vulnerability notifies you, and closes the issue once every scan finds nothing. When govulncheck itself fails, the job fails and leaves the issue as it is. Only a scan job with read access runs govulncheck. A second job, the only one that can write issues, reads the scan's findings and updates the issue, and it does so only in a run on `main`, so a run started on another branch never closes it. The scans cover devvm's Go code alone, not the packages in the VM images, the pinned tools, Lima, or releases older than the two they scan.
|
||||
|
||||
To fix a vulnerability, move what it's in to the version that fixes it:
|
||||
|
||||
@@ -103,18 +109,51 @@ Until a fix ships, users can still build base, because devvm's fallback to the r
|
||||
|
||||
## Releasing
|
||||
|
||||
- **Once, the keys:** a minisign key for releases, `minisign -G -p packaging/minisign.pub -s ~/.minisign/devvm.key` (commit `packaging/minisign.pub`; the secret key and its password never go in the repo), and a key git signs tags with (`git config user.signingkey`, GPG, or SSH with `gpg.format ssh`) that `git tag -v` verifies on this machine. Commit its fingerprint in `packaging/release-signer`, one per line (`#` comments): the GPG fingerprint (`gpg --fingerprint`, no spaces), or the SSH key's `SHA256:…` (`ssh-keygen -lf KEY.pub`). `release.sh` refuses a tag signed by any other key, even one git trusts. To rotate, add the new key's line, tag with it, then remove the old one.
|
||||
- **Between releases,** changes on `main` add their entries to the `## Unreleased` section at the bottom of `CHANGELOG.md`, which a line under the page's title links to, so the top of the page shows the latest release.
|
||||
- **Each release:** bump `VERSION`, move the Unreleased entries to the top as the release's `## <version>` entry, leaving the empty `## Unreleased` section at the bottom, and commit it on `main`. Then tag main's HEAD with `git tag -s v<version>` and run `mise exec -- scripts/publish.sh`, which asks for the minisign password once and asks once more before it publishes anything. The secret key never leaves this machine, and only minisign reads it, so no CI job and no GitHub secret ever has it.
|
||||
- **Once, GitHub:** the release environment, the rulesets, immutable releases and the co-signer's GitHub App, as [Setting up GitHub for releases](github-setup.md) lists them in order. Until that's done, releases go out with `scripts/publish.sh --local`, as [Publishing from this machine](#publishing-from-this-machine) describes.
|
||||
- **Once, the keys:** the three release keys, as [Release keys](#release-keys) describes, the old release key, a minisign key that signs each release while releases bridge from it, `minisign -G -p packaging/minisign.pub -s ~/.minisign/devvm.key` (commit `packaging/minisign.pub`; the secret key and its password never go in the repo), and a key git signs tags with (`git config user.signingkey`, GPG, or SSH with `gpg.format ssh`) that `git tag -v` verifies on this machine. Commit its fingerprint in `packaging/release-signer`, one per line (`#` comments): the GPG fingerprint (`gpg --fingerprint`, no spaces), or the SSH key's `SHA256:…` (`ssh-keygen -lf KEY.pub`). `release.sh` refuses a tag signed by any other key, even one git trusts. To rotate, add the new key's line, tag with it, then remove the old one.
|
||||
- **Between releases,** each change on `main` that someone could notice adds its line to the `## Unreleased` section at the bottom of `CHANGELOG.md`, in the group of the people who notice it, and its full story as a section of the next release's page in `releases/`, in the same commit. A line under the page's title links Unreleased, so the top of the page shows the latest release. Unreleased has no Highlights, because they're written at the release, and a change that affects nobody, such as a refactor, adds no line.
|
||||
- **Before the release commit, sort the lines by audience.** List every Unreleased line in a table for the maintainer, with the group it goes in, who notices it and the line itself, and name the close calls, the lines that could go in either of two groups, with the case for each. Once the maintainer approves the table, write the Highlights and the lines as it says. Then someone who didn't write the lines, such as a fresh agent, reviews them with the docs-voice skill, reading the visible part as a user would on GitHub and then each collapsed group, and flags what's vague, padded, repeated across groups or about the notes themselves. Fold in the fixes until the review finds nothing to change.
|
||||
- **Each release:** bump `VERSION`, move the Unreleased lines to the top as the release's `## <version>` entry, leaving the empty `## Unreleased` section at the bottom, and commit it on `main`. Then tag main's HEAD and push it, and CI and the co-signer do the rest:
|
||||
|
||||
```sh
|
||||
git tag -s v<version> # sign the tag with your SSH key
|
||||
scripts/publish.sh # check the tag, then push main and the tag
|
||||
mise exec -- scripts/publish.sh --sign-legacy # once the co-signer's draft is there, while the bridge lasts
|
||||
```
|
||||
|
||||
Approve the Release workflow's run in the Actions tab, and GitHub emails you when it waits. Approve only a run for the tag you just pushed, because the run is that tag's own workflow, and approving it gives CI's release key to the tag's code. Within the hour, the co-signer rebuilds the release, signs it and makes its draft release, or tells you through its notify command why not. While releases bridge from the old release key, `--sign-legacy` adds that key's signature to the draft, asking for its password, and at its next run the co-signer publishes the release and updates the tap. The old key's secret half never leaves this machine, and only minisign reads it, so no CI job and no GitHub secret ever has it.
|
||||
- **If a final release changed the state format,** freeze `testdata/v<version>/` once the tag exists: run its `generate.sh` against the tag on a Mac and on Linux, and add its tests, as [Freezing a release's state](structure.md#freezing-a-releases-state) says. A release that changes nothing on disk adds no fixture, and a release candidate adds none either, because its final release's fixture holds the state it changed.
|
||||
- **A prerelease,** such as a release candidate or a beta, goes out the same way, with a version of the form `x.y.z-<word>.N`: `VERSION` holds `0.2.0-rc.1`, `CHANGELOG.md` gets an entry `## 0.2.0-rc.1`, and the tag is `v0.2.0-rc.1`. The word is lowercase letters, such as `rc`, `beta` or `alpha`, and `release.sh` refuses any other form of `VERSION`. `scripts/publish.sh` marks a prerelease's GitHub release as a prerelease, passing `--prerelease` to `gh release create` and `gh release edit`, so GitHub's latest release skips it, and so do the install script's default, devvm upgrade and the daily release check. In the tap it changes only `Formula/devvm-rc.rb`, the formula that follows prereleases, in a commit titled `devvm-rc <version>`, so the formula `devvm` stays on the last release. At the end, it prints how to check the prerelease with `brew upgrade devvm-rc` or `brew install devvmhq/tap/devvm-rc`, and the prerelease's install script line.
|
||||
- **The tap's two formulas** are `devvm`, the newest release's, and `devvm-rc`, the newest prerelease's or release's, whichever is newer. `devvm-rc` only moves forward: each publish, a release's or a prerelease's, points `Formula/devvm-rc.rb` at the version it publishes, unless the tap's `devvm-rc` already names a newer one. So a release moves `devvm-rc` users onto it once it's newer than their prerelease, and a patch release of an older line, or a prerelease older than the tap's, leaves `devvm-rc` where it is. The printout says which way it goes, and when nothing in the tap changes, as for such a prerelease, it has no tap step and prints the install script line and devvm upgrade `--to` for checking it.
|
||||
- **A prerelease,** such as a release candidate or a beta, goes out the same way, with a version of the form `x.y.z-<word>.N`: `VERSION` holds `0.2.0-rc.1`, `CHANGELOG.md` gets an entry `## 0.2.0-rc.1`, and the tag is `v0.2.0-rc.1`. The word is lowercase letters, such as `rc`, `beta` or `alpha`, and `release.sh` refuses any other form of `VERSION`. The co-signer, or `scripts/publish.sh --local`, marks a prerelease's GitHub release as a prerelease, so GitHub's latest release skips it, and so do the install script's default, devvm upgrade and the daily release check. In the tap it changes only `Formula/devvm-rc.rb`, the formula that follows prereleases, in a commit titled `devvm-rc <version>`, so the formula `devvm` stays on the last release. At the end, `--local` prints how to check the prerelease with `brew upgrade devvm-rc` or `brew install devvmhq/tap/devvm-rc`, and the prerelease's install script line.
|
||||
- **The tap's two formulas** are `devvm`, the newest release's, and `devvm-rc`, the newest prerelease's or release's, whichever is newer. `devvm-rc` only moves forward: each publish, a release's or a prerelease's, points `Formula/devvm-rc.rb` at the version it publishes, unless the tap's `devvm-rc` already names a newer one. So a release moves `devvm-rc` users onto it once it's newer than their prerelease, and a patch release of an older line, or a prerelease older than the tap's, leaves `devvm-rc` where it is. The co-signer and `--local` follow the same rule. `--local`'s printout says which way it goes, and when nothing in the tap changes, as for such a prerelease, it has no tap step and prints the install script line and devvm upgrade `--to` for checking it.
|
||||
- **The changelog's entry is sorted by who notices each change.** Each line goes where a reader asking "does this affect me?" looks for it, so the question for a line is who notices it: everyone upgrading, the users of one feature, only a hostile VM, or nobody in practice. The entry starts with a paragraph that says which release it is and how to install it, then a line that links the release page, then its groups in this order, each one only when it has something:
|
||||
- **Highlights:** three to five concrete lines on what the release means for you, such as what now works or which reported bugs are fixed. A highlight never refers to the notes themselves, such as by pointing at What to do.
|
||||
- **What to do:** numbered steps, each an action that someone upgrading takes, such as running `devvm update` or restarting each running VM, with why when it isn't plain. A breaking change goes here when it asks something of you.
|
||||
- **Fixed:** the bugs that users reported, with their issues, and the ones a typical user plausibly hit.
|
||||
- **If you use…:** a collapsed block for each feature, such as `<details><summary>If you use a Linux host</summary>`, holding the changes that only that feature's users notice.
|
||||
- **Security hardening:** a collapsed block whose summary starts `Security hardening:` and says what the hardening means for you, such as `<details><summary>Security hardening: a VM that tries to attack your machine can now do much less</summary>`, with one line for each change that matters only when a VM is hostile.
|
||||
- **Internal changes:** a collapsed block, `<details><summary>Internal changes</summary>`, for rare conditions, limits nobody meets, pins, logs, status lines and the rest.
|
||||
- **A collapsed block renders its list on GitHub** only with a blank line after its `<details><summary>…</summary>` line and another before its `</details>`. markdownlint allows `details` and `summary` and no other inline HTML.
|
||||
- **Each line is one outcome sentence, then its links.** The sentence says what changes for you and what to do, if anything, in at most 35 words, not counting its links or a credit, and how devvm does it goes on the release page. A step in What to do may run longer, but it says only what to do and why. A line that covers several changes keeps every link of each.
|
||||
- **The links come in this form and order:** the user page to act on, for a step in What to do or a breaking change, then the change's section on the release page, then its issue, then its commit, as in `([details](https://next.devvm.dev/docs/releases/0.2.0/#claude-codes-setup-token-login), [#57](https://github.com/devvmhq/devvm/issues/57), [6965efc](https://github.com/devvmhq/devvm/commit/6965efcc0a97f7f6334f00d0530007ecf459972c))`. The issue is a full link, such as `[#57](https://github.com/devvmhq/devvm/issues/57)`, or `/pull/N` in place of `/issues/N` for a pull request, because a bare `#57` links only in GitHub's view of the release's notes, and not in `CHANGELOG.md` or anywhere else the entry is read. `gh api repos/devvmhq/devvm/issues/N --jq .pull_request` tells them apart: it prints nothing for an issue. Every reference to an issue or a pull request in the changelog is written this way, a credit's included, and the release page writes them the same way. The commit is the one that made the change, or the main one of several, linked by its full SHA and shown by its first seven characters. Find each one with `git log v<last release>..main` and its messages, and `git log -G` on `CHANGELOG.md` names the commit that added a line. Credits, such as thanks for a report, stay in the line's text, after its sentence and before its links.
|
||||
- **The links point at next.devvm.dev** in a release candidate's entry, because devvm.dev shows the latest release's docs, which don't have its release page yet, and at devvm.dev in a release's entry. Each anchor is the heading's ID as Hugo makes it, such as `#a-no_proxy-entrys-port` for A `NO_PROXY` entry's port, so check a new one against the built page. lychee checks the docs' links offline, so it doesn't check these.
|
||||
- **`TestChangelogShape` keeps the shape,** in `internal/cli/docgen/changelog_test.go`, which `mise run lint:docs` and `mise run test` run. For each entry from 0.2.0-rc.1 on, and for Unreleased once it has a line, it checks the groups and their order, three to five Highlights in a release's entry, each collapsed group's `<details>`, `<summary>` and blank lines, each line's 35 words outside What to do, its `details` link to a `releases/` page, and a full link for every issue and pull request. The entries before 0.2.0-rc.1 are history, and the test leaves them as they are.
|
||||
- **The release page holds each change's full story,** and it is `docs/content/docs/releases/<major>.<minor>.0.md`, such as `releases/0.2.0.md`, which covers the release and its release candidates. Each release candidate adds its changes there, in the same commit as its changelog entry, so the page is written as the release is made. Each change gets a section of its own with its full story, under Breaking changes, Changes, Fixes and Hardening, as [Writing docs](docs.md#writing-docs) describes, and the Releases section's own page lists the page. Every fact a changelog line leaves out is in its section, so a line can stay one sentence. A change that two lines describe, such as a step in What to do and a line in Fixed, can share one section, which both link, and a line that covers several changes links each one's section.
|
||||
- **A prerelease's changelog entry** lists what changed since the version before it, whether that's a release or another prerelease, and it becomes that prerelease's notes on GitHub. When the release itself goes out, its entry, such as `## 0.2.0`, replaces its prereleases' entries and lists everything since the last release, so someone who upgrades from that release reads one entry. Each prerelease's notes stay on its GitHub release.
|
||||
- **Before it builds,** `scripts/publish.sh` checks what it needs and stops with nothing done when a check fails. The tag `v<version>` has to pass `release.sh`'s own checks, so it exists, is signed, and is signed by a key in `packaging/release-signer`. The tag's commit has to be `main`'s HEAD, and `origin`'s `main` has to be an ancestor of it, so that the push is a fast-forward. If `origin` already has the tag, it has to be the same tag. The working tree has to be clean, `gh` has to be installed and logged in (`gh auth status`), and minisign has to be installed. A published GitHub release for the tag is refused unless it already has every file, which is the case when an earlier run stopped after it, and unless GitHub marks it as a prerelease exactly when the version is one. The refusal names the `gh release edit` command that fixes the mark. The tap's checkout, a clone of `devvmhq/homebrew-tap`, has to exist, be clean and be on `main`, for a prerelease too, and its `origin` has to have no commits that its `main` lacks. The checkout is `DEVVM_TAP_DIR`, or `../homebrew-tap` next to this repo by default.
|
||||
- **`scripts/publish.sh`**, with no flag, checks and stops with nothing done when a check fails. The working tree has to be clean. The tag `v<version>` has to pass `scripts/release.sh --check-tag`, which runs `release.sh`'s checks of the tag and the release keys and needs no container runtime, so the tag exists, is signed, and is signed by a key in `packaging/release-signer`. Its commit has to hold the release keys in `packaging/keys`, because CI's workflow refuses one without, and without them it stops, pointing at [step 1 of Setting up GitHub for releases](github-setup.md#1-the-release-keys) and at `--local`. `CHANGELOG.md` has to have an entry for the version, which the co-signer makes the release's notes from. The tag's commit has to be `main`'s HEAD, `origin`'s `main` has to be an ancestor of it, and if `origin` already has the tag, it has to be the same tag. Then it prints the version, the tag's commit and its two steps, each marked done or to do, and asks `Push main and v<version> to origin? [y/N]` on the terminal. It pushes `main`, then the tag, and prints what comes next. `--dry-run` stops before the question. It needs git alone, and it builds and publishes nothing.
|
||||
- **`scripts/publish.sh --sign-legacy`** adds the old release key's signature to the co-signer's draft, while releases bridge from that key. It needs `gh`, logged in, and minisign. It reads `VERSION`'s GitHub release, which has to be a draft holding `SHA256SUMS`, `SHA256SUMS.ci.minisig` and `SHA256SUMS.cosign.minisig`, and says so and stops when there's no draft yet, when the co-signer's signature isn't on it yet, when it's published, or when it holds `SHA256SUMS.minisig` already. It downloads those three files, and `scripts/release.sh --sign-legacy DIR` checks both signatures with this checkout's `packaging/keys`, refusing when it has no release keys, and the trusted comment `devvm-release <version>`, so the old key signs only what both builders built and signed. Then it signs `SHA256SUMS` with the old key, `DEVVM_MINISIGN_KEY` or `~/.minisign/devvm.key`, as `SHA256SUMS.minisig` with the trusted comment `devvm <version>`, which minisign asks the password for, and checks it with `packaging/minisign.pub`. It prints `SHA256SUMS`, asks `Upload SHA256SUMS.minisig to devvm <version>'s draft release? [y/N]`, and uploads it with `gh release upload`. `--dry-run` signs it but uploads nothing.
|
||||
|
||||
### Publishing from this machine
|
||||
|
||||
`scripts/publish.sh --local` builds, signs and publishes a release from this machine, as releases went out before CI and the co-signer. Its release carries the old key's signature alone, which devvm accepts while the bridge lasts, and it needs no release keys in `packaging/keys`, so it's the way releases go out until they're made. The tag it pushes still starts CI's Release workflow, which stops at its first step while there are no keys, so that failed run is expected: reject it when it waits for your approval, or leave it. Use it until GitHub is set up and the first release through CI is published, and it goes when the bridge ends at the latest, because a release that only the old key signed is then one no devvm accepts. A release it publishes after the co-signer's `init` is one the co-signer alerts on, because the co-signer didn't publish it.
|
||||
|
||||
- **Before it builds,** `scripts/publish.sh --local` checks what it needs and stops with nothing done when a check fails. The tag `v<version>` has to pass `release.sh`'s own checks, so it exists, is signed, and is signed by a key in `packaging/release-signer`. The tag's commit has to be `main`'s HEAD, and `origin`'s `main` has to be an ancestor of it, so that the push is a fast-forward. If `origin` already has the tag, it has to be the same tag. The working tree has to be clean, `gh` has to be installed and logged in (`gh auth status`), and minisign, curl and podman or Docker have to be installed. A published GitHub release for the tag is refused unless it already has every file, which is the case when an earlier run stopped after it, and unless GitHub marks it as a prerelease exactly when the version is one. The refusal names the `gh release edit` command that fixes the mark. The tap's checkout, a clone of `devvmhq/homebrew-tap`, has to exist, be clean and be on `main`, for a prerelease too, and its `origin` has to have no commits that its `main` lacks. The checkout is `DEVVM_TAP_DIR`, or `../homebrew-tap` next to this repo by default.
|
||||
- **Then it builds and shows the release.** It runs `scripts/release.sh`, which builds `dist/` and signs `SHA256SUMS`, and where minisign asks for the password. It prints the version, the tag's commit, each file with its size and SHA-256, the release notes, which are the `CHANGELOG.md` entry for the version, and the tap's changes as a `git diff` of each formula it writes: `Formula/devvm.rb` for a release, and `Formula/devvm-rc.rb`, with a line saying when a release moves it too, or when it stays on a newer version. It lists the four steps, each marked done or to do, and when nothing in the tap changes, the fourth says so. Then it asks `Publish devvm <version>? [y/N]` on the terminal, and any answer but y stops it with nothing published. `--dry-run` stops before the question, so it pushes and publishes nothing and makes no commit in the tap, and `--help` describes the script.
|
||||
- **Then it publishes, in this order.** It pushes `main` and then the tag to `origin`. It makes the GitHub release `devvmhq/devvm` `v<version>` with `gh release create --verify-tag`, titled `devvm <version>`, with the release notes and the archives, the source tarball, `SHA256SUMS`, `SHA256SUMS.minisig` and `install.sh`. The release starts as a draft and is published only once every file is uploaded, so nobody sees a release that is missing files. Last, it copies `dist/devvm.rb` to the tap's `Formula/devvm.rb` and `dist/devvm-rc.rb` to its `Formula/devvm-rc.rb`, each only when it's one the tap gets and it differs, commits them in one commit, `devvm <version>` for a release or `devvm-rc <version>` for a prerelease, with the tap's own commit signing, and pushes the tap. It uses `gh` for GitHub and never puts a GitHub token on a command line. At the end it prints how to check the release: `brew update && brew upgrade devvm`, or `brew trust --formula devvmhq/tap/devvm` and then `brew install devvmhq/tap/devvm`, with `devvm-rc` in place of `devvm` for a prerelease, and the install script's `curl` line.
|
||||
- **When a step fails,** it says which steps it published and which it didn't. Fix what failed and run it again, because every step skips what's already done: a pushed `main` or tag, a published release whose `SHA256SUMS` matches the new build's, and a tap whose formulas are already this build's. A draft release that an earlier run left gets this build's files again before it's published. A release published from another build, whose `SHA256SUMS` doesn't match, is refused. To finish by hand instead, run the steps it didn't do in order: `git push origin main`, `git push origin v<version>`, the `gh release create` above (or `gh release upload --clobber` to a draft, then `gh release edit v<version> --draft=false`), each with `--prerelease` for a prerelease, and then copy the formulas the printout listed, `dist/devvm.rb` and `dist/devvm-rc.rb`, to the tap's `Formula/`, commit them and push it.
|
||||
- `scripts/release.sh` checks the tag with `git tag -v` and its signer against this checkout's `packaging/release-signer`, then builds `dist/` from the tagged commit with GoReleaser (`.goreleaser.yaml`), in a clone of its own, so only what's committed goes in, with one `goreleaser release --skip=publish`. It checks that the binary built for this host prints the version, writes `install.sh` and adds its checksum to `SHA256SUMS`, then signs `SHA256SUMS` with `~/.minisign/devvm.key` (or `DEVVM_MINISIGN_KEY`) and verifies it with `packaging/minisign.pub`. Nothing is published, because publishing is `scripts/publish.sh`'s. `scripts/release.sh --check` runs only the tag's checks and the build's preconditions, prints the tag's commit and builds nothing, and `scripts/publish.sh` runs it first.
|
||||
- **When a step fails,** it says which steps it published and which it didn't. Fix what failed and run `scripts/publish.sh --local` again, because every step skips what's already done: a pushed `main` or tag, a published release whose `SHA256SUMS` matches the new build's, and a tap whose formulas are already this build's. A draft release that an earlier run left gets this build's files again before it's published. A release published from another build, whose `SHA256SUMS` doesn't match, is refused. To finish by hand instead, run the steps it didn't do in order: `git push origin main`, `git push origin v<version>`, the `gh release create` above (or `gh release upload --clobber` to a draft, then `gh release edit v<version> --draft=false`), each with `--prerelease` for a prerelease, and then copy the formulas the printout listed, `dist/devvm.rb` and `dist/devvm-rc.rb`, to the tap's `Formula/`, commit them and push it.
|
||||
|
||||
### The release script
|
||||
|
||||
- `scripts/release.sh` checks the tag with `git tag -v` and its signer against this checkout's `packaging/release-signer`, then builds `dist/` from the tagged commit with GoReleaser (`.goreleaser.yaml`), in a repository of its own that holds only the commit and the tag, so only what's committed goes in, with one `goreleaser release --skip=publish`. The build runs in the release's container, as [Reproducible releases](#reproducible-releases) describes. In the container, it checks that the Linux binary for the container's processor prints the version, writes `install.sh` and adds its checksum to `SHA256SUMS`. Then, outside the container, it signs `SHA256SUMS` with `~/.minisign/devvm.key` (or `DEVVM_MINISIGN_KEY`) and verifies it with `packaging/minisign.pub`. Nothing is published, because publishing is `scripts/publish.sh --local`'s, or the co-signer's for CI's build. Before it builds anything, it checks the release keys in the tag's commit, and so do `--check` and `--tag`, though a snapshot, such as `--head`'s, skips the check ([Release keys](#release-keys)). `packaging/keys` must hold none of the three or all of them, because a devvm with one or two refuses every upgrade. When it holds none, the commit's `install.sh` must have no key in its `release_<role>_key` lines. When it holds all three, each must be a minisign public key, a different one, not the old release key, not marked `PLACEHOLDER` in its comment, and the same as the commit's `install.sh` has in its `release_<role>_key` line. `scripts/release.sh --check` runs only the tag's checks and the build's preconditions, prints the tag's commit and builds nothing, and `scripts/publish.sh --local` runs it first. `scripts/release.sh --check-tag` runs the tag's and the keys' checks alone, needing no container runtime or signing key, and `scripts/publish.sh` runs it.
|
||||
- `dist/` then holds:
|
||||
|
||||
| File | What |
|
||||
@@ -126,11 +165,99 @@ Until a fix ships, users can still build base, because devvm's fallback to the r
|
||||
| `devvm-rc.rb` | the Homebrew formula `devvm-rc`, which follows prereleases, set to each platform's archive, its URL and its checksum from `SHA256SUMS` |
|
||||
| `devvm.rb` | for a release, not a prerelease, the Homebrew formula `devvm`, set the same way |
|
||||
|
||||
- `scripts/release.sh --head` builds from HEAD's commit instead, for testing, with `VERSION`'s version, a release's or a prerelease's. It's unsigned unless `DEVVM_MINISIGN_KEY` names a test key; `DEVVM_MINISIGN_PUB` names its public key in place of `packaging/minisign.pub`. `DEVVM_RELEASE_URL` points the formula at a test location. A commit without `install.sh` is refused.
|
||||
- `scripts/release.sh --head` builds from HEAD's commit instead, for testing, with the version in that commit's `VERSION`, a release's or a prerelease's, and `scripts/release.sh --commit COMMIT` does the same for any other commit. It's unsigned unless `DEVVM_MINISIGN_KEY` names a test key; `DEVVM_MINISIGN_PUB` names its public key in place of `packaging/minisign.pub`. A build signed with a test key never replaces a `dist/` whose `SHA256SUMS` verifies with this checkout's `packaging/minisign.pub`, the release key, and stops before it builds anything, so move the release's `dist/` first, or set `DEVVM_RELEASE_DIST`. `DEVVM_RELEASE_URL` points the formula at a test location. A commit without `install.sh` is refused.
|
||||
- `scripts/release.sh --tag TAG` builds the tag `TAG` as its release is built, with the same checks of the tag and its signer and the tag's version, but doesn't sign it, so another builder can build a release and compare its `SHA256SUMS` with the published one. An unsigned build, such as this one, never replaces a `dist/` that holds `SHA256SUMS.minisig`, and stops before it builds anything, so move the signed build's `dist/` first, or set `DEVVM_RELEASE_DIST` to a folder that doesn't exist yet for the unsigned one.
|
||||
- `scripts/release.sh --formula-from DIR` writes only the formulas, for `VERSION`'s release once it's published, and builds nothing: `dist/devvm-rc.rb`, and `dist/devvm.rb` too when `VERSION` isn't a prerelease. Download the release's `SHA256SUMS` and `SHA256SUMS.minisig` into `DIR` first. The script checks the signature against `packaging/minisign.pub`, and that its trusted comment is `devvm <version>` for `VERSION`'s version, so it refuses another release's files. Then it fills in the formulas the same way a build does, from that `SHA256SUMS`.
|
||||
- `scripts/release.sh --ci TAG DIR` and `--ci-sign TAG DIR` are CI's release workflow's build and signature, as [CI's release workflow](#cis-release-workflow) describes.
|
||||
- To try `dist/install.sh` on such a build, copy `dist/` to `DIR/releases/download/v<version>/`, then in a throwaway `HOME` with `DEVVM_PREFIX` under it: `DEVVM_INSTALL_TEST=1 source dist/install.sh`, set `repo_url=file://DIR` and `protos='=https,file'` (it downloads over HTTPS only), and run `main --no-deps`. Without `--no-deps` it offers to install what the host lacks: answer no, or run it with no terminal.
|
||||
- Every build sets the version with `-X github.com/devvmhq/devvm/internal/cli.version=<version>`: devvm doesn't read `VERSION`. The formula template (`packaging/homebrew/devvm.rb`) is both formulas' one source, and it builds nothing. It has an archive for each of macOS and Linux on arm64 and Intel, the same archives the install script installs, and it installs the binary alone from the one for this machine. `release.sh` fills in each formula's class, `Devvm` or `DevvmRc`, and the other formula, which it conflicts with by its full name, `devvmhq/tap/devvm-rc` or `devvmhq/tap/devvm`, because both install the `devvm` command. It also fills in each archive's URL and its checksum, which it reads from the `SHA256SUMS` it just wrote, on every line that isn't a comment. Both generated formulas pass `brew audit --strict --online` and `brew style`.
|
||||
- Publishing is the maintainer's call, so an agent asks first and never runs `scripts/publish.sh` without `--dry-run` on its own. The script's tests (`testdata/script/publish.txtar`) run it against a local bare repo as `origin`, a local bare tap and a fake `gh`.
|
||||
- Publishing is the maintainer's call, so an agent asks first and never runs `scripts/publish.sh`, in any mode, without `--dry-run` on its own. The script's tests run it against a local bare repo as `origin` and a fake `gh`: `testdata/script/publish_tag.txtar` the default and `--sign-legacy`, and `testdata/script/publish.txtar` `--local`, with a local bare tap. `testdata/script/release_ci.txtar` runs CI's `--ci` and `--ci-sign`.
|
||||
|
||||
### Release keys
|
||||
|
||||
devvm upgrade and the install script accept a release's `SHA256SUMS` when any two of three release keys signed it, so one stolen key signs nothing and one lost key stops nothing. `internal/minisign` makes the check, and the structure test keeps every other package from checking a signature itself ([the checks on owners](structure.md#the-checks-on-owners)). Each key has a role, and each role signs into a file of its own beside `SHA256SUMS`:
|
||||
|
||||
| Role | Who holds the key | Its signature |
|
||||
| --- | --- | --- |
|
||||
| `ci` | GitHub's CI, which builds the release | `SHA256SUMS.ci.minisig` |
|
||||
| `cosign` | the co-signer, a machine of the maintainer's that builds the same bytes again | `SHA256SUMS.cosign.minisig` |
|
||||
| `recovery` | the maintainer, offline, to sign in place of a lost key | `SHA256SUMS.recovery.minisig` |
|
||||
|
||||
- **The names** keep `.minisig` last, as minisign's own `-x` default does, so tools and readers take each file for a minisign signature, and `SHA256SUMS.*.minisig` lists the three. The role, rather than the key's ID, names the file, so the names stay the same when a key is replaced, and none of them is `SHA256SUMS.minisig`, the old release key's, which devvm 0.1 and 0.2 read.
|
||||
- **The trusted comment** is `devvm-release <version>`, such as `devvm-release 0.3.0`. minisign's global signature covers it, and devvm compares it with the version it asked for exactly, so a `SHA256SUMS` signed for one release can't stand in for another's, and a manifest of another kind can't stand in for a release's.
|
||||
- **Each check counts signers, not files.** Each file is checked only against its own role's key, and `minisign.NewKeys` refuses two roles with the same key or the same key ID, so two signatures are always two signers'. `TestReleaseKeys` checks that the keys in `packaging/keys`, once they're made, are three such keys, and that none of them is the old release key, so the old key's signature and one release key's are never two of three.
|
||||
- **Each kind has keys of its own.** A kind is what a manifest describes, so `devvm-base` has its own three keys, its own trusted comment and its own key files, `packaging/keys/base-<role>.pub`, though devvm doesn't read a published base yet. A key of one kind can't sign another kind's manifest.
|
||||
|
||||
The co-signer, `devvm-cosign`, holds the `cosign` keys. CI's token can only read the repo, so CI hands its build and its signature over as a workflow artifact, and the co-signer signs it only when its own rebuild matches. Then the co-signer makes the release, publishes it once two of the three keys signed it, and updates the tap. Nothing else can make or publish a release but the maintainer, and the co-signer raises an alert for any release published without it since its state began, whatever its tag, as [The co-signer](cosigner.md) describes, with its setup.
|
||||
|
||||
The public halves are in `packaging/keys`, as `release-ci.pub`, `release-cosign.pub` and `release-recovery.pub`, which `packaging.Key` embeds in devvm, and in `install.sh`'s `release_ci_key`, `release_cosign_key` and `release_recovery_key` lines, which `TestInstallScriptKeys` keeps the same as the files. To make a key, run `minisign -G -p packaging/keys/release-<role>.pub -s <its secret key's file>` where its holder keeps it, then commit the `.pub` file and copy its key into `install.sh`'s line. The co-signer's key has no password, as [Making its keys](cosigner.md#making-its-keys) says, because it signs unattended. A secret key never goes in the repo.
|
||||
|
||||
Until the maintainer makes the keys, `packaging/keys` has none of them and `install.sh`'s three lines are empty. A devvm built then has no release keys, so devvm upgrade and its install script check each release with the old release key alone, through [the bridge](#the-bridge-from-the-old-release-key), and a release signed by the release keys but not by the old key is refused. `scripts/publish.sh --local` builds and signs each release with the old key, as [Publishing from this machine](#publishing-from-this-machine) describes. CI's Release workflow, `scripts/publish.sh` without `--local`, `--sign-legacy` and the co-signer all need the keys and refuse to run without them, pointing at [step 1 of Setting up GitHub for releases](github-setup.md#1-the-release-keys), which makes them. The keys go in together, all three in `packaging/keys` and in `install.sh` in one commit, because `release.sh` refuses to build a release from a commit with one or two of them, as a devvm with only some of them would refuse every upgrade.
|
||||
|
||||
`release.sh` checks the keys of each tag it builds: none, with `install.sh`'s lines empty or missing, or all three, each a minisign key of its own, none of them the old release key, and each the same as its line in `install.sh`. It also refuses a key whose comment holds `PLACEHOLDER`, such as a stand-in made for a test, because a devvm built with a key nobody holds could never check a release. The Go tests check the same on the committed keys: `TestReleaseKeys` that they're none or three distinct keys and never the old one, `TestInstallScriptKeys` that `install.sh`'s lines match them, and `TestReleaseRefusesPlaceholders` that none is marked `PLACEHOLDER`.
|
||||
|
||||
### The bridge from the old release key
|
||||
|
||||
While releases bridge from the old release key, devvm upgrade and the install script also accept `SHA256SUMS` when the old key alone signed it, in `SHA256SUMS.minisig`, with the trusted comment `devvm <version>`, as 0.1 and 0.2's releases are. That's what lets 0.1 and 0.2, which know only that key, upgrade to a release that the new keys sign, as long as each such release carries the old key's signature too, and it's what lets devvm upgrade `--to` and the install script's `--version` install a 0.1 or 0.2 release. While the bridge lasts, the old key alone is still enough to sign a release, as it is today, so the release keys protect a release only once the bridge ends. The bridge is in one place in each:
|
||||
|
||||
- **devvm upgrade:** `internal/upgrade/legacy.go`, which `checkSums` calls when two of the release keys' signatures don't check out, with `Source.Key`, `packaging.MinisignKey` and `DEVVM_RELEASE_KEY`.
|
||||
- **The install script:** `minisign_key`, `check_legacy` and the lines of `download_signatures` and `check_signature` that name them.
|
||||
|
||||
Each release through CI and the co-signer carries the old key's signature beside the two new ones, which you add to the co-signer's draft with `scripts/publish.sh --sign-legacy`, and the co-signer waits for it before it publishes, because its config's `legacy_key` names the old key ([What a run does](cosigner.md#what-a-run-does)). A release from `scripts/publish.sh --local` carries the old key's signature alone, so devvm upgrade and the install script check it through the bridge.
|
||||
|
||||
The bridge ends with a release, the last one the old key signs, after at least two releases have gone out through CI and the co-signer, so that path is proven, and once 0.1 and 0.2's daily release check has had a few weeks to offer users a release that checks two of three. That release takes out the bridge: devvm upgrade's `legacy.go` fallback, the install script's `check_legacy`, and `minisign_key` with its lines, so its devvm and install script accept only two of the three release keys. It still carries `SHA256SUMS.minisig` itself, so 0.1 and 0.2 can upgrade to it. Its changelog entry has a What to do step for anyone still on 0.1 or 0.2: upgrade to it by name, with `devvm upgrade --to <version>`, before any later release, or install a later release with the install script, because a 0.1 or 0.2 devvm refuses every release after it. After it, the co-signer's config drops `legacy_key`, so it publishes without waiting, and `scripts/publish.sh` drops `--sign-legacy` and `--local`, and `scripts/release.sh` its old-key signing (`--sign-legacy`, and the signature its default build makes).
|
||||
|
||||
### CI's release workflow
|
||||
|
||||
The Release workflow, `.github/workflows/release.yml`, is CI's half of each release. It runs for each pushed tag that starts with `v`, in the `release` environment, which waits for the maintainer to approve the run and holds the two things the workflow trusts: the variable `RELEASE_TAG_SIGNERS`, the SSH keys that sign release tags, and the secret `RELEASE_CI_KEY`, CI's release key ([Setting up GitHub for releases](github-setup.md)). Its job's token can read the repo and nothing else, but for what the attestation needs, so the workflow can't make or publish a release. It takes these steps:
|
||||
|
||||
1. **It checks the tag** with `scripts/release.sh --ci TAG DIR`, against the signers in `RELEASE_TAG_SIGNERS`, written to an allowed signers file for git, and never against the tagged commit's `packaging/release-signer`, because CI runs the workflow and `release.sh` from the tagged commit. The tag has to be an annotated tag of a release's version, signed by one of those keys, whose tag object names the tag itself, so a tag pushed under another name is refused, and its commit has to be on `main`. The commit has to hold the three release keys in `packaging/keys`, because its devvm checks CI's and the co-signer's signatures with them, and the workflow's first step, before it installs anything, stops a tag without them and points at [step 1 of Setting up GitHub for releases](github-setup.md#1-the-release-keys).
|
||||
2. **It builds the release** as `scripts/release.sh --tag` does, with the same signers as git's allowed signers, under the runner's podman, then copies `SHA256SUMS` and exactly the files it lists, each checked against its SHA-256, into `DIR`. The formulas aren't among them, because the co-signer renders them itself.
|
||||
3. **It signs `SHA256SUMS`** with `scripts/release.sh --ci-sign TAG DIR`, which reads CI's release key on its standard input, from the environment's secret through a pipe, so the key is never in a file or an argument. The key has to be an unencrypted minisign secret key, the signature's trusted comment is `devvm-release <version>`, and the signature has to check out with the tag's `packaging/keys/release-ci.pub`, which can't be marked `PLACEHOLDER`. The signature is `SHA256SUMS.ci.minisig`.
|
||||
4. **It adds an attestation**, GitHub's signed record of which workflow run built each file `SHA256SUMS` lists, which `gh attestation verify FILE --repo devvmhq/devvm` checks. devvm doesn't check attestations, and they're a public audit trail.
|
||||
5. **It hands the build over** as the artifact `release`, which holds `SHA256SUMS`, `SHA256SUMS.ci.minisig` and the files, side by side, kept for 90 days. The co-signer finds it through the workflow's runs for the tag, as [The co-signer](cosigner.md#what-ci-hands-over) describes.
|
||||
|
||||
The workflow installs only minisign, with mise and no cache, and pins every action by its commit. The published base's workflow isn't there yet: it comes with the published base, as a workflow of its own, `base.yml`, beside this one, with its own environment, key and artifact, `base`, which the co-signer already reads.
|
||||
|
||||
### Reproducible releases
|
||||
|
||||
The same commit or tag, built on any machine, gives byte-identical release files: every archive, the source tarball, `install.sh`, `SHA256SUMS` and the formulas. To check it, build twice and compare:
|
||||
|
||||
```sh
|
||||
scripts/repro-check.sh # build HEAD twice and compare every file
|
||||
scripts/repro-check.sh <commit> # the same for another commit
|
||||
scripts/repro-check.sh v<version> # a tag, built as its release is, to compare with its published SHA256SUMS
|
||||
```
|
||||
|
||||
`repro-check.sh` runs both builds with this checkout's `scripts/release.sh`, which runs the commit's own code only in the build's container, never on your machine directly. That code still runs, though, and the container is only as isolated as your container runtime keeps it, so building a commit is running its code. A commit from outside the project, such as a pull request's, is built only with the maintainer's go-ahead for that run, as any outside code is. A commit builds as `release.sh --commit` builds it, unsigned. A tag builds as `release.sh --tag` builds it, with the tag's checks and version and without the signature, so its `SHA256SUMS` matches the published one. A commit or tag whose `release.sh` pins no `release_image`, from before reproducible builds, is refused. The second build differs from the first in what the fixes below keep out of the bytes, so that losing one of them shows as a difference:
|
||||
|
||||
- **A stray tag.** Build 2 fetches the commit from a repository with a tag, `v0.0.0-stray`, at the commit, which Go would stamp into the binary as its version if the build saw it. It's a v0 version because Go ignores a tag whose major version the module's path doesn't name.
|
||||
- **Another user.** When podman and Docker are both installed, build 1 runs under podman, as root, and build 2 under Docker, as you, and the archives would record each. With one of them, both builds run as the same user, and the script says so.
|
||||
- **The archives' headers.** Every file in each platform's archive has to be root's, with mode 0755 or 0644, as `tar -tv` lists it, whichever user either build ran as.
|
||||
|
||||
It prints each file's SHA-256, says `DIFFERS` beside any file whose two builds differ, and exits 1 when one does or when an archive's headers aren't those. Both builds run on this machine, in the same image and on its processor, so to compare two machines, run it on both and diff the printouts, which list the files in the same order on every machine. CI's `repro` job runs it under the runner's podman and Docker, on every push and pull request that CI runs on, so the runner needs cgroups v2, with the `pids` and `memory` controllers delegated to its user for podman. It needs podman or Docker, git and curl, and no mise.
|
||||
|
||||
What makes the bytes the same:
|
||||
|
||||
- **One container.** `release.sh` runs GoReleaser, writes `install.sh` and the formulas, and adds `install.sh` to `SHA256SUMS` inside one container image, with no network, `release_image` at the top of `release.sh`: Debian's `buildpack-deps:trixie-scm`, pinned by its index's digest, which `scripts/bump.sh release-image` moves. So git, which writes the source tarball, and awk, tar and gzip are the same on every builder. The image and the code that runs in the container, `release.sh`'s build, are the built commit's copies, so a tag builds the same bytes from any checkout, even one whose pin has moved since. It uses podman when it's installed and Docker otherwise, and `DEVVM_RELEASE_RUNTIME` names one. The container runs this machine's processor, `linux/arm64` or `linux/amd64`.
|
||||
- **Go and GoReleaser from the commit's `mise.lock`.** `release.sh` reads the URL and SHA-256 of the `linux-arm64` or `linux-x64` download of each from the built commit's `mise.lock`, so a tag builds with its own pins. It keeps each download in `${XDG_CACHE_HOME:-~/.cache}/devvm-release`, named by its SHA-256, and checks every copy against `mise.lock` before the build uses it. A copy that doesn't match stops the build and is deleted from the cache, so the next run downloads it again. A Go toolchain cross-compiles to the same bytes on either processor.
|
||||
- **Go's modules as `go.sum` pins them.** The modules the commit's `go.mod` needs are downloaded before the build, with this checkout's Go, and Go checks each against the commit's `go.sum`, so every builder builds from the same module files, whichever Go downloaded them. They come from Go's module proxy, `proxy.golang.org`, so rebuilding an old tag needs the proxy to still serve its modules, which it does for good unless a module is taken down, for legal reasons for example.
|
||||
- **The same environment inside.** The build runs with umask 022, `TZ=UTC`, `LC_ALL=C.UTF-8`, `CGO_ENABLED=0`, `GOTOOLCHAIN=local`, `-mod=readonly`, and no git configuration but `safe.directory`. Go's caches, `HOME` and the tools go in a folder of the container's own, because Docker Desktop's shared folders lose files that Go's parallel module downloads rename, and `-trimpath` keeps their paths out of the binaries.
|
||||
- **Only the tag built from.** The build's repository holds the commit and, for a tag, `v<version>`, and no other tags, because Go stamps the binary with a version from the tags it finds, and every machine holds different ones.
|
||||
- **Fixed archive headers.** `.goreleaser.yaml` sets each archive file's owner and group to `root`, its mode (0755 for the binary, 0644 for the rest) and its time to the commit's (`builds_info` and each file's `info`), in place of GoReleaser's defaults, which copy them from the files on disk, and `mod_timestamp` sets the binary's own time to the commit's. Without them, a build under Docker on a Mac records your user and group, and a build under podman records root, so the archives differ.
|
||||
|
||||
The signature, `SHA256SUMS.minisig`, is made outside the container, after the build, so it never changes the bytes of the other files.
|
||||
|
||||
What runs on your machine, outside the containers, is this checkout's `release.sh`: the tag's checks, the downloads, the checks on what the build wrote, and the signature. It limits what the commit's code, in the build's container, can reach and leave behind:
|
||||
|
||||
- **Downloads only from their publishers.** Each `mise.lock` URL has to start with `https://dl.google.com/go/` for Go, or `https://github.com/goreleaser/goreleaser/releases/download/` for GoReleaser, and it goes to curl as `--url`'s value, so a lock can't pass curl an option. It can't hold `..`, or a `%`, which curl would decode, so that `%2e%2e` would be `..`. curl follows redirects over HTTPS only, and gives up after 30 seconds connecting, after 15 minutes, or past 1 GiB. A lock with two entries for a tool, or two downloads of one for this platform, is refused. The tests' lock files use `file://` URLs, which `release.sh` allows only from the folder that `DEVVM_RELEASE_TEST_FILE_URLS` names, and only when that folder exists and isn't `/`, so the variable set by mistake reads no other file of yours, and each download is still checked against `mise.lock`.
|
||||
- **A repository of the build's own.** `release.sh` fetches the commit and the tag into a new repository, which has no hooks, none of this checkout's other branches, tags or objects, and no files it shares with this one, as a local clone's hardlinks would be. Its `origin` is devvm's repository on GitHub, which GoReleaser reads and nothing fetches from.
|
||||
- **No network for the build.** The Go modules are downloaded first, in a container of their own, which is the only one with the network. Everything it runs is this checkout's, never the commit's: its `release_image`, its `release.sh`, and the Go that its `mise.lock` pins, so the commit can't choose an old Go with a known flaw for the one container with the network. It gets only the commit's `go.mod` and `go.sum`, read-only, and a commit whose `go.mod` needs a newer Go than this checkout's is refused before anything runs, so build it from a checkout at least as new. Go downloads the modules from its module proxy alone, `proxy.golang.org`, and checks each against `go.sum`, or against Go's checksum database for one that `go.sum` lacks, and downloading runs none of the modules' code. So every module path that the commit's `go.mod` names is looked up on Google's proxy and checksum database, even a private one, which fails there. The build's container then runs with `--network none` and reads the modules read-only, as a module proxy's files, so the commit's code can't reach your network or the services on your machine, such as the ones that Docker Desktop and podman machine forward to the Mac's `localhost`.
|
||||
- **No capabilities and no new privileges.** Every container runs with `--cap-drop ALL` and `--security-opt no-new-privileges`. So root in the container can't give a file another owner or ignore a file's mode, and a setuid file in the commit's image gives no privileges, even under a rootful runtime, where root in the container would otherwise be root on your machine.
|
||||
- **Bounded processes and memory.** Every container runs with `--pids-limit 8192` and `--memory 8g`, so a build that forks without end or keeps allocating stops at those limits rather than using up your machine's, which matters most under rootful Docker on Linux, whose containers share your kernel and have no limit of their own. Rootless podman supports them only on cgroups v2, with the `pids` and `memory` controllers delegated to your user, as systemd does by default. Disk space has no limit that both runtimes support, so while a build runs, it can fill the disk that holds your temporary folder or the runtime's storage, until the time limit stops it.
|
||||
- **The right user.** The container runs as root under a rootless runtime, rootless podman or Docker's rootless mode, which maps root to you, and as you under a rootful one, Docker or Docker Desktop, so the files it writes are yours either way. The runtime's info says which, never its name, so podman behind a `docker` command runs as podman does, and a runtime that doesn't answer, such as Docker Desktop when it isn't running, stops the build before it starts.
|
||||
- **Only your own files back.** The build writes its files to a folder of their own, mounted at `/out`, which the container can't swap for a link, because a mount point can't be renamed. Before `release.sh` copies, signs or keeps any of them, it checks that the folder is still the one it made, not a link to another, that everything in it is a file or a folder, never a link, that each is yours and is neither setuid, setgid, sticky nor writable by anyone, and that they come to 2 GiB at most, which a release is far under. Then it copies the files to `dist/` rather than moving them, so each copy is yours, with mode 0755 or 0644. So neither minisign, `publish.sh` nor `gh` follows a link that the container made, and no file the container wrote keeps its owner or its mode. `release.sh` runs with umask 022 on your machine too, so the signature it adds to `dist/` is 0644 as well, even under a umask such as Ubuntu's 0002, which would leave it writable by your group.
|
||||
- **A time limit, and no container left behind.** `release.sh` names each container for its run alone and removes it from your machine once it has run for two hours, or for `DEVVM_RELEASE_TIMEOUT` seconds, whatever its image does. It removes it too as soon as `release.sh` stops early. Ctrl+C, a closed terminal and `kill` stop it at once, and after `kill -9` a watchdog that outlives `release.sh` removes the container and the build's temporary folder within a few seconds. The container's first process is `bash`, so the image's own entrypoint never runs.
|
||||
|
||||
## The docs sites
|
||||
|
||||
|
||||
@@ -18,15 +18,15 @@ weight: 3
|
||||
| `goroutines` | in non-test files, a function that starts a goroutine, with a `go` statement, a wait group's `Go` or `time`'s or `context`'s `AfterFunc`, is in `goroutineSites`, with what waits for its goroutines to end, or `detached:` and why nothing does, and a package that starts one calls `leaktest.Main` in its tests' `TestMain` |
|
||||
| `dropped-errors` | in non-test files, no function assigns a `Wait`'s error, or a `strconv` parse's, to `_`, such as `_ = cmd.Wait()` or `n, _ := strconv.Atoi(s)`, unless `droppedErrors` lists it with why, because a failed wait would read as a clean exit and text that isn't a number as 0 |
|
||||
| `read-limits` | in non-test files, every `io.ReadAll` reads through an `io.LimitReader` made in its call, such as `io.ReadAll(io.LimitReader(r, limit+1))`, unless `unboundedReads` lists its function with why, so a peer or a file that never ends can't fill the memory |
|
||||
| `folder-ids` | in non-test files outside `internal/platform`, no function compares a folder's identity or its volume with `==` or `!=`, but with `""`, switches on one, passes one to `strings.EqualFold`, `strings.Compare`, `slices.Contains` or `slices.Index`, or keys a map by one, indexed or in a map's literal, its type written out or a named map type of the module's: a field named `Folder` or `GitID`, a call of a state's `Folder` or `FolderVolume`, of `FolderID`, `folderID` or `FolderDevice`, or a name in the same function that one of those, or such a name, was assigned to, unless `exactFolderIDs` lists it with why, because a boot can number an unchanged folder's device anew, which only `platform.SameFolder` and `platform.SameOpenFolder` allow for |
|
||||
| `status-lines` | in non-test files outside the folders `statusFree` lists, a function that does slow work, which makes a host command with `exec.Command` or `exec.CommandContext`, runs host git through `internal/hostgit`, walks a folder with `fs.WalkDir`, `filepath.Walk`, `filepath.WalkDir`, `hostsafety.Walk` or `safefile.Walk`, looks up a volume with `platform.VolumeUUID`, makes a request with `internal/fetch`'s `Open`, `Resolve`, `Get` or `Download`, waits for a lock with `platform.LockFile`, `LockFileShared` or `LockDir` whose waiting is `nil` or `platform.NoWait`, or runs a backend's command outside a step with its `Runner`'s `Output` or `Attach`, shows a status line itself, with a Reporter's `Status`, a `LoggedCmd` step or its `Runner`'s `Run`, unless `statusSites` lists it with why, so the user sees what devvm waits for ([status lines](cli.md#status-lines)) |
|
||||
| `folder-ids` | in non-test files outside `internal/platform`, no function compares a folder's identity or its volume with `==` or `!=`, except with `""`, switches on one, passes one to `strings.EqualFold`, `strings.Compare`, `slices.Contains` or `slices.Index`, or keys a map by one, whether indexed or in a map's literal, with its type written out or as a named map type of the module's. A folder's identity is a field named `Folder` or `GitID`, a call of a state's `Folder` or `FolderVolume`, a call of `FolderID`, `folderID` or `FolderDevice`, or a name in the same function that one of those, or such a name, was assigned to. A function passes when `exactFolderIDs` lists it with why. The rule is there because a boot can number an unchanged folder's device anew, which only `platform.SameFolder` and `platform.SameOpenFolder` allow for |
|
||||
| `status-lines` | in non-test files outside the folders `statusFree` lists, a function that does slow work shows a status line itself, with a Reporter's `Status`, a `LoggedCmd` step or its `Runner`'s `Run`, unless `statusSites` lists it with why, so the user sees what devvm waits for ([status lines](cli.md#status-lines)). Slow work is making a host command with `exec.Command` or `exec.CommandContext`, running host git through `internal/hostgit`, walking a folder with `fs.WalkDir`, `filepath.Walk`, `filepath.WalkDir`, `hostsafety.Walk` or `safefile.Walk`, looking up a volume with `platform.VolumeUUID`, making a request with `internal/fetch`'s `Open`, `Resolve`, `Get` or `Download`, a `fetch.Resumable{…}.Download` or `ubuntu.Download`, waiting for a lock with `platform.LockFile`, `LockFileShared` or `LockDir` whose waiting is `nil` or `platform.NoWait`, or running a backend's command outside a step with its `Runner`'s `Output` or `Attach` |
|
||||
|
||||
The layers:
|
||||
|
||||
- Only `cmd/devvm` and `internal/cli` import `internal/ui`; only `internal/cli` imports `internal/vm`; only `cmd/devvm` imports `internal/cli`.
|
||||
- `internal/backend/...` imports none of `internal/vm`, `build`, `tools`, `netpolicy`, `secrets`, `project`, `gitprotect`, `sshconfig`, `sshagent`, `trust` or `vmssh`, so the port forwarder and the link sessions stay devvm's on every backend.
|
||||
- Only `internal/backend/registry` and `internal/cli` import a backend (`lima`); only tests import `backendtest`, `internal/leaktest`, `internal/memnet`, and `internal/stubtest` and the packages below it, which import only `internal/msg` and each other. The stubs' binary, `internal/stubtest/stub`, and its state, `internal/stubtest/stubstate`, import nothing else of devvm's, because the binary stands in for the tools devvm runs and is built apart from it.
|
||||
- `internal/proxy` imports no other devvm package but `internal/daemon`, `internal/landlock`, `internal/redact`, `internal/safefile` and `internal/vmname`.
|
||||
- `internal/proxy` imports no other devvm package except `internal/daemon`, `internal/landlock`, `internal/redact`, `internal/safefile` and `internal/vmname`.
|
||||
- `assets`, `locales`, `internal/platform`, `internal/msg/gen`, `internal/testbuild`, `internal/hostgit`, `internal/shell`, `internal/vmname`, `internal/daemon`, `internal/fetch`, `internal/jsonc`, `internal/redact`, `internal/agents`, `internal/safefile`, `internal/landlock`, `internal/leaktest` and `internal/memnet` import no devvm package; `internal/agentlogin` only `internal/agents`, `internal/fetch`, `internal/jsonc`, `internal/platform`, `internal/proxy`, `internal/redact`, `internal/safefile` and `internal/state`, because it holds agents' logins; `internal/msg` only `locales` and `internal/vmname`; `internal/paths` only `internal/msg` and `internal/vmname`; `internal/state` only `internal/msg`, `internal/paths`, `internal/platform` and `internal/vmname`; `internal/image` only `assets`, `internal/agents`, `internal/msg`, `internal/paths` and `internal/shell`; `internal/devcontainer` only `internal/image`, `internal/jsonc`, `internal/msg` and `internal/shell`.
|
||||
|
||||
Everything it holds the code to is in `devvm()` in `internal/structure/structure_test.go`:
|
||||
@@ -36,8 +36,8 @@ Everything it holds the code to is in `devvm()` in `internal/structure/structure
|
||||
- **`layers`** is the layering table: a layer's packages (`from`, but not `exceptFrom`) import none of `to` (but `exceptTo`); `x/...` is `x` and the packages below it.
|
||||
- **`commands`** maps a host command to the one package that runs it. **`execSites`** lists the files that make a host command with `exec.Command` or `exec.CommandContext`, each with why, and a listed file that no longer makes one fails. **`guardOwner`** names `internal/backend/guard.go`, the one file that asserts a backend's type. **`envOwner`** names the one file that reads devvm's `DEVVM_` variables. **`envSettings`** lists the variables read elsewhere, each with the files that read it and why. A listed file that no longer reads its variable fails. **`envOwners`** maps another variable to the one file that reads it, which for `HOME` is `internal/paths/dirs.go`.
|
||||
- **`literals`** maps a text that only one package's string literals may hold to that package and what the others use instead. **`names`** maps a name that only one package's string literals may be, whole, to that package and what the others use, and **`namesFree`** lists the folders whose literals may be one anyway: `internal/stubtest`, whose stubs are named after the commands they stand in for.
|
||||
- **`goroutineSites`** lists every function outside tests that starts a goroutine, as its file and its name (`internal/proxy/splice.go: splice`, or `Type.Method` for a method), with a function literal's goroutine counted in the function it's in, or in the package-level var whose value it is. A goroutine starts with a `go` statement, a wait group's `Go`, or `time`'s or `context`'s `AfterFunc`, whose function runs in a goroutine of its own. Goroutines the standard library starts otherwise, such as an HTTP server's for each connection, are the leak checks' to find, not the registry's. Each entry says what waits for the goroutines to end, such as `scanAll's wg.Wait`, or starts with `detached:` and says why nothing does and what ends them anyway, such as a look at a folder whose disk may hang, which `folderWithin` leaves to finish on its own. A new goroutine fails until its function is listed, and a listed function that no longer starts one fails, so the list stays current. A package that starts a goroutine also fails until a test file of its calls `leaktest.Main`. The tests' own goroutines are the [leak checks'](tests.md#goroutine-leaks).
|
||||
- **`droppedErrors`** lists the functions outside tests that assign a `Wait`'s or a `strconv` parse's error to `_`, by the same name as `goroutineSites`, each with why, and none does today. The check reads no types, so a call of any method named `Wait` counts, and the parses are `Atoi`, the `Parse` functions, `Unquote`, `UnquoteChar` and `QuotedPrefix`. A listed function that no longer drops one fails, so the list stays current.
|
||||
- **`goroutineSites`** lists every function outside tests that starts a goroutine, as its file and its name (`internal/proxy/splice.go: splice`, or `Type.Method` for a method). A function literal's goroutine counts in the function it's in, or in the package-level var whose value it is. A goroutine starts with a `go` statement, a wait group's `Go`, or `time`'s or `context`'s `AfterFunc`, whose function runs in a goroutine of its own. Goroutines that the standard library starts otherwise, such as an HTTP server's for each connection, are for the leak checks to find, not the registry. Each entry says what waits for the goroutines to end, such as `scanAll's wg.Wait`, or starts with `detached:` and says why nothing does and what ends them anyway, such as a look at a folder whose disk may hang, which `folderWithin` leaves to finish on its own. A new goroutine fails until its function is listed, and a listed function that no longer starts one fails, so the list stays current. A package that starts a goroutine also fails until a test file of its calls `leaktest.Main`. The tests' own goroutines are the [leak checks'](tests.md#goroutine-leaks).
|
||||
- **`droppedErrors`** lists the functions outside tests that assign a `Wait`'s or a `strconv` parse's error to `_`, each named as in `goroutineSites` and with why, and none does today. The check reads no types, so a call of any method named `Wait` counts, and the parses are `Atoi`, the `Parse` functions, `Unquote`, `UnquoteChar` and `QuotedPrefix`. A listed function that no longer drops one fails, so the list stays current.
|
||||
- **`unboundedReads`** lists the functions outside tests whose `io.ReadAll` reads with no limit, in the same way, each with why its reader ends: the status line's look at the end of the run's own log, which only that run writes, and the test stubs' reads of the standard input that devvm under test writes and closes. A reader limited before the call, held in a variable, counts as unlimited, so the limit goes in the call itself. A listed function that no longer reads with no limit fails.
|
||||
- **`exactFolderIDs`** lists the functions outside tests and `internal/platform` that compare a field named `Folder` or `GitID` with `==` or `!=`, in the same way, each with why: the agents' and exports' fields of that name, which are paths, `recordMove`'s check that the state is as it was read, and `folderChanged`, which runs after a start recorded the folder's identity as it is now. The check reads no types, so any field by those names counts. A listed function that no longer compares one fails.
|
||||
- **`statusSites`** lists the functions outside tests that do slow work and show no status line of their own, in the same way, each with why: the status line of the caller it runs under, named by its message, such as `checking_vm` for a launch's checks of the project folder, work that takes the terminal, such as `ssh-add` asking for a passphrase, a process with no UI, such as a forwarder or a link session, or a command made for its caller to run. **`statusFree`** lists the folders whose code shows none, each with why: `internal/ui`, which draws the status line, the proxy's and devvm's background processes, `internal/hostgit` and `internal/fetch`, whose callers' functions are the sites, and the tests' stubs. The check reads no types, so it doesn't see a backend's methods, such as `Exec`, which `TestLaunchStatusLines` checks for a launch, and a caller's status line is only named, so a reviewer checks that it covers the call. A listed function that no longer does slow work without one fails.
|
||||
@@ -49,7 +49,7 @@ Shell scripts that live in Go strings get shellcheck too, since lint's shellchec
|
||||
|
||||
## One owner for each concern
|
||||
|
||||
Each concern in devvm has one owner, the package or function that does it, such as `internal/hostgit` for every git command devvm runs on the host, `internal/paths` for every folder and file devvm uses, `internal/settings` for every default (`settings.Read` and `settings.Save`, over `config.toml` and `settings.json`, with each value's parser), and `locales/en.toml` for every message. Before you add a helper, a parser, a path, a file reader, a message or a table, find its owner and extend it. A second copy drifts from the first, and then one of them is wrong. Code with no owner yet can have a second copy, because a copy can be cheaper than the wrong shared helper, so extract an owner at the third copy, or at once for a judge such as `proxy.Public` or `NormHost`, whose two copies would disagree on what's allowed. [The packages](#the-packages) says what each package owns, and the failures of the checks below name the owners too.
|
||||
Each concern in devvm has one owner, the package or function that does it, such as `internal/hostgit` for every git command devvm runs on the host, `internal/paths` for every folder and file devvm uses, `internal/settings` for every default (`settings.Read` and `settings.Save`, over `config.toml` and `settings.json`, with each value's parser), and `locales/en.toml` for every message. Before you add a helper, a parser, a path, a file reader, a message or a table, find its owner and extend it. A second copy drifts from the first, and then one of them is wrong. Code with no owner yet can have a second copy, because a copy can be cheaper than the wrong shared helper, so extract an owner at the third copy. A judge, such as `proxy.Public` or `NormHost`, gets its owner at once, because its two copies would disagree on what's allowed. [The packages](#the-packages) says what each package owns, and the failures of the checks below name the owners too.
|
||||
|
||||
### The packages
|
||||
|
||||
@@ -59,55 +59,57 @@ Each package owns these concerns, and a package's `doc.go`, where it has one, ma
|
||||
| --- | --- |
|
||||
| `cmd/devvm` | the entry point: `ui.Main` makes the run's UI and runs the root command with it, and it's the only `os.Exit` |
|
||||
| `internal/cli` | the command line. Each Cobra command has a file of its own, and its `about` holds its docs page, its help group and the reason it has no `--json`. The package also holds the run's services (`app.go`), the argument and flag checks, whose failures are usage errors, help, `--json`, the CLI tests, `docgen/`, which writes the CLI reference, and doctor's check of Linux's pins (`pins.go`) |
|
||||
| `internal/vm` | what each command does to a folder's VM, below the command line: `Env` and its parts, the one start, the finder, the inventory, `Launch`, the agents' store, logins and saves, `Lifecycle` and the one remake, `Housekeeping`, `Settings`, `Net` and `Links`, which its `doc.go` maps with their owners. A `--clone` VM's copy is `cloneseed.go`'s: its in-VM scripts `initRepos`, `seedStage` and `seedApply`, sent through the backend's `Exec`, with the shallow file read through `internal/safefile` and the pack made by `internal/hostgit`'s git. Its uncommitted changes are `cloneworktree.go`'s `seedTree`: the index read through `internal/safefile` and normalised by `internal/hostgit`'s git, `hostgit.DiffFiles` for what differs, and each working copy read through a `safefile.Root`, opening each folder from its parent with `OpenDir`, so no link on the way is followed, then the record of what went, which `clonecheck.go` reads back. An operation in progress, the `info` files and the stash are `clonestate.go`'s `seedState`, each file read through `internal/safefile`, and only the files its `stateIDs` lists are read for object ids. The settings and hooks are `cloneconfig.go`'s `seedConfig`, an allowlist of config keys whose URLs `cleanURL` takes the credentials out of, and a VM's stash entry is saved by `clonesave.go`, without its untracked files |
|
||||
| `internal/vm` | what each command does to a folder's VM, below the command line: `Env` and its parts, the one start, the finder, the inventory, `Launch`, the agents' store, logins and saves, `Lifecycle` and the one remake, `Housekeeping`, `Settings`, `Net` and `Links`, which its `doc.go` maps with their owners. A `--clone` VM's copy is `cloneseed.go`'s: its in-VM scripts `initRepos`, `seedStage` and `seedApply`, sent through the backend's `Exec`, with the shallow file read through `internal/safefile` and the pack made by `internal/hostgit`'s git. Its uncommitted changes are `cloneworktree.go`'s `seedTree`: the index read through `internal/safefile` and normalised by `internal/hostgit`'s git, `hostgit.DiffFiles` for what differs, and each working copy read through a `safefile.Root`, opening each folder from its parent with `OpenDir`, so no link on the way is followed, then the record of what went, which `clonecheck.go` reads back. An operation in progress, the `info` files and the stash are `clonestate.go`'s `seedState`, each file read through `internal/safefile`, and only the files its `stateIDs` lists are read for object ids. The settings and hooks are `cloneconfig.go`'s `seedConfig`, an allowlist of config keys whose URLs `cleanURL` takes the credentials out of, and a VM's stash entry is saved by `clonesave.go`, without its untracked files. `Tools.update` is the step devvm tools update takes, which devvm update takes first, and `filePorts` works out a VM's ports again from its `devcontainer.json`'s, with the rules of devvm ports add and devvm ports rm ([reading the devcontainer.json again](../internals/overview.md#reading-the-devcontainerjson-again)). `vm.AgentImport` reads each agent's folder through that folder as an `os.Root` ([links out of an agent's folder](../internals/agents.md#links-out-of-an-agents-folder)). `Launch.buildTools` builds the tool images that a VM's shared tools need and the share lacks, and `retainTools` is retention's `tools.unused-age`. `Inventory.GitKeeper` names the VM that keeps a path locked, and `cloneState` is the script that reads a `--clone` VM's state back, its stash entries included. A Git LFS object file is opened beneath the common dir through an `os.Root`, each folder on the way checked first, because an `os.Root` still follows a link that stays inside it. `confinementFor` chooses a start's confinement from the tier, `starter.start` registers the interrupt's cleanup around the backend's `Start`, `vm.Env.Terminal` gives an agent's login the terminal's files (`ui.Terminal`), and `AgentLogin.endLogin` ends the login in the VM |
|
||||
| `internal/shell` | quoting for a POSIX shell (`Quote`, `QuoteJoin`), a word on one line for bash (`QuoteLine`, ANSI-C quoting) and a shell variable's names (`EnvName`), with the standard library alone |
|
||||
| `internal/vmname` | the name of every machine devvm runs on a backend, `VM`, which a field or a parameter holds instead of a string, and the parsers that make one where it's read: `Parse` for a project VM's name from an argument or a file name, which also reads `vm.json`'s name and runs in `project.Nth`, `ParseListed` for one a backend lists, `VM`'s `UnmarshalText` for one in a JSON file, which may be any machine's, so a field that must hold a project VM's is still checked with `IsProject`, `Image` for an image's machine and `VM.Aside` for a remake's old one. `msg.M.VM` reads back the VM a message's function took. It also holds a project VM's name grammar (`Prefix`, `HashLen`, `IsVM`, and `VM`'s `IsProject`, `Hash`, `Slug`, `Short`, `ImageKey` and a remake's `Aside`), with the standard library alone, so the proxy uses it too ([the checks on owners](#the-checks-on-owners)) |
|
||||
| `internal/project` | a project folder: its VM's name, its link targets, the folders that aren't safe to use and its parents |
|
||||
| `internal/gitprotect` | `.git` protection: one `scan` for each check, a `Locker` for each host, which is `Flags` on macOS, `Binds` on Linux, whose pins the start sets, or else `Watch`, and the table of its reports |
|
||||
| `internal/hostsafety` | the folder's other checks on the host: one `Walk` once the VM is stopped, which skips `.git` and finds set-id files and nested repos, and an SSH origin |
|
||||
| `internal/hostgit` | every git command devvm runs on the host, with no fsmonitor, hooks, filters or signing programs, ssh only, none of the environment's `GIT_*` variables and no prompts, and with `GIT_NO_REPLACE_OBJECTS=1` and `GIT_GRAFT_FILE=/dev/null`, so it sees a repo's real history |
|
||||
| `internal/vmname` | the name of every machine devvm runs on a backend, `VM`, which a field or a parameter holds instead of a string, and the parsers that make one where it's read. `Parse` reads a project VM's name from an argument or a file name, and it also reads `vm.json`'s name and runs in `project.Nth`. `ParseListed` reads one that a backend lists. `VM`'s `UnmarshalText` reads one in a JSON file, which may be any machine's, so a field that must hold a project VM's is still checked with `IsProject`. `Image` names an image's machine, and `VM.Aside` a remake's old one. `msg.M.VM` reads back the VM a message's function took. It also holds a project VM's name grammar (`Prefix`, `HashLen`, `IsVM`, and `VM`'s `IsProject`, `Hash`, `Slug`, `Short`, `ImageKey` and a remake's `Aside`), with the standard library alone, so the proxy uses it too ([the checks on owners](#the-checks-on-owners)) |
|
||||
| `internal/project` | a project folder: its VM's name, the hash that names its VM's state folder (`project.Hash`), its link targets, the folders that aren't safe to use and its parents |
|
||||
| `internal/gitprotect` | `.git` protection: one `scan` for each check, a `Locker` for each host, which is `Flags` on macOS, `Binds` on Linux, whose pins the start sets, or else `Watch`, and the table of its reports. A nested repo is left to another only when that repo's scan locks its git folder whole (`snapshot.covered`). `gitprotect.Protector.Check` is the check of a stopped VM, and for a VM that devvm 0.1.0 or 0.1.1-rc.1 made strict, the `converter`'s `unstrict` then takes `diff.ignoreSubmodules = all` out of its repos' configs, on a context that an interrupt doesn't cancel (`context.WithoutCancel`), and `strictLeft` does the same for `devvm git-protect on` and `off` and `devvm rm`, without the warning. `gitprotect.Keeps` says whether another VM's protection still covers a path. The configs it reads, the watch's hashed files and git's `.git`, `commondir` and `gitdir` files all go through `internal/safefile` ([.git protection](../internals/git-protection.md)) |
|
||||
| `internal/hostsafety` | the folder's other checks on the host: one `Walk` once the VM is stopped, which skips `.git` and finds set-id files and nested repos (`hostsafety.Walk`, which only `starter.walk` calls), git's own test for a bare repo's shape (`hostsafety.IsGitDir`), doctor's read of `safe.bareRepository` (`hostsafety.BareExplicit`), and an SSH origin |
|
||||
| `internal/hostgit` | every git command devvm runs on the host, with no fsmonitor, hooks, filters or signing programs, ssh only, none of the environment's `GIT_*` variables and no prompts, and with `GIT_NO_REPLACE_OBJECTS=1` and `GIT_GRAFT_FILE=/dev/null`, so it sees a repo's real history. `hostgit.UserConfig` reads one key of git's global and system config by the files' names, the files that `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` name included |
|
||||
| `internal/sshconfig` | the ssh config that reaches running VMs by name, and its Include line in `~/.ssh/config` |
|
||||
| `internal/sshagent` | each VM's choice of SSH agent, devvm's own agent and its keys |
|
||||
| `internal/build` | building and rebuilding images, and their records |
|
||||
| `internal/image` | image keys and names, with no side effects, and the shared tools' registry, `SharedTools`: one entry for each toolchain, with its members, its detection, its installer, its guest environment, its `PATH` folders and its version files (the structure test's `names`) |
|
||||
| `internal/fetch` | every HTTP client, with the standard library alone: `NewClient`, with a timeout and `HTTPSOnly` or `SameScheme`, `Retry` and `Transient`, `ReadCapped`, `Get`, `Resolve`, which finds where a HEAD's redirects end, and `Download`, which checks the SHA-256 and caps the size |
|
||||
| `internal/upgrade` | devvm upgrade: how this devvm was installed (`Detect`), the releases (`Source`, with the newest, `Check` for a notice, and `Fetch`, which checks minisign's `ED` signature by the built-in key, then the SHA-256), the unpack, the link's switch and its rollback, and Homebrew. `upgradetest/`, for tests only, has a TLS release server and a minisign signer |
|
||||
| `internal/build` | building and rebuilding images, and their records. `build.Names` checks an image name's layers and refuses a shared tool's name |
|
||||
| `internal/image` | image keys and names, with no side effects, and the shared tools' registry, `SharedTools`: one entry for each toolchain, with its members, its detection, its installer, its guest environment, its `PATH` folders and its version files (the structure test's `names`), and whether it's built for glibc alone (`image.ToolDef.GlibcOnly`) |
|
||||
| `internal/fetch` | every HTTP client, with the standard library alone: `NewClient`, with a timeout and `HTTPSOnly` or `SameScheme`, `Retry` and `Transient`, the failures callers tell apart (`Gone`, `Untrusted`, `BadCertificate` and `Unverified`), `ReadCapped`, `Get`, `Resolve`, which finds where a HEAD's redirects end, `Download`, which checks the SHA-256 and caps the size, and `Resumable`, a large download that goes on from where a cut or a stall stopped it, in this run or the next. `fetch.Client.Trust` adds your CAs to a client's roots, for the download of devvm's own mise and an agent's OAuth refresh |
|
||||
| `internal/upgrade` | devvm upgrade: how this devvm was installed (`Detect`), the releases (`Source`, with the newest, `Check` for a notice, and `Fetch`, which checks `SHA256SUMS` with `checkSums`, two of the three built-in release keys' signatures through `internal/minisign`, or while releases bridge from it, the old release key's in `legacy.go`, then the SHA-256), the unpack, the link's switch and its rollback, and Homebrew. `upgradetest/`, for tests only, has a TLS release server and the release's signers (`Signers`) |
|
||||
| `internal/minisign` | every check of a signature of devvm's own, with the standard library and `x/crypto`'s `blake2b` alone ([the checks on owners](#the-checks-on-owners)): minisign's keys and signatures (`ParsePublicKey`, and `PublicKey.Check`, which takes only the prehashed `ED` signature and compares its trusted comment exactly), a key's `Role` (`CI`, `Cosign`, `Recovery`) and the `Kind` it signs (`Release`, `Base`), the names of each role's signature and key files (`SigName`, `KeyFile`) and a kind's trusted comment (`Kind.Comment`), and `Keys`, a kind's three different keys, whose `Check` accepts a manifest that two of them signed and whose `CheckRole` checks one role's signature. It also signs, for the co-signer: `SecretKey`, a minisign secret key made with no password (`ParseSecretKey`), whose `Sign` writes the signature file minisign would. `minisigntest/`, for tests only, signs as minisign does |
|
||||
| `internal/cosign` | the co-signer, `devvm-cosign`, a program of its own (`cmd/devvm-cosign`), which imports the standard library, BurntSushi/toml and `internal/minisign` alone, and which nothing of devvm's imports ([The co-signer](cosigner.md)): its config (`LoadConfig`, and `ReadConfig` without the keys), a run (`Cosigner.Run`) and the maintainer's `retry` and `ack` (`Cosigner.Clear`), CI's artifacts, unzipped into its stage (`unzip`), the rebuild (`ReleaseBuild`, and `BaseBuilder` for bases), the tap's formulas, rendered from the signed `SHA256SUMS` (`renderFormula`), the SSH tag check (`VerifyTag`), `state.json` (`Store`), the GitHub client (`Client`, with the Actions API's runs and artifacts) and the app's token (`AppToken`); `doc.go` maps its files |
|
||||
| `internal/from` | `--from`: references, registry digests with an anonymous token, Docker's IDs and the recorded digests |
|
||||
| `internal/redact` | passwords out of logs, with the standard library alone: `String` for the run log's lines, which takes out proxy keys and URL passwords, `In` for another program's log as it grows, in place and keeping its length, reading a line not yet ended again from its start when it's within `MatchMax` of what an earlier look read, else from `MatchMax` back, starring what runs on to an `@` there (`Look.Cut` does the same after a rotation's cut), and `Unended` for a copy's cut end; and `Secret`, the type of the values that let whoever holds them act as you or as a VM ([Secrets in the code](#secrets-in-the-code)) |
|
||||
| `internal/vmlog` | every log a VM can drive but the proxy's own: `Limit`, the rate and length of what a VM makes devvm's background processes write, which the port forwarder and the link session write through and whose `Allow` the link session's warnings take their turns from; `Capped`, a background process's log held to its cap as it appends, with `Trim` at its next start; and `KeepVM`, which the VM's proxy (through `proxy.IO.KeepLogs`) and a build run on the logs the backend writes as the VM runs (`backend.Run.Logs`), the serial consoles' among them, each in a goroutine of its own, redacting what each gained every second (`redact.In`), so a reboot in place can't leave the proxy's password there, and skipping a log that hasn't grown. `Redact` is Lima's redaction at the end of a start. Each rotation copies the log's end to its `.1` file, redacting only what the last look didn't reach and masking a secret cut at its end, and empties it with `f.Truncate`, counting a log by what it holds past the hole its writer left, as Lima's programs write at their own offset. Every log is opened through `safefile` (`Opts.Write`), never through a link or waiting on a FIFO. The proxy, which imports only the standard library and a few of devvm's leaves, rotates its own logs itself (`proxy.rotating`) |
|
||||
| `internal/safefile` | every read of a file a VM can write or swap, with the standard library alone, so the proxy uses it too ([the checks on owners](#the-checks-on-owners)) |
|
||||
| `internal/landlock` | the proxy's child's confinement on Linux, with the standard library alone, behind its own build tags: `Self`, which confines every thread of the process to its folders with `no_new_privs`, Landlock and the hand-written seccomp filter (`filter`), checks that it holds, and returns what it got (`Result`), which the proxy's `confineSelf` turns into its line in `run/proxy.confined` (`proxy.Confinement`) ([the child's sandbox](../internals/network.md#the-childs-sandbox)) |
|
||||
| `internal/devcontainer` | a project's `devcontainer.json`, with no side effects: finding it, mapping it to a new VM's plan, its refusals, and what devvm update's second reading replaces (`Reread`) |
|
||||
| `internal/redact` | passwords out of logs, with the standard library alone, and `Secret`, the type of the values that let whoever holds them act as you or as a VM ([Secrets in the code](#secrets-in-the-code)). `String` redacts the run log's lines, taking out proxy keys and URL passwords. `In` redacts another program's log as it grows, in place and keeping its length. It reads a line not yet ended again from its start when the line is within `MatchMax` of what an earlier look read, and otherwise from `MatchMax` back, starring what runs on to an `@` there, and `Look.Cut` does the same after a rotation's cut. `Unended` redacts a copy's cut end |
|
||||
| `internal/vmlog` | every log a VM can drive, except the proxy's own. `Limit` is the rate and length of what a VM makes devvm's background processes write. The port forwarder and the link session write through it, and the link session's warnings take their turns from its `Allow`. `Capped` is a background process's log, held to its cap as it appends, with `Trim` at its next start. `KeepVM` is what the VM's proxy (through `proxy.IO.KeepLogs`) and a build run on the logs the backend writes as the VM runs (`backend.Run.Logs`), the serial consoles' among them. It watches each log in a goroutine of its own, redacts what each one gained every second (`redact.In`), so a reboot in place can't leave the proxy's password there, and skips a log that hasn't grown. `Redact` is Lima's redaction at the end of a start. Each rotation copies the log's end to its `.1` file, redacting only what the last look didn't reach and masking a secret cut at its end, and empties it with `f.Truncate`, counting a log by what it holds past the hole its writer left, as Lima's programs write at their own offset. Every log is opened through `safefile` (`Opts.Write`), never through a link or waiting on a FIFO. The proxy, which imports only the standard library and a few of devvm's leaves, rotates its own logs itself (`proxy.rotating`) |
|
||||
| `internal/safefile` | every read of a file a VM can write or swap, with the standard library alone, so the proxy uses it too ([the checks on owners](#the-checks-on-owners)). It refuses a file that isn't regular with `safefile.ErrNotRegular` and one past its cap with `safefile.ErrTooLong` |
|
||||
| `internal/landlock` | the proxy's child's confinement on Linux, with the standard library alone, behind its own build tags: `Self`, which confines every thread of the process to its folders with `no_new_privs`, Landlock and the hand-written seccomp filter (`filter`), checks that it holds, and returns what it got (`Result`), which the proxy's `confineSelf` turns into its line in `run/proxy.confined` (`proxy.Confinement`) ([the child's sandbox](../internals/network.md#the-childs-sandbox)). It makes each call on every thread through `syscall.AllThreadsSyscall`, which works only without cgo |
|
||||
| `internal/devcontainer` | a project's `devcontainer.json`, with no side effects: finding it, mapping it to a new VM's plan, its refusals, and what devvm update's second reading replaces (`Reread`): `devcontainer.Reread` drops the parts the file gave that it no longer calls for and adds the ones it now calls for |
|
||||
| `internal/jsonc` | JSON with comments (`jsonc.Strip`), with the standard library alone |
|
||||
| `internal/tools` | the shared tools: the lock, mise on the host, the daily check, the tool images' builds and the share |
|
||||
| `internal/netpolicy` | network policy: the choice of tier, learning the hosts a VM reached, `RiskOf`, the VM's proxy and the self-check |
|
||||
| `internal/secrets` | tokens on the host and the VM's bindings to them, and your own secrets (`custom.go`, with their checks, `Yours` and `custom-secrets.json`) |
|
||||
| `internal/trust` | your CAs in `~/.config/devvm/ca`, read and checked, sent to VMs, the build VMs' `Trust` scripts and the guest environment, and each VM's own CA and its next one (`InitCA`, in `vms/<hash>/run/ca/`) |
|
||||
| `internal/agents` | the coding agents' registry, with the standard library alone: one `Def` for each agent, with its shared tool, settings, logins, history, guest environment, ways to log in and `[pass-keys]`, which every list of the agents comes from. Code about one agent names it by its constant (the structure test's `names`) |
|
||||
| `internal/agentlogin` | agents' login and settings files on the host: the VM's copies with placeholders, the bindings, the values and the OAuth refresh (`File`, with a `format` for each kind of login), the shape of every placeholder (`Placeholder`), `Redact`, and `Restore`, which puts the store's values back for a VM's placeholders |
|
||||
| `internal/proxy` | the proxy, which runs as two processes, its broker, `devvm _proxy` (`broker.go`, `process.go`), and its child, `devvm _proxy-child` (`child.go`), which talk over a socketpair in the broker's protocol (`wire.go`), as its `README.md` describes, the relay of a VM's SSH agent, the only socket of an agent a VM's backend forwards, on `paths.Dirs.AgentRelay` (`Config.Agent`, `agent.go`), and the one form of a host that every package judges and compares hosts in (`Host`, `NormHost`, `HostOK`), which the structure test holds it to ([the checks on owners](#the-checks-on-owners)) |
|
||||
| `internal/tools` | the shared tools: the lock, mise on the host, the daily check, the tool images' builds and the share. `Share.Build` builds a VM's tool images under the making lock, which `tools.Making` holds, and `tools.HasBuilds` refuses a glibc-only tool, such as pi, for a musl VM. `ShareBusy` says whether another devvm holds the share's lock, so retention skips the tool images that day. `Share.NoVM` lists the current tool images that no VM's state lists, and `Versions.StaleMise` the folders of mise's other versions, which gc deletes. `withSDKDownloads` in `internal/tools/dotnet.go` adds each platform's dotnet SDK archive to the lock ([building tools](../internals/images.md#building-tools)) |
|
||||
| `internal/netpolicy` | network policy: the choice of tier, learning the hosts a VM reached, `RiskOf`, the VM's proxy and the self-check. `netpolicy.Policies` lists a VM's policies for its tier, the built-in ones and yours, and `netpolicy.PolicyWarnings` warns of the lines that aren't rules. `netpolicy.Proxy.Prepare` readies a VM's proxy at each launch, its policy warnings and the CA bundle included, `netpolicy.Proxy.PrepareRunning` checks what could refuse a running VM's new proxy before the old one stops, and `netpolicy.Proxy.Refusal` runs the company proxy's check with the check of your CAs. The event log's readers are `netpolicy.Log.Blocks`, which gives a quiet block no `Allow`, `netpolicy.Log.Learned`, with `Learned.NoProxy` for the hosts that only transparent mode reached and `agentWord` for a `User-Agent`'s first word, `Log.Countable` and `netpolicy.Log.MarkLearning`. `netpolicy.Judge.Quiet` keeps quiet hosts out of what devvm network lock offers, `netpolicy.Tickable`, with its list `tickable`, and `netpolicy.RiskOf` mark the hosts it offers, and `quietMark` and `RuleFile.Quiet` show the quiet lines in devvm network ([network policy](../internals/network.md)) |
|
||||
| `internal/secrets` | tokens on the host and the VM's bindings to them, and your own secrets (`custom.go`, with their checks, `Yours` and `custom-secrets.json`). `secrets.BoundSecret` records in a VM's state the definition and hosts a secret of yours was bound with, and the store's lookup (`Store.Get`, `secrets.Store.Get`) checks every binding against that record. `secrets.Store.Save` saves a secret, `secrets.ClaudeOf(store).Login` picks the one Claude Code login devvm keeps, and `secrets.ClaudeOf(store).Sums` gives that login's checksums |
|
||||
| `internal/trust` | your CAs in `~/.config/devvm/ca`, read and checked, sent to VMs, the build VMs' `Trust` scripts and the guest environment, and each VM's own CA and its next one (`InitCA`, in `vms/<hash>/run/ca/`). `trust.Env` holds the CAs' variables that a build's scripts and every project VM start with. `trust.Read` reads your CA folder, looking at each file with `os.Lstat` and following no link, `trust.CAs.Host` writes the bundle for the host's mise on Linux, and `trust.InitCA` readies each VM's CA and its next one |
|
||||
| `internal/agents` | the coding agents' registry, with the standard library alone: one `Def` for each agent, with its shared tool, settings, logins, history, guest environment, ways to log in and `[pass-keys]`, which every list of the agents comes from. Code about one agent names it by its constant (the structure test's `names`). `agents.Def`'s `PassKeys` says whether an agent's keys are withheld by default, and `agents.Providers` lists the providers whose keys the proxy puts in |
|
||||
| `internal/agentlogin` | agents' login and settings files on the host: the VM's copies with placeholders, the bindings, the values and the OAuth refresh (`File`, with a `format` for each kind of login), the shape of every placeholder (`Placeholder`), `Redact`, and `Restore`, which puts the store's values back for a VM's placeholders. The package `agentlogin` saves a captured login (`agentlogin.File.Capture`), refreshes and reads one (`agentlogin.File.Get`) and makes the VM's copy (`agentlogin.File.VMCopy`), whose `VMFile` reports `PassBound`, the bound providers that `[pass-keys]` lists. `agentlogin.Pick` tells whose login a request is by its `User-Agent`, `agentlogin.Endpoints` lists every format's endpoints, `agentlogin.SetupToken` recognises claude setup-token's request, `agentlogin.ClaudeOAuthBindings` makes the Claude login's bindings, `agentlogin.OpencodeImport` makes opencode's import entries, and `agentlogin.PiSettings` drops the pi settings that would undo devvm's. The formats' field lists are `codexKeep`, `claudeAccountKeep` and `cursorFormat`, `internal/agentlogin/logins.go` holds `opencodeVM` and `withheldEntry`, and `internal/agentlogin/pi.go` holds pi's format ([agents' logins and settings](../internals/network.md#agents-logins-and-settings)) |
|
||||
| `internal/proxy` | the proxy, as its `README.md` describes. It runs as two processes, its broker, `devvm _proxy` (`broker.go`, `process.go`), and its child, `devvm _proxy-child` (`child.go`), which talk over a socketpair in the broker's protocol (`wire.go`). The package also holds the relay of a VM's SSH agent on `paths.Dirs.AgentRelay` (`Config.Agent`, `agent.go`), which is the only socket of an agent that a VM's backend forwards. And it holds the one form of a host that every package judges and compares hosts in (`Host`, `NormHost`, `HostOK`), which the structure test holds every package to ([the checks on owners](#the-checks-on-owners)). The desktop's local proxy listens in the VM at `proxy.LocalProxyAddr` and `proxy.LocalProxyPort` ([the local proxy](../internals/desktop.md#the-local-proxy)). The package `proxy` reads policies in `policy.go`: `proxy.ParsePolicy` is the one parser of every policy file, which returns each line with its number and whether it's a rule, `proxy.ValidRule` decides what's a rule, `proxy.BrokenDeny` marks a broken `!` line, and `proxy.ReadPolicy` reads a file through `internal/safefile`. `readBuiltins` keeps a built-in policy's `quiet` lines (`PolicyLine.Quiet`), and `loadPolicy` drops any other file's. `proxy.NarrowRule` writes a rule by method and path in its canonical form, in `proxy.Methods`' order, and `proxy.ExactRule` the exact rule for one host and port. `proxy.ReadAllowlist` reads the allowlist tier's policies, whose `Allowlist.Allows`, `Allowlist.Denies` and `Allowlist.Quiet` are the proxy's own decisions. A decision reads the rules that cover a host and port in one read (`policy.rulesFor`, a `hostRules`), `policy.all` leaves the quiet rules out and `policy.quiet` matches them. `hostRules.byRequest` says when requests are judged one by one, by `policy.judge`, and `hostRules.unjudgeable` covers a request that names a method outside `proxy.Methods`. `request.go` judges each request in an intercepted tunnel (`server.judgeRequest`) with the one matcher of rules and bindings, `proxy.match`, which uses `plainPath`, `proxy.PathOK` and `matchPath` for paths and patterns, `overrides` and `overrideLike` for the methods a request names, and `match.allows`, `match.denies` and `trimDots`, and Go's `url.ParseQuery`, whose `ParseQuery` reads a query differently from some servers ([requests by method and path](../internals/network.md#requests-by-method-and-path)). In `proxy.go`, `server.blocked` marks a block's event `Quiet` only for the reason `notAllowed`, `blockPage` writes the block page, and `proxy.Public` is the one judge of a public address. `secrets.go` holds the bindings file (`proxy.BindingList.Encode`), how a `secret` binding's value goes in (`Binding.secretValue`) and a `login` binding's (`Binding.takes`), and the refusals `githubMinting` and `cursorMints`. `cursor.go` holds Cursor's routes and refusals (`cursorRoutes`, `cursorPersists`, `cursorStore`, `cursorChanges`) and the reply scanners (`frameScanner`, `jwtScanner`). `upstream.go` holds the route to a company proxy (`proxy.Upstream.WithPassword`, `proxy.Upstream.Route`), which a lookup's context carries with `proxy.WithRoute` and gives back with `proxy.RouteOf`, and the CAs a lookup trusts (`proxy.WithRoots`, `proxy.RootsOf`). The config is `proxy.Config`, and `proxy.Config.Sum` tells devvm whether a running proxy must start again |
|
||||
| `internal/seatbelt` | macOS's sandbox as devvm uses it: `sandbox-exec`'s path (`Exec`), a Seatbelt string and a real path in a profile (`String`, `Path`), the links a sandboxed lookup goes through (`Links`), and the profile of a VM's proxy's child (`ChildProfile`), which `Sandbox.ProxyChild` gives the broker through `proxy.IO.Seatbelt`, because the proxy imports the standard library alone. Lima's profile for its hostagent (`lima/seatbelt.go`) is written with the same strings and paths. How the child is confined, its report in `run/proxy.confined` (`proxy.Confinement`), the check that it holds (`checkConfined`) and the hook where a platform confines the child in the process (`confineSelf`) are `internal/proxy`'s `confine.go`, which every platform's confinement shares |
|
||||
| `internal/daemon` | devvm's background processes, with the standard library alone: detached starts, pid files checked against the process's arguments, stopping with TERM and then KILL, readiness by a status file, the lifeline, and an accept loop's wait after an error that leaves its listener open (`AcceptRetry`), which the port forwarder, the link session, a login's forward, the proxy's SSH agent relay and the desktop relay share. It's the only place that signals a process by its pid. [Processes](../internals/processes.md) has what each of those processes holds, reads, writes and is confined by |
|
||||
| `internal/daemon` | devvm's background processes, with the standard library alone: detached starts in a session of their own (`daemon.Detach`), pid files checked against the process's arguments before any signal (`daemon.Proc`), stopping with TERM and then KILL, each sent to the process's group (`daemon.SignalGroup`), readiness by a status file, the lifeline, and an accept loop's wait after an error that leaves its listener open (`AcceptRetry`), which the port forwarder, the link session, a login's forward, the proxy's SSH agent relay and the desktop relay share. It's the only place that signals a process by its pid. [Processes](../internals/processes.md) has what each of those processes holds, reads, writes and is confined by |
|
||||
| `internal/desktop` | devvm desktop's relay on the host, which checks VNC's password, then opens an ssh channel to the VM's socket and drops the viewer's clipboard, and the desktop's passwords |
|
||||
| `internal/backend` | `Backend` and its roles, `Caps`, `Require`, `Check`, the registry and its guard (`As`), as [how a backend plugs in](extending.md#how-a-backend-plugs-in) describes. Below it are `backendtest/`, the fake, `registry/`, which holds every backend, and `lima/`, whose `pins.go` has QEMU's user and mount namespace on Linux, its pins, their events and the probe, while `platform`'s `pinrun_linux.go` is the namespace's side |
|
||||
| `internal/backend` | `Backend` and its roles, `Caps`, `Require`, `Check`, the registry and its guard (`As`), as [how a backend plugs in](extending.md#how-a-backend-plugs-in) describes. Below it are `backendtest/`, the fake, `registry/`, which holds every backend, and `lima/`, whose `pins.go` has QEMU's user and mount namespace on Linux, its pins, their events and the probe, while `platform`'s `pinrun_linux.go` is the namespace's side. A build's `ImageSpec.Trust`, a `Trust`, holds the `Add` and `Remove` scripts made from `ca.sh` and the `Env` each script gets, and a tools build runs `ToolsSpec.Trust.Add` alone. A backend runs `Add` before anything downloads and `Remove` once the scripts are done: Lima runs `Add` right after the start and `Remove` before the final sync, and a tools build needs no `Remove`. `backend.NetProxy` confines a VM to its proxy and `backend.NetDirect` puts it on its backend's own network, `Confinement.GuestProxy` says whether the guest's proxy settings name devvm's proxy, and Lima's clone sets the VM's environment from `VMSpec.Env` ([a company's CA in builds](../internals/images.md#a-companys-ca-in-builds)) |
|
||||
| `internal/vmssh` | devvm's own use of a VM's ssh, on every backend. `Checked` is the one way to a VM's ssh ([how a backend plugs in](extending.md#how-a-backend-plugs-in)), and `Forwards` is the port forwarder's one owner, which locks, stops and starts it with its ports from `vm.json`. The package also holds a login's forward of this machine's loopback ports, in devvm's own process (`ForwardLoopback`), the links' sessions, and each VM's one record of its host keys for each start (`PinHostKeys`, in `vms/<hash>/run/known_hosts`), which every ssh of devvm's checks |
|
||||
| `internal/ui` | the only package that prints: `ui.UI`, with messages, prompts, the status line, the run log and the cleanups, and `ui.Main`, which handles signals. It has no package state |
|
||||
| `internal/msg`, `locales` | messages: `en.toml`, the generated functions, the doc links (`docs.go`), the generator (`gen/`), `Reporter` and `Question` ([messages](cli.md#messages)) |
|
||||
| `internal/ports` | a VM's ports section, with the forwards asked for and the host ports chosen, and the one allocator of host ports, under the claims lock, which puts VMs' ssh only on the ports browsers refuse (`SSHPorts`) |
|
||||
| `internal/paths` | every folder and file devvm uses, a VM's in its folder (`Dirs.VM`, and a project VM's folder, `vms/<hash>/`, from `Dirs.VMDir`), and host paths resolved and compared (`Physical`, `PhysicalParent`, `Within`, `Below`, `In` and `Under`, where `resolve.go` says which one is for what) |
|
||||
| `internal/paths` | every folder and file devvm uses, a VM's in its folder (`Dirs.VM`, and a project VM's folder, `vms/<hash>/`, from `Dirs.VMDir`), and host paths resolved and compared (`Physical`, `PhysicalParent`, `Within`, `Below`, `In` and `Under`, where `resolve.go` says which one is for what). Among the locks, `paths.Dirs.GitLock` is the host's lock of `.git` protection, taken before any VM's own, and `Dirs.MakingLock` is the tool images' making lock |
|
||||
| `internal/state` | a VM's state, `vm.json`, with its core fields and one section for each package, which changes only in `VM.Update` under the VM's lock. It also owns the layout version (`CheckLayout` and `migrations`, while `testdata/script/layout.txtar` lists every file), every file written whole (`WriteFile`, `WriteFileMode`) and private folders (`PrivateDir`) |
|
||||
| `internal/settings` | the defaults (`Defaults`, `Read`, `Save`), with your `config.toml`, read strictly, over devvm's `settings.json`, and each value's check (`ParsePorts`, `ParseCPUs`, `ParseGiB` and the retention settings) |
|
||||
| `internal/platform` | the code for each system, behind build tags |
|
||||
| `internal/ubuntu` | finding Ubuntu's cloud image and verifying it, without ever downloading one |
|
||||
| `internal/settings` | the defaults (`Defaults`, `Read`, `Save`), with your `config.toml`, read strictly, over devvm's `settings.json`, and each value's check (`ParsePorts`, `ParseCPUs`, `ParseGiB` and the retention settings). `settings.CompanyProxy.Upstream` checks the company proxy's settings and its password, `settings.CompanyProxy.Route` is the route devvm's own clients take through it, and `settings.PassKeys` is `config.toml`'s `[pass-keys]` |
|
||||
| `internal/platform` | the code for each system, behind build tags, such as `platform.SameFolder`, which tells whether a project folder whose device number changed after a restart is still the VM's ([an existing VM](../internals/overview.md#an-existing-vm)), and `platform.FoldsCase`, whether the system's file systems fold case |
|
||||
| `internal/ubuntu` | finding Ubuntu's cloud image and verifying it, and its download (`ubuntu.Download`, a `fetch.Resumable`), which the backend calls, the release pocket's date (`ubuntu.Released`), and versions ordered as `dpkg --compare-versions` orders them (`ubuntu.CompareVersions`) |
|
||||
| `internal/testbuild` | whether this is a test build, which ldflags set: only a test build reads the test overrides (`cli`'s `readOverrides`) |
|
||||
| `assets` | the files devvm ships, embedded as `assets.FS`, which `cli` passes to constructors. `base.yaml` is base's Lima template, and `prelude.sh`, with `$devvm_arch`, `$devvm_libc` and `devvm_sha`, comes first in each build script run with bash, the user's layers included, and is put in place of a script's `#!` line, as one `eval` line quoted by `shell.QuoteLine`, by `image.WithPrelude`, which `image.OwnScript` calls for devvm's own. `layers/` holds base's scripts, its policy and Ubuntu's signing keys, and the built-in layers, `desktop`, `docker` and `nix`, each with its policy. `network/` holds the network tiers' own policies, `features/` base's optional features, and `shared-tools/` its `mise.toml`, `build.sh` and `*.policy` files. `guest/` holds the scripts in the VM that every launch sends, and the port forwarder's `ports.sh`, and `oci/` is `--from`'s conversion, as its `README.md` describes |
|
||||
| `assets` | the files devvm ships, embedded as `assets.FS`, which `cli` passes to constructors. `base.yaml` is base's Lima template, and `prelude.sh`, with `$devvm_arch`, `$devvm_libc` and `devvm_sha`, comes first in each build script run with bash, the user's layers included, and is put in place of a script's `#!` line, as one `eval` line quoted by `shell.QuoteLine`, by `image.WithPrelude`, which `image.OwnScript` calls for devvm's own. `layers/` holds base's scripts, its policy and Ubuntu's signing keys, and the built-in layers, `desktop`, `docker` and `nix`, each with its policy. `network/` holds the network tiers' own policies, `features/` base's optional features, and `shared-tools/` its `mise.toml`, `build.sh` and `*.policy` files. `guest/` holds the scripts in the VM that every launch sends, and the port forwarder's `ports.sh`, and `oci/` is `--from`'s conversion, as its `README.md` describes. So the How it works pages' scripts are, in the repo, `assets/base.yaml`, `assets/prelude.sh`, `assets/layers/apt.sh`, whose first step is `assets/layers/apt.sh begin`, `assets/layers/base.sh`, `assets/layers/<name>.sh` for each built-in layer, which are `assets/layers/desktop.sh`, `assets/layers/docker.sh` and `assets/layers/nix.sh`, with `assets/layers/desktop.policy`, `assets/layers/docker.policy` and `assets/layers/nix.policy`, Ubuntu's keys, `assets/layers/ubuntu-cloud.gpg` and `assets/layers/ubuntu-archive.gpg`, base's features, `assets/features/<name>.sh`, the shared tools' `assets/shared-tools/mise.toml` and `assets/shared-tools/build.sh`, the conversion's `assets/oci/build.sh` and `assets/oci/bootify.sh`, and the CA script, `assets/guest/ca.sh`, which `assets/guest/ca.sh DIR` runs to install the CAs in a VM. The built-in policies are paths in `assets/` ([images](../internals/images.md)) |
|
||||
| `internal/structure` | the [structure test](#the-structure-test), for tests only, and `owners_doc_test.go`, which writes [the checks on owners](#the-checks-on-owners) |
|
||||
| `internal/stubtest` | the test [stubs](tests.md#stubs), for tests only |
|
||||
| `internal/leaktest` | the [goroutine leak checks](tests.md#goroutine-leaks), `Main` for a package's `TestMain` and `Check` for one test, for tests only, and the standard library only, so the proxy's tests use it too |
|
||||
| `internal/memnet` | the network in memory for [tests in a synctest bubble](tests.md#time-and-lifecycles): connections (`Pipe`) that close their writing side alone, hold a buffer's worth and have deadlines, and listeners by address (`Network`), for tests only, and the standard library only, so the proxy's tests use it too |
|
||||
| `testdata` | the CLI tests (`script/*.txtar`), the [golden fixtures](testing.md#golden-fixtures) (`golden/<os>/`), a lock to test with (`mise.lock`), each package's [coverage baseline](tests.md#coverage) on each system (`coverage/<os>.txt`), each release's [state fixture](#released-state) (`v<release>/<os>/`), and the lines that break each forbidigo rule (`lint/`, [Go lint rules](_index.md#go-lint-rules)) |
|
||||
| `tests/e2e`, `tests/e2e-mise.lock` | the [end-to-end tests](tests.md#end-to-end-tests) on real VMs, in Go with the tag `e2e` and a file for each section. `TestE2E` is the run, `sandbox_test.go` has the sandbox, its slot's paths and lock and `e2eUbuntuRelease`, and `slots_test.go` runs the slots. The lock file holds the shared tools' versions that every section but `tools` uses (`scripts/bump.sh e2e-tools`) |
|
||||
| `scripts`, `packaging`, `.goreleaser.yaml`, `VERSION`, `CHANGELOG.md` | `bump.sh` updates the pins. `release.sh` runs the signed tag's checks around GoReleaser, then minisign, and `publish.sh` makes the release itself, with its checks, `release.sh`, one yes, then the pushes, `gh release` and the tap. The `test` and `coverage` tasks run `test.sh`, which runs `coverage.sh` to check each package's coverage against its baseline. `packaging/` holds the Homebrew formula and `key.go`, which embeds its folder, so devvm upgrade's key is `minisign.pub`'s, and a build without that file has none. Only the scripts read `VERSION` ([releasing](maintaining.md#releasing)) |
|
||||
| `scripts`, `packaging`, `.goreleaser.yaml`, `VERSION`, `CHANGELOG.md` | `bump.sh` updates the pins. `release.sh` runs the signed tag's checks, then GoReleaser in its pinned container, then minisign, and CI's build and signature (`--ci`, `--ci-sign`), `repro-check.sh` builds a release twice and compares the bytes, and `publish.sh` checks the tag and pushes it for CI and the co-signer, signs their draft with the old key while the bridge lasts (`--sign-legacy`), or makes the release itself (`--local`), with its checks, `release.sh`, one yes, then the pushes, `gh release` and the tap. The `test` and `coverage` tasks run `test.sh`, which runs `coverage.sh` to check each package's coverage against its baseline. `packaging/` holds the Homebrew formula and `key.go`, which embeds its folder, so devvm upgrade's release keys are those in `keys/` (`release-ci.pub`, `release-cosign.pub` and `release-recovery.pub`) and its old release key is `minisign.pub`'s, and a build without a file has no such key ([release keys](maintaining.md#release-keys)). Only the scripts read `VERSION` ([releasing](maintaining.md#releasing)) |
|
||||
| `install.sh` | `curl \| bash`: it installs the host's archive, with the binary, the README, the changelog and the license, checked, into `~/.local/lib/devvm/<version>`, then runs doctor's fixes, asking first. Tests source it (`DEVVM_INSTALL_TEST`) |
|
||||
|
||||
### The checks on owners
|
||||
@@ -122,6 +124,7 @@ An owner gets a check only when a second copy would be a bug or a security hole,
|
||||
| forbidigo, `os.FindProcess`, `syscall.Kill`, `unix.Kill` and `os.Process`'s `Kill` and `Signal` | `internal/daemon`, which signals a background process only while its pid file and its arguments say it's still that process (`Proc`), or through the process it started (`Handle`) | `internal/platform`; tests, which signal the children they started; and a child that hasn't been waited for yet, whose pid is still its own, with a `nolint` saying so |
|
||||
| forbidigo, `unicode.IsGraphic`, `IsPrint`, `IsControl` and `Bidi_Control` | `msg.Safe` in `internal/msg/safe.go`, the one rule for which characters reach the terminal, which `msg.Printable`, `msg.OneLine`, the UI's renderers and devvm agent save's diff follow, so a second rule can't let through what this one refuses ([Colors](cli.md#colors) says what it refuses) | a check that isn't about the terminal, such as a path one line long, with a `//nolint:forbidigo` saying so |
|
||||
| forbidigo, HTTP clients | `internal/fetch`, whose `NewClient` sets each client's timeout and redirect policy (`HTTPSOnly` or `SameScheme`), and whose `Retry`, `Transient`, `ReadCapped`, `Get`, `Resolve` and `Download` try again after the failures that may pass, cap what a body or a download may hold, follow a HEAD's redirects to where they end and check a download's SHA-256 before anything uses it. `fetch.Client` is its own type, so a client that `NewClient` didn't make, such as `&fetch.Client{}`, fails every request, and a caller changes a client's transport through its `Transport` method | `internal/proxy`, which is the standard library only, and tests, which make their own servers' clients |
|
||||
| forbidigo, `x509`'s `UnknownAuthorityError`, `HostnameError` and `CertificateInvalidError` and `tls.CertificateVerificationError` | `fetch.Untrusted`, `fetch.BadCertificate` and `fetch.Unverified` in `internal/fetch/fetch.go`, beside `fetch.Gone`: a server's certificate that no CA this machine trusts signed, which the user's CA mends, one a trusted CA signed that's for another host, out of date or not valid yet, which no CA mends, and any failure to verify one, with its reason. `Transient` asks `Unverified`, so none is tried again. Ubuntu's lookups and the cloud image's download ask all three, so each names the same cause, and host mise's asks `Untrusted` | tests, which make those errors |
|
||||
| forbidigo, `netip.Addr`'s `IsPrivate` | `proxy.Public` in `internal/proxy/proxy.go`, the one judge of whether an address is on the internet: netip's classes, the table of the other ranges that aren't (`notPublic`), and the IPv4 address in a NAT64 or 6to4 address. The proxy's floor, `devvm network lock`, a `--clone` VM's partial-clone remotes and `--from`'s registries all ask it, so a range added to it holds for each | `internal/proxy` |
|
||||
| forbidigo, `redact.Secret`'s `Reveal`; the structure test, a struct that embeds `redact.Secret` and an interface that declares `Reveal() string` | `redact.Secret` in `internal/redact/secret.go`, the type of the values that let whoever holds them act as the user or a VM, but for those [Secrets in the code](#secrets-in-the-code) names: a VM's proxy password, a secret's value, a login's keys and tokens once they leave its file, and the company proxy's password and its `Proxy-Authorization`. Every way of printing one shows `<redacted>` or, in an unexported field, an address, and encoding one as JSON or text is an error, never a stand-in, so a file that holds the real value writes it through its own wire type, and a value can't be lost by going somewhere it isn't meant to | where the value is used, each call to `Reveal` with a `//nolint:forbidigo` that says why: the proxy's password check, its config file, the headers it puts values in, the company proxy's credentials, the VM's CA key as it signs and the broker's frames to its child; the store's file and Keychain; the VM's proxy URL and its key in `vm.json`; a login's file, its refresh and its claims; and tests. No struct embeds `redact.Secret` and no interface declares `Reveal() string` outside `internal/redact` |
|
||||
| forbidigo, `os.WriteFile`, `os.Create` and `os.O_TRUNC` | `internal/state`, whose `WriteFile` and `WriteFileMode` write a file whole through a temporary file in its folder, renamed over it, so a reader never sees half of it | `internal/proxy`, which imports only the standard library and has its own writer, `writeAtomic`; `internal/msg/gen`, which imports no devvm package; `internal/stubtest`; tests; and, with a `nolint` saying why, a file written another way: a log that a process writes as it runs, a download that streams into its file, and `internal/daemon`'s pid and status files, each written in one write that a reader takes as missing until its line ends |
|
||||
@@ -130,9 +133,10 @@ An owner gets a check only when a second copy would be a bug or a security hole,
|
||||
| forbidigo, `os.Setenv`, `os.Unsetenv`, `os.Clearenv` and `syscall`'s | each command's own environment, its `exec.Cmd`'s `Env`, because every command and background process devvm starts inherits devvm's. A VM's SSH agent is one: the finder's `target` carries its socket, its proxy's relay (`netpolicy.Proxy.Prepare`), which goes to the backend in `backend.ExecOpts.Agent`, `backend.ShellOpts.Agent` and `Confinement.AgentSocket`, and Lima sets `SSH_AUTH_SOCK` on that VM's `limactl` commands alone, so a run that reaches several VMs never gives one another's | `daemon.Ready` in `internal/daemon/status.go`, which takes the status file's name out of a background process's own environment; `stubtest.NoGitRepo`, which takes git's variables that pick a repo out of a test's environment until the test ends; and tests, which use `t.Setenv` |
|
||||
| the structure test's `owners`, host commands | the runners: the UI's `LoggedCmd`, which a package takes as a field and which runs a command into the run log, a backend's `Runner`, and `internal/hostgit`. A host command that one of them doesn't run is made only in the files `execSites` lists: those that make the command a runner then runs, such as Lima's `limactl` and mise's, and those whose command can't go into the run log, because it streams for as long as a link, the port forwarder or the desktop's relay lasts, asks on the terminal, outlives the run, or carries a secret | tests |
|
||||
| the structure test's `owners`, a backend's other interfaces | `backend.As` in `internal/backend/guard.go`, because the registry's backends are behind its guard, whose type has only `backend.Backend`'s methods, so a type assertion to `backend.Forgetter` or `*lima.Lima` on one is always false | tests |
|
||||
| the structure test's `owners`, git | `internal/hostgit`, which runs git without the repo's fsmonitor, hooks, filters or signing programs, over ssh only, without the environment's `GIT_*` variables, prompts, replace refs or grafts. It's also the only package whose string literals may be `"push"`, whole (`names`), and none is: a `--clone` VM's copy goes through the backend's `Exec` (`internal/vm/cloneseed.go`), never git's transport, whose receive-pack refuses shallow and SHA-256 repos. Nor may any other package's be `"diff-files"`, which enters each submodule, where that repo's own config can name a filter: `hostgit.DiffFiles` doesn't. In tests, which run plain git to make their repos, it's `internal/stubtest`'s `Git`, which leaves out git's variables that pick a repo, its files or its config (`GitEnv`), so a git that runs the tests, such as a hook's or `git rebase --exec`'s, never sends a test's git to the checkout itself | nothing else |
|
||||
| the structure test's `owners`, git | `internal/hostgit`, which runs git without the repo's fsmonitor, hooks, filters or signing programs, over ssh only, without the environment's `GIT_*` variables, prompts, replace refs or grafts. It's also the only package whose string literals may be `"push"`, whole (`names`), and none is: a `--clone` VM's copy goes through the backend's `Exec` (`internal/vm/cloneseed.go`), never git's transport, whose receive-pack refuses shallow and SHA-256 repos. Nor may any other package's be `"diff-files"`, which enters each submodule, where that repo's own config can name a filter: `hostgit.DiffFiles` doesn't. In tests, which run plain git to make their repos, it's `internal/stubtest`'s `Git`, which leaves out git's variables that pick a repo, its files or its config (`GitEnv`), so a git that runs the tests, such as a hook's or `git rebase --exec`'s, never sends a test's git to the checkout itself | the files `commandsFree` lists for git, which may run no other guarded command: the co-signer's `internal/cosign/build.go`, a program of its own that imports none of devvm's packages but `internal/minisign`, whose git fetches a release's tag over HTTPS into repositories it makes, with no config but its own |
|
||||
| forbidigo, `os.UserHomeDir`, and the structure test's `owners`, `HOME` | `paths.FromEnv` in `internal/paths/dirs.go`, which reads `HOME` once into `paths.Dirs.Home`, so a test or an e2e run that sets its own `HOME` moves every path devvm takes from it | tests |
|
||||
| the structure test's `owners`, `DEVVM_` variables | `readOverrides` in `internal/cli/overrides.go`, which reads a test build's stand-ins, while a release reads none | the settings in `envSettings`, and tests |
|
||||
| the structure test's `owners`, signatures | `internal/minisign`, whose `PublicKey.Check` checks a minisign signature and its trusted comment, exactly, and whose `Keys.Check` checks a manifest, such as a release's `SHA256SUMS`, against any two of a kind's three keys, by role, each signer counted once. A call of `ed25519`'s `Verify` or `VerifyWithOptions`, `rsa`'s `VerifyPKCS1v15` or `VerifyPSS`, or `ecdsa`'s `Verify` or `VerifyASN1`, an import of one of those packages with a dot, a call of a method named `CheckSignature`, `CheckSignatureFrom` or `CheckCRLSignature`, as `crypto/x509`'s are, and an import of `golang.org/x/crypto/blake2b`, fail, so devvm's own signatures are checked in one place, with the key's role and kind | `internal/minisign/minisigntest`, which signs for tests; the files in `signatureFree`, which check other projects' formats, Ubuntu's OpenPGP signatures (`internal/ubuntu/pgp.go`), cache.nixos.org's (`internal/proxy/nixcache.go`) and git's SSH signatures on release tags, which the co-signer checks against its pinned signers (`internal/cosign/sshsig.go`); and tests |
|
||||
| the structure test's `owners`, shell quoting | `internal/shell`, whose `Quote` and `QuoteJoin` quote words for a POSIX shell, so a value never runs as a command, and `QuoteLine` a word on one line for bash | tests |
|
||||
| the structure test's `owners`, the VM-name grammar | `internal/vmname`, whose `IsVM` tells a project VM's name from an image's, so gc never takes a project VM for an image | tests |
|
||||
| the structure test's `owners`, VM names | `internal/vmname`, whose `VM` is the name of every machine devvm runs on a backend: a project VM, an image's machine, a build VM, or a VM's old machine while a remake makes the new one. A name is made a `VM` only where it's read: `Parse` takes a project VM's name from an argument or a file name, and also reads `vm.json`'s name and runs in `project.Nth`, `ParseListed` one a backend lists, `VM.UnmarshalText` one in a JSON file (one path element that doesn't start with `-`, or none, and any machine's, so a field that must hold a project VM's is still checked with `IsProject`), `Image` names an image's machine and `VM.Aside` a remake's old one, and a backend's build VMs are typed constants. A struct field, a parameter or a result named for a VM (`vm`, `vms`, `otherVM`, `vmName`) whose type is a string, a pointer to one, a list of them or a map keyed on them fails, and so do a conversion of anything but a literal to `vmname.VM` and a type alias of it, so a path, an alias or a folder's name is never passed for a VM's name. The check goes by names, so it doesn't see a VM's name in a string named otherwise (`target`, `client`, `parent`, `to`, `name`), `vmname` imported with a dot or reached through a type parameter, or a VM joined to a string constant, whose type is still `vmname.VM` (`l.VM+lineNoLinks` in `internal/vmssh/links.go`) | `msg.M.VM` in `internal/msg/msg.go`, which reads back the VM a message's function took; `internal/stubtest`, whose stubs stand in for `limactl` and `ssh`, whose arguments are strings; the names `notNames` lists that aren't a VM's, such as `backend.Registry.NewVMs`, a backend's name; and tests |
|
||||
@@ -155,9 +159,9 @@ The shared tools have one owner too, the table `image.SharedTools` in `internal/
|
||||
|
||||
The scripts that devvm's builds run with bash have one owner for the machine they run on, `assets/prelude.sh`, whose `$devvm_arch`, `$devvm_libc` and `devvm_sha` give each script its architecture, its C library and its pinned checksum for each download ([the scripts' prelude](../internals/images.md#the-scripts-prelude)). A script reads them rather than run `uname -m` or look for `apk` itself, and checks that the prelude came first with `: "${devvm_arch:?}"` for each variable it reads, which also tells shellcheck that the variable is set. Go reads each of those scripts through `image.OwnScript`, which puts the prelude before it, so a recipe, a tool image's key and the conversion's copy of `oci/build.sh` all hold the two together. `TestPreludeUsers` in `internal/image` fails when a script that doesn't get the prelude, such as `assets/oci/bootify.sh` or `assets/guest/`'s, uses it, or when a script reads a variable without that check. `testdata/script/prelude.txtar` checks which pin `devvm_sha` picks from each script's pins on arm64 and amd64, with glibc and with musl. A CLI test or a Go test that sources one of these scripts sources `assets/prelude.sh` first.
|
||||
|
||||
`internal/paths` also owns how a path on the host is resolved and compared with a folder, in `resolve.go`, whose comment says which resolver each question takes. `paths.Physical` resolves every symlink as far as the path exists, for where a folder or file really is, such as a project folder against devvm's own folders or an SSH key against the folders VMs mount. `paths.PhysicalParent` resolves only the folder's symlinks and keeps the last element as named, for a path that may itself be a symlink devvm mustn't follow, such as a key's recorded path or a Seatbelt rule. `filepath.EvalSymlinks` itself, which fails when the path doesn't exist, is for a path that must exist, such as the folder devvm runs in. Then `paths.Within` tells whether a path is a folder or inside it, and `paths.Below` whether it's inside it only. Both compare names, so both paths are resolved the same way first. A check that keeps a VM away from a folder, such as `project.Unsafe`'s, an SSH key against the folders VMs mount, or a project folder against an agent's folder, uses `paths.In` or `paths.Under` instead, which also compare the folder itself: the path, or a folder above it, is the same folder as the other, by device and inode. On a volume that ignores case, as macOS's do by default, `~/.Config/devvm` is `~/.config/devvm`, which a comparison of names alone misses.
|
||||
`internal/paths` also owns how a path on the host is resolved and compared with a folder, in `resolve.go`, whose comment says which resolver each question takes. `paths.Physical` resolves every symlink as far as the path exists, for where a folder or file really is, such as a project folder against devvm's own folders or an SSH key against the folders VMs mount. `paths.PhysicalParent` resolves only the folder's symlinks and keeps the last element as named, for a path that may itself be a symlink devvm mustn't follow, such as a key's recorded path or a Seatbelt rule. `filepath.EvalSymlinks` itself, which fails when the path doesn't exist, is for a path that must exist, such as the folder devvm runs in, or a stopped VM's project folder, which each of a start's three checks resolves with `filepath.EvalSymlinks` ([an existing VM](../internals/overview.md#an-existing-vm)). Then `paths.Within` tells whether a path is a folder or inside it, and `paths.Below` whether it's inside it only. Both compare names, so both paths are resolved the same way first. A check that keeps a VM away from a folder, such as `project.Unsafe`'s, an SSH key against the folders VMs mount, or a project folder against an agent's folder, uses `paths.In` or `paths.Under` instead, which also compare the folders themselves and match when the path, or a folder above it, is the same folder as the other, by device and inode. On a volume that ignores case, as macOS's do by default, `~/.Config/devvm` is `~/.config/devvm`, which a comparison of names alone misses.
|
||||
|
||||
A VM's state, `vm.json`, has one owner too, `internal/state`, which reads and writes the whole file and knows only its core fields. Every other package that keeps something of a VM's owns one section of it, with its own type, its name (`Section`), and an `Of` that reads it through `state.Section`: `internal/netpolicy` owns `net`, `internal/gitprotect` `git`, `internal/ports` `ports`, `internal/sshagent` `agent`, `internal/tools` `tools`, `internal/secrets` `secrets`, and `internal/vm` `size`, `clone`, `devcontainer`, `desktop` and `links` (`internal/vm/state.go`). A section's type keeps what the user asked for at its top level and what devvm made under `made`. A change goes through `state.VM.Update`, which takes the VM's lock, reads the file again, runs the change and writes the file once: the change sets its section with `state.SetSection` and works out a list's new value from the file as it is then, never from what the command read earlier, so a change another devvm made meanwhile is kept. A change that fails writes nothing. `Update` holds one VM's lock, so a change takes no other lock inside it, and a change to several VMs updates each in turn. Test builds and the tests panic on a lock taken out of that order ([the lock rule](../internals/design.md#the-state-layout)). `state.VM.Claim` is `Update` that also holds the claims lock, for what no two VMs may have (`ports.Allocator` chooses every VM's host port through it), and `state.VM.Create` writes a new VM's whole state once, its ssh alias chosen under the claims lock. A build VM has no state, so `ports.Allocator.Build` chooses its ssh port through `state.Claims`, which holds the claims lock alone. A VM's alias is one `vmname.IsAlias` accepts, or devvm doesn't use it. `internal/vm`'s `checkState` reads every section of the folder's VM's state as the VM is found, so a section that can't be read stops the command instead of reading as empty. A new section adds its check there.
|
||||
A VM's state, `vm.json`, has one owner too, `internal/state`, which reads and writes the whole file and knows only its core fields. Every other package that keeps something of a VM's owns one section of it, with its own type, its name (`Section`), and an `Of` that reads it through `state.Section`: `internal/netpolicy` owns `net`, `internal/gitprotect` `git`, `internal/ports` `ports`, `internal/sshagent` `agent`, `internal/tools` `tools`, `internal/secrets` `secrets`, and `internal/vm` `size`, `clone`, `devcontainer`, `desktop` and `links` (`internal/vm/state.go`). A section's type keeps what the user asked for at its top level and what devvm made under `made`. A change goes through `state.VM.Update`, which takes the VM's lock, reads the file again, runs the change and writes the file once: the change sets its section with `state.SetSection` and works out a list's new value from the file as it is then, never from what the command read earlier, so a change another devvm made meanwhile is kept. A change that fails writes nothing. `Update` holds one VM's lock, so a change takes no other lock inside it, and a change to several VMs updates each in turn. Test builds and the tests panic on a lock taken out of that order ([the lock rule](design.md#the-state-layout)). `state.VM.Claim` is `Update` that also holds the claims lock, for what no two VMs may have (`ports.Allocator` chooses every VM's host port through it), and `state.VM.Create` writes a new VM's whole state once, its ssh alias chosen under the claims lock. A build VM has no state, so `ports.Allocator.Build` chooses its ssh port through `state.Claims`, which holds the claims lock alone. A VM's alias is one `vmname.IsAlias` accepts, or devvm doesn't use it. `internal/vm`'s `checkState` reads every section of the folder's VM's state as the VM is found, so a section that can't be read stops the command instead of reading as empty. A new section adds its check there.
|
||||
|
||||
### Agreement tests
|
||||
|
||||
@@ -179,13 +183,13 @@ Each copy gets one of three outcomes: extend the owner, make one owner, or leave
|
||||
|
||||
### Secrets in the code
|
||||
|
||||
A value that lets whoever holds it act as you or as a VM is a `redact.Secret`, from the moment devvm reads it until the place it's used. That covers a VM's proxy password (`netpolicy.Key`, `proxy.Config.Password`, `backend.Confinement.ProxyPassword`) and a build proxy's, a secret's value (`secrets.Store.Value`, `Get` and `Save`, and what `ui.UI.Secret` reads), the company proxy's password and the `Proxy-Authorization` the proxy sends it, the values the proxy caches for a VM's bindings (`proxy.Lookup`), and an agent's API keys and tokens once they leave its login file (`agentlogin.File.Get` and `SetKey`, and the tokens a capture or a refresh brings). Two such values stay strings, as [where secret values live](../internals/design.md#where-secret-values-live) explains: the value on its way through `platform.KeychainGet` and `KeychainSet`, which `secrets.Store` makes a `Secret` at once, and devvm desktop's VNC password, which you must see. A `Secret` prints as `<redacted>` with `%v`, `%s`, `%q`, `%x`, `%#v` and every other verb, so a log line, an error or a struct printed with `%+v` never shows it. Its value is behind a pointer, because `fmt` prints a value in an unexported field without calling its `Format`, and such a field then shows only an address. Two `Secret`s are equal with `==` only when they're the same one, so compare their values with `Reveal`, or the structs that hold them with `reflect.DeepEqual`.
|
||||
A value that lets whoever holds it act as you or as a VM is a `redact.Secret`, from the moment devvm reads it until the place it's used. That covers a VM's proxy password (`netpolicy.Key`, `proxy.Config.Password`, `backend.Confinement.ProxyPassword`) and a build proxy's, a secret's value (`secrets.Store.Value`, `Get` and `Save`, and what `ui.UI.Secret` reads), the company proxy's password and the `Proxy-Authorization` the proxy sends it, the values the proxy caches for a VM's bindings (`proxy.Lookup`), and an agent's API keys and tokens once they leave its login file (`agentlogin.File.Get` and `SetKey`, and the tokens a capture or a refresh brings). Two such values stay strings, as [where secret values live](design.md#where-secret-values-live) explains: the value on its way through `platform.KeychainGet` and `KeychainSet`, which `secrets.Store` makes a `Secret` at once, and devvm desktop's VNC password, which you must see. A `Secret` prints as `<redacted>` with `%v`, `%s`, `%q`, `%x`, `%#v` and every other verb, so a log line, an error or a struct printed with `%+v` never shows it. Its value is behind a pointer, because `fmt` prints a value in an unexported field without calling its `Format`, and such a field then shows only an address. Two `Secret`s are equal with `==` only when they're the same one, so compare their values with `Reveal`, or the structs that hold them with `reflect.DeepEqual`.
|
||||
|
||||
`Reveal` is the only way to the value, and forbidigo refuses every call to it but in tests, so each place that must use a value says why in a `//nolint:forbidigo // <why>` on that line: the proxy's password check and the headers it puts values in, the store's file and the Keychain, the VM's proxy URL and a login's file, its refresh and its claims. Anywhere else, pass the `Secret` on. `testdata/lint/forbidigo.go` keeps a call to `Reveal` that the rule must report. The structure test refuses a struct that embeds `redact.Secret` outside `internal/redact`, which would take on its methods, and an interface that declares `Reveal() string`, which would carry a value past forbidigo's eye. It reads the source alone, so it doesn't see a `Secret` embedded through another type or reached through reflection.
|
||||
`Reveal` is the only way to the value, and forbidigo refuses every call to it except in tests. So each place that must use a value says why in a `//nolint:forbidigo // <why>` on that line. Those places are the proxy's password check and the headers it puts values in, the store's file and the Keychain, the VM's proxy URL and a login's file, its refresh and its claims. Anywhere else, pass the `Secret` on. `testdata/lint/forbidigo.go` keeps a call to `Reveal` that the rule must report. The structure test refuses a struct that embeds `redact.Secret` outside `internal/redact`, which would take on its methods, and an interface that declares `Reveal() string`, whose calls forbidigo wouldn't see. It reads the source alone, so it doesn't see a `Secret` embedded through another type or reached through reflection.
|
||||
|
||||
Encoding a `Secret` as JSON or as text is an error (`redact.ErrEncode`), never `<redacted>`, so a value written somewhere by accident fails at once rather than losing your login. A file that must hold the real value therefore writes it through its own wire type, a struct with the value as a string that only that file's reader and writer use:
|
||||
|
||||
- **The proxy's config,** `proxy.json`, is `configFile`, with `Config`'s fields in `Config`'s order, so its bytes, and the `Sum` that decides whether a running VM's proxy starts again, are the same as before. `TestConfigFile` holds the two types together.
|
||||
- **The proxy's config,** `proxy.json`, is `configFile`, with `Config`'s fields in `Config`'s order, so its bytes, and the `Sum` that decides whether a running VM's proxy starts again, match what earlier releases wrote. `TestConfigFile` holds the two types together.
|
||||
- **A VM's key in `vm.json`** is `netpolicy.NetMade`'s own `MarshalJSON` and `UnmarshalJSON`, through `netMade`.
|
||||
- **A secret's file without a Keychain** is the value and a line's end, which `secrets.Store.save` writes and `saved` reads.
|
||||
- **A login's file** is the agent's own format, read and written whole as a map so that fields devvm doesn't know stay, and a key or token leaves the map through `agentlogin`'s `token` and goes into it through `setToken`.
|
||||
@@ -194,7 +198,7 @@ To add a field that holds a secret, give it the type `redact.Secret`. If a struc
|
||||
|
||||
## Changing the state layout
|
||||
|
||||
[State files](../internals/overview.md#state-files) describes the layout, and [the design note](../internals/design.md#the-state-layout) says why it's built that way. Every path in it comes from `internal/paths`. `paths.Dirs` names the shared folders and files, and `Dirs.VM(name)` gives a VM's `paths.VM`, whose methods name each file in the VM's folder: `Dirs.VMDir(hash)`, `vms/<hash>/`, for a project VM, and `run/builds/<name>/` for a build VM. A new file of a VM's gets a method on `paths.VM`, so it lands in the VM's folder, and `vmFolders.teardown` in `internal/vm/teardown.go` deletes it with the folder, with no list of files to update. A new socket goes in `Dirs.Run()`, named by a hash, and `TestSocketsFit` checks the longest path against `paths.SocketMax`. A new record that only devvm writes is JSON, read with `encoding/json`, which ignores fields it doesn't know, and written whole with `state.WriteFile`. A new default goes in `internal/settings`, which reads `config.toml` strictly and saves `settings.json`, and a new lock is an OS file lock (`platform.LockFile` and its kin) on a file that `paths` names.
|
||||
[State files](../internals/overview.md#state-files) describes the layout, and [the design note](design.md#the-state-layout) says why it's built that way. Every path in it comes from `internal/paths`. `paths.Dirs` names the shared folders and files, and `Dirs.VM(name)` gives a VM's `paths.VM`, whose methods name each file in the VM's folder: `Dirs.VMDir(hash)`, `vms/<hash>/`, for a project VM, and `run/builds/<name>/` for a build VM. A new file of a VM's gets a method on `paths.VM`, so it lands in the VM's folder, and `vmFolders.teardown` in `internal/vm/teardown.go` deletes it with the folder, with no list of files to update. A new socket goes in `Dirs.Run()`, named by a hash, and `TestSocketsFit` checks the longest path against `paths.SocketMax`. A new record that only devvm writes is JSON, read with `encoding/json`, which ignores fields it doesn't know, and written whole with `state.WriteFile`. A new default goes in `internal/settings`, which reads `config.toml` strictly and saves `settings.json`, and a new lock is an OS file lock (`platform.LockFile` and its kin) on a file that `paths` names.
|
||||
|
||||
The data folder and the config folder each hold a `version` file with their layout version, `state.Layout` in `internal/state/layout.go`. Before each command that reads them, `state.CheckLayout` takes `version.lock` in the data folder and compares both files with `state.Layout`. A folder without the file gets this devvm's version, the same version goes on, and a newer one stops the command with `layout_newer`, because a newer devvm changed the folders. An older one runs the migrations from that version to this one, in order, and then writes `state.Layout` into both files. `skipsLayout` in `internal/cli/root.go` lists the commands that skip the check: help, completion, the version and devvm's own hidden commands.
|
||||
|
||||
@@ -220,13 +224,13 @@ A fixture is frozen. It's generated once, from the release's own binary, and nev
|
||||
|
||||
The unit tests read every fixture's files with today's readers. `stateFixtures` in `internal/vm/fixture_test.go` lists each release's expectations: its VMs, the version of their `vm.json`, its layout version, its clones of one repo, and functions that check its VMs, its defaults and its agent store. 0.1.0's entry is `v010Fixture` in `fixture_v010_test.go`. `TestFixtureVMStates`, `TestFixtureVMsRead`, `TestFixtureSettings`, `TestFixtureAgentStore` and `TestFixtureClonesReadAsOneRepo` run once for each release and system, and they check that each field the release wrote reads and writes back unchanged. `TestStateFixturesListed` fails when a folder in `testdata` has no entry, or an entry has no folder. Two packages keep a table of their own for what only they read. In `internal/proxy`, `fixtureBinaries` records the SHA-256 of the binary that made each release's state, which its proxy configs name, and `TestFixtureBindings` and `TestFixtureProxyConfig` read every release's bindings files and proxy configs. In `internal/secrets`, `storeFixtures` names a secret that each release's store on Linux keeps as a file, which `TestFixtureStoreGet` reads through a VM's binding. `TestV010Rules` is a copy of 0.1.0's own tests of the proxy's rules, kept apart from today's.
|
||||
|
||||
The CLI tests run today's commands on each fixture. A release's scripts are in `testdata/script/`, named `fixture_v` and the release's version without its dots, such as `fixture_v010.txtar`, `fixture_v010_clone.txtar` and `fixture_v010_network.txtar` for 0.1.0. Each one puts the state into a sandbox with `fixture v<release>`, which moves it to the sandbox's folder: the folder's path, each VM's name hash, its folder's and `.git`'s identities and its backend's place become what they are there, each host port, and each port that a VM or the defaults forward, becomes one of the sandbox's own that nothing on this host listens on, and nothing else changes. The ports change because a launch that finds a VM's port taken, by a program of yours or by another run of the tests, rightly chooses another one and edits the VM's Lima config, and warns that it can't forward a port a program has, such as a web server of yours on 3000. A script names a forwarded port by what it was, as `$FIXTURE_PORT_3000`. The script then runs today's devvm on it. Each `--json` must have everything the release's had (`json_superset`), the read-only commands must change no file, and a launch must start each VM as it is, without a Lima edit. The scripts stay separate for each release, because their checks name that release's VMs and what each one has, and `TestFixtureScripts` in `internal/cli` fails when a fixture has no script or a script names a fixture that isn't there.
|
||||
The CLI tests run today's commands on each fixture. A release's scripts are in `testdata/script/`, named `fixture_v` and the release's version without its dots, such as `fixture_v010.txtar`, `fixture_v010_clone.txtar` and `fixture_v010_network.txtar` for 0.1.0. Each one puts the state into a sandbox with `fixture v<release>`, which moves it to the sandbox's folder: the folder's path, each VM's name hash, its folder's and `.git`'s identities and its backend's place become what they are there, each host port, and each port that a VM or the defaults forward, becomes one of the sandbox's own that nothing on this host listens on, and nothing else changes. The ports change because a launch that finds a VM's port taken, by a program of yours or by another run of the tests, rightly chooses another one and edits the VM's Lima config. It also warns that it can't forward a port that a program has, such as a web server of yours on 3000. A script names a forwarded port by what it was, as `$FIXTURE_PORT_3000`. The script then runs today's devvm on it. Each `--json` must have everything the release's had (`json_superset`), the read-only commands must change no file, and a launch must start each VM as it is, without a Lima edit. The scripts stay separate for each release, because their checks name that release's VMs and what each one has, and `TestFixtureScripts` in `internal/cli` fails when a fixture has no script or a script names a fixture that isn't there.
|
||||
|
||||
#### Changing what devvm does with state
|
||||
|
||||
A change that reads or writes state, such as a new command, a new section in `vm.json` or a new field in a record, runs its new commands on every fixture in the same commit, and reading the files isn't enough. Add the steps to each release's scripts, as `fixture_v010_network.txtar` runs rules by method and path on 0.1.0's app VM and `fixture_v010_clone.txtar` runs devvm clone add on its web VM. When a fixture's test fails, today's devvm breaks the state that the release's users have. Fix devvm, or add a migration, but never change the fixture.
|
||||
|
||||
A change in what devvm does with existing state gets an entry marked Breaking in `CHANGELOG.md`, in the Unreleased section at the bottom until its release moves it to the top. When the user has to do something about it, such as run a command, devvm also tells them once, at the first launch after the upgrade.
|
||||
A change in what devvm does with existing state gets a line in `CHANGELOG.md`, in the Unreleased section at the bottom until its release moves it to the top: a step in What to do when the user has to act on it, and otherwise a line in the group of the people who notice it, as [Releasing](maintaining.md#releasing) says. When the user has to do something about it, such as run a command, devvm also tells them once, at the first launch after the upgrade.
|
||||
|
||||
#### Freezing a release's state
|
||||
|
||||
|
||||
@@ -208,19 +208,21 @@ The tests run a test build of devvm, which is one made with `-ldflags "-X github
|
||||
| Variable | Stands in for |
|
||||
| --- | --- |
|
||||
| `DEVVM_HOST_MISE` | devvm's pinned and checked mise on the host |
|
||||
| `DEVVM_TOOL_SLOTS` | `backend.MaxToolSlots`, the most tool images that build side by side, which the host's memory, CPUs and free space lower further |
|
||||
| `DEVVM_KVM` | Linux's `/dev/kvm` |
|
||||
| `DEVVM_UBUNTU_URL` | `https://cloud-images.ubuntu.com/releases/resolute`, where devvm finds Ubuntu's dated releases |
|
||||
| `DEVVM_UBUNTU_URL` | `https://cloud-images.ubuntu.com/releases/resolute`, where devvm finds Ubuntu's dated releases and downloads the cloud image from. A `file://` address is read from disk, and devvm copies the image into its own folder as it does a download |
|
||||
| `DEVVM_LIMA_TEMPLATES` | the folder of Lima's own templates beside `limactl`, whose cloud images `devvm gc --caches` never frees from Lima's cache: the CLI tests' stub `limactl` has none |
|
||||
| `DEVVM_UBUNTU_RELEASE` | the newest dated release, which devvm pins base to: the end-to-end tests pin their own, `e2eUbuntuRelease`, so its images stay cached between runs, and devvm checks it as it does the newest |
|
||||
| `DEVVM_UNREVIEWED` | the refusal of unreviewed emulations ([unreviewed emulations](#unreviewed-emulations)) |
|
||||
| `DEVVM_SSH_PORTS` | the 17 ports every browser refuses, which VMs' ssh comes from (`ports.SSHPorts`): a comma-separated list of the CLI test sandbox's own, so sandboxes running at once never share them |
|
||||
| `DEVVM_SSH_PORTS` | the 17 ports every browser refuses, which VMs' ssh comes from (`ports.SSHPorts`). It's a comma-separated list of the CLI test sandbox's own ports, so sandboxes running at once never share them |
|
||||
| `DEVVM_TEST_CPUS`, `DEVVM_TEST_MEMORY_GIB`, `DEVVM_TEST_FREE_GIB`, `DEVVM_TEST_LIST_TIMEOUT` | this machine's size and how long devvm waits for a backend's listings ([a host of any size](#a-host-of-any-size)) |
|
||||
| `DEVVM_PIPED_ANSWERS` | a terminal to answer questions in: with `1`, each question reads its answer as a line of input that isn't a terminal, without its prompt, where devvm would refuse it |
|
||||
| `DEVVM_VOLUME` | the volume of every folder, such as `uuid:…`, in place of `diskutil`'s on macOS and the file system's ID on Linux, as devvm records and matches it when it makes, launches, adopts, moves, deletes or lists a VM, so a script needn't depend on the real one; `fail` makes each lookup fail |
|
||||
| `DEVVM_VOLUME` | the volume of every folder, such as `uuid:…`, in place of `diskutil`'s on macOS and the file system's ID on Linux, as devvm records and matches it when it makes, launches, adopts, moves, deletes or lists a VM, so a script needn't depend on the real one, and `fail` makes each lookup fail |
|
||||
| `DEVVM_HISTORY_MAX` | the 2 GiB that an export of agents' history holds at most, in bytes, so a script whose VM writes an export without end reaches the cap at once |
|
||||
| `DEVVM_CLIP_TOOLS` | where devvm paste finds the clipboard tools: macOS's `/usr/bin/osascript` and `/usr/bin/pbcopy`, and `wl-paste`, `wl-copy` and `xclip` in Linux's system folders, so the tests' stand-ins run in their place |
|
||||
| `DEVVM_PASTE_WAIT` | how long devvm paste waits for its script in the VM, in seconds, in place of 10 minutes for a write and 2 for a count or a delete, so a script whose VM never answers reaches the limit at once |
|
||||
|
||||
The settings that the [environment table](../using/settings.md#environment) lists, such as `DEVVM_LIMA_HOME`, `DEVVM_SECRET_SERVICE` and `DEVVM_NO_TOOL_CHECK`, are yours to set, so every build reads them.
|
||||
The settings that the [environment table](../using/settings.md#environment) lists, such as `DEVVM_LIMA_HOME`, `DEVVM_SECRET_SERVICE` and `DEVVM_NO_TOOL_CHECK`, are yours to set, so every build reads them. Sandboxes for manual runs that have data folders of their own but share one `DEVVM_LIMA_HOME` lock only their own shared tools, so don't build shared tools or run `devvm gc` in two of them at once: either can delete a build VM that the other is still using ([building tools](../internals/images.md#building-tools)).
|
||||
|
||||
## Tests on real Lima
|
||||
|
||||
@@ -304,20 +306,20 @@ When a target fails, `go test` writes the input that broke it to the package's `
|
||||
|
||||
### The nightly run
|
||||
|
||||
The Fuzz workflow (`.github/workflows/fuzz.yml`) fuzzes every target for five minutes each night, eight targets at a time, and you can start it by hand from the Actions tab. It minimizes each new input in at most 1,000 runs (`-fuzzminimizetime 1000x`), because by default `go test` minimizes each one for up to a minute, and a target whose runs write files, such as `FuzzUnpack`, would spend its five minutes doing that. It finds the targets by reading each `func Fuzz` in the tests, so a new target is fuzzed without any change to the workflow, and the proxy's targets run first. A target's name must be its own across the packages, because its artifacts and its line in the issue are named by it, and two targets of one name fail the run.
|
||||
The Fuzz workflow (`.github/workflows/fuzz.yml`) fuzzes every target for five minutes each night, eight targets at a time, and you can start it by hand from the Actions tab. It minimizes each new input in at most 1,000 runs (`-fuzzminimizetime 1000x`), because by default `go test` minimizes each one for up to a minute, and a target whose runs write files, such as `FuzzUnpack`, would spend its five minutes doing that. It finds the targets by reading each `func Fuzz` in the tests, so a new target is fuzzed without any change to the workflow, and the proxy's targets run first. A target's name must be its own across the packages, because the workflow names the target's artifacts and its line in the issue after it, and two targets of one name fail the run.
|
||||
|
||||
Each target starts from its corpus, the inputs that its earlier nights found reaching new code, so each night goes further than the last rather than starting again from the seeds. `go test` keeps a target's corpus in the `fuzz` folder of `GOCACHE`, and the workflow restores it from a cache of the target's own before fuzzing and saves it afterwards, whether the target failed or not. When a target fails, the workflow uploads the input that broke it as an artifact named `crash-<target>`, and it adds the input to the target's corpus, so the target fails on it again each night until the fix is on `main`.
|
||||
|
||||
The workflow keeps the failures in one issue, "Fuzzing found failing inputs":
|
||||
|
||||
- **It opens the issue** on the first night a target fails. The issue lists each failing target with its package and how its run ended, and links the night's run, where the `crash-<target>` artifacts are. A target whose job reported nothing counts as failing too.
|
||||
- **It opens the issue** on the first night a target fails. The issue lists each failing target with its package and how its run ended, and links the night's run, where the `crash-<target>` artifacts are. A target whose job reported nothing also counts as failing.
|
||||
- **It comments on the issue** when the failing targets change, so a new failure notifies you, and otherwise it only updates the issue's link to the latest run.
|
||||
- **It closes the issue** on the first night every target passes, the inputs that failed included.
|
||||
- **Only a run on `main` updates the issue,** so a run started on another branch never closes it. The fuzz jobs run the repo's code with read access alone, and the issue job, the only one that can write issues, runs none of it.
|
||||
|
||||
### What each target checks
|
||||
|
||||
The parsers of what a VM can write, its output and its files, and of what comes from the network fail closed: what they take is only what their format allows, within its caps. A secret's value goes only where it's bound, and a redaction leaves no planted secret behind. The host readers' targets are differential: each checks one reader against a frozen copy of how it read a host before devvm read every host in one form, and allows only the differences that [One form of a host](../internals/design.md#one-form-of-a-host) lists.
|
||||
The parsers of what a VM can write, its output and its files, and of what comes from the network fail closed, so they take only what their format allows, within its caps. A secret's value goes only where it's bound, and a redaction leaves no planted secret behind. The host readers' targets are differential, which means each one checks one reader against a frozen copy of how it read a host before devvm read every host in one form, and allows only the differences that [One form of a host](design.md#one-form-of-a-host) lists.
|
||||
|
||||
| Target | Package | What it checks |
|
||||
| --- | --- | --- |
|
||||
@@ -335,8 +337,10 @@ The parsers of what a VM can write, its output and its files, and of what comes
|
||||
| `FuzzCapture` | `internal/agentlogin` | Whatever an agent's token endpoint replies to whatever request, for every agent whose login devvm captures, the VM's reply is a JSON object holding none of the reply's tokens, and a reply that isn't captured leaves the store unwritten. |
|
||||
| `FuzzSplit` | `internal/redact` | A password that `String` finds in a line, in a URL of at most the tail's length, never reaches the log when the line comes in parts of any size and is written after each part as far as `Split` lets it, as the run log writes it. |
|
||||
| `FuzzStrip` | `internal/jsonc` | `Strip` keeps every offset, blanking bytes with spaces and keeping newlines, leaves JSON as it is, and, against `encoding/json`, makes JSON with comments, trailing commas and a byte order mark read as the same value as the JSON without them. |
|
||||
| `FuzzParsePublicKey` | `internal/upgrade` | A minisign public key is read only from one base64 line, alone or after its untrusted comment, as exactly its key ID and its Ed25519 key. |
|
||||
| `FuzzVerify` | `internal/upgrade` | A signature verifies only the data its key's holder signed, with the trusted comment that was signed. |
|
||||
| `FuzzParsePublicKey` | `internal/minisign` | A minisign public key is read only from one base64 line, alone or after its untrusted comment, as exactly its key ID and its Ed25519 key. |
|
||||
| `FuzzCheck` | `internal/minisign` | A signature checks out only for the data its key's holder signed, and only with the trusted comment that was signed, exactly. |
|
||||
| `FuzzKeysCheck` | `internal/minisign` | A manifest checks out only as the one signed, for the subject signed, and when at least two roles' files are each a signature of it by that role's own key. |
|
||||
| `FuzzSumOf` | `internal/upgrade` | A file's hash in `SHA256SUMS` is the first field of the first line that is exactly a 64-character hash and the file's name, and such a line is always found. |
|
||||
| `FuzzEntryName` | `internal/upgrade` | An archive's entry is taken only as the release's folder or as a regular file right in it, which lands in the folder `unpack` makes and nowhere else. |
|
||||
| `FuzzUnpack` | `internal/upgrade` | `unpack` writes only regular files right in the folder it makes, `devvm` among them, each as the archive has it, `devvm` executable and the rest not, at most `unpackCap` in all and nothing outside the folder. An archive it refuses leaves no folder. |
|
||||
| `FuzzParseHostKeys` | `internal/vmssh` | Each host key taken from what a VM shows is of a type ssh has, with no certificate, marker or pattern, in strict base64 of at most `keyMax` that names its own type, from a line of the VM's own, in order. Its line in the record is three fields, which read back as that key. |
|
||||
@@ -346,15 +350,15 @@ The parsers of what a VM can write, its output and its files, and of what comes
|
||||
| `FuzzParseKept` | `internal/vm` | What a seed's apply kept, which devvm only shows, is the VM's own lines and names as it wrote them, none of them empty. |
|
||||
| `FuzzParseLFSPointer` | `internal/vm` | A blob is taken as a Git LFS pointer only as the spec writes one, with its version line first and each line ended, one oid of 64 lowercase hex digits, which names its object's path, and one size of at least 0. |
|
||||
| `FuzzHandshakeVM` | `internal/desktop` | The relay's handshake with the VM's VNC server succeeds only for version 3.8 or later, a list of security types that has None, and an OK result, and reads no more than those. It writes only version 3.8, then None, and None only from a list that has it, and its error, which goes in the log, stays short. |
|
||||
| `FuzzHostSites` | `internal/proxy` | Each of the proxy's readers of a host reads it as its frozen copy did, but for the listed differences. |
|
||||
| `FuzzClaudeHostSite`, `FuzzPromisorHostSite`, `FuzzPublicHostSite`, `FuzzRiskSites`, `FuzzCheckHostSite` | `internal/agentlogin`, `internal/vm`, `internal/from`, `internal/netpolicy`, `internal/secrets` | The other readers of a host, an MCP server's, a promisor remote's, `--from`'s registry's, `devvm network lock`'s and a secret's `--host`, read it as their frozen copies did, but for the listed differences. |
|
||||
| `FuzzHostSites` | `internal/proxy` | Each of the proxy's readers of a host reads it as its frozen copy did, except for the listed differences. |
|
||||
| `FuzzClaudeHostSite`, `FuzzPromisorHostSite`, `FuzzPublicHostSite`, `FuzzRiskSites`, `FuzzCheckHostSite` | `internal/agentlogin`, `internal/vm`, `internal/from`, `internal/netpolicy`, `internal/secrets` | The other readers of a host, an MCP server's, a promisor remote's, `--from`'s registry's, `devvm network lock`'s and a secret's `--host`, read it as their frozen copies did, except for the listed differences. |
|
||||
| `FuzzParseRule` | `internal/proxy` | A rule's text parses back to the same rule, a host rule never holds a space or a slash, and `ParsePolicy` marks a line a rule exactly when `ValidRule` takes it. |
|
||||
| `FuzzRequest` | `internal/proxy` | A request target the proxy accepts is a plain host, and the allow command it suggests allows exactly that host and port. |
|
||||
| `FuzzDenyBypass` | `internal/proxy` | A deny of `/gists/` and of `POST` holds however a request spells the path or the method. |
|
||||
| `FuzzClientHello` | `internal/proxy` | Reading a tunnel's first bytes never hangs, a stream whose first byte starts a TLS record counts as TLS, and only a whole record of TLS's version is returned. |
|
||||
| `FuzzTransparent` | `internal/proxy` | Whatever its first bytes, a transparent connection to a proxy whose policy allows nothing reaches nothing. |
|
||||
| `FuzzNixPath` | `internal/proxy` | What `nixPath` takes is one of the cache's exact forms and names a file inside its folder. |
|
||||
| `FuzzParse` | `internal/devcontainer` | A `devcontainer.json` refuses `${localEnv:…}`, its variables are names and shell words the environment file holds as they are, and nothing it keeps has a NUL. |
|
||||
| `FuzzParse` | `internal/devcontainer` | A `devcontainer.json` refuses `${localEnv:…}` and `${env:…}`. The check reads each variable as devvm does, from `${` to the first `}` after it, so a nested one such as `${${localEnv:HOME}}` is left as text. Its environment variables are names and shell words the environment file holds as they are, and nothing it keeps has a NUL. |
|
||||
| `FuzzParseRef` | `internal/from` | Any image reference parses into a tag without `/` or `:`, and a valid one parses the same once written out in full. |
|
||||
| `FuzzRestrictNetdev` | `internal/backend/lima` | `RestrictNetdev` refuses, or returns at most one network, restricted, with nothing else changed. |
|
||||
| `FuzzQuote` | `internal/shell` | A string that `Quote` quotes reaches a shell as itself. |
|
||||
|
||||
@@ -15,26 +15,26 @@ Every change to devvm's logic comes with a test, and Go tests are table tests ne
|
||||
- **A `msg.Fake`** is the `msg.Reporter` a package under test prints and asks through. Its zero value is quiet: it prints nothing, has no terminal, so it refuses every question as the UI does where it can't ask, and runs a logged command as it is. Its fields change that: `OnInfo`, `OnWarn` and the other `On` funcs are given each message or question of their kind, with a question's context going to `OnNote` first, `OnAny` every message, and `Terminal`, `Picks`, `Interrupt` and the writers stand for the terminal, the picker, an interrupt and the output. `OnStatus` is given each status line's label and each logged command's step, and `Showing` returns the one showing now, for a test that checks slow work runs under its status line ([status lines](cli.md#status-lines)).
|
||||
- **A `msg.Recorder`** keeps the messages it's given. Set a `msg.Fake`'s `OnInfo` or `OnWarn` to the recorder's `Add`, then compare its `Names` or its `IDs`.
|
||||
- **`backendtest.Stored`** is the fake backend with its disks on the host, for the free-space checks.
|
||||
- **The proxy's child in a test's process** gets `IO`'s `confine`, a confinement that confines nothing (`noConfine`), because `confineChild` would confine the test's whole process on Linux: `ChildMain` uses `confineChild` only when the field is nil, and `runChildOn` refuses to start without one. A test of `confineChild`'s own logic calls `confineWith` with a confinement of its own. A test's server made with `newServer` looks up its names and connects in the test's process, as `newChildServer` gives it the broker itself, while the tests that run the child over a real socketpair (`inProcess`) send every lookup and connection through the broker, and a broker in a test connects through a seam of its own (`broker.net`'s `connect`) wherever it could reach the internet. `internal/landlock`'s `TestSelf` runs the test binary again as a child that confines itself and logs what it could still do. It runs only without cgo (`CGO_ENABLED=0`), as CI's `nocgo` job and a hand run on a Linux host do, and skips under the race detector, whose cgo keeps Go from reaching every thread. The CLI tests' devvm is built without cgo, so on Linux their VMs' proxies' children run confined too.
|
||||
- **The proxy's child in a test's process** gets `IO`'s `confine`, a confinement that confines nothing (`noConfine`), because `confineChild` would confine the test's whole process on Linux. `ChildMain` uses `confineChild` only when the field is nil, and `runChildOn` refuses to start without one. A test of `confineChild`'s own logic calls `confineWith` with a confinement of its own. A test's server made with `newServer` looks up its names and connects in the test's process, because `newChildServer` gives it the broker itself. The tests that run the child over a real socketpair (`inProcess`) send every lookup and connection through the broker instead, and a broker in a test connects through a seam of its own (`broker.net`'s `connect`) wherever it could reach the internet. `internal/landlock`'s `TestSelf` runs the test binary again as a child that confines itself and logs what it could still do. It runs only without cgo (`CGO_ENABLED=0`), as CI's `nocgo` job and a hand run on a Linux host do, and skips under the race detector, whose cgo keeps Go from reaching every thread. The CLI tests' devvm is built without cgo, so on Linux their VMs' proxies' children run confined too.
|
||||
|
||||
## Goroutine leaks
|
||||
|
||||
A goroutine that outlives its test is one that would outlive its command in devvm, such as a tunnel the proxy carries after it has closed, or a goroutine that passes signals on after its child has ended. `internal/leaktest` finds them in every package that starts goroutines: `internal/proxy`, `vmssh`, `daemon`, `desktop`, `ui`, `vm`, `backend/lima`, `platform`, `cli`, `gitprotect`, `vmlog` and `memnet`. It imports only the standard library, so the proxy's and the daemon's tests use it too.
|
||||
|
||||
- **`leaktest.Main(m)`**, in a package's `TestMain`, runs the tests and, once they've passed, reads every goroutine's stack. It gives the goroutines that are still ending, such as a closed listener's accept loop, five seconds, then fails the test binary with the stacks of any still running. It leaves out the standard library's own goroutines that outlive every test and that no test can end, which `allowed` lists with why: `signal.Notify`'s loop and an HTTP client's idle connections. It then reads Go's `goroutineleak` profile, which names each goroutine blocked for good on a channel, a lock or a wait group that nothing still running can reach, and fails on any it names. A `TestMain` that makes the test binary a helper process runs the helper first and calls `leaktest.Main` last.
|
||||
- **`leaktest.Check(t)`**, called first in a test, fails that test when a goroutine started while it ran is still running once it has ended, its context cancelled and its cleanups run, after the same five seconds. It counts the goroutines the test started, and theirs, followed through those still running, so a test running in parallel doesn't count. Nor does a goroutine that a server shared between tests starts for the test, such as one that `TestMain` or a `sync.Once` started, because it leads back to that server's goroutine, which ran before the test, and `Main` finds those at the end. Its failure names the test, where `Main`'s names only the binary, so a test of something that starts and stops goroutines, such as a link session, the port forwarder or the desktop's relay, calls it.
|
||||
- **`leaktest.Check(t)`**, called first in a test, fails that test when a goroutine started while it ran is still running once it has ended, its context cancelled and its cleanups run, after the same five seconds. It counts the goroutines the test started, and theirs, followed through those still running, so a test running in parallel doesn't count. Nor does a goroutine that a server shared between tests starts for the test, such as a server that `TestMain` or a `sync.Once` started. That goroutine leads back to the server's own goroutine, which ran before the test, and `Main` finds such goroutines at the end. `Check`'s failure names the test, where `Main`'s names only the binary, so a test of something that starts and stops goroutines, such as a link session, the port forwarder or the desktop's relay, calls it.
|
||||
|
||||
Anything `Main` or `Check` finds is a leak to fix, with a test that fails without the fix. Only a goroutine the standard library starts, that outlives every test, goes in `allowed`. A new package that starts goroutines gets a `main_test.go` that calls `leaktest.Main`, which the structure test checks, and the structure test lists every goroutine devvm's code starts, with what waits for it to end ([`goroutineSites`](structure.md#the-structure-test)).
|
||||
Anything `Main` or `Check` finds is a leak to fix, with a test that fails without the fix. Only a goroutine that the standard library starts and that outlives every test goes in `allowed`. A new package that starts goroutines gets a `main_test.go` that calls `leaktest.Main`, which the structure test checks, and the structure test also lists every goroutine devvm's code starts, with what waits for it to end ([`goroutineSites`](structure.md#the-structure-test)).
|
||||
|
||||
## Time and lifecycles
|
||||
|
||||
A test of a timeout, a grace or a close, such as the relay's grace, the forwarder's close or the proxy's ClientHello deadline, runs in a [`testing/synctest`](https://pkg.go.dev/testing/synctest) bubble, `synctest.Test(t, func(t *testing.T) { … })`, rather than sleeping on the real clock. Inside the bubble, time is fake and moves only when every goroutine of the test is blocked, so `time.Sleep(30 * time.Second)` returns at once, and `synctest.Wait()` returns once every other goroutine has done what it can. Such a test takes no time, and a loaded CI machine can't make it fail, so it never needs the margins a real-clock test does.
|
||||
|
||||
A test checks that something happens at the moment it's due and not a nanosecond before: it sleeps to just short of the moment, calls `synctest.Wait()` and checks, then sleeps the last nanosecond and checks again. A goroutine that never ends fails the bubble as a deadlock, and a test of something that starts and stops goroutines calls [`leaktest.Check(t)`](#goroutine-leaks) before the bubble as well.
|
||||
A test checks that something happens at the moment it's due and not a nanosecond before. It sleeps to just short of the moment, calls `synctest.Wait()` and checks, then sleeps the last nanosecond and checks again. A goroutine that never ends fails the bubble as a deadlock, and a test of something that starts and stops goroutines calls [`leaktest.Check(t)`](#goroutine-leaks) before the bubble as well.
|
||||
|
||||
Time moves only while each goroutine waits on something inside the bubble: a channel, a timer, `time.Sleep`, a `sync.Cond` or a wait group. A socket's read, a process's wait or any system call that blocks keeps it from moving, so the code under test gets seams, fields that a test sets to stand-ins in memory, as every test seam is a field:
|
||||
Time moves only while each goroutine waits on something inside the bubble: a channel, a timer, `time.Sleep`, a `sync.Cond` or a wait group. A socket's read, a process's wait or any system call that blocks keeps it from moving, so the code under test gets seams. Like every test seam, each one is a field that a test sets to a stand-in in memory:
|
||||
|
||||
- **`internal/memnet`** is a network in memory for tests: `memnet.Pipe()` makes a connection, and a `memnet.Network` holds listeners by address, whose `Listen`, `Dial` and `DialContext` stand in for a socket's. Its connections close their writing side alone (`CloseWrite`), as TCP's do and `net.Pipe`'s don't, hold up to 64 KiB that the other end hasn't read before a write waits, as a socket's buffer does, and have deadlines on the bubble's clock, and its listeners have `SetDeadline` too. It uses only the standard library, so the proxy's tests use it.
|
||||
- **`internal/memnet`** is a network in memory for tests. `memnet.Pipe()` makes a connection, and a `memnet.Network` holds listeners by address, whose `Listen`, `Dial` and `DialContext` stand in for a socket's. Its connections close their writing side alone (`CloseWrite`), as TCP's do and `net.Pipe`'s don't. They hold up to 64 KiB that the other end hasn't read before a write waits, as a socket's buffer does. They have deadlines on the bubble's clock, and so do its listeners, through `SetDeadline`. It uses only the standard library, so the proxy's tests use it.
|
||||
- **The forwarder and the link sessions** take their listeners from their `Listen` fields, so a test gives them a `memnet.Network`'s.
|
||||
- **The relays** carry each connection through an `sshRelay`, whose `start` field starts its `ssh -W`. In production it's `execSSH`, and a test's stand-in, `memSSH`, is a VM in memory that sends what the test tells it and ends only when its context does, as `exec.CommandContext` kills ssh.
|
||||
- **The proxy** connects to the far ends through its egress's `connect` field, which `memServe` points at a `memnet.Network` while it serves the proxy on a listener in memory.
|
||||
@@ -43,7 +43,7 @@ Time moves only while each goroutine waits on something inside the bubble: a cha
|
||||
|
||||
A stand-in can't show what the real thing does with a kernel's buffers, a real ssh or a real process, so each kind of lifecycle keeps one test that runs the real one, on the real clock: `TestPipeSSHGrace`, `TestPipeSSHGraceSlowClient` and `TestPipeSSHGraceWriteError` run the relay with an ssh stand-in on `PATH`, `TestForwarderEndsStuckRelay` closes a forward whose relay's ssh never ends, `TestLinksBurst` fills a link's real Unix socket, `TestSpliceKeepsAnEarlyAnswer` splices over TCP and `TestProcStop` stops real processes. A new seam keeps the real test of its kind.
|
||||
|
||||
The proxy's tests that start a whole proxy, such as `TestMainRuns` and `TestAgentRelay`, run its child in the test's process (`inProcess`), on real sockets, so they can't run in a bubble. Their broker waits `testStartWait`, 30 seconds, for the child to say it's ready, through `IO`'s `startWait` field, where devvm's own proxy waits 4 seconds, and each test waits as long for the proxy to listen (`retryFor`). Under the race detector on a loaded Linux host, those starts took more than 4 seconds, most of it hashing the test's executable, which each broker does as it starts, so the 4 seconds made them fail.
|
||||
The proxy's tests that start a whole proxy, such as `TestMainRuns` and `TestAgentRelay`, run its child in the test's process (`inProcess`), on real sockets, so they can't run in a bubble. Their broker waits `testStartWait`, 30 seconds, for the child to say it's ready, through `IO`'s `startWait` field, where devvm's own proxy waits 4 seconds, and each test waits as long for the proxy to listen (`retryFor`). Under the race detector on a loaded Linux host, those starts can take more than 4 seconds, most of it spent hashing the test's executable, which each broker does as it starts, so a wait of 4 seconds would fail them.
|
||||
|
||||
## CLI tests
|
||||
|
||||
@@ -73,7 +73,8 @@ Each script runs in a sandbox under `/tmp`, never the real folders:
|
||||
| `STUB_DIR` | `stub/`, for stubs' state |
|
||||
| `STUB_LOG` | `stub/calls`, the stubs' call log |
|
||||
| `DEVVM_SECRET_SERVICE` | `devvm-test`, the Keychain service name |
|
||||
| `DEVVM_UBUNTU_URL` | `ubuntu/`, with a dated release as Ubuntu signed it |
|
||||
| `DEVVM_UBUNTU_URL` | `ubuntu/`, with a dated release as Ubuntu signed it. Its cloud image is a gigabyte, so the sandbox has a stand-in for this host's in `data/devvm/images/ubuntu/`, named for its SHA-256 in the release's checksums, as if devvm had downloaded it, and a script that tests the download or the import from Lima's cache removes it |
|
||||
| `DEVVM_TOOL_SLOTS` | 1, so tool images build one at a time and the stubs' calls keep their order, and `tools_side_by_side.txtar` sets 3 |
|
||||
| `DEVVM_KVM` | `stub/kvm`, a file standing in for Linux's `/dev/kvm` |
|
||||
| `DEVVM_TEST_CPUS`, `DEVVM_TEST_MEMORY_GIB`, `DEVVM_TEST_FREE_GIB` | 8, 16 and 500: a large host, whatever runs the tests ([details](testing.md#a-host-of-any-size)) |
|
||||
| `DEVVM_HOST_MISE` | the `mise` stub, which resolves the shared tools in place of devvm's own mise |
|
||||
@@ -85,15 +86,15 @@ Each script runs in a sandbox under `/tmp`, never the real folders:
|
||||
| `DEVVM_REPO` | the checkout, for the scripts in `scripts/`, which tests copy into a throwaway repo before running, and the scripts in `assets/`, which tests source to check their pieces |
|
||||
| `DEVVM_SSH_PORTS`, `SANDBOX_PORT_NEXT`, `SANDBOX_PORT_END`, `DEVVM_PORT_RANGE` | the sandbox's own ports, as the next paragraph says |
|
||||
|
||||
Each sandbox has a block of 160 ports of its own, between 10000 and 19999, below both the range devvm chooses ports from and the system's ephemeral range, so neither a devvm that a script runs nor an outgoing connection takes one. The sandbox holds the block's lock file in `/tmp/devvm-test-ports-<uid>/`, a folder of your user's alone, while it lasts, so no other sandbox has the same block, whether it's in the same test process or in another one running at once, such as a second worktree's gate. While every block is held, a new sandbox waits for one, up to 5 minutes. The block's first 60 ports are for the scripts: the VMs' ssh ports (`DEVVM_SSH_PORTS`) come first, and then `free_port VAR…` and the fixtures' ports, each taken in turn from `SANDBOX_PORT_NEXT` up to `SANDBOX_PORT_END` and free on every address, `127.0.0.1` included, as it's taken (`free_port -range FIRST LAST` takes two in a row). The other 100 are the range the sandbox's devvm chooses its VMs' proxy and desktop ports from (`DEVVM_PORT_RANGE`, which only a test build reads), so two sandboxes' devvms never choose the same port.
|
||||
Each sandbox has a block of 160 ports of its own, between 10000 and 19999, below both the range devvm chooses ports from and the system's ephemeral range, so neither a devvm that a script runs nor an outgoing connection takes one. The sandbox holds the block's lock file in `/tmp/devvm-test-ports-<uid>/`, a folder of your user's alone, while it lasts, so no other sandbox has the same block, whether it's in the same test process or in another one running at once, such as a second worktree's gate. While every block is held, a new sandbox waits for one, up to 5 minutes. The block's first 60 ports are for the scripts. The VMs' ssh ports (`DEVVM_SSH_PORTS`) come first, and then the ports for `free_port VAR…` and the fixtures. Each of those is taken in turn from `SANDBOX_PORT_NEXT` up to `SANDBOX_PORT_END`, and it's free on every address, `127.0.0.1` included, when it's taken (`free_port -range FIRST LAST` takes two in a row). The other 100 are the range the sandbox's devvm chooses its VMs' proxy and desktop ports from (`DEVVM_PORT_RANGE`, which only a test build reads), so two sandboxes' devvms never choose the same port.
|
||||
|
||||
The built `devvm` is a [test build](testing.md#test-builds), so it reads the stand-ins above that a release ignores, such as `DEVVM_KVM` and `DEVVM_HOST_MISE`. A script answers a question in one of two ways: `ttyin -stdin FILE` gives the next `exec` a terminal whose input is the file, so devvm asks as it does in yours, and `env DEVVM_PIPED_ANSWERS=1` with `stdin FILE` has each question read its answer as a line of the file instead, without its prompt. Without either, devvm has no terminal, so it refuses every question, as a script's devvm does. It has the checkout's `assets/` embedded, as a release has, and no test build reads them from elsewhere: a script that needs other files for devvm (layers, features, policies) puts them in the user's folders in the sandbox, as a user would.
|
||||
|
||||
`$WORK`, the script's own folder, is the current folder. `project NAME` makes the folder `$WORK/NAME` and goes to it, as a project's folder, and `project NAME git` makes it a git repo too. Once devvm has made the folder's VM, `vm_name VAR NAME` finds it among the states in `$VMS` and sets `$VAR` to the VM's name, which ends in an ID the test can't know, so a script can pass it to a stub (`exec limactl stop $WEB`). It also sets `$VAR_dir` to the VM's folder, `$VMS/<hash>`, so a script reads the VM's state as `$WEB_dir/vm.json` and its network log as `$WEB_dir/logs/network.jsonl`. `catg GLOB` prints the one file a glob matches, and fails when the glob matches none or more than one, so a check never reads two files by mistake. `vm_state GLOB` prints the one VM state a glob matches as sorted `KEY=VALUE` lines for `stdout` to match: a section's fields are dotted (`net.on=true`, `ports.host.ssh=23456`), a list of strings is joined with spaces (`tools.names=node claude`), a list of objects is indexed (`links.links.0.name=db`), and anything but a string is JSON. Negated, `! catg GLOB` and `! vm_name VAR NAME` pass when there isn't exactly one. `json_set GLOB KEY=VALUE…` sets string fields in each JSON file the glob matches and keeps the rest, or makes the file when a glob without wildcards matches none. `KEY:=JSON` sets any JSON value, and a dotted key sets a field of an object, which it makes when it's missing. Scripts write devvm's JSON records with it, such as a tool image's record (`json_set $SHARE/node-*.json built=2020-01-01T00:00:00Z`), because a record's times are in the file, where `touch` can't change them. `renumber FILE` changes a VM's state as a boot that numbered the disks' devices anew leaves it, as macOS does: the folder's identity and each `.git`'s `git_id` get another device, with their inodes and birth times as they were, and `$FOLDER_ID` and `$GIT_ID` hold the folder's and its own `.git`'s identities from before. `fixture VERSION` puts a release's state into the sandbox, and `json_superset [-shape] [-changes PATH] WANT GOT` checks that one JSON file has everything another has, as [Released state](structure.md#released-state) says. A VM state a script writes as a fixture needs `version`, `id`, `name`, `image`, `dir` and `backend`, `created` for a VM whose creation finished, and a hash of its own for its folder (`json_set $VMS/12345612345601/vm.json version:=1 id=x name=devvm-live-12345612345601 image=base dir=/p/live backend=lima created=2020-01-01T00:00:00Z net.on:=false`).
|
||||
`$WORK`, the script's own folder, is the current folder. `project NAME` makes the folder `$WORK/NAME` and goes to it, as a project's folder, and `project NAME git` makes it a git repo too. Once devvm has made the folder's VM, `vm_name VAR NAME` finds it among the states in `$VMS` and sets `$VAR` to the VM's name, which ends in an ID the test can't know, so a script can pass it to a stub (`exec limactl stop $WEB`). It also sets `$VAR_dir` to the VM's folder, `$VMS/<hash>`, so a script reads the VM's state as `$WEB_dir/vm.json` and its network log as `$WEB_dir/logs/network.jsonl`. `catg GLOB` prints the one file a glob matches, and fails when the glob matches none or more than one, so a check never reads two files by mistake. `vm_state GLOB` prints the one VM state a glob matches as sorted `KEY=VALUE` lines for `stdout` to match: a section's fields are dotted (`net.on=true`, `ports.host.ssh=23456`), a list of strings is joined with spaces (`tools.names=node claude`), a list of objects is indexed (`links.links.0.name=db`), and anything but a string is JSON. Negated, `! catg GLOB` and `! vm_name VAR NAME` pass when there isn't exactly one. `json_set GLOB KEY=VALUE…` sets string fields in each JSON file the glob matches and keeps the rest, or makes the file when a glob without wildcards matches none. `KEY:=JSON` sets any JSON value, and a dotted key sets a field of an object, which it makes when it's missing. Scripts write devvm's JSON records with it, such as a tool image's record (`json_set $SHARE/node-*.json built=2020-01-01T00:00:00Z`), because a record's times are in the file, where `touch` can't change them. `renumber FILE` changes a VM's state as a boot that numbered the disks' devices anew leaves it, as macOS does. The folder's identity and each `.git`'s `git_id` get another device, with their inodes and birth times as they were, and `$FOLDER_ID` and `$GIT_ID` hold the folder's and its own `.git`'s identities from before the change. `fixture VERSION` puts a release's state into the sandbox, and `json_superset [-shape] [-changes PATH] WANT GOT` checks that one JSON file has everything another has, as [Released state](structure.md#released-state) says. A VM state a script writes as a fixture needs `version`, `id`, `name`, `image`, `dir` and `backend`, `created` for a VM whose creation finished, and a hash of its own for its folder (`json_set $VMS/12345612345601/vm.json version:=1 id=x name=devvm-live-12345612345601 image=base dir=/p/live backend=lima created=2020-01-01T00:00:00Z net.on:=false`).
|
||||
|
||||
Tests never touch the network. Downloads are served from a test server (`net/http/httptest`) or read from a `file://` folder. `DEVVM_UBUNTU_URL` replaces `https://cloud-images.ubuntu.com/releases/resolute`, where devvm finds Ubuntu's dated releases: point it at a folder of `release-YYYYMMDD/` folders, each with its `SHA256SUMS` and `SHA256SUMS.gpg`, as `file:///path/to/folder`. The CLI tests serve `internal/ubuntu/testdata/resolute`, a release as Ubuntu published and signed it, and Go tests sign their own releases with a key they make (`internal/ubuntu/pgp_test.go`). devvm's own releases, which `devvm upgrade` installs, come from `internal/upgrade/upgradetest`: a TLS test server laid out as GitHub's releases, with a minisign key of the test's own that signs each release's `SHA256SUMS` as minisign does. A script starts one with `release_server [-badsig] LATEST [VERSION...]`, which serves a release of each version, the first the newest, each devvm in it a script that prints its version, and with `-badsig` signs them with another key. It points a test build at the server with `DEVVM_REPO_URL`, at its key with `DEVVM_RELEASE_KEY` and at its certificate with `DEVVM_RELEASE_CA`, and `DEVVM_TEST_VERSION` gives the test build a release's version. Container registries (`--from`) are a TLS test server in Go tests; scripts use pinned digests, which need no lookup, or set `HTTPS_PROXY` to a closed port, so lookups fail as offline ones do.
|
||||
Tests never touch the network. Downloads are served from a test server (`net/http/httptest`) or read from a `file://` folder. `DEVVM_UBUNTU_URL` replaces `https://cloud-images.ubuntu.com/releases/resolute`, where devvm finds Ubuntu's dated releases: point it at a folder of `release-YYYYMMDD/` folders, each with its `SHA256SUMS` and `SHA256SUMS.gpg`, as `file:///path/to/folder`. The CLI tests serve `internal/ubuntu/testdata/resolute`, a release as Ubuntu published and signed it, and Go tests sign their own releases with a key they make (`internal/ubuntu/pgp_test.go`). devvm's own releases, which `devvm upgrade` installs, come from `internal/upgrade/upgradetest`: a TLS test server laid out as GitHub's releases, with keys of the test's own (`Signers`, which `internal/minisign/minisigntest` makes) that sign each release's `SHA256SUMS` as minisign does, as a release is signed while releases bridge from the old release key: by CI's and the co-signer's keys, and by the old key. A script starts one with `release_server [-badsig] [-legacy|-keys] LATEST [VERSION...]`, which serves a release of each version, the first the newest, each devvm in it a script that prints its version. `-legacy` has only the old key sign them, as 0.1 and 0.2's releases are, `-keys` only the release keys, and `-badsig` other keys. It points a test build at the server with `DEVVM_REPO_URL`, at the release keys with `DEVVM_RELEASE_KEYS`, as `ci=KEY cosign=KEY recovery=KEY`, at the old key with `DEVVM_RELEASE_KEY` and at its certificate with `DEVVM_RELEASE_CA`, and `DEVVM_TEST_VERSION` gives the test build a release's version. Container registries (`--from`) are a TLS test server in Go tests; scripts use pinned digests, which need no lookup, or set `HTTPS_PROXY` to a closed port, so lookups fail as offline ones do.
|
||||
|
||||
A command left running in the background (`exec devvm … &name&`) can be interrupted with `kill -INT name`. `wait_file FILE` waits up to 60 seconds for a file to appear, such as one a stub writes when it gets somewhere, and fails at once when every background command has ended. For anything else, `wait_until SCRIPT` runs `sh -c SCRIPT` every 100 ms until it succeeds, for up to 90 seconds, and fails at once when every background command has ended, or when SCRIPT exits 100, which a check that can no longer succeed gives, such as a session that ended. Wait with these two rather than a loop of your own. A script that runs a copy of devvm makes it with `cp_exe SRC DST`, not `cp`: on Linux, a command another script starts while the copy is being written keeps the file open for writing until it runs, so running the copy then fails with "text file busy", and `cp_exe` writes the file while no command can start.
|
||||
A command left running in the background (`exec devvm … &name&`) can be interrupted with `kill -INT name`. `wait_file FILE` waits up to 60 seconds for a file to appear, such as one a stub writes when it gets somewhere, and fails at once when every background command has ended. For anything else, `wait_until SCRIPT` runs `sh -c SCRIPT` every 100 ms until it succeeds, for up to 90 seconds. It fails at once when every background command has ended, or when SCRIPT exits 100, which is how a check that can no longer succeed says so, as when it waits on a session that ended. Wait with these two rather than a loop of your own. A script that runs a copy of devvm makes it with `cp_exe SRC DST`, not `cp`: on Linux, a command another script starts while the copy is being written keeps the file open for writing until it runs, so running the copy then fails with "text file busy", and `cp_exe` writes the file while no command can start.
|
||||
|
||||
### Stubs
|
||||
|
||||
@@ -135,7 +136,7 @@ A switch is a file a test makes in `$STUB_DIR` to change what a stub does, such
|
||||
|
||||
`limactl` keeps its instances in the state and fails or hangs on request. It keeps each instance's size and config as `create`, `clone` and `edit` set them, and a [contract test](testing.md#tests-on-real-lima) checks that it does so as real Lima does. Its `shell` reaches the guest, the VM the stubs make believe in, which `ssh` reaches too. One module, `guest.go`, answers whatever devvm runs in a VM, with one set of switches whichever way devvm gets there. `limactl shell` is also the shell devvm opens in a VM, which then ends, so a script sees it as devvm's last call. In the shared tools' build VM, its `shell` writes the images `build.sh` is asked for into the build's folder (or, on request, a symlink instead), and it keeps what a VM's setup is sent as `$STUB_DIR/sync.tar`. A base build's packages go in as `$STUB_DIR/packages-in.tar`, and what the build gives back is `$STUB_DIR/packages-out.tar`, or no packages. In the `--from` build VM, its `shell` writes what `oci/build.sh` would (or, on request, a hostile disk, command line, C library or symlink), and a call naming `$STUB_DIR/interrupt-on`'s text interrupts devvm, as Ctrl+C would. The VM's ssh host keys are one made-up key for each VM, unless `$STUB_DIR/hostkeys-fails` exists.
|
||||
|
||||
`docker` stands in only for what `--from` asks of it. It has an image only when `$STUB_DIR/docker-image` holds its ID, its `save` writes a tarball naming that image (or `$STUB_DIR/docker-saved`'s, a tag that moved), and it isn't running when `$STUB_DIR/docker-down` exists. `ssh` answers a port forwarder's master with `$STUB_DIR/guest-ports`, and a link session's master listens on its control socket. Either master outlives the process that started it, as ssh's does, until the sandbox's cleanup stops it or 5 minutes pass. A direct connection from a VM (the self-check's) fails, as a confined VM's does, unless `$STUB_DIR/net-direct` exists. A `--clone` VM's git and its seed's scripts run on the host, with real bash, git and tar, on `$STUB_DIR/vmfs/<folder>`, and `ssh` fetches from there (it fails with `$STUB_DIR/ssh-fails`). A clone's command fails, as any shell does, when `$STUB_DIR/shell-fails-on` holds text its arguments hold, such as `index-pack` for the seed's apply. `security` stands in for the Keychain and `tmutil` for Time Machine, both keeping their items in the state, never in the real ones. `mise` writes `$MISE_STUB_LOCK` as the lock (`$MISE_STUB_OLDER_LOCK` for a list of versions), lists `$MISE_STUB_VERSIONS`, and fails like mise offline with `MISE_STUB_FAIL` set. `chflags` sets no flags, so `.git` protection leaves test folders deletable. `qemu-img` and QEMU are there so Linux hosts pass devvm's checks.
|
||||
`docker` stands in only for what `--from` asks of it. It has an image only when `$STUB_DIR/docker-image` holds its ID, its `save` writes a tarball naming that image (or `$STUB_DIR/docker-saved`'s, a tag that moved), and it isn't running when `$STUB_DIR/docker-down` exists. `ssh` answers a port forwarder's master with `$STUB_DIR/guest-ports`, and a link session's master listens on its control socket. Either master outlives the process that started it, as ssh's does, until the sandbox's cleanup stops it or 5 minutes pass. A direct connection from a VM (the self-check's) fails, as a confined VM's does, unless `$STUB_DIR/net-direct` exists. A `--clone` VM's git and its seed's scripts run on the host, with real bash, git and tar, on `$STUB_DIR/vmfs/<folder>`, and `ssh` fetches from there (it fails with `$STUB_DIR/ssh-fails`). A clone's command fails, as any shell does, when `$STUB_DIR/shell-fails-on` holds text its arguments hold, such as `index-pack` for the seed's apply. `security` stands in for the Keychain and `tmutil` for Time Machine, both keeping their items in the state, never in the real ones. `mise` writes `$MISE_STUB_LOCK` as the lock (`$MISE_STUB_OLDER_LOCK` for a list of versions), lists `$MISE_STUB_VERSIONS`, and fails like mise offline with `MISE_STUB_FAIL` set. With `MISE_STUB_FAIL=404`, it fails like mise when node's newest version, and one of the older versions a step back locks together, have no musl download yet. A lock of named tools then adds only their entries, for the platforms it names, to the lock that's there, and a lock naming `$MISE_STUB_OFFLINE_TOOL` fails like mise offline. `chflags` sets no flags, so `.git` protection leaves test folders deletable. `qemu-img` and QEMU are there so Linux hosts pass devvm's checks.
|
||||
|
||||
To add a stub, write its function in `internal/stubtest/stub`, with a comment that says what it does and lists its switches, and add it to `stubs()` under the command's name. It logs its call with `c.log()` first, keeps what it must remember in the state through `c.update`, and reads its switches with `c.on` and `c.text`. A new command the state needs goes in `control`. To add a switch, read it in the stub's function, name it for what it does as above, and add it to that function's comment. Each stub has unit tests in `stub_test.go`, which run it in the test's own process. Where a stub prints what devvm parses, such as `limactl list --json`, the [golden fixtures](testing.md#golden-fixtures) check that it prints what the real tool prints.
|
||||
|
||||
@@ -186,13 +187,13 @@ The sections so far:
|
||||
- `clone`: `--clone` with a throwaway repo, and host git and devvm run with a home of the section's own, so neither reads your `~/.ssh/config` or your git settings, and the Include line isn't offered. The VM has its own clone with every branch, even though the repo's `url.*.insteadOf` sends its URL elsewhere, only the shared tools are mounted, and its shell opens in the clone. The repo gets a `devvm` remote named after the VM, and nothing of `.git` is locked or watched. Without a terminal, `devvm rm --force` refuses while the clone has commits that weren't fetched and keeps the VM. Once `git fetch devvm` through devvm's ssh config has brought the VM's commit, `devvm rm` refuses for uncommitted changes in the clone, and then for those in a worktree in the clone, shown under its path, and `devvm rm --no-clone-check` deletes the VM after a warning, the worktree's change with it, and removes the remote, while the fetched work stays as a local branch. A git worktree's VM gets a clone of only its branch and that branch's upstream. On a VM that mounts its folder, `devvm clone on` without a terminal is refused, and `devvm clone` shows off. `devvm clone on --force` then makes it again with its own clone of every branch, only the shared tools mounted and `.git` unlocked, and it keeps its home and its ID. `devvm clone off --force` without a terminal refuses while the clone has commits that weren't fetched and keeps the clone, and once they're fetched, it mounts the folder again with `.git` protected, keeps the VM's home and ID, removes the remote and leaves the work as a local branch. Last, `devvm --clone --repos all` in a folder of repos gives one VM a clone of each repo at its path, with every branch, the folder's own file, and nothing mounted but the shared tools. `devvm clone fetch` brings both repos' work back and lists the branch with both repos, `devvm clone add` copies a third repo into the VM at its path, with a remote, `devvm rm` without a terminal refuses for the work in one repo that wasn't fetched, naming that repo, and `devvm rm --no-clone-check` deletes the VM and removes each repo's remote. A repo with a detached `HEAD`, an annotated tag, origin's branches and an older VM's remote gets a clone detached at the same commit, with the tag still annotated and origin's branches, and none of the VM remote's. The same repo's staged, unstaged and intent-to-add changes and a tracked file turned into a folder give the same `git status` in the VM, which has neither the untracked `.env` nor the folder, and devvm names the folder. Its clone has origin's URL, another remote's https URL without the user and token it has here, a branch as far ahead of its upstream as here, and the repo's `user.name` and `user.email`, which a commit there takes with no identity given, none of its credential settings, and its pre-commit hook, which runs there. `devvm clone fetch` brings back a commit only the VM's detached `HEAD` has, as `saved/devvm/HEAD`, and `devvm rm` names another, but not the uncommitted changes copied in, which the VM left as they came. A repo whose rebase, started with `--autostash`, stopped on a conflict, after a reset, with a stash of a plain entry and a `--all` one, gets a clone in the same rebase, which `git rebase --continue` finishes there, bringing the autostash back; its stash is the repo's but for the `--all` entry, which devvm names, the commit only the reset's `ORIG_HEAD` reached isn't there, and `devvm rm` names a stash entry the VM made, not the one copied in. A `blob:none` clone of a small public repo, on the internet tier, gets a promisor clone whose git fetches a blob it lacks from the repo's origin. Work in the VM that names another blob neither side has doesn't come back, and `devvm clone fetch` says so with `clone_fetch_partial`, then brings it back once git in the VM has read the blob. Both checks are skipped when github.com can't be reached. A repo with a submodule that has one of its own, both initialised, gets clones of them in the VM, where `git submodule status --recursive` is as here; a VM commit in the submodule comes back into its repo here with `devvm clone fetch`, and `devvm rm` without a terminal names a commit in the nested one that wasn't fetched, and keeps the VM. A repo that uses Git LFS, made without `git-lfs` on this machine, has its LFS file's content in the VM, whose `git status` is clean, with git-lfs's filter in the clone's own config and not in the VM's system or global config; a file the VM's `git-lfs` adds comes back with `devvm clone fetch`, its object in the repo here, and an object in the VM that isn't what its pointer names stays out, named with `clone_lfs_kept`.
|
||||
- `gc`: a VM from a folder named `img-keep`, which is named like an image, and a fixture layer edited after its build: `devvm gc` deletes the stale image and its record and an old tool image no VM lists (once there's a tools lock), and keeps base and the VM.
|
||||
- `tools`: first, the shared tools resolve to upstream's newest versions, with devvm's pinned mise (downloaded once), each download with its checksum. This section is the only one that uses the newest versions, and no other step checks for them (`DEVVM_NO_TOOL_CHECK`). At the section's end, e2e puts the pinned lock back. Then a node project's VM: node, npm, pnpm, bun and yarn at the locked versions, each a read-only EROFS image, the share read-only even for root, `npm i -g` into the VM's home, a non-login shell over SSH, an `.nvmrc`'s own version, the tools mounted at boot without devvm, and a second node VM that builds nothing. Last, a .NET project's VM on the allowlist tier, chosen by its solution file: the shared SDK at the locked version from the share, a console project that restores a package from NuGet, builds and runs, `dotnet tool install -g` into `~/.dotnet/tools` with the tool run from a non-login shell, every toolchain's environment and `PATH` folders in a login shell and a non-login one, a workload installed into `~/.dotnet`, nothing of it blocked, and a `global.json`'s own SDK installed into the VM.
|
||||
- `network`: a VM with Claude Code, Codex, opencode and pi and `--network allowlist`, a fake token in devvm's environment and a fake `~/.claude.json` and Codex login in a home of its own, which `devvm agent import` copies into the sandbox's agent store, only yours to read. Its proxy runs and the self-check passed; its password was in no host process's arguments while devvm launched it (`ps`, sampled), and the guest has it; `ssh devvm-net` reaches it; with transparent mode stopped, direct connections fail, even as root, to an address and to other ports, TCP to a public server's port 53 included, and with it running a public DNS server and Lima's DNS addresses answer only with the stand-in address, TTL 0, or nothing; an allowed host works and others, or other ports, are blocked; a line in the VM's policy file that reads as a deny but isn't a rule makes the running proxy refuse an allowed host, with no allow command in `devvm network log --blocked`, `devvm network rm` warns of it, and the host works again once it's gone; with transparent mode stopped, DNS fails at once, `/etc/resolv.conf` names `127.0.0.1` alone, and Lima's DNS addresses answer nothing. Transparent mode runs: its service, the stand-in address on `lo` and dnsmasq and socat on that address alone; names with a dot resolve to it, a name without a dot to nothing, IPv6 has none at once, and `/etc/hosts`' names keep theirs; curl without proxy settings and a static Go client with its own resolver reach github.com with its own certificate, logged `without proxy settings`; a blocked host gets the `403` over the VM's CA; port 5432 of a name is refused at once and `devvm-why` names it, while an IPv6 connection on loopback that works isn't listed as refused; a port a rule names, on a TLS server on this machine, is redirected while the rule is there and refused at once after `devvm network rm`; servers of the VM's own bind `0.0.0.0:443` and `:80`; the service comes back when it's killed or its table flushed; `devvm network transparent off` takes it out at the next launch and `on` puts it back. In a VM of the docker layer, containers without proxy settings reach github.com on the default bridge and on a network of their own, a blocked host is logged, no other port of the stand-in address answers them, a container's published 5432 isn't reached through the stand-in address from the VM or another container while its published 443 keeps the VM's connections off it, and an `--internal` network reaches nothing. The host's loopback services are out of reach, directly or through the proxy. Behind the run's company proxy on this machine's loopback, named in the shell's `HTTPS_PROXY`, the VM's proxy sends an allowed host there by name and refuses a blocked one before it gets there. Then `config.toml`'s `[proxy]` names the same company proxy with its user alone, and the shell sets no proxy: the launch is refused until `devvm secret set proxy --stdin` saves the password, and once it's saved, the VM's proxy config names the secret and holds no password, and the company proxy, which refuses any request without that password, carries GitHub. After each launch the password is in no process's arguments, no log and nowhere in the guest, and after the `config.toml` launch not in the VM's proxy config either, and the launch after, with neither setting, goes directly. The section's leak scan, run once its secrets are used and again at its end, looks for each company proxy's password as it is, as a URL's `user:password`, as Basic's base64 and as the whole `Proxy-Authorization` value, in devvm's logs, the VMs' proxies' logs and Lima's, and before it starts, the section deletes any of its secrets that a killed run left behind. The proxy refuses requests without the VM's password; the token is nowhere in the VM, which has its own CA and the next one, its own placeholder and logins' copies with placeholders only; the proxy puts the token in for its host (for the VM's own placeholder only), an MCP server's header and Codex's key for theirs, over TLS the VM verifies; a second allowlist VM has CAs of its own, each VM trusts only its own and has no key, each proxy serves and presents only its own VM's CAs, and `devvm rm` deletes one VM's CAs and leaves the other's; the home folder's and the store's login files are unchanged. `devvm agent save` saves the VM's changed `~/.claude.json` with the store's MCP header in place of its placeholder, and once the VM changes that server's URL it leaves the file out, so the store keeps the server as it was. `devvm secret set github --stdin` saves a fake token (in the Keychain on macOS, under the run's service, found through a link to `~/Library/Keychains` in the VM's home), read from a file so it's in no process's arguments, and `devvm secret` lists it saved, while asking `devvm secret` for a `get` subcommand is refused without printing it; `secret use github` binds it to the running proxy at once, and on the next launch the VM has its own placeholdLine truncated
|
||||
- `network`: a VM with Claude Code, Codex, opencode and pi and `--network allowlist`, a fake token in devvm's environment and a fake `~/.claude.json` and Codex login in a home of its own, which `devvm agent import` copies into the sandbox's agent store, only yours to read. Its proxy runs and the self-check passed; its password was in no host process's arguments while devvm launched it (`ps`, sampled), and the guest has it; `ssh devvm-net` reaches it; with transparent mode stopped, direct connections fail, even as root, to an address and to other ports, TCP to a public server's port 53 included, and with it running a public DNS server and Lima's DNS addresses answer only with the stand-in address, TTL 0, or nothing; an allowed host works and others, or other ports, are blocked; a line in the VM's policy file that reads as a deny but isn't a rule makes the running proxy refuse an allowed host, with no allow command in `devvm network log --blocked`, `devvm network rm` warns of it, and the host works again once it's gone; with transparent mode stopped, DNS fails at once, `/etc/resolv.conf` names `127.0.0.1` alone, and Lima's DNS addresses answer nothing. Transparent mode runs: its service, the stand-in address on `lo` and dnsmasq and socat on that address alone; names with a dot resolve to it, a name without a dot to nothing, IPv6 has none at once, and `/etc/hosts`' names keep theirs; curl without proxy settings and a static Go client with its own resolver reach github.com with its own certificate, logged `without proxy settings`; a blocked host gets the `403` over the VM's CA; port 5432 of a name is refused at once and `devvm-why` names it, while an IPv6 connection on loopback that works isn't listed as refused; a port a rule names, on a TLS server on this machine, is redirected while the rule is there and refused at once after `devvm network rm`; servers of the VM's own bind `0.0.0.0:443` and `:80`; the service comes back when it's killed or its table flushed; `devvm network transparent off` takes it out at the next launch and `on` puts it back. In a VM of the docker layer, containers without proxy settings reach github.com on the default bridge and on a network of their own, a blocked host is logged, no other port of the stand-in address answers them, a container's published 5432 isn't reached through the stand-in address from the VM or another container while its published 443 keeps the VM's connections off it, and an `--internal` network reaches nothing. The host's loopback services are out of reach, directly or through the proxy. Behind the run's company proxy on this machine's loopback, named in the shell's `HTTPS_PROXY`, the VM's proxy sends an allowed host there by name and refuses a blocked one before it gets there. Then `config.toml`'s `[proxy]` names the same company proxy with its user alone, and the shell sets no proxy: the launch is refused until `devvm secret set proxy --stdin` saves the password, and once it's saved, the VM's proxy config names the secret and holds no password, and the company proxy, which refuses any request without that password, carries GitHub. After each launch, the password is in no process's arguments, in no log and nowhere in the guest, and after the `config.toml` launch it isn't in the VM's proxy config either. The launch after that, with neither setting, goes directly. The section's leak scan, run once its secrets are used and again at its end, looks for each company proxy's password as it is, as a URL's `user:password`, as Basic's base64 and as the whole `Proxy-Authorization` value, in devvm's logs, the VMs' proxies' logs and Lima's. Before the section starts, it deletes any of its secrets that a killed run left behind. The proxy refuses requests without the VM's password; the token is nowhere in the VM, which has its own CA and the next one, its own placeholder and logins' copies with placeholders only; the proxy puts the token in for its host (for the VM's own placeholder only), an MCP server's header and Codex's key for theirs, over TLS the VM verifies; a second allowlist VM has CAs of its own, each VM trusts only its own and has no key, each proxy serves and presents only its own VM's CAs, and `devvm rm` deletes one VM's CAs and leaves the other's; the home folder's and the store's login files are unchanged. `devvm agent save` saves the VM's changed `~/.claude.json` with the store's MCP header in place of its placeholder, and once the VM changes that server's URL it leaves the file out, so the store keeps the server as it was. `devvm secret set github --stdin` saves a fake token (in the Keychain on macOS, under the run's service, found through a link to `~/Library/Keychains` in the VM's home), read from a file so it's in no process's arguments, and `devvm secret` lists it saved, while asking `devvm secret` for a `get` subcommand is refused without printing it; `secret use github` binds it to the running proxy at once, and on the next launch the VM has its own plaLine truncated
|
||||
- `desktop`: a VM of base has none of the desktop's programs, and devvm desktop refuses it, naming the layer. `--layers desktop` makes a VM of the desktop image, and devvm desktop serves its desktop on this machine's `127.0.0.1` alone, keeping its port and its password from one run to the next. A viewer with a wrong password is refused, and one with the password gets the VM's desktop. The VM's server listens on its user's own socket and on no TCP port, with the clipboard off, and the password is in no file of the VM's, in no run log and in no host process's arguments while devvm desktop starts. With network policy, the VM still reaches only its proxy and not the desktop's port on this machine, the desktop's browsers use the VM's local proxy without a password, a blocked host still gets a `403`, and the local proxy isn't forwarded to this machine. When root in the VM runs a server of its own without a password, a viewer with a wrong password is still refused and one with the password gets in, and the refused viewer never reaches the VM, nor does the viewer's clipboard, only its key event. Ctrl+C ends devvm desktop and closes its port, and `devvm desktop --clipboard` starts the server again on the same port with the clipboard on, which a viewer with the password gets.
|
||||
- `nix`: the nix layer. A copy of `assets/layers/nix.sh` as a layer of the run's own, built behind a company proxy of the run's own, reaches Nix's releases through it and leaves no proxy settings for `nix-daemon` (and not the company proxy's password) anywhere on its image's disk. Then a folder with `package.json`, `flake.nix` and `.envrc` gets a VM with node on the nix layer (`--layers nix`) on the allowlist tier: Nix and direnv at their pins, a store that's root's, `sandbox` on with no fallback, `trusted-users` root alone and an untrusted user's `--option substituters` ignored, `nix-daemon` with the VM's own proxy in devvm's drop-in alone, `nix run nixpkgs#hello` from Nix's cache, a build in Nix's sandbox, `sudo nix` and `nix` over ssh, the flake's dev shell (nixpkgs at a pinned revision) loaded by direnv in an interactive shell, its `node` ahead of the shared node prompt after prompt and gone outside the folder, nix-direnv's cache in the VM's home with no `.direnv` in the folder, a fixed-output download from a host that isn't allowed refused with `403` and named by `devvm-why`, and after `devvm network open` and `devvm restart`, no drop-in and no proxy for the daemon.
|
||||
- `from`: run with a `docker` that isn't running, so nothing comes from Docker. Its container images go by their pinned digests, as `node:24@sha256:…`, so devvm looks them up nowhere, except the company proxy's `alpine:3.21`, which keeps its tag so that devvm's registry lookup is checked too. A VM from `node:24` with node, python and Claude Code on the docker and nix layers (Debian 12, in a home of its own) boots, with its base keyed by the pinned digest, its node, python and claude at the locked versions, GNU `tar` as its commands find it, its tool images built in a clone of devvm's own Ubuntu base when the run builds them, the docker layer's Docker from Docker's Debian repository, and the nix layer's Nix under systemd running `nix run nixpkgs#hello` and a build in Nix's sandbox, then, after `devvm network allowlist` and `devvm restart`, transparent mode's checks as the network section has them, and with its service stopped, Lima's DNS and a public server answering nothing; a VM from `alpine:3` with node and dotnet, which its `package.json` and `global.json` call for, on the docker, nix and desktop layers runs node and pnpm from musl tool images, and dotnet's musl SDK with ICU, which makes and runs a console project, built in its own base and keyed and recorded by its digest, the docker layer's Docker on OpenRC, the desktop layer's programs from Alpine's packages, with no crashed services, and the nix layer's Nix as an OpenRC service, with `nix run nixpkgs#hello` and a sandboxed build, then after `devvm network allowlist` and `devvm restart` transparent mode's checks on OpenRC and musl, as for Debian 12, and a download only its daemon makes from a host that isn't allowed refused with the proxy's `403`, and with GNU `tar` as its commands find it, `devvm history import` puts an export into it, while an export with a path outside the agents' history imports nothing there, and on a Linux host, given Lima's `mmap` with no mode chosen, `devvm mount-cache none` gives it `none` at its next start, through the restart that a remount Alpine refuses gets, which devvm's portable check of the folder confirms; base builds from `ubuntu:26.04`; and the build VM and its temporary folders are gone.
|
||||
- `link`: links between VMs, each check the end-to-end proof of a row of the threat check in [the design note](../internals/design.md#links-between-vms). It runs devvm with a soft limit of 256 open files, macOS's default, as the link sessions it starts get that limit too, and it makes two small open targets, each forwarding no port and running servers on its own `127.0.0.1` (`/var/tmp/e2e-link.pl`, in perl, which every base has), and a client that forwards every port. Each of the three reserves the link checks' ports (`ip_local_reserved_ports`), so Linux never gives one to a connection's own end, where a connection that just ended would hold it for a minute and a later server or `ssh -R` couldn't bind it. `sshd -T` in each VM shows remote forwards allowed on `127.77.*:*` alone, at the address the host asks for, and the client's own Lima rules ignore every port. A port the target doesn't publish is refused by `devvm link add`, and once a port is published, `devvm link add` on the running client reaches it within seconds as `NAME:PORT` and `NAME.devvm.internal:PORT`, by curl and by a raw TCP client (bash's `/dev/tcp`), while with `--as NAME` the target's folder name doesn't resolve. Two targets on one port are each reached by their own name, port 80 is linked on port 80, `devvm link` and `devvm link publish` list what they hold with `"version": 1` in their `--json`, and `devvm network allowlist` is refused for the client while it links to open targets. A published port that isn't linked has nothing listening for it, `devvm link unpublish` refuses the link's next connection, logs it and names the client, and `devvm link rm` takes the listener away within seconds. In the client, sshd listens only on its own port and the links' addresses, and nothing from a link listens on `127.0.0.1`, `::1` or every address, so this machine gets no forward of a link, while a server of the client's own on `127.0.0.1` with a link's port is forwarded as usual. Each link's socket is mode 600 in the run folder of mode 700, and the link session and every process it starts listen on no TCP port and connect only to the VMs' ssh ports. `ssh -R` into the client binds nothing outside `127.77.0.0/16` (`rfwd_links`). A program in the client that holds a link's address first fails that link alone with `link_port_taken`, 256 connections at once, past the socket's backlog of 128 on macOS, are all carried, and a 257th is refused and logged as `link_limit`. Root in the client then loosens its sshd and the link session connects again: with `PermitListen any` the client binds only the links' addresses, because the host asks for nothing else, and with `GatewayPorts yes` too, the link session still listens on no TCP port of this machine and connects only to the VMs' sshd. `devvm network log` shows the links' connections and refusals. A stopped target refuses the connection, logs `link_target_stopped` and stays stopped, and the client's launch warns of it. Once it's restarted, the link works again. `devvm rm` of the target removes the client's link, names the client and removes its sockets, and a VM made again in that folder isn't linked. Then the client and one target get the allowlist tier, the target while it runs. Until the target restarts, `devvm ls` shows it `unenforced`, the client's next connection is refused and logged as `unenforced` while the target's server runs, and `devvm link add` and the client's launch warn of it (`link_target_unenforced`). Once both have restarted, the client reaches its link by curl through its proxy settings and by a raw TCP client while a direct connection fails. A link added while the client runs is reached at once by curl through its proxy, by `GET` and `CONNECT`, with no link name in `NO_PROXY` and the client's boot and host keys unchanged, and the client's proxy refuses names, ports and addresses that aren't on its own list, while the target's proxy refuses the client's link name. `devvm link add` refuses an open target, `devvm network open` is refused for the target, and with the rule broken by hand in the target's state the next connection is refused and the client's launch warns and runs without the link until the rule holds again. In the `--from` tier, an Alpine client reaches its link to port 80. `devvm rm` of the client leaves no link session, socket, pid file, log or link state.
|
||||
- `link`: links between VMs, each check the end-to-end proof of a row of the threat check in [the design note](design.md#links-between-vms). It runs devvm with a soft limit of 256 open files, macOS's default, as the link sessions it starts get that limit too, and it makes two small open targets, each forwarding no port and running servers on its own `127.0.0.1` (`/var/tmp/e2e-link.pl`, in perl, which every base has), and a client that forwards every port. Each of the three reserves the link checks' ports (`ip_local_reserved_ports`), so Linux never gives one to a connection's own end, where a connection that just ended would hold it for a minute and a later server or `ssh -R` couldn't bind it. `sshd -T` in each VM shows remote forwards allowed on `127.77.*:*` alone, at the address the host asks for, and the client's own Lima rules ignore every port. A port the target doesn't publish is refused by `devvm link add`, and once a port is published, `devvm link add` on the running client reaches it within seconds as `NAME:PORT` and `NAME.devvm.internal:PORT`, by curl and by a raw TCP client (bash's `/dev/tcp`), while with `--as NAME` the target's folder name doesn't resolve. Two targets on one port are each reached by their own name, port 80 is linked on port 80, `devvm link` and `devvm link publish` list what they hold with `"version": 1` in their `--json`, and `devvm network allowlist` is refused for the client while it links to open targets. A published port that isn't linked has nothing listening for it, `devvm link unpublish` refuses the link's next connection, logs it and names the client, and `devvm link rm` takes the listener away within seconds. In the client, sshd listens only on its own port and the links' addresses, and nothing from a link listens on `127.0.0.1`, `::1` or every address, so this machine gets no forward of a link, while a server of the client's own on `127.0.0.1` with a link's port is forwarded as usual. Each link's socket is mode 600 in the run folder of mode 700, and the link session and every process it starts listen on no TCP port and connect only to the VMs' ssh ports. `ssh -R` into the client binds nothing outside `127.77.0.0/16` (`rfwd_links`). A program in the client that holds a link's address first fails that link alone with `link_port_taken`, 256 connections at once, past the socket's backlog of 128 on macOS, are all carried, and a 257th is refused and logged as `link_limit`. Root in the client then loosens its sshd and the link session connects again: with `PermitListen any` the client binds only the links' addresses, because the host asks for nothing else, and with `GatewayPorts yes` too, the link session still listens on no TCP port of this machine and connects only to the VMs' sshd. `devvm network log` shows the links' connections and refusals. A stopped target refuses the connection, logs `link_target_stopped` and stays stopped, and the client's launch warns of it. Once it's restarted, the link works again. `devvm rm` of the target removes the client's link, names the client and removes its sockets, and a VM made again in that folder isn't linked. Then the client and one target get the allowlist tier, the target while it runs. Until the target restarts, `devvm ls` shows it `unenforced`, the client's next connection is refused and logged as `unenforced` while the target's server runs, and `devvm link add` and the client's launch warn of it (`link_target_unenforced`). Once both have restarted, the client reaches its link by curl through its proxy settings and by a raw TCP client while a direct connection fails. A link added while the client runs is reached at once by curl through its proxy, by `GET` and `CONNECT`, with no link name in `NO_PROXY` and the client's boot and host keys unchanged, and the client's proxy refuses names, ports and addresses that aren't on its own list, while the target's proxy refuses the client's link name. `devvm link add` refuses an open target, `devvm network open` is refused for the target, and with the rule broken by hand in the target's state the next connection is refused and the client's launch warns and runs without the link until the rule holds again. In the `--from` tier, an Alpine client reaches its link to port 80. `devvm rm` of the client leaves no link session, socket, pid file, log or link state.
|
||||
|
||||
Every section but `tools` uses the shared tools' versions pinned in `tests/e2e-mise.lock`, for both architectures' glibc and musl VMs, and the `--from` checks start from container images pinned by digest in `tests/e2e/from_test.go` (`fromNodeDigest`, `fromAlpineDigest` and `fromUbuntuDigest`). The images built from them stay valid until a pin moves. base starts from the dated release of Ubuntu's cloud image that `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go` names, given to devvm as `DEVVM_UBUNTU_RELEASE`, in place of the newest that a user's devvm pins, so base's key stays the same between runs and on every machine of one architecture. devvm keeps a release it has pinned, so when the sandbox's pin names another release, after `scripts/bump.sh e2e-ubuntu` moves `e2eUbuntuRelease`, the run deletes that pin before its first section, and the next build pins `e2eUbuntuRelease`. Its packages are those its key recorded at its first build in the sandbox, which stay in the sandbox's package cache through `--clean`, so base built again under the same key installs the same packages until `assets/` or the release changes its key. `scripts/bump.sh e2e-tools` moves the lock to upstream's newest versions, resolved with devvm's pinned host mise, `scripts/bump.sh e2e-from` moves the digests to what Docker Hub has for each tag, and `scripts/bump.sh e2e-ubuntu` moves the release to the newest Ubuntu lists; `scripts/bump.sh --check` shows them against upstream. The lock's first line is the SHA-256 of the `assets/shared-tools/mise.toml` it was resolved from, and a run stops at once when that file has changed since, until `scripts/bump.sh e2e-tools` resolves the lock again.
|
||||
Every section but `tools` uses the shared tools' versions pinned in `tests/e2e-mise.lock`, for both architectures' glibc and musl VMs, and the `--from` checks start from container images pinned by digest in `tests/e2e/from_test.go` (`fromNodeDigest`, `fromAlpineDigest` and `fromUbuntuDigest`). The images built from them stay valid until a pin moves. base starts from the dated release of Ubuntu's cloud image that `e2eUbuntuRelease` in `tests/e2e/sandbox_test.go` names, given to devvm as `DEVVM_UBUNTU_RELEASE`, in place of the newest that a user's devvm pins, so base's key stays the same between runs and on every machine of one architecture. devvm keeps a release it has pinned, so when the sandbox's pin names another release, as it does after `scripts/bump.sh e2e-ubuntu` moves `e2eUbuntuRelease`, the run deletes that pin before its first section, and the next build pins `e2eUbuntuRelease`. Its packages are those its key recorded at its first build in the sandbox, which stay in the sandbox's package cache through `--clean`, so base built again under the same key installs the same packages until `assets/` or the release changes its key. `scripts/bump.sh e2e-tools` moves the lock to upstream's newest versions, resolved with devvm's pinned host mise, `scripts/bump.sh e2e-from` moves the digests to what Docker Hub has for each tag, and `scripts/bump.sh e2e-ubuntu` moves the release to the newest Ubuntu lists; `scripts/bump.sh --check` shows them against upstream. The lock's first line is the SHA-256 of the `assets/shared-tools/mise.toml` it was resolved from, and a run stops at once when that file has changed since, until `scripts/bump.sh e2e-tools` resolves the lock again.
|
||||
|
||||
base, the `--from` bases and the shared tool images stay cached between runs, except what a rebuild or gc deletes: every stale image in the sandbox (other selections' bases, whose features differ, among them) and every unused tool image (an earlier `from` run's musl ones, and the `tools` section's newest versions where they differ from the pins); every other VM a run makes is deleted at its end, and its project folders are unlocked and deleted. Each check prints `[n/N]`, how long it took and the time left as the last complete run of each of its sections measured it, and a heartbeat every minute shows the latest output. e2e keeps each section's times in a file of its own in slot 0's state folder, `timings/plain/SECTION`, or `timings/features/SECTION` for a run whose base has every feature, because that run also checks base's features. So a run of any selection, in any slot, estimates from and compares with the sections it runs. A check fails on its first failure, except the few marked `Flaky`, which flake on timing, such as the network section's check that the proxy's password was in no host process's arguments, and the link section's 256-connection check and its stopped-target check. When one of these fails, e2e shows its output and runs it once more, and a second failure fails it. Its result says `retried once`, its line in the timings has a third field, `retried`, and the summary counts the retried checks and names each one. A check a run has nothing for is counted as `SKIP`: base's features, with base cached. A section that runs fewer checks than its last complete run with the same `tests/e2e` Go files fails the run, because an error ended it early, and e2e keeps the times it had. After you edit those files, each section's first complete run sets the count the next runs compare with. Checks look for devvm's messages with `devvm _msg`, never by their wording. The Go tests that need a real VM or desktop, `TestE2EExecQuoting`, `TestE2ESelfCheck` and `TestE2EDesktop`, skip unless their `DEVVM_E2E_*` variables are set, and e2e runs each of them through `s.GoE2E`, which sets those variables in the test's environment, so a value such as the desktop's password is in no process's arguments.
|
||||
|
||||
@@ -209,3 +210,24 @@ Before the slots start, e2e takes every slot's lock and gives each other slot wh
|
||||
Each slot's output appears as it comes, each line led by its slot's number, such as `[1]`, and stays in the slot's `e2e.log`. When every slot has ended, e2e prints each slot's sections, results and time, then the sums: checks passed, failed, skipped and retried, the failed checks by name, and the time the whole run took. The run fails when any slot fails or ends without its results. TERM or Ctrl+C stops every slot with TERM, and each one cleans up as a single run does.
|
||||
|
||||
[Testing on other hosts](testing.md#slots-for-each-host) says how many slots each kind of host runs. [Testing on other hosts](testing.md) also covers Linux hosts, x86_64 and the checks to run by hand.
|
||||
|
||||
## The tests behind How it works
|
||||
|
||||
The How it works pages say in words what the tests of a mechanism check, and this section names those tests, so you can find the one to extend when you change the mechanism. Each unit test is named with its package, the CLI tests are files in `testdata/script/`, and the end-to-end checks are in `tests/e2e`, in the section the page names. The design notes name the tests of each emulation themselves ([design notes](design.md)).
|
||||
|
||||
- **[How the proxy puts secrets in](../internals/network.md#how-the-proxy-puts-them-in):**
|
||||
- `TestCheckName`, `TestCheckHost`, `TestCheckHeader`, `TestCheckEnv`, `TestCheckPrefix`, `TestDefine` and `TestChangeApply`, in `internal/secrets`, check what a secret of yours may be and what devvm secret set's flags change.
|
||||
- `TestReservedEnvAssets` and `TestEnvReservedForSecrets`, in `internal/netpolicy`, check the variables a secret can't take.
|
||||
- `TestInjectSecretShapes` and `TestSchemeOK`, in `internal/proxy`, check each shape a value goes in and each that keeps the placeholder, and `TestPathWithin`, `TestForRequestMethods` and `TestInterceptSecretMethods` that a binding's path and methods let it in only for the requests they match.
|
||||
- `TestGetChecksTheBinding` checks that a binding that isn't the secret's as it's saved gets nothing, `TestValueMax` and `TestKeychainLine`, in `internal/platform`, that a value too long for the Keychain's line is refused, and `TestPlaceholders` the placeholders' one shape.
|
||||
- `TestCustomStore`, `TestCustomsUnreadable` and `TestWriteFilesCustom` check the list, its mode and its checks, `TestValuesCachedByBinding`, in `internal/proxy`, that two bindings of one name are cached apart, and `TestCustomSecrets`, in `internal/vm`, use, a new value and the question before a delete.
|
||||
- The CLI tests are `secret_custom.txtar` and `layout.txtar`, and the end-to-end checks are in `tests/e2e`'s `network` section.
|
||||
- **[The VM's CA](../internals/network.md#the-vms-ca):** `TestInitCA`, `TestInitCASwitch`, `TestInitCAReplaced`, `TestInitCATogether` and `TestInitCACancelled`, in `internal/trust`, `TestPrepareOpen`, in `internal/netpolicy`, and `TestNextCASigns`, `TestLoadCA` and `TestServersApart`. The CLI tests are `network.txtar`, `sync.txtar` and `layout.txtar`.
|
||||
- **[Logins made in a VM](../internals/network.md#logins-made-in-a-vm):**
|
||||
- `TestCaptureLogin`, `TestCapturePaths`, `TestCaptureEarlyHintsAnswerAndSaved`, `TestCaptureErrorPasses`, `TestCaptureRefuses` and `TestCaptureGet`, in `internal/proxy`, check what goes out, what the VM gets and what's refused.
|
||||
- `TestCodexCapture`, `TestOpencodeCapture`, `TestClaudeCapture`, `TestClaudeSetupToken`, `TestClaudeOAuthGet`, `TestCaptureRefuses`, `TestEndpoints` and `TestPick`, in `internal/agentlogin`, check each agent's file, its placeholders and copies, and its refresh.
|
||||
- `TestOneClaudeLogin`, `TestClaudeBindings` and `TestClaudeOAuthVMCopy`, in `internal/secrets`, check the one Claude Code login and its bindings, and `TestCapturer` and `TestCaptureOwnAgents`, in `internal/netpolicy`, the endpoints in every VM's config and which agent a capture is.
|
||||
- `TestAgentLoginTerminal`, in `internal/vm`, and `TestTerminal`, in `internal/ui`, check that an agent's login gets the terminal's files only when devvm's input and output are both terminals. The end-to-end checks are in `tests/e2e`'s `network` section.
|
||||
- **[Agents' logins and settings](../internals/network.md#agents-logins-and-settings):** `TestFormatsWithholdUnknown` plants a field that no format knows in every login file, `~/.claude.json` included, and checks that no VM's copy holds it.
|
||||
- **[Learning from the log](../internals/network.md#learning-from-the-log):** `TestTickable` checks that no name devvm network lock ticks is a shared-hosting domain or under one.
|
||||
- **[A company's CA in builds](../internals/images.md#a-companys-ca-in-builds):** `tests/e2e`'s `images` section checks that a layer built with a test CA trusts it while its script runs and keeps its key once the folder is emptied, and that a copy of its image booted without devvm has none of devvm's CA files. Its `project` and `tools` sections check [a company's CA](../internals/network.md#a-companys-ca) in a VM, which `tests/e2e` runs on real VMs.
|
||||
@@ -13,9 +13,9 @@ This page lists devvm's commands in the groups that `devvm --help` shows them in
|
||||
| `devvm` | open a shell in this folder's VM, at the same path, making the VM first with the toolchains, agents and layers you choose, or that `--tools`, `--agents` and `--layers` name ([details](../using/images.md#what-a-new-vm-gets)) |
|
||||
| `devvm restart` | stop this folder's VM, start it again and open a shell in it, for changes that apply only when it starts ([details](../using/vms.md#restarting-and-stopping)) |
|
||||
| `devvm stop` | stop this folder's VM ([details](../using/vms.md#restarting-and-stopping)) |
|
||||
| `devvm update [--force] [--no-export] [--clean-home]` | move this folder's VM to the newest shared tools, and when its image or its `devcontainer.json` has changed, make it again from the image's new build and the file as it is now, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#outdated-vms)) |
|
||||
| `devvm rm [--force] [--no-export] [--no-clone-check]` | delete this folder's VM after asking, exporting its agents' history first unless `--no-export` ([details](../using/vms.md#deleting-a-vm)) |
|
||||
| `devvm rm VM [--force] [--no-export] [--no-clone-check]` | delete a VM whose folder is gone, by its name or ssh alias, after asking ([details](../using/vms.md#a-vm-whose-folder-is-gone)), or one whose folder is on a disk that isn't connected, only after asking in a terminal ([details](../using/vms.md#a-folder-on-a-disk-that-isnt-connected)) |
|
||||
| `devvm update [--force] [--no-export] [--clean-home [--no-worktree-check]]` | move this folder's VM to the newest shared tools, and when its image or its `devcontainer.json` has changed, make it again from the image's new build and the file as it is now, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#outdated-vms)) |
|
||||
| `devvm rm [--force] [--no-export] [--no-clone-check] [--no-worktree-check]` | delete this folder's VM after asking, exporting its agents' history first unless `--no-export` ([details](../using/vms.md#deleting-a-vm)) |
|
||||
| `devvm rm VM [--force] [--no-export] [--no-clone-check] [--no-worktree-check]` | delete a VM whose folder is gone, by its name or ssh alias, after asking ([details](../using/vms.md#a-vm-whose-folder-is-gone)), or one whose folder is on a disk that isn't connected, only after asking in a terminal ([details](../using/vms.md#a-folder-on-a-disk-that-isnt-connected)) |
|
||||
| `devvm adopt` | use the VM made for an earlier folder at this path here ([details](../using/vms.md#a-folder-made-again)), or the VM made for this folder before you moved or renamed it ([details](../using/vms.md#a-moved-or-renamed-folder)) |
|
||||
| `devvm adopt VM` | move a VM whose folder is gone to this folder, such as a copy of that folder on another disk, after asking ([details](../using/vms.md#a-moved-or-renamed-folder)) |
|
||||
| `devvm ls` | list the project VMs ([details](../using/vms.md#listing-vms)) |
|
||||
@@ -84,13 +84,13 @@ These options are for a new VM, so a VM that exists ignores them with a warning,
|
||||
| `devvm ssh-agent add KEY_FILE [--confirm] [--lifetime DURATION]` | load a key into devvm's own agent, and load it again whenever a VM needs it ([details](../using/ssh.md#devvms-own-agent)) |
|
||||
| `devvm ssh-agent rm KEY_FILE` | take a key out of devvm's own agent, so devvm doesn't load it again ([details](../using/ssh.md#devvms-own-agent)) |
|
||||
| `devvm git-protect [on\|off]` | show or change this folder's VM's `.git` protection, while it's stopped ([details](../safety/git-protection.md#turning-it-on-or-off)) |
|
||||
| `devvm clone [on\|off] [--force] [--no-export] [--clean-home] [--no-clone-check] [--repos LIST]` | show whether this folder's VM has its own clone of the repo, or make it again with one, or with the folder mounted, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/clone.md#switching-a-vm-that-exists)) |
|
||||
| `devvm clone [on\|off] [--force] [--no-export] [--clean-home [--no-worktree-check]] [--no-clone-check] [--repos LIST]` | show whether this folder's VM has its own clone of the repo, or make it again with one, or with the folder mounted, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/clone.md#switching-a-vm-that-exists)) |
|
||||
| `devvm secret`, `devvm secret rm NAME` | list the secrets, whether each is saved and the VMs using it, or delete a saved one ([details](../safety/network.md#saving-and-binding-secrets)) |
|
||||
| `devvm secret set claude\|github [--stdin]` | save your Claude Code token or GitHub token on this machine, so that VMs get a placeholder and their proxy puts the secret in ([details](../safety/network.md#saving-and-binding-secrets)) |
|
||||
| `devvm secret set NAME --host HOST --env VARIABLE` | save a secret of your own, such as an API key, which VMs that use it send only to its hosts ([details](../safety/network.md#your-own-secrets)) |
|
||||
| `devvm secret use\|unuse NAME` | let this folder's VM use a secret, or stop it, though a VM with Claude Code always uses `claude` ([details](../safety/network.md#saving-and-binding-secrets)) |
|
||||
| `devvm layer add LAYER... [--force] [--no-export] [--clean-home]` | make this folder's VM again with more layers on top, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#adding-layers-to-a-vm)) |
|
||||
| `devvm layer rm LAYER... [--force] [--no-export] [--clean-home]` | make this folder's VM again without some of its layers, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#taking-layers-out-of-a-vm)) |
|
||||
| `devvm layer add LAYER... [--force] [--no-export] [--clean-home [--no-worktree-check]]` | make this folder's VM again with more layers on top, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#adding-layers-to-a-vm)) |
|
||||
| `devvm layer rm LAYER... [--force] [--no-export] [--clean-home [--no-worktree-check]]` | make this folder's VM again without some of its layers, keeping its home folder and settings, after asking, then open a shell in it ([details](../using/images.md#taking-layers-out-of-a-vm)) |
|
||||
|
||||
## Links between VMs
|
||||
|
||||
|
||||
@@ -18,4 +18,5 @@ These pages explain how devvm does what the other sections describe, for readers
|
||||
- [Lima](lima.md): devvm's Lima home, confinement, clones and port forwarding on Lima.
|
||||
- [Processes](processes.md): what each of devvm's processes holds, reads, writes and is confined by, the listeners a VM's bytes reach, and why devvm is written in Go.
|
||||
- [Coding agents](agents.md): how the agents' settings, logins and history reach a VM, and what devvm checks when it imports, saves and exports them.
|
||||
- [Design notes](design.md): why devvm is built this way, what failed, and what's still open.
|
||||
|
||||
Why devvm is built this way, what failed and what's still open is in the [design notes](../contributing/design.md), under Contributing.
|
||||
@@ -12,7 +12,7 @@ Each launch installs the guide again whenever it differs from devvm's, and it be
|
||||
|
||||
## Pasting
|
||||
|
||||
How devvm paste reads the clipboard, names a copied file, refuses links and finds Linux's clipboard programs is in the design note on [pasting images](design.md#pasting-images).
|
||||
How devvm paste reads the clipboard, names a copied file, refuses links and finds Linux's clipboard programs is in the design note on [pasting images](../contributing/design.md#pasting-images).
|
||||
|
||||
## Each agent's variables
|
||||
|
||||
@@ -22,15 +22,15 @@ Every VM sets `OPENCODE_DISABLE_AUTOUPDATE=1`, as it sets `DISABLE_AUTOUPDATER=1
|
||||
|
||||
The import copies only the paths in [the store's table](../using/coding-agents.md#devvms-agent-store), from `~/.claude`, `~/.claude.json`, `~/.codex`, `~/.config/opencode`, `~/.local/share/opencode` and `~/.pi/agent`, so it never copies your history, such as `~/.claude/projects`, `~/.codex`'s sessions or `~/.pi/agent/sessions`, and never `~/.claude/.credentials.json`. Of `~/.claude/plugins` it copies only what a seed has, `known_marketplaces.json`, `marketplaces` and `cache`, whether the folder is in `~/.claude` or a link you allowed leads to it, so this machine's own entries, such as each plugin's data in `data`, its MCP bundles in `mcpb`, the plugins that claude.ai synced, its trash and its record of the plugins it installed, never reach the store ([Claude Code's plugins](#claude-codes-plugins)). Claude Code's plugin records name the plugins' folders by their paths, so the store's copies of the JSON files in `~/.claude/plugins` name the plugins' folders in the store, where the VMs mount them.
|
||||
|
||||
A link inside an agent's folder that leads to a file inside it is copied as that file only when the file, by the name the link resolves to, one link at a time, is one of the settings that the import copies of the folder itself. So a link never copies what the import leaves out, such as `~/.claude/projects`, `~/.claude/.credentials.json` or a plugin's data in `~/.claude/plugins/data`, and a name that differs from a setting's only in case, which a Mac's file system would still find, is left out too. The import reads each file it listed, a link's by the path the link resolved to, through the agent'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's folder, such as a skill you work on in `~/.claude/skills`, 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's folder or holds it. A VM whose state devvm can't read gets a warning of its own, naming its state file, because devvm can't tell where its project folder is, and while any state can't be read, devvm leaves out, with a warning naming the state, every path it would read through a link: an agent's folder or login whose path passes through one, and every link out of an agent's folder. That counts the links on the way to your home folder too, because a VM made with `--unsafe-folder` on a folder that holds your home folder holds them, but not a link that only root can change, such as macOS's `/var` or the `/home` of Fedora Silverblue, whose folders up to `/` are root's alone, by their modes and by what the system says you may write, an ACL included: a VM changes this machine's files only as you, so no VM can change where such a link leads. devvm opens an agent'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't swap the folder between the two. A project folder that holds an agent's folder, such as `~/.pi` for pi's `~/.pi/agent`, lets its VM put a link in the agent folder's place, so devvm resolves the folder's path one link at a time and leaves the folder out, with a warning, when a link in a VM's project folder leads it out of that folder, which would let the VM choose any folder of this machine's, such as your home folder. A login file in a folder left out so, such as pi's `auth.json`, is left out with it. Otherwise devvm reads the folder where the path led when it resolved it, and an agent's login file, but Claude Code's `~/.claude.json`, where its path led when devvm resolved it, one link at a time, and left out in the same way, through its folder opened one folder at a time without following a link, never resolved again, the file itself opened without following one, 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's folder, the bounds of [saving a VM's settings](#saving-a-vms-settings), so such a VM can'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, as it opens each folder from the agent's folder down, one name at a time, through the folder opened one folder at a time, so a chain of folders nested deeper fails the import in the same way, and a link or a FIFO swapped in for a folder as it walks fails it rather than leading elsewhere or holding it. A file that grows past 16 MiB, or past what'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'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.
|
||||
A link inside an agent'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 `~/.claude/projects`, `~/.claude/.credentials.json` or a plugin's data in `~/.claude/plugins/data`, and the import also leaves out a name that differs from a setting's only in case, which a Mac's file system would still find. The import reads each file it listed, and a link's file by the path that the link resolved to. It reads through the agent'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's folder, such as a skill you work on in `~/.claude/skills`, 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's folder or holds it. A VM whose state devvm can't read gets a warning of its own, naming its state file, because devvm can't tell where its project folder is, and while any state can't be read, devvm leaves out, with a warning naming the state, every path it would read through a link: an agent's folder or login whose path passes through one, and every link out of an agent's folder. That also counts the links on the way to your home folder, because a VM made with `--unsafe-folder` on a folder that holds your home folder holds them. It doesn't count a link that only root can change, such as macOS's `/var` or the `/home` of Fedora Silverblue, whose folders up to `/` are root's alone, by their modes and by what the system says you may write, an ACL included. A VM changes this machine's files only as you, so no VM can change where such a link leads. devvm opens an agent'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't swap the folder between the two. A project folder that holds an agent's folder, such as `~/.pi` for pi's `~/.pi/agent`, lets its VM put a link in the agent folder's place, so devvm resolves the folder's path one link at a time and leaves the folder out, with a warning, when a link in a VM's project folder leads it out of that folder, which would let the VM choose any folder of this machine's, such as your home folder. A login file in a folder left out so, such as pi's `auth.json`, is left out with it. Otherwise devvm reads the folder where the path led when it resolved it. It reads an agent's login file, other than Claude Code's `~/.claude.json`, 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's folder, the bounds of [saving a VM's settings](#saving-a-vms-settings), so such a VM can'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'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'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'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.
|
||||
|
||||
The import reads and writes every agent's settings into a staging folder of the agent's store first, `.devvm-import-` and a random name, beside the agent's folder there, so no VM mounts it. A file that fails to read, changed since it was listed or passes the bounds, fails the import with the store as it was, the staging folder taken out, and so does an interrupt before every agent's settings are staged, its staging folders taken out by the run's cleanups. Once every agent'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't be saved, puts back every agent'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's cleanups take the staging folder out. It puts back every agent's store that it changed, even after putting one back fails, and only then, when one did fail, says so, naming each store it couldn't put back and its staging folder, which it keeps, as it holds what devvm couldn't put back, until the next import or save. A run that'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's lock, `agents.lock` in devvm's data folder, from its staging to its logins, as [the save](#saving-a-vms-settings) does while it writes, and a start does while it cleans [Claude Code's plugins](#claude-codes-plugins), once it finds something to take out, so no two of them change the store at once: 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's, so the import doesn'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's folders, so a running VM's mounts still show them. The import and [the save](#saving-a-vms-settings) read names as the volume that holds the store reads them, so on a volume that ignores case, as a Mac's does by default, a file named `foo.md` replaces the store's `Foo.md` in place, under the store'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's `Foo.md` stays. Their staging folder is on the same volume and holds only what they wrote, so a name that's already there before they write it, under no name they wrote, is one the volume reads as another of theirs, such as `a.md` after `A.md`. They then fail before the store changes and name both, and the save counts a name it leaves out too. The staging folder reads names by its own folder's rules, which are the store's wherever a volume's rules hold for every folder, as on macOS, but Linux'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's written or kept under, and the save'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 [the save](#saving-a-vms-settings) check every folder and file they'll write by its path: each part of the path below devvm's config folder must be a folder, never a link, so a link there, which only a hand-made store has and which could lead to your home folder, fails the command, naming it, before the store changes, for any of the agents the command handles. A link in the store in place of a settings file is replaced, never followed. They then write only through the agent's store, or its folder there, opened from devvm's config folder as a root, every part of its path a folder, so a link put in the store after the check can't lead a write out of it. They also reach a folder of the store that they empty from devvm's config folder in the same way, as the start does for [Claude Code's plugins](#claude-codes-plugins), and devvm's config folder itself may be a link, as a dotfiles repo's is.
|
||||
The import reads and writes every agent's settings into a staging folder of the agent's store first, `.devvm-import-` and a random name, beside the agent'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's settings are staged does the same, and the run's cleanups take out its staging folders. Once every agent'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't be saved, puts back every agent'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's cleanups take the staging folder out. It puts back every agent'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't put back and its staging folder. It keeps that staging folder, which holds what devvm couldn't put back, until the next import or save. A run that'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's lock, `agents.lock` in devvm's data folder, from its staging to its logins, as [the save](#saving-a-vms-settings) does while it writes, and a start does while it cleans [Claude Code's plugins](#claude-codes-plugins) or [opencode's service settings](#opencodes-service), 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's, so the import doesn'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's folders, so a running VM's mounts still show them. The import and [the save](#saving-a-vms-settings) read names as the volume that holds the store reads them, so on a volume that ignores case, as a Mac's does by default, a file named `foo.md` replaces the store's `Foo.md` in place, under the store'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's `Foo.md` stays. Their staging folder is on the same volume and holds only what they wrote, so a name that's already there before they write it, under no name they wrote, is one the volume reads as another of theirs, such as `a.md` after `A.md`, 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's rules, which are the store's wherever a volume's rules hold for every folder, as on macOS, but Linux'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's written or kept under, and the save'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 [the save](#saving-a-vms-settings) check the path of every folder and file they'll write, and each part of the path below devvm'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's store, or its folder there, opened from devvm's config folder as a root, every part of its path a folder, so a link put in the store after the check can't lead a write out of it. They also reach a folder of the store that they empty from devvm's config folder in the same way, as the start does for [Claude Code's plugins](#claude-codes-plugins), and devvm's config folder itself may be a link, as a dotfiles repo's is.
|
||||
|
||||
opencode 2 keeps its logins in its own database rather than in `~/.local/share/opencode/auth.json`, so when this machine's opencode is version 2 or later, devvm reads its logins with `opencode auth export` and saves them in the store in the format of `auth.json`, the file that devvm copies for opencode 1. When `opencode auth export` fails, the import fails too, and the store keeps the login it had.
|
||||
|
||||
### Links out of an agent's folder
|
||||
|
||||
The import reads each agent's folder through that folder as an `os.Root`, so no link inside it leads out of it. A link that leads out is resolved, every link on the way, and only then followed, as [links out of an agent's folder](../using/coding-agents.md#links-out-of-an-agents-folder) says, and [the design note](design.md#links-out-of-an-agents-folder) explains why:
|
||||
The import reads each agent's folder through a handle that's rooted at that folder, so no link inside it leads out of it ([the packages](../contributing/structure.md#the-packages)). A link that leads out is resolved, every link on the way, and only then followed, as [links out of an agent's folder](../using/coding-agents.md#links-out-of-an-agents-folder) says, and [the design note](../contributing/design.md#links-out-of-an-agents-folder) explains why:
|
||||
|
||||
- **How it resolves.** 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' folders by name and by identity, so another spelling of a folder, such as `~/.SSH` on a Mac, where case doesn't count, is still that folder.
|
||||
- **Where it reads.** devvm opens the folder it reads the link's target through, a `follow-links` folder, the linked folder or the linked file's own folder, one folder at a time from `/`, 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.
|
||||
@@ -40,9 +40,9 @@ The import reads each agent's folder through that folder as an `os.Root`, so no
|
||||
|
||||
## Saving a VM's settings
|
||||
|
||||
The save reads only the settings in [the store's table](../using/coding-agents.md#devvms-agent-store) from the VM's home, and never the logins, so it never reads your history, `~/.claude/.credentials.json`, `~/.codex/auth.json`, opencode's `auth.json` or pi's. From the VM's `~/.claude.json` 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'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't change it, and the save leaves it as it is, but Claude Code's plugins folder, which is the VM's own, with the store's as its seed ([Claude Code's plugins](#claude-codes-plugins)). A folder that the store doesn't have yet is the VM's own until you save it, and once the VM next starts with the store's new folder mounted, its setup links that folder in place of its own ([mounts](../using/coding-agents.md#mounts)).
|
||||
The save reads only the settings in [the store's table](../using/coding-agents.md#devvms-agent-store) from the VM's home, and never the logins, so it never reads your history, `~/.claude/.credentials.json`, `~/.codex/auth.json`, opencode's `auth.json` or pi's. From the VM's `~/.claude.json` 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'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't change it, and the save leaves it as it is. The exception is Claude Code's plugins folder, which is the VM's own, with the store's as its seed ([Claude Code's plugins](#claude-codes-plugins)). A folder that the store doesn't have yet is the VM's own until you save it, and once the VM next starts with the store's new folder mounted, its setup links that folder in place of its own ([mounts](../using/coding-agents.md#mounts)).
|
||||
|
||||
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'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' settings or a name with a character that a terminal wouldn'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't parse whole, such as a `settings.json` that isn'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't have stays in the store. A folder that the VM sends, but Claude Code's plugins folder, replaces the store's folder whole, so devvm writes each of its files again and takes out the files that the VM's folder doesn't have, but it keeps the store's folder itself, so a running VM's mounts still show it. It compares each of the VM's names with the store's file that the store's volume reads it as, found by what the file is, so where the volume ignores case, the diff shows the VM's `foo.md` as a change to the store's `Foo.md` rather than a file added and another removed. The save writes holding the store's lock, as [the import](#importing) 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's path, because putting one in the other's place would take out what the store has there, which the diff doesn't show. It then saves all or nothing, as the import does: it writes every agent's files into a staging folder of the agent's store first, with the import's name, `.devvm-import-` 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 `~/.claude.json` last, holding the lock of the folder of Claude Code's logins, which a VM'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't be saved, puts back every agent'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't put back and its staging folder, which it keeps until the next import or save. A run that'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's lock or the login's ends the wait, and the save leaves the store as it was.
|
||||
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'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' settings or a name with a character that a terminal wouldn'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't parse whole, such as a `settings.json` that isn'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't have stays in the store. A folder that the VM sends, other than Claude Code's plugins folder, replaces the store's folder whole, so devvm writes each of its files again and takes out the files that the VM's folder doesn't have, but it keeps the store's folder itself, so a running VM's mounts still show it. It compares each of the VM's names with the store's file that the store's volume reads it as, found by what the file is, so where the volume ignores case, the diff shows the VM's `foo.md` as a change to the store's `Foo.md` rather than a file added and another removed. The save writes holding the store's lock, as [the import](#importing) 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's path, because putting one in the other's place would take out what the store has there, which the diff doesn't show. It then saves all or nothing, as the import does, so it first writes every agent's files into a staging folder of the agent's store first, with the import's name, `.devvm-import-` 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 `~/.claude.json` last, holding the lock of the folder of Claude Code's logins, which a VM'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't be saved, puts back every agent'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't put back and its staging folder, which it keeps until the next import or save. A run that'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's lock or the login's ends the wait, and the save leaves the store as it was.
|
||||
|
||||
The VM's [copies](../using/coding-agents.md#copies) of the settings files and of `~/.claude.json` hold placeholders, such as `devvm-redacted`, where the store has your secrets. devvm puts the store's secret back in place of each placeholder, as long as the VM'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't send a secret it never saw to another host, and you can make that change in the store's file yourself. devvm also leaves out any other file that holds a placeholder, such as a skill. No VM gets opencode's files in `~/.config/opencode` that are neither settings nor Markdown, such as a `.env`, so devvm leaves out the VM's own file of that name and keeps the store's.
|
||||
|
||||
@@ -54,27 +54,33 @@ The VM reads every file in these folders, a Claude Code marketplace's git clone
|
||||
|
||||
## Claude Code's plugins
|
||||
|
||||
Claude Code keeps everything of its plugins in one folder, `~/.claude/plugins` unless `CLAUDE_CODE_PLUGIN_CACHE_DIR` names another, and writes there as it runs: each plugin's data in `data/<plugin>`, which a plugin reaches as `${CLAUDE_PLUGIN_DATA}`, the plugins it installs in `cache`, its marketplaces' copies in `marketplaces` and their updates, its MCP bundles in `mcpb`, the plugins claude.ai synced in `synced`, its trash in `.trash`, and its records, such as `installed_plugins.json`. The store'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 ([the design note](design.md#claude-codes-plugins-a-seed-and-a-folder-of-the-vms-own)). So each VM's `~/.claude/plugins` is its own folder, on its own disk, and the store's folder is the VM's seed, Claude Code's own support for a plugins folder it only reads. Every shell in the VM sets `CLAUDE_CODE_PLUGIN_CACHE_DIR` to `~/.claude/plugins` and `CLAUDE_CODE_PLUGIN_SEED_DIR` to `~/.claude/plugins-seed`, where the VM links the store's folder. A seed is laid out as a plugins folder, with the marketplaces' records in `known_marketplaces.json`, their copies in `marketplaces` and the plugins in `cache`. As Claude Code starts, it registers the seed's marketplaces in the VM's own folder, turns off their updates, and loads each plugin that `enabledPlugins` turns on from the seed's `cache`, 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 `marketplaces`, so a marketplace from a folder on this machine, which Claude Code reads in place and never copies, isn't one, and Claude Code in the VM adds it from `extraKnownMarketplaces` in `settings.json` only when that folder is in the VM too. In `claude -p`, Claude Code registers the seed's marketplaces during the first session that the VM's folder doesn't have them yet, so a plugin's hooks for the start of a session run from the next session on.
|
||||
Claude Code keeps everything of its plugins in one folder, `~/.claude/plugins` unless `CLAUDE_CODE_PLUGIN_CACHE_DIR` names another, and writes there as it runs: each plugin's data in `data/<plugin>`, which a plugin reaches as `${CLAUDE_PLUGIN_DATA}`, the plugins it installs in `cache`, its marketplaces' copies in `marketplaces` and their updates, its MCP bundles in `mcpb`, the plugins claude.ai synced in `synced`, its trash in `.trash`, and its records, such as `installed_plugins.json`. The store'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 ([the design note](../contributing/design.md#claude-codes-plugins-a-seed-and-a-folder-of-the-vms-own)). So each VM's `~/.claude/plugins` is its own folder, on its own disk, and the store's folder is the VM's seed, Claude Code's own support for a plugins folder it only reads. Every shell in the VM sets `CLAUDE_CODE_PLUGIN_CACHE_DIR` to `~/.claude/plugins` and `CLAUDE_CODE_PLUGIN_SEED_DIR` to `~/.claude/plugins-seed`, where the VM links the store's folder. A seed is laid out as a plugins folder, with the marketplaces' records in `known_marketplaces.json`, their copies in `marketplaces` and the plugins in `cache`. As Claude Code starts, it registers the seed's marketplaces in the VM's own folder, turns off their updates, and loads each plugin that `enabledPlugins` turns on from the seed's `cache`, 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 `marketplaces`, so a marketplace from a folder on this machine, which Claude Code reads in place and never copies, isn't one, and Claude Code in the VM adds it from `extraKnownMarketplaces` in `settings.json` only when that folder is in the VM too. In `claude -p`, Claude Code registers the seed's marketplaces during the first session that the VM's folder doesn't have them yet, so a plugin's hooks for the start of a session run from the next session on.
|
||||
|
||||
At every launch, the VM's setup makes `~/.claude/plugins` a folder of the VM's own when it isn't one, replacing a link there, and it links `~/.claude/plugins-seed` to the store's folder. A VM made again with other layers keeps its own plugins folder, as it keeps the rest of its home.
|
||||
|
||||
devvm 0.1.0's `devvm agent import` copied the whole of `~/.claude/plugins` into the store, each plugin's data included, and every VM with Claude Code mounts the store's folder whole, so every start, before the VM runs, takes out of the store's plugins folder each entry that a seed doesn't have and warns once, naming them. It leaves the folder itself, so no VM's mounts change and its Lima config needs no edit. A VM that'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's mount would follow, perhaps to your own `~/.claude/plugins`. It takes a link among the entries out without following it, and it leaves the temporary files that a `devvm agent import` or `devvm agent save` running at the same time writes `known_marketplaces.json` through. When it can'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.
|
||||
A store that devvm 0.1.0's `devvm agent import` wrote can hold the whole of `~/.claude/plugins`, each plugin's data included, and every VM with Claude Code mounts the store's folder whole. So every start, before the VM runs, takes out of the store's plugins folder each entry that a seed doesn't have and warns once, naming them. It leaves the folder itself, so no VM's mounts change and its Lima config needs no edit. A VM that'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's mount would follow, perhaps to your own `~/.claude/plugins`. It takes a link among the entries out without following it, and it leaves the temporary files that a `devvm agent import` or `devvm agent save` running at the same time writes `known_marketplaces.json` through. When it can'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.
|
||||
|
||||
`devvm agent import` and `devvm agent save` copy only what a seed has, so neither copies what each machine keeps of its own. The save's script in the VM excludes, by name, every other entry of the VM's `~/.claude/plugins` when it'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' settings. The VM's folder holds only what the VM added to its seed, so the save adds the files that the VM's folder has and changes those that differ, but it never takes a file out of the store's folder. The VM's `known_marketplaces.json` joins the store's: a path in the VM's records to its own plugins folder is renamed to the store's folder, where every VM mounts it, and then each marketplace whose copy is in the store's `marketplaces`, by a path without `.` or `..` parts, replaces the store's of the same name. The others stay as the store has them, because a seed can't use them: those that Claude Code registered from the seed, whose copies are at the seed's link, which are the store'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't a JSON object. The save's script sends an entry whose name has a wildcard's character, such as `*`, rather than exclude it by a pattern that could match other names, so devvm then saves nothing, naming it.
|
||||
`devvm agent import` and `devvm agent save` copy only what a seed has, so neither copies what each machine keeps of its own. The save's script in the VM excludes, by name, every other entry of the VM's `~/.claude/plugins` when it'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' settings. The VM's folder holds only what the VM added to its seed, so the save adds the files that the VM's folder has and changes those that differ, but it never takes a file out of the store's folder. The save merges the VM's `known_marketplaces.json` into the store's. It renames each path in the VM's records that leads to the VM's own plugins folder to the store's folder, where every VM mounts it, and then each marketplace whose copy is in the store's `marketplaces`, by a path without `.` or `..` parts, replaces the store's of the same name. The others stay as the store has them, because a seed can't use them. They are the ones that Claude Code registered from the seed, whose copies are at the seed's link, which are the store'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't a JSON object. The save's script sends an entry whose name has a wildcard's character, such as `*`, rather than exclude it by a pattern that could match other names, so devvm then saves nothing, naming it.
|
||||
|
||||
An export of a VM's history leaves out the VM's `~/.claude/plugins`, and an import of one leaves out both it and `~/.claude/plugins-seed`. The VM's plugins folder holds settings, not history: the plugins it installed reach another VM only through `devvm agent save`, after you read its diff, and each plugin's data can hold the plugin's own logins and large caches, which an export on this machine would keep. A new VM gets the store's plugins from its seed again.
|
||||
An export of a VM's history leaves out the VM's `~/.claude/plugins`, and an import of one leaves out both it and `~/.claude/plugins-seed`. The VM's plugins folder holds settings, not history. The plugins it installed reach another VM only through `devvm agent save`, after you read its diff, and each plugin's data can hold the plugin's own logins and large caches, which an export on this machine would keep. A new VM gets the store's plugins from its seed again.
|
||||
|
||||
## Copies
|
||||
|
||||
devvm merges the settings and MCP servers from the store's `.claude.json` into the VM's own `~/.claude.json`, so servers added in the VM stay ([MCP servers](network.md#mcp-servers)). 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' settings files with `devvm-redacted`, 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's command, devvm replaces the secrets in its URLs, the keys that start like a known key, such as `sk-` or `ghp_`, and the credential after `Bearer` or `Basic`, and keeps the words around them ([keys in settings files](network.md#keys-in-settings-files)). pi's settings files that can hold a key are `settings.json`, `models.json` and `mcp.json`, so a provider's `apiKey` in `models.json` reaches the VM as `devvm-redacted`, and pi's `keybindings.json` and Markdown files reach it as they are. From the `env` of Claude Code's `settings.json`, the VM gets only Claude Code's own settings, such as `ANTHROPIC_MODEL`, the `CLAUDE_CODE_*`, `DISABLE_*` and `MAX_*` variables and those ending in `_TIMEOUT_MS`, but none whose name marks it as a credential, such as `ANTHROPIC_AUTH_TOKEN`. It also gets the values that only name where a secret is, base URLs without their passwords, `true`, `false` and short numbers. Every other env value, and every env value of an MCP server, becomes `devvm-redacted`. When devvm can't parse a settings file to take its secrets out, the VM doesn't get a copy of it, and neither does it get opencode's files in `~/.config/opencode` that are neither settings nor Markdown, such as a `.env`. devvm names each file it doesn't copy, and when it can't make the copy of a login, it says why.
|
||||
|
||||
## opencode's service
|
||||
|
||||
opencode keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-<channel>.json` for a channel other than latest, dev, beta or next (an earlier build named it `service-<hash>.json`), and it writes each one through a temporary file beside it, `<file>.<pid>.tmp`. They hold the service'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 `opencode service get` with no key hides both, and only `opencode service get password` shows the password. They also hold the service's port, host name, CORS origins and environment. That makes them each machine's own rather than settings, so the import and the save leave out every entry of `~/.config/opencode` with one of these names, what's in a folder of that name included, and the save's script in the VM never sends them, so the VM's own file never makes a save fail. The VM's file stays in the VM, so a VM made again keeps it, and no export of the VM's history holds it, because `~/.config/opencode` isn't history.
|
||||
|
||||
A store that an earlier import filled can hold them, so every start looks for them in the store's `~/.config/opencode`, which it opens as it opens [Claude Code's plugins](#claude-codes-plugins) folder, and once it finds any, it takes them out holding the store's lock and warns once, naming them. No VM gets them from the store meanwhile, because a VM'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 `devvm-redacted` 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's setup takes out each such regular file in the VM's `~/.config/opencode` and leaves the VM's own files, links and folders, so the VM's opencode makes its own password when its service next starts. A service that's running keeps the password it started with until it stops, as when the VM restarts.
|
||||
|
||||
## Claude Code's login
|
||||
|
||||
`devvm agent login claude` runs Claude Code's own login in the VM, and the VM's proxy saves the login as it reaches Claude'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.
|
||||
|
||||
A VM gets either `~/.claude/.credentials.json` or `CLAUDE_CODE_OAUTH_TOKEN` 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.
|
||||
|
||||
The VM's setup merges devvm's copy of the login into the VM's own `~/.claude/.credentials.json`, because Claude Code keeps more than its Claude login in that file, such as its logins to MCP servers under `mcpOAuth`, which hold an MCP server's tokens and, while a login is under way, its PKCE verifier. devvm sends its copy beside the setup as `claude-credentials.json`, and the setup's `merge_claude_credentials` replaces the VM's `claudeAiOauth` with the copy's, or takes it out when the copy has none, and keeps every other key of the VM's file. It reads the file with `jq` and writes the result whole, mode 600, to a temp file in `~/.cache`, which neither an export of the VM's history nor a VM made again carries, and then moves it over the file. When the VM's file is a link, isn't JSON or isn'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'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'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's file stays as it is: Claude Code uses the token in its environment over any login left in the file, and that login's placeholder gets the token at `api.anthropic.com` and nothing at `mcp-proxy.anthropic.com` ([logins made in a VM](network.md#logins-made-in-a-vm)).
|
||||
The VM's setup merges devvm's copy of the login into the VM's own `~/.claude/.credentials.json`, because Claude Code keeps more than its Claude login in that file, such as its logins to MCP servers under `mcpOAuth`, which hold an MCP server's tokens and, while a login is under way, its PKCE verifier. devvm sends its copy beside the setup as `claude-credentials.json`, and the setup's `merge_claude_credentials` replaces the VM's `claudeAiOauth` with the copy's, or takes it out when the copy has none, and keeps every other key of the VM's file. It reads the file with `jq` and writes the result whole, mode 600, to a temp file in `~/.cache`, which neither an export of the VM's history nor a VM made again carries, and then moves it over the file. When the VM's file is a link, isn't JSON or isn'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'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'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's file stays as it is. Claude Code uses the token in its environment over any login left in the file, and that login's placeholder gets the token at `api.anthropic.com` and nothing at `mcp-proxy.anthropic.com` ([logins made in a VM](network.md#logins-made-in-a-vm)).
|
||||
|
||||
The MCP servers' logins stay in the VM. `devvm agent save` reads only the settings, an export of the VM's history leaves `~/.claude/.credentials.json` out and an import never writes it, and a VM made again doesn't get it, so nothing of the VM's file reaches devvm's store, this machine or another VM. Only the store's copy goes into the file, and it holds the placeholders alone.
|
||||
|
||||
@@ -124,10 +130,37 @@ With some of these keys, code in the VM can make a credential of its own that wo
|
||||
|
||||
## History exports
|
||||
|
||||
The agents' logins aren't in the export, which leaves out `~/.claude/.credentials.json`, `~/.codex/auth.json`, and opencode's `auth.json`, `account.json`, `mcp-auth.json` and `bin`, and holds nothing of `~/.pi/agent` but its sessions, so pi's `auth.json` stays out too. It leaves out the VM's `~/.claude/plugins`, which holds settings and each plugin's data rather than history ([Claude Code's plugins](#claude-codes-plugins)). opencode keeps its sessions and its logins together in one database, `~/.local/share/opencode/opencode.db`, so the export holds a copy of that database without its logins. The VM makes the copy with `sqlite3`, 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's own database keeps them ([how](design.md#opencodes-database-in-history-exports)). The export never holds the database's `-wal`, `-shm` or `-journal` files, which can hold logins that opencode saved last. When the VM has no `sqlite3`, such as a VM made from an image built without it, the export leaves the database out, so opencode's sessions aren't in it, and the run log says so. devvm starts a stopped VM for the export as a launch does, so it locks the folder's `.git` again and checks the VM'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's disk is full. When the VM sends more, devvm stops the export and keeps nothing of it, so `devvm history export` fails, while `devvm rm` 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, `devvm rm` keeps the VM, and `devvm rm --no-export` deletes it without exporting. `devvm rm VM`, for a VM whose folder is gone, exports in the same way, but only from a running VM or a `--clone` VM, because starting any other would make its folder again ([a VM whose folder is gone](../using/vms.md#a-vm-whose-folder-is-gone)).
|
||||
The agents' logins aren't in the export, which leaves out `~/.claude/.credentials.json`, `~/.codex/auth.json`, and opencode's `auth.json`, `account.json`, `mcp-auth.json` and `bin`, and holds nothing of `~/.pi/agent` but its sessions, so pi's `auth.json` stays out too. It leaves out the VM's `~/.claude/plugins`, which holds settings and each plugin's data rather than history ([Claude Code's plugins](#claude-codes-plugins)). It also leaves out what of `~/.local/state/opencode` is the VM's own as a machine:
|
||||
|
||||
- its `machine` folder, whose `home-key` is the private key that every machine opencode pairs with `opencode machine add` trusts
|
||||
- its `service.json`, or `service-<channel>.json` for another channel's opencode, which holds the password of opencode's background service, and the handoff tickets and temporary files that opencode writes beside it
|
||||
- its `pty` folder, which holds the sockets of its terminals' daemons and their access tokens
|
||||
- its `plugin-approvals.json`, with its lock and the temporary files it's written through, which holds the project plugins you approved in opencode's native client, which doesn't ship in opencode 2.4.1
|
||||
- its `plugin-staged` folder, the approved plugins' copies, which that client runs without checking their hash again, so an export would otherwise approve a plugin for another VM
|
||||
|
||||
The copy of opencode's database leaves out its `machine` 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's opencode makes its own, and a VM made again keeps the VM's own, because it's the same machine ([what a VM made again keeps](../using/images.md#what-a-vm-made-again-keeps)).
|
||||
|
||||
opencode keeps its sessions and its logins together in one database, `~/.local/share/opencode/opencode.db`, so the export holds a copy of that database without its logins. The VM makes the copy with `sqlite3`, 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's own database keeps them ([how](../contributing/design.md#opencodes-database-in-history-exports)). The copy also leaves out what opencode 2.4 would act on without asking in the VM that imports it:
|
||||
|
||||
- its `automation` table, because opencode runs each automation's shell command on its schedule or event without asking again
|
||||
- its `permission` table, the requests you said always to allow
|
||||
- its `job` table, the subagents' jobs, and its `session_inbox` table, the messages queued for a session's next turn, because opencode's service starts those jobs and turns when it starts
|
||||
- each session's allow rules, as the session keeps only the deny and ask rules of its permission rules
|
||||
- each suspended session's mark, so no session resumes its turn on its own
|
||||
- each project's commands, whose start command opencode runs for each worktree it makes
|
||||
|
||||
The export also leaves out opencode's git repositories in `~/.local/share/opencode`, which are `snapshot`, `repos` and `worktree`, because a repository's config can name a command that git runs, and opencode's own git commands would run it in the VM that imports it. So the export doesn't hold opencode's worktrees, and the work in them stays in the VM, which a VM made again keeps and `devvm rm` deletes, after it checks them ([opencode's worktrees](#opencodes-worktrees)). Their commits are in the project'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's `-wal`, `-shm` or `-journal` files, which can hold logins that opencode saved last. When the VM has no `sqlite3`, such as a VM made from an image built without it, the export leaves the database out, so opencode's sessions aren't in it, and the run log says so. It does the same when the VM's `sqlite3` can't read JSON, which the sessions' rules are. devvm starts a stopped VM for the export as a launch does, so it locks the folder's `.git` again and checks the VM'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's disk is full. When the VM sends more, devvm stops the export and keeps nothing of it, so `devvm history export` fails, while `devvm rm` 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, `devvm rm` keeps the VM, and `devvm rm --no-export` deletes it without exporting. `devvm rm VM`, for a VM whose folder is gone, exports in the same way, but only from a running VM or a `--clone` VM, because starting any other would make its folder again ([a VM whose folder is gone](../using/vms.md#a-vm-whose-folder-is-gone)).
|
||||
|
||||
## opencode's worktrees
|
||||
|
||||
opencode 2.4 makes each worktree with `git worktree add`, in `~/.local/share/opencode/worktree/<project>/<name>`, where `<project>` is the first six characters of the project's ID in opencode. Because an export leaves that folder out, `devvm rm`, and a command that makes the VM again with `--clean-home`, read the worktrees there before the VM's disk goes. devvm runs one command in the running VM, in its home folder, which finds each folder at that depth with a `.git` in it, those whose names start with a dot too, and prints, for each one, its path, its `git status --porcelain`, 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 `git status` 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't keep `devvm rm` waiting.
|
||||
|
||||
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'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't come in time keeps the VM, because the VM may hold work devvm can't see, and devvm names `--no-worktree-check`. 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 `--clone` VM, the same question covers the clone check's findings, so devvm asks once.
|
||||
|
||||
devvm checks only that folder. A worktree that opencode's `worktree.directory` setting puts elsewhere in the VM's home folder isn'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 `--clone` VM, whose check covers the worktrees inside its folder ([deleting the VM](../using/clone.md#deleting-the-vm)).
|
||||
|
||||
## Importing history
|
||||
|
||||
The import works on every VM, whether its base is Ubuntu's image or a Debian-, Ubuntu- or Alpine-based container image ([starting from a container image](../using/from.md)), because it unpacks the export with GNU `tar`, which Debian and Ubuntu always have and which devvm installs in every base made `--from alpine`.
|
||||
|
||||
An export holds what a VM wrote, so devvm treats it as untrusted. Its transcripts can hold what the old VM'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's tier only from the `.folder` file beside it in `~/.local/share/devvm/exports`, 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's own `tar` unpacks it there as the VM'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 <!-- the agents' history, generated from internal/agents by mise run cli-docs -->`~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`<!-- end of the agents' history -->, starts with `/` or has a `.`, `..` or empty part, such as `.claude/./plugins` or `.claude//plugins`, devvm imports nothing and says so, because `tar` 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 `._`, which macOS's `tar` 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's umask applies and no file is set-user-ID. It also takes out every symbolic link that points outside the folder it's in, which is any link to an absolute path or one with a `..` part, so an agent writing to a session file can't follow a link out of its history. An export that devvm didn't write, such as a `.tar.gz` you made yourself, can hold opencode's database with its logins, so the import takes out the database's `-wal`, `-shm` and `-journal` files and puts in a copy of the database without its logins, as the export makes it, or leaves the database out when the VM has no `sqlite3`. 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's sessions from the export aren't imported.
|
||||
An export holds what a VM wrote, so devvm treats it as untrusted. Its transcripts can hold what the old VM'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's tier only from the `.folder` file beside it in `~/.local/share/devvm/exports`, 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's own `tar` unpacks it there as the VM'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 <!-- the agents' history, generated from internal/agents by mise run cli-docs -->`~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`<!-- end of the agents' history -->, starts with `/` or has a `.`, `..` or empty part, such as `.claude/./plugins` or `.claude//plugins`, devvm imports nothing and says so, because `tar` 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 `._`, which macOS's `tar` 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's umask applies and no file is set-user-ID. It also takes out every symbolic link that points outside the folder it's in, which is any link to an absolute path or one with a `..` part, so an agent writing to a session file can't follow a link out of its history. An export that devvm didn't write, such as a `.tar.gz` you made yourself, can hold opencode's database with its logins, so the import takes out the database's `-wal`, `-shm` and `-journal` 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 ([history exports](#history-exports)), or leaves the database out when the VM has no `sqlite3`. It never writes opencode'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's sessions from the export aren't imported.
|
||||
@@ -27,7 +27,7 @@ Each thing devvm needs from a backend is a feature, such as building images, mou
|
||||
|
||||
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: `read-only-paths` and `mount-cache` on `project-mount`, `ports-all` on `ports`, `agent-toggle` on `agent-forwarding`, and `link` on `ssh`. A backend has such a feature no better than the one it's built on, so the feature is emulated wherever its base is emulated, and none wherever its base is none.
|
||||
|
||||
devvm uses an emulation only once its review has passed, and until then it refuses the emulation. A review takes a [design note](design.md#emulated-features), a threat check with the security-audit skill, and end-to-end checks that prove the guarantee.
|
||||
devvm uses an emulation only once its review has passed, and until then it refuses the emulation. A review takes a [design note](../contributing/design.md#emulated-features), a threat check with the security-audit skill, and end-to-end checks that prove the guarantee.
|
||||
|
||||
`devvm doctor` lists Lima's features, and `devvm doctor --json` those of every backend devvm has. Both show an emulation whose review hasn't passed as `unreviewed`.
|
||||
|
||||
@@ -40,8 +40,8 @@ devvm uses an emulation only once its review has passed, and until then it refus
|
||||
| `from` | `base` from a container image (`--from`) | native: devvm converts the image to a disk |
|
||||
| `clone` | a project VM from an image | native: an APFS copy-on-write copy on macOS, and a qcow2 overlay on Linux ([details](lima.md#clones-and-overlays)) |
|
||||
| `project-mount` | the project folder, read-write | native: virtiofs on macOS, and 9p on Linux |
|
||||
| `read-only-paths` | paths in the project folder that the guest can't change while the VM runs, which [.git protection](git-protection.md#on-linux-hosts) asks for on Linux | 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 ([details](design.md#read-only-paths-on-linux)). None on macOS, where `.git` protection locks the host's files itself, and none where devvm's check of the kernel fails |
|
||||
| `mount-cache` | choosing how the guest caches the project folder's mount, which `devvm mount-cache` sets | native on Linux, where it's 9p's cache option, `none` for new VMs ([details](design.md#the-9p-cache-on-linux)). None on macOS, where virtiofs has no such option |
|
||||
| `read-only-paths` | paths in the project folder that the guest can't change while the VM runs, which [.git protection](git-protection.md#on-linux-hosts) asks for on Linux | 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 ([details](../contributing/design.md#read-only-paths-on-linux)). None on macOS, where `.git` protection locks the host's files itself, and none where devvm's check of the kernel fails |
|
||||
| `mount-cache` | choosing how the guest caches the project folder's mount, which `devvm mount-cache` sets | native on Linux, where it's 9p's cache option, `none` for new VMs ([details](../contributing/design.md#the-9p-cache-on-linux)). None on macOS, where virtiofs has no such option |
|
||||
| `agent-folders` | agents' host folders, read-only | native: read-only mounts, enforced by the host |
|
||||
| `tools-share` | the shared tools, read-only | native: a read-only mount, enforced by the host |
|
||||
| `egress-proxy` | network traffic only through devvm's proxy | native: Seatbelt on macOS, and on Linux QEMU's `restrict=on` with a `guestfwd` to the proxy ([details](lima.md#confinement)) |
|
||||
@@ -57,13 +57,13 @@ devvm uses an emulation only once its review has passed, and until then it refus
|
||||
| `nix-layer` | the [nix layer](../using/images.md#nix): Nix's daemon and its store in the VM, with builds in Nix's sandbox | native ([details](images.md#the-nix-layer)) |
|
||||
| `link` | links between VMs: a program in one VM reaches a port another VM publishes, by name | native: a link session of devvm's own over Lima's ssh, with remote forwards to `127.77.0.0/16` alone ([details](ports.md#links-between-vms)) |
|
||||
|
||||
`egress-proxy` is what every [network tier](../safety/network.md#network-tiers) but open needs. The open tier needs no feature of its own: every backend must let a VM on its own network (`NetDirect`) reach a port on the host's loopback and set the guest's proxy settings from the confinement (`Confinement.GuestProxy`, `ProxyURL`), which the conformance suite checks (`checkProxyURL`), because every VM's proxy carries its requests. So a backend without `egress-proxy` still has open VMs, and devvm refuses every other tier on it in one line (`net_tier_backend`).
|
||||
`egress-proxy` is what every [network tier](../safety/network.md#network-tiers) 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's loopback and set the guest's proxy settings from what devvm confines the VM to, which the conformance suite checks ([how a backend plugs in](../contributing/extending.md#how-a-backend-plugs-in)), because every VM's proxy carries its requests. So a backend without `egress-proxy` still has open VMs, and devvm refuses every other tier on it in one line (`net_tier_backend`).
|
||||
|
||||
### What each backend emulates
|
||||
|
||||
On Lima, devvm emulates forwarding ports, both the listed ones and every one, through its forwarder, and the emulation is reviewed ([port forwarding](ports.md)). Everything else on Lima is Lima's own.
|
||||
|
||||
The forwarder is devvm's own on every backend, never a backend's. A backend that has `ports` turns its own forwards off, and devvm's forwarder reaches a running VM's sshd the way the backend's `SSH` says, which is a user, a key and a port. devvm refuses that target unless it's on this machine's loopback, `127.0.0.1`, with the same check it uses for links and the ssh config (`vmssh.FromTarget`). devvm reads which ports the VM forwards from its state, chooses which of them are free, pins the VM's host keys for its current start and starts the forwarder, which follows the backend's lifeline for the VM.
|
||||
The forwarder is devvm's own on every backend, never a backend's. A backend that has `ports` turns its own forwards off, and devvm's forwarder reaches a running VM's sshd the way the backend's `SSH` says, which is a user, a key and a port. devvm refuses that target unless it's on this machine's loopback, `127.0.0.1`, 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's host keys for its current start and starts the forwarder, which follows the backend's lifeline for the VM.
|
||||
|
||||
## Missing and unreviewed features
|
||||
|
||||
@@ -97,7 +97,7 @@ Which ports a VM forwards stays in the VM's state alone, and the backend never h
|
||||
|
||||
## VM names
|
||||
|
||||
A project VM's name is `devvm-<folder>-<hash>`. The folder part is up to 20 characters of the folder'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 `foo (copy)` gives `foo-copy`. The hash part is 14 hex digits of a hash of the folder's path. devvm takes a name as a project VM's only when it has that form, so a name in a state file or a backend's list whose folder part has any other character, starts or ends with a dash, or has two dashes in a row isn't a project VM's. A state file whose name has dashes in a row and no `created` time is from a VM that Lima refused to make, so devvm reads it as no VM's state, and the folder's next VM replaces it.
|
||||
A project VM's name is `devvm-<folder>-<hash>`. The folder part is up to 20 characters of the folder'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 `foo (copy)` gives `foo-copy`. The hash part is 14 hex digits of a hash of the folder's path. devvm takes a name as a project VM's only when it has that form, so a name in a state file or a backend's list whose folder part has any other character, starts or ends with a dash, or has two dashes in a row isn't a project VM's. A state file whose name has dashes in a row and no `created` time belongs to a VM that Lima refused to make, so devvm reads it as no VM's state and the folder's next VM replaces it.
|
||||
|
||||
A backend may need shorter names, and then devvm cuts the folder's part to fit. When fewer than 4 characters of it would fit, devvm refuses (`vm_name_no_room`). On Lima the room for a name depends on the Lima home's path, because Lima keeps each VM's ssh socket under it, so there the fix is a shorter Lima home (`lima_home_too_long`, [limits](../backends/lima.md#limits)).
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ The built-in `desktop` layer installs Xfce, TigerVNC's `Xvnc`, `socat` for [the
|
||||
|
||||
Every request from the VM to its [proxy](network.md#the-proxy) carries the VM's password in `Proxy-Authorization`, and the VM's proxy settings carry it in their URL, `http://devvm:[email protected]:PORT`. Command-line tools take the password from that URL, but Chrome, Chromium and Firefox ignore it and ask for the proxy's username and password instead, on every site. So the desktop's programs use a local proxy in the VM, `devvm-local-proxy`, which needs no password and adds the VM's.
|
||||
|
||||
The VM's setup writes `devvm-local-proxy` into `/usr/local/bin` at each launch, mode 700 and the VM's user's, with the VM's proxy address and password in it, and installs it whole, so a connection that's already running keeps the copy it started with. The VM already holds the same password in its environment. `devvm-desktop` runs `devvm-local-proxy start` before it starts `Xvnc`, which starts `socat` unless it's running, so the local proxy starts with the desktop and runs until the VM stops. `socat` listens on `127.0.77.1:3128` alone, which is on the VM's loopback, takes connections only from `127.0.0.0/8`, carries at most 256 at once, and runs `devvm-local-proxy` on each connection itself. Its log is `~/.cache/devvm-local-proxy.log`. The address comes from devvm (`proxy.LocalProxyAddr` and `proxy.LocalProxyPort`), which the setup gets as `DEVVM_LOCAL_PROXY`, and `devvm-desktop` sets `http_proxy`, `https_proxy`, `HTTP_PROXY` and `HTTPS_PROXY` to `http://127.0.77.1:3128` 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's, which is its default.
|
||||
The VM's setup writes `devvm-local-proxy` into `/usr/local/bin` at each launch, mode 700 and the VM's user's, with the VM's proxy address and password in it, and installs it whole, so a connection that's already running keeps the copy it started with. The VM already holds the same password in its environment. `devvm-desktop` runs `devvm-local-proxy start` before it starts `Xvnc`, which starts `socat` unless it's running, so the local proxy starts with the desktop and runs until the VM stops. `socat` listens on `127.0.77.1:3128` alone, which is on the VM's loopback, takes connections only from `127.0.0.0/8`, carries at most 256 at once, and runs `devvm-local-proxy` on each connection itself. Its log is `~/.cache/devvm-local-proxy.log`. The address comes from devvm's proxy code ([the packages](../contributing/structure.md#the-packages)), which the setup gets as `DEVVM_LOCAL_PROXY`, and `devvm-desktop` sets `http_proxy`, `https_proxy`, `HTTP_PROXY` and `HTTPS_PROXY` to `http://127.0.77.1:3128` 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's, which is its default.
|
||||
|
||||
For each connection, `devvm-local-proxy` 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:
|
||||
|
||||
@@ -37,7 +37,7 @@ Each connection to the port goes through devvm's relay, which runs in `devvm des
|
||||
2. Only then does the relay connect to the VM: an ssh channel to the VM's socket (`ssh -W /run/devvm-desktop/vnc.sock`), through devvm's ssh config'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 (`IdentityAgent=none`, `ForwardAgent=no`, `ForwardX11=no`, `ClearAllForwardings=yes`). The relay does the viewer's side of the VM's handshake, asking for no authentication, and tells the viewer it's in.
|
||||
3. From then on it carries the viewer's messages to the VM and the VM's to the viewer. Without `--clipboard`, it reads each of the viewer's messages and drops its clipboard ones (`ClientCutText`, extended clipboard ones included). It ends a connection that sends a message it doesn't know, so nothing it can't read reaches the VM.
|
||||
|
||||
At most 8 viewers connect at once. The VM's password is 8 characters of lowercase letters and digits without `0`, `o`, `1`, `l` and `i`, about 40 bits, because VNC's authentication uses 8 characters at most. devvm makes it the first time and keeps it in the VM's state, in its `desktop` section (`made.password`), 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. [Processes](processes.md#the-desktop-relay) sets the relay beside devvm's other processes, with the [listeners](processes.md#listeners-a-vm-reaches) a VM's bytes reach.
|
||||
At most 8 viewers connect at once. The VM's password is 8 characters of lowercase letters and digits without `0`, `o`, `1`, `l` and `i`, about 40 bits, because VNC's authentication uses 8 characters at most. devvm makes it the first time and keeps it in the VM's state, in its `desktop` section (`made.password`), 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. [Processes](processes.md#the-desktop-relay) describes the relay alongside devvm's other processes, and it lists the [listeners](processes.md#listeners-a-vm-reaches) that a VM's bytes reach.
|
||||
|
||||
## What the VM can and can't change
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ devvm locks these paths, of the folder's own repo and of each [nested repo](#nes
|
||||
|
||||
devvm records a new VM'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 `--no-git-protect` or on hosts without locks, and `clone` for a `--clone` VM, which mounts no `.git`. devvm locks once the backend has made the VM, and again on each launch that finds the VM stopped and on `devvm stop`, so nothing in the VM can race the locks. A VM whose creation stopped before its first locks, or that `devvm adopt` 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 `devvm stop` or the next launch that finds the VM stopped, such as `devvm restart`, sets new ones. `devvm git-protect` on a running VM saves the mode in the VM's state (the `git` section's `next`).
|
||||
|
||||
Each time it locks, devvm records in the VM's state what it locked and found: the identity of `.git` (its device and inode, and its birth time where the file system keeps one), every git folder it locked besides `.git` (those under `.git/modules` and the submodules' 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. A `.git` whose device alone differs, at the same path with no link on it and with the same inode and birth time, is the `.git` devvm locked on a disk that macOS numbered anew at boot, as for [one VM per folder](security.md#one-vm-per-folder), so the check records its identity as it is now and reports no replaced `.git`. The same places first check `.git` under the mode the VM ran with, so a `.git` that the VM replaced meanwhile is still named (`git_replaced`), and then set the new mode, which locks `.git` as it is then.
|
||||
Each time it locks, devvm records in the VM's state what it locked and found: the identity of `.git` (its device and inode, and its birth time where the file system keeps one), every git folder it locked besides `.git` (those under `.git/modules` and the submodules' 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 `.git` differs, and it's at the same path with no link on it and has the same inode and birth time, it's the `.git` that devvm locked, on a disk that macOS numbered anew at boot, as for [one VM per folder](security.md#one-vm-per-folder). The check then records its identity as it is now and doesn't report a replaced `.git`. The same places first check `.git` under the mode the VM ran with, so a `.git` that the VM replaced meanwhile is still named (`git_replaced`), and then set the new mode, which locks `.git` as it is then.
|
||||
|
||||
A new VM that's interrupted before its first shell is deleted, and devvm takes its locks off. When `devvm rm` deletes a VM, devvm also takes its locks off. It unlocks what it would lock now and every git folder the VM's state records locking, so a submodule whose entry the VM dropped from the index since is unlocked too.
|
||||
|
||||
@@ -57,9 +57,9 @@ devvm protects each git repo nested in the project folder as it protects the fol
|
||||
|
||||
### The walk
|
||||
|
||||
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 `devvm stop`, at `devvm git-protect` on a stopped VM, and when `devvm clone off` mounts the folder again. It's one walk that also finds the set-id files on a Linux host (`hostsafety.Walk`, which only `starter.walk` calls), and a launch into a running VM never walks. The walk stays on the project folder's file system, follows no symlink and never enters a `.git` folder, so it never finds the repos of `.git/modules`, which are the folder's own repo's to protect. It takes a folder for a repo when the folder has anything named `.git`, 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's now or not, because the VM can make it one at any time. On macOS, whose file systems fold case, `.GIT` is `.git` to git, so the walk takes any case of the name there (`platform.FoldsCase`). It looks for repos at most four folders below the project folder, and not in `node_modules`, `vendor`, `.venv`, `__pycache__` or `.terraform`, 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't enter those folders at all. On Linux it walks them for set-id files anyway, and counts the `.git` it sees there and below four folders (`git_nested_skipped`). It counts the folders it doesn't enter because they're on another file system (`git_nested_devices`). It keeps the first 100 repos it finds, in the walk's order, and counts the rest, keeping the names of the first ten of those (`git_nested_past_bound`).
|
||||
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 `devvm stop`, at `devvm git-protect` on a stopped VM, and when `devvm clone off` mounts the folder again. It's one walk that also finds the set-id files on a Linux host, which only the start runs ([the checks on owners](../contributing/structure.md#the-checks-on-owners)), and a launch into a running VM never walks. The walk stays on the project folder's file system, follows no symlink and never enters a `.git` folder, so it never finds the repos of `.git/modules`, which are the folder's own repo's to protect. It takes a folder for a repo when the folder has anything named `.git`, 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's now or not, because the VM can make it one at any time. On macOS, whose file systems fold case, `.GIT` is `.git` 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 `node_modules`, `vendor`, `.venv`, `__pycache__` or `.terraform`, 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't enter those folders at all. On Linux it walks them for set-id files anyway, and counts the `.git` it sees there and below four folders (`git_nested_skipped`). It counts the folders it doesn't enter because they're on another file system (`git_nested_devices`). It keeps the first 100 repos it finds, in the walk's order, and counts the rest, keeping the names of the first ten of those (`git_nested_past_bound`).
|
||||
|
||||
The walk also names each folder up to four folders down that git could take for a bare repo (`git_nested_bare`), one shaped like a git folder by git's own test (`hostsafety.IsGitDir`): a `HEAD`, and `objects` and `refs`, files or folders, in the folder or in the folder its `commondir` names. A git folder that a repo's scan locks, or that a nested repo's `.git` file names, isn't named. `devvm doctor` reads `safe.bareRepository` from git's global and system config (`hostsafety.BareExplicit`), the files that `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` name included, which it reads by name (`hostgit.UserConfig`) because devvm's host git ignores every `GIT_*` variable, and it gives a tip unless the setting is `explicit` (`doctor_git_bare`).
|
||||
The walk also names each folder up to four folders down that git could take for a bare repo (`git_nested_bare`), one shaped like a git folder by git's own test: a `HEAD`, and `objects` and `refs`, files or folders, in the folder or in the folder its `commondir` names. A git folder that a repo's scan locks, or that a nested repo's `.git` file names, isn't named. `devvm doctor` reads `safe.bareRepository` from git's global and system config, the files that `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` name included, which it reads by name because devvm's host git ignores every `GIT_*` variable, and it gives a tip unless the setting is `explicit` (`doctor_git_bare`).
|
||||
|
||||
A check takes the repos the walk found, the ones the VM'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 `.git`, because the VM can make a `.git` that the walk or git's own test passes over while git still takes it: objects and refs renamed with a `commondir` that leads to a git folder of its own, a `.GIT`, or a `.git` it can't read, which devvm can't lock and names (`git_not_locked`). A check without a walk, such as `devvm rm` and the start that pins, takes the repos the state records. A launch into a running VM checks the folder's own repo alone and keeps the nested repos' 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's pins goes by those records without scanning them. devvm scans each repo as it scans the folder'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.
|
||||
|
||||
@@ -67,7 +67,7 @@ A check takes the repos the walk found, the ones the VM's state records first. A
|
||||
|
||||
Each repo has two bounds. Its own top folder is where its `.git` is, where `.git/modules` and a relative `core.hooksPath` are read from, and where its submodules' folders are. The project folder, which the VM mounts, is what the VM can write, so it'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's git folder outside the project folder is one devvm can't lock (`git_gitdir_outside`). A nested repo's hooks path that leads into a sibling repo is inside, because the VM can write it.
|
||||
|
||||
A nested repo is left to another repo only when that repo's scan locks its git folder whole (`snapshot.covered`): the git folder is that repo's `.git`, one under its `.git/modules` that reads its config from itself, with no `commondir` that leads elsewhere, or one of its linked worktrees under `.git/worktrees` whose `commondir` leads back. Anything else below a `.git`, such as a `.git/evil` the VM made for a `src/.git` file to name, isn't locked by anything, so the repo is scanned on its own, and named as one that appeared and as one devvm doesn't protect. A submodule in the working tree is scanned as a repo of its own as well as its parent's submodule, because the index that names it is the VM's to write: a gitlink the VM adds, whose `.git` file names a nested repo's git folder, would otherwise hide that repo'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 `.git` is a file is locked as the folder's own is when it's a linked worktree, by its `.git` file. When the git folder that file names is in the project folder and no repo's scan locks it, devvm names the repo as one it doesn't protect, and when it's outside the project folder, it names the repo as one whose git folder it can't lock (`git_nested_gitdir_outside`), as it does a submodule's.
|
||||
A nested repo is left to another repo only when that repo's scan locks its git folder whole: the git folder is that repo's `.git`, one under its `.git/modules` that reads its config from itself, with no `commondir` that leads elsewhere, or one of its linked worktrees under `.git/worktrees` whose `commondir` leads back. Anything else below a `.git`, such as a `.git/evil` the VM made for a `src/.git` file to name, isn't locked by anything, so the repo is scanned on its own, and named as one that appeared and as one devvm doesn't protect. A submodule in the working tree is scanned as a repo of its own as well as its parent's submodule, because the index that names it is the VM's to write: a gitlink the VM adds, whose `.git` file names a nested repo's git folder, would otherwise hide that repo'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 `.git` is a file is locked as the folder's own is when it's a linked worktree, by its `.git` file. When the git folder that file names is in the project folder and no repo's scan locks it, devvm names the repo as one it doesn't protect, and when it's outside the project folder, it names the repo as one whose git folder it can't lock (`git_nested_gitdir_outside`), as it does a submodule's.
|
||||
|
||||
A scan follows each submodule git folder once, by its resolved path, and one check'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't make a check run git without end. A repo whose scan stopped there is named at every check (`git_scan_bounded`).
|
||||
|
||||
@@ -77,11 +77,11 @@ The VM's state records each protected nested repo in the `git` section's `made.r
|
||||
|
||||
A VM an earlier devvm made has no `made.nested`, so it protects only the folder's own repo. The first check of it that finds nested repos names them once (`git_nested_protectable`, recorded as `nested_noticed`), and `devvm git-protect on` protects them. The nested repos that a check finds and the protection doesn't cover are recorded in `nested`, with `nested_more` for how many more the walk counted, and named (`git_nested_unprotected`, `git_nested_past_bound`): on a host that locks, all of them when devvm creates the VM and at `devvm git-protect on`, and at a check of a stopped VM those it hadn'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't lock, each launch names those the last walk recorded, after `git_unprotected`, which a folder without a `.git` of its own gets too when it has nested repos, and `devvm git-protect off` quiets both.
|
||||
|
||||
A VM that devvm 0.1.0 or 0.1.1-rc.1 made strict has `strict` as its `mode`, and its repos' configs have the `diff.ignoreSubmodules = all` that strict set. devvm reads that mode as `on`: it locks, pins and keeps the VM's paths as it does for `on`, and `devvm git-protect`, its `--json` and `devvm ls` show `on`. The first check that finds the VM stopped (`gitprotect.Protector.Check`, then the `converter`'s `unstrict`), at a launch, `devvm stop`, `devvm clone on` or the undo of a `devvm clone off`, runs as an `on` VM's does. Then, under the host's lock of `.git` protection, it takes the value `all` out of the `.git/config` of each repo that the VM's state recorded protecting before that check, the folder's own and the nested ones, with `git config --unset-all diff.ignoreSubmodules '^all$'`, and leaves any other value. It acts only on a repo whose `.git` has the identity the state recorded (`git_id`), so a `.git` the VM replaced, which the check names and locks nothing in, and a VM with no record, as after `devvm adopt`, keep their setting, which devvm names once when it's `all` (`git_strict_unknown`). It reads the config through `internal/safefile` 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 `.git`, else it names the path (`git_lock_raced`). On a host that watches as well as locks, it leaves a config whose sum isn't the one the check just recorded, and puts the new sum of each config it changed into the watch's, so the next check doesn't name devvm's own change. It locks each config again even after an interrupt (`context.WithoutCancel`), and an interrupt records nothing, so the next check goes again. Then it records `on` in `mode`, and in `next` when an earlier devvm saved `strict` there for the VM's next stop, and warns once (`git_strict_converted`), unless `next` is `off`. A config that git can't change keeps the setting, and devvm names it (`git_strict_left`). `devvm git-protect on` and `off` and the unlock at `devvm rm` take the setting out the same way, without the warning (`strictLeft`).
|
||||
A VM that devvm 0.1.0 or 0.1.1-rc.1 made strict has `strict` as its `mode`, and its repos' configs have the `diff.ignoreSubmodules = all` that strict set. devvm reads that mode as `on`: it locks, pins and keeps the VM's paths as it does for `on`, and `devvm git-protect`, its `--json` and `devvm ls` show `on`. The first check that finds the VM stopped, at a launch, `devvm stop`, `devvm clone on` or the undo of a `devvm clone off`, runs as an `on` VM's does, and then converts the VM. Under the host's lock of `.git` protection, it takes the value `all` out of the `.git/config` of each repo that the VM's state recorded protecting before that check, the folder's own and the nested ones, with `git config --unset-all diff.ignoreSubmodules '^all$'`, and leaves any other value. It acts only on a repo whose `.git` has the identity the state recorded (`git_id`), so a `.git` the VM replaced, which the check names and locks nothing in, and a VM with no record, as after `devvm adopt`, keep their setting, which devvm names once when it's `all` (`git_strict_unknown`). It reads the config through devvm'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 `.git`, else it names the path (`git_lock_raced`). On a host that watches as well as locks, it leaves a config whose sum isn't the one the check just recorded, and puts the new sum of each config it changed into the watch's, so the next check doesn't name devvm's own change. It locks each config again even after an interrupt, on a context the interrupt doesn't cancel, and an interrupt records nothing, so the next check goes again. Then it records `on` in `mode`, and in `next` when an earlier devvm saved `strict` there for the VM's next stop, and warns once (`git_strict_converted`), unless `next` is `off`. A config that git can't change keeps the setting, and devvm names it (`git_strict_left`). `devvm git-protect on` and `off` and the unlock at `devvm rm` take the setting out the same way, without the warning ([the packages](../contributing/structure.md#the-packages) names the code).
|
||||
|
||||
### Two VMs, one repo
|
||||
|
||||
A nested repo with a VM of its own is protected by two VMs, the parent folder's and its own. On macOS both set the same flag on the same files, so when one VM's protection comes off, at `devvm rm` or `devvm git-protect off`, devvm leaves locked every path that another VM's protection still covers (`gitprotect.Keeps`: a git folder it recorded locking, of its own repo or of a nested one), and names that VM (`git_kept_locked`). The inventory reads every VM's state for that (`Inventory.GitKeeper`). It fails closed: a state it can't read keeps locked every path in the folder whose hash names that state's folder (`project.Hash`), and when it can't read the VMs' folder at all, everything stays locked, each named with the state to fix (`git_kept_unread`). Locking a VM's repos and recording them, and unlocking another's, take the host's lock of `.git` protection first (`paths.Dirs.GitLock`, before any VM's own lock), so one VM's unlock never runs between another's locks and their record. Taking a strict VM's `diff.ignoreSubmodules` 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 (`git_strict_kept`). The repo goes in the state's `strict_left`, 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't change a config, devvm locks it again all the same. On Linux each VM's pins are in its own QEMU's namespace, and the watch locks nothing, so neither needs this.
|
||||
A nested repo with a VM of its own is protected by two VMs, the parent folder's and its own. On macOS both set the same flag on the same files, so when one VM's protection comes off, at `devvm rm` or `devvm git-protect off`, devvm leaves locked every path that another VM'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 (`git_kept_locked`). The inventory reads every VM's state for that. It fails closed: a state it can't read keeps locked every path in the folder whose hash names that state's folder, and when it can't read the VMs' folder at all, everything stays locked, each named with the state to fix (`git_kept_unread`). Locking a VM's repos and recording them, and unlocking another's, take the host's lock of `.git` protection first, before any VM's own lock, so one VM's unlock never runs between another's locks and their record. Taking a strict VM's `diff.ignoreSubmodules` 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 (`git_strict_kept`). The repo goes in the state's `strict_left`, 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't change a config, devvm locks it again all the same. On Linux each VM's pins are in its own QEMU's namespace, and the watch locks nothing, so neither needs this.
|
||||
|
||||
## On Linux hosts
|
||||
|
||||
@@ -89,7 +89,7 @@ Linux hosts have no immutable flag that a user can set, so devvm makes what it l
|
||||
|
||||
The guest reaches the project folder only through QEMU, so a write to a pinned path gets `EROFS`, and a rename or a removal of one, `.git` itself included, gets `EBUSY`, because it's a mount point. A mount can't be undone from the guest, and QEMU, which has no capability, can'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 `.git` gets `EXDEV`. The namespace ends with QEMU, so nothing persists once the VM stops, and nothing changes on this machine's side, where git works as usual.
|
||||
|
||||
A git command on this machine that writes `.git/config` writes a new file and renames it over the old one, and the new file isn't pinned in the namespace. `devvm _qemu pinned` watches each pinned path's folder with inotify, a few folders for each repo, so the 100 nested repos devvm protects at most stay far below the kernel'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 meet the rename: the kernel takes the old file's mount away before the new file has its name, so the pin may open the old file, which is gone by the time it binds (`move_mount`'s `ENOENT`). Then it opens the path again and pins what the rename left, up to 50 times, so a busy host never takes 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't take back, or give it another name. So each pin it makes again, and each it can't, it records in the VM's run folder (`run/git-pins.jsonl`), 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't start (`qemu_pins_failed`). The next check of the stopped VM, at `devvm stop` or at the next launch, names them before anything else, one line for each path and kind however often it happened (`git_pin_again`, `git_pin_linked_run`, `git_pin_lost`), then removes the file. An event `devvm _qemu pinned` can't add goes to Lima's log, with a warning, and to the file as a mark if it still takes one. A record the check can't trust is named (`git_pins_unrecorded`): one it can't read, which it keeps, a line that isn't an event, a mark, or a file that doesn't start with a run'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 [watch](#the-watch) does, and names what changed since the VM's last check, so a file the guest changed in that window, or through a handle it kept, is named too. macOS's flag has no window, because a locked config can't be replaced on the host either.
|
||||
A git command on this machine that writes `.git/config` writes a new file and renames it over the old one, and the new file isn't pinned in the namespace. `devvm _qemu pinned` watches each pinned path's folder with inotify, a few folders for each repo, so the 100 nested repos devvm protects at most stay far below the kernel'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'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 (`move_mount`'s `ENOENT`). `devvm _qemu pinned` 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't take back, or give it another name. So each pin it makes again, and each it can't, it records in the VM's run folder (`run/git-pins.jsonl`), 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't start (`qemu_pins_failed`). The next check of the stopped VM, at `devvm stop` or at the next launch, names them before anything else, one line for each path and kind however often it happened (`git_pin_again`, `git_pin_linked_run`, `git_pin_lost`), then removes the file. An event `devvm _qemu pinned` can't add goes to Lima's log, with a warning, and to the file as a mark if it still takes one. A record the check can't trust is named (`git_pins_unrecorded`): one it can't read, which it keeps, a line that isn't an event, a mark, or a file that doesn't start with a run'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 [watch](#the-watch) does, and names what changed since the VM's last check, so a file the guest changed in that window, or through a handle it kept, is named too. macOS's flag has no window, because a locked config can't be replaced on the host either.
|
||||
|
||||
Each launch of a running VM that's on, and `devvm stop` before it stops it, read QEMU's mounts (`/proc/<pid>/mountinfo`, QEMU's pid from Lima's `qemu.pid`) and name what of `.git` and of the git folders it locked QEMU lacks (`git_pins_missing`): `.git` and each git folder that isn't a mount point of its own, and each read-only path that QEMU doesn't see read-only,, such as all of them for a VM that `limactl start` started. A VM that's on whose `.git` has nothing devvm can pin, such as one whose `.git` is a symlink, is named at its start (`git_pins_none`).
|
||||
|
||||
@@ -101,7 +101,7 @@ devvm doesn't pin `.git/commondir` against the VM making one, which would point
|
||||
|
||||
Where the host can't pin, devvm locks nothing, and every VM that mounts its folder gets `off` as its mode. devvm watches the paths it would lock instead, and names what changed after the fact (`git_changed`), which [Linux hosts](../safety/git-protection.md#when-devvm-names-a-change) tells the user how to check.
|
||||
|
||||
devvm hashes the same paths that [what's locked](#whats-locked) lists, found in the same way, and `.git/commondir`, there or not, the files that `include.path` and `includeIf.*.path` lead to in the project folder, and the folder that `core.hooksPath` names in it. For a hooks folder, it hashes each entry below it, except git's `.sample` files, which git never runs, starting with the entries at its top that have a hook's name (githooks(5)), which git runs, and then the rest. It hashes a regular file's contents with SHA-256, opened with `O_NOFOLLOW` and `O_NONBLOCK` and checked to be a regular file once it's open (`internal/safefile`). It records a symlink by where it points, and a path under a symlink, such as `.git/config` when `.git` is a symlink, by that fact. When the link resolves to a file or folder inside the project folder, it adds that file's hash, or a hash of that folder'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's own repo and 200 of each nested repo, so a folder with many nested repos never overflows it. The VM can't set a change time back over 9p, so a change that keeps a large file's size is still named. Each check names, in its own warning (`git_watch_blind`), every path that is a symlink or under one, past a bound, or past the 2,000, because the watch can't see every change there.
|
||||
devvm hashes the same paths that [what's locked](#whats-locked) lists, found in the same way, and `.git/commondir`, there or not, the files that `include.path` and `includeIf.*.path` lead to in the project folder, and the folder that `core.hooksPath` names in it. For a hooks folder, it hashes each entry below it, except git's `.sample` files, which git never runs, starting with the entries at its top that have a hook's name (githooks(5)), which git runs, and then the rest. It hashes a regular file's contents with SHA-256, opened with `O_NOFOLLOW` and `O_NONBLOCK` and checked to be a regular file once it'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 `.git/config` when `.git` is a symlink, by that fact. When the link resolves to a file or folder inside the project folder, it adds that file's hash, or a hash of that folder'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's own repo and 200 of each nested repo, so a folder with many nested repos never overflows it. The VM can't set a change time back over 9p, so a change that keeps a large file's size is still named. Each check names, in its own warning (`git_watch_blind`), every path that is a symlink or under one, past a bound, or past the 2,000, because the watch can't see every change there.
|
||||
|
||||
The same checks first run what a lock's check reports, without locking (`protect` with `watching`): a `.git` replaced since the last check (`git_replaced`), after which the next check compares with the new one, a `commondir` (`git_commondir`), linked worktrees whose `commondir` leads elsewhere, a repo or submodule git folder that appeared, a submodule's folder that isn't a git folder (`git_gitdir_not_git`), which the watch doesn't hash as one and where devvm creates nothing, and includes, hook links and `core.hooksPath` into the project folder. They don't report hooks in folders that aren't locked, because nothing is, and the watch names their changes. `.git`'s identity and the git folders and delegations found are recorded in the `git` section's `made`, as a lock's check records them. A VM whose `made` isn't set yet reports as a new VM does.
|
||||
|
||||
@@ -113,7 +113,7 @@ Each launch also warns that the VM can change `.git` (`git_unprotected`), unless
|
||||
|
||||
## What a lock can't stop
|
||||
|
||||
The VM can rename `.git` and put a new one in its place, add `.git/commondir` to point git at another config, or do the same with a linked worktree's folder in `.git/worktrees`. When devvm creates the VM, and [on each launch](#on-each-launch), it reports a `commondir` that's there, linked worktrees whose `commondir` leads somewhere else, and paths it couldn't lock because they're symlinks. devvm reads git's own small files, a `.git` file, a `commondir` and a linked worktree's `gitdir`, through a symbolic link as git does, but only when each is a regular file of at most 16 MiB, opened without blocking (`internal/safefile`), so a FIFO the VM leaves there can't hang devvm. devvm doesn't repair anything, so check what it names before you run git in the folder. When you don't trust what runs in the VM, use [`--clone`](../using/clone.md), which mounts no `.git` at all.
|
||||
The VM can rename `.git` and put a new one in its place, add `.git/commondir` to point git at another config, or do the same with a linked worktree's folder in `.git/worktrees`. When devvm creates the VM, and [on each launch](#on-each-launch), it reports a `commondir` that's there, linked worktrees whose `commondir` leads somewhere else, and paths it couldn't lock because they're symlinks. devvm reads git's own small files, a `.git` file, a `commondir` and a linked worktree's `gitdir`, 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't hang devvm. devvm doesn't repair anything, so check what it names before you run git in the folder. When you don't trust what runs in the VM, use [`--clone`](../using/clone.md), which mounts no `.git` at all.
|
||||
|
||||
The VM writes `.git/index`, because it has to in order to commit, so it can also add a submodule with its own config, which `git status` on the host reads. A submodule's `core.fsmonitor` 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 `.gitmodules`, whose `ignore` line for a submodule beats `diff.ignoreSubmodules`, and git falls back to the index's and `HEAD`'s copies of the file when the working tree has none. `git add -A`, `-u` and `.` enter a submodule whatever any setting says, and `git diff-index`, `git diff-files` and `git describe --dirty` enter one that `.gitmodules` doesn't name. A setting for a submodule's name in `.git/config` holds only for the name the VM chooses in `.gitmodules`. Only [`--clone`](../using/clone.md) keeps the VM's code away from git on the host.
|
||||
|
||||
@@ -173,7 +173,7 @@ A submodule's own folder isn't a repo that `--clone` takes by itself: its `.git`
|
||||
|
||||
Base's image has `git-lfs`, 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 `git lfs install --local --skip-repo`, which writes the repo's own config and no hooks, and when that fails, devvm says the clone's LFS files may be pointers there (`clone_lfs_setup_failed`). No `git-lfs` runs on this machine for the copy or for what comes back, and when the repo's `lfs.storage` puts its objects outside `.git`, devvm copies none either way and says so (`clone_lfs_storage`).
|
||||
|
||||
Every object file devvm reads or writes on this machine is opened beneath the repo's common dir through Go's `os.Root`, and before that, each folder on the way, `lfs`, `lfs/objects`, both two-character folders and `lfs/tmp`, must be a folder, never a link, as `os.Root` still follows a link that stays inside the root. So a link planted in `.git/lfs` can't make devvm send a file from elsewhere on this machine or write the VM's content anywhere else.
|
||||
Every object file devvm reads or writes on this machine is opened beneath the repo's common dir through a root that no path can leave, and before that, each folder on the way, `lfs`, `lfs/objects`, both two-character folders and `lfs/tmp`, must be a folder, never a link, as such a root still follows a link that stays inside it. So a link planted in `.git/lfs` can't make devvm send a file from elsewhere on this machine or write the VM's content anywhere else.
|
||||
|
||||
On the way in, devvm reads the pointers among the index's blobs: those of at most 1,024 bytes, `git cat-file --batch-check` says, which, read with `git cat-file --batch`, are a pointer as git-lfs's spec has it, with its version line first, an `oid sha256:` of 64 lowercase hex characters and a `size`, 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 `lfs/objects/<oid[0:2]>/<oid[2:4]>/<oid>` in its common dir, a regular file of its pointer's size, is hashed before anything is sent, and one whose SHA-256 isn't its oid stays on this machine, named (`clone_lfs_bad`), while the copy goes on. The rest go in the tar as `lfs/<oid>`, hashed again as they're sent, so one that changed in between fails the copy, its tar cut short. The VM moves each into its repo's `lfs/objects`, where it has no file of that name, before the checkout. The checkout runs with `GIT_LFS_SKIP_SMUDGE=1`, so `git-lfs` never fetches during the copy, then `git lfs checkout`, which reads only the objects the repo has, writes each file's content; a file whose object isn't there stays a pointer.
|
||||
|
||||
@@ -212,7 +212,7 @@ The pack carries the commits the operation needs, and only those that its files
|
||||
|
||||
The stash goes as its entries, oldest first, each with its message, read with `git reflog show --format='%H %gs' refs/stash`, the newest 1,000, the rest named (`clone_stash_over_kept`), and the VM stores each with `git stash store -m`, the commits it was made on with it. An entry with untracked files, a third parent, is taken for one of `git stash --all` and stays, named (`clone_stash_all_kept`), because it may hold ignored files, such as `.env`, when any of those files is a `.gitignore`, when the entry changes a `.gitignore` (`git stash --all` 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 (`git check-ignore --no-index`), as they are now or as the entry's own `.gitignore` 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's copy sends no stash, which is the whole repo's. The VM records each entry it stores in `.git/devvm-seeded-stash`, 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's own.
|
||||
|
||||
`cloneState` prints every other entry as `SHA stash@{N}`, devvm names it as `stash-N` when this repo doesn't have its commit, and fetches it by that commit. `devvm clone fetch` does the same, with a script of its own whose lines devvm takes only for a detached `HEAD`'s commit and stash entries, so the VM can't have it save a branch of another name, and an entry it can't fetch is named, the others saved. For rm and `clone off`, an entry that can't be fetched keeps the VM. A stash entry is never saved with its untracked files, because `git stash apply` writes them, ignored ones too, such as a virtualenv's `sitecustomize.py` that Python runs on its own, while `git stash show` doesn't list them. devvm makes the entry again with `git commit-tree`, 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 `saved/devvm/stash-N`. The untracked files go to `saved/devvm/stash-N-untracked`, and devvm names them, and those that git on this machine ignores (`clone_stash_untracked`, `clone_stash_untracked_ignored`). Every fetch from a VM checks each object it receives (`transfer.fsckObjects`). No ref names an older entry, and devvm's ssh passes no `GIT_PROTOCOL` to the VM, so its `git upload-pack` speaks protocol v0, which refuses a commit no ref names unless the fetch runs it with `uploadpack.allowAnySHA1InWant`, as devvm's does. That only lets the host ask the VM for its own objects. The stubs drop `GIT_PROTOCOL` too, so the tests fetch over v0.
|
||||
The script that reads the clone's state prints every other entry as `SHA stash@{N}`, devvm names it as `stash-N` when this repo doesn't have its commit, and fetches it by that commit. `devvm clone fetch` does the same, with a script of its own whose lines devvm takes only for a detached `HEAD`'s commit and stash entries, so the VM can't have it save a branch of another name, and an entry it can't fetch is named, the others saved. For rm and `clone off`, an entry that can't be fetched keeps the VM. A stash entry is never saved with its untracked files, because `git stash apply` writes them, ignored ones too, such as a virtualenv's `sitecustomize.py` that Python runs on its own, while `git stash show` doesn't list them. devvm makes the entry again with `git commit-tree`, 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 `saved/devvm/stash-N`. The untracked files go to `saved/devvm/stash-N-untracked`, and devvm names them, and those that git on this machine ignores (`clone_stash_untracked`, `clone_stash_untracked_ignored`). Every fetch from a VM checks each object it receives (`transfer.fsckObjects`). No ref names an older entry, and devvm's ssh passes no `GIT_PROTOCOL` to the VM, so its `git upload-pack` speaks protocol v0, which refuses a commit no ref names unless the fetch runs it with `uploadpack.allowAnySHA1InWant`, as devvm's does. That only lets the host ask the VM for its own objects. The stubs drop `GIT_PROTOCOL` too, so the tests fetch over v0.
|
||||
|
||||
The state goes in only when the copy sets `HEAD`, as the working tree does, since an operation applies to the commit it started from, and so do the refs of an operation, below `refs/rewritten/` and `refs/bisect/`. The stash goes in either way.
|
||||
|
||||
|
||||
@@ -12,12 +12,20 @@ devvm builds each image in a VM of its own, and that VM then is the image:
|
||||
|
||||
1. For base, devvm makes a new VM from [Ubuntu's cloud image](#ubuntus-cloud-image) with `base.yaml`'s settings, or, with `--from`, from a container image [converted into a disk](#how-its-converted). A layer's VM is a copy of its parent image.
|
||||
2. 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's loopback, and on Linux it reaches the host's loopback too, as [Lima](lima.md#confinement) describes.
|
||||
3. The script runs. For base, that's `assets/layers/base.sh` and then the [features](../using/customizing.md) you chose, and for a layer, it's the layer's script.
|
||||
3. The script runs. For base, that's base's own script, `base.sh`, and then the [features](../using/customizing.md) you chose, and for a layer, it's the layer's script.
|
||||
4. The VM stops. devvm writes the image's record last, `~/.local/share/devvm/images/<key>/record.json`, with its name, its chain, what base started from and its digest, its C library, the glibc version of a `--from` base with glibc, when the build finished and the version of the devvm that built it (`made_by`). The record is JSON that only devvm writes, and devvm ignores fields it doesn't know, so a newer devvm's record still reads.
|
||||
|
||||
While the VM is being built, it already has the image's final name, so devvm holds a lock for each image it builds, `~/.local/share/devvm/images/locks/<key>`, 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 (`image_build_waiting`), and once it gets the lock, it finds the image built. An image without a record is unfinished only when its lock is free, so devvm then deletes it and builds it again (`image_leftover`). While the lock is held, the image is `building`, and `devvm gc`, `devvm rebuild` and `devvm images rm` leave it alone (`image_building`). The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a crash never leaves an image looking like it's still being built. devvm deletes the lock file together with the image's folder.
|
||||
|
||||
Nothing from the host is mounted into a build, because layer scripts run third-party installers, which mustn't see your files. Behind a company proxy, a build on Lima goes through a proxy of devvm's on this machine for that build alone, which goes through the company proxy. The scripts' commands get only that proxy's address, with a password devvm makes for the build, so neither the build nor its image ever has the company proxy's password ([a company proxy](design.md#a-company-proxy)). A build gets base's size fitted to the host, which the images built on base, and their VMs, keep ([base's size](#bases-size)).
|
||||
Nothing from the host is mounted into a build, because layer scripts run third-party installers, which mustn't see your files. Behind a company proxy, a build on Lima goes through a proxy of devvm's on this machine for that build alone, which goes through the company proxy. The scripts' commands get only that proxy's address, with a password devvm makes for the build, so neither the build nor its image ever has the company proxy's password ([a company proxy](../contributing/design.md#a-company-proxy)). A build gets base's size fitted to the host, which the images built on base, and their VMs, keep ([base's size](#bases-size)).
|
||||
|
||||
A build's downloads survive a network that cuts or stalls them:
|
||||
|
||||
- **`devvm-fetch`**, 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't resume (curl's exits 33 and 36) starts the file again from nothing, and so does a file that doesn'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.
|
||||
- **apt** tries a package's download again three times once a source has answered ([base's packages](#bases-packages)).
|
||||
- **crane**, in a `--from` conversion, is tried again five times, and **oh-my-bash**'s clone, in the `omb` feature, is tried five times in all, each failing on a connection that stays slower than 1 KB/s for 30 seconds.
|
||||
- **mise**, in a tool image's build and on this machine, tries each download again six times (`MISE_HTTP_RETRIES`), as its own three end within a two-minute stall.
|
||||
- **`tldr --update`**, in the `cli-tools` 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.
|
||||
|
||||
## Keys and caching
|
||||
|
||||
@@ -25,11 +33,11 @@ devvm builds images in layers and caches them, as Docker does. `base` comes firs
|
||||
|
||||
| Image | Its key hashes |
|
||||
| --- | --- |
|
||||
| `base` | the backend, `assets/base.yaml`, `assets/prelude.sh`, `assets/layers/apt.sh`, `assets/layers/base.sh`, the chosen features that devvm has, in order (each name and its script, `assets/features/<name>.sh`), its rebuild counter, and with `--from`, 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's disk size, and the user that a `--from` conversion puts in the image (its name, uid and home folder) with the converted disk's size |
|
||||
| a built-in layer | its parent's key, its name, `assets/prelude.sh`, `assets/layers/apt.sh`, its script (`assets/layers/<name>.sh`) and its rebuild counter |
|
||||
| a custom layer | its parent's key, its name, `assets/prelude.sh`, `assets/layers/apt.sh`, its script (`~/.config/devvm/layers/<name>.sh`) with the prelude before it, and its rebuild counter |
|
||||
| `base` | the backend, base's Lima template (`base.yaml`), devvm's prelude (`prelude.sh`), the apt script (`apt.sh`), base's script (`base.sh`), the chosen features that devvm has, in order (each name and its script), its rebuild counter, and with `--from`, 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's disk size, and the user that a `--from` conversion puts in the image (its name, uid and home folder) with the converted disk's size |
|
||||
| a built-in layer | its parent's key, its name, the prelude, the apt script, its own script, which devvm ships, and its rebuild counter |
|
||||
| a custom layer | its parent's key, its name, the prelude, the apt script, its script (`~/.config/devvm/layers/<name>.sh`) with the prelude before it, and its rebuild counter |
|
||||
|
||||
devvm puts together each image'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's own and a custom layer's alike, starts with devvm's prelude, `assets/prelude.sh`, which [the scripts' prelude](#the-scripts-prelude) describes, so the recipe holds the prelude and the script together. The recipe of `base` starts with the backend's own steps, which say what the backend makes `base`'s disk from. On Lima, those are the Ubuntu cloud image pinned on this machine, base's disk size and `base.yaml`, and with `--from`, the conversion's scripts too, `build.sh` with its arguments. Then come `apt.sh begin`, `base.sh`, the chosen features' scripts and `apt.sh end`, while a layer's recipe is `apt.sh lists` 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't hold, apart from base's packages: those are the ones its key recorded at its first build, or the mirror to record them from, which [base's packages](#bases-packages) describes. A chosen feature without a script isn't in the recipe, and devvm warns about it (`unknown_feature`) when it builds `base`. The user's CAs and a company proxy's variables are added to each step while it runs and taken out again, so they aren't in the recipe, and the image keeps none of them. A build's CPUs and memory aren't in it either, because the host's size doesn't change what an image holds, but base's disk size is, because the disk is part of the image ([base's size](#bases-size)).
|
||||
devvm puts together each image'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's own and a custom layer's alike, starts with devvm's prelude, which [the scripts' prelude](#the-scripts-prelude) describes, so the recipe holds the prelude and the script together. The recipe of `base` starts with the backend's own steps, which say what the backend makes `base`'s disk from. On Lima, those are the Ubuntu cloud image pinned on this machine, base's disk size and `base.yaml`, and with `--from`, the conversion's scripts too, `build.sh` with its arguments. Then come `apt.sh begin`, `base.sh`, the chosen features' scripts and `apt.sh end`, while a layer's recipe is `apt.sh lists` 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't hold, apart from base's packages: those are the ones its key recorded at its first build, or the mirror to record them from, which [base's packages](#bases-packages) describes. A chosen feature without a script isn't in the recipe, and devvm warns about it (`unknown_feature`) when it builds `base`. The user's CAs and a company proxy's variables are added to each step while it runs and taken out again, so they aren't in the recipe, and the image keeps none of them. A build's CPUs and memory aren't in it either, because the host's size doesn't change what an image holds, but base's disk size is, because the disk is part of the image ([base's size](#bases-size)).
|
||||
|
||||
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's record keeps its chain, which is the key of each image it's built on, from `base` up.
|
||||
|
||||
@@ -67,29 +75,39 @@ A VM keeps the image it was made from, and its state keeps that image's chain. W
|
||||
|
||||
## Ubuntu's cloud image
|
||||
|
||||
On Lima, base starts from a dated release of Ubuntu 26.04's cloud image (`release-YYYYMMDD` on cloud-images.ubuntu.com), which devvm pins on this machine the first time it builds base. devvm's own files hold only the release, 26.04, and Ubuntu's cloud image key, `assets/layers/ubuntu-cloud.gpg` (fingerprint `D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81`), so nothing in devvm needs moving when Ubuntu publishes a new image.
|
||||
On Lima, base starts from a dated release of Ubuntu 26.04's cloud image (`release-YYYYMMDD` on cloud-images.ubuntu.com), which devvm pins on this machine the first time it builds base. devvm's own files hold only the release, 26.04, and Ubuntu's cloud image key (fingerprint `D2EB44626FDDC30B513D5BB71A5D6C4C7DB87C81`), so nothing in devvm needs moving when Ubuntu publishes a new image.
|
||||
|
||||
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:
|
||||
|
||||
- The release's `SHA256SUMS` must carry a valid signature from Ubuntu's cloud image key, in its `SHA256SUMS.gpg`. No other key counts. devvm checks the signature itself, with the standard library's RSA and SHA-2, so it needs no `gpgv` or other program. When the signature is missing or doesn't check out, devvm refuses the release (`ubuntu_bad_signature`), and it never falls back to an older release for that reason.
|
||||
- The host's image, `ubuntu-26.04-server-cloudimg-arm64.img` or `-amd64.img`, 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 (`no_ubuntu_release`).
|
||||
- When devvm can't read the list, it stops (`ubuntu_unreachable`), and nothing is pinned.
|
||||
- When devvm can't read the list, it stops (`ubuntu_unreachable`), and nothing is pinned. When a server's certificate is what stops devvm reading the list, a release's checksums or their signature, it says why, as it does for the download below (`ubuntu_untrusted`, `ubuntu_bad_certificate`, `ubuntu_certificate_invalid`).
|
||||
|
||||
devvm records the pin in `~/.local/share/devvm/images/ubuntu.json`: the release, the image's file name, its SHA-256 and when it was pinned. One devvm pins at a time, holding `~/.local/share/devvm/images/locks/ubuntu`, 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 Lima has it cached, and Lima checks the download against the pinned SHA-256. 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 `--from` base's conversion boots the pinned image too, and pins one only when none is.
|
||||
devvm records the pin in `~/.local/share/devvm/images/ubuntu.json`: the release, the image's file name, its SHA-256 and when it was pinned. One devvm pins at a time, holding `~/.local/share/devvm/images/locks/ubuntu`, 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.
|
||||
|
||||
devvm downloads the image itself, into `~/.local/share/devvm/images/ubuntu/<sha256>.img`, and gives Lima that file, so Lima downloads nothing. The download goes through the company proxy, when there is one ([a company proxy](../contributing/design.md#a-company-proxy)), and it trusts the CAs in `~/.config/devvm/ca` as well as this machine's own, as the lookups of the dated releases do. A server whose certificate this machine doesn't trust fails it at once (`ubuntu_untrusted`), naming the folder of your CAs, and so does a certificate from a CA it trusts that's for another host, out of date or not valid yet (`ubuntu_bad_certificate`), 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's reason (`ubuntu_certificate_invalid`). These are `fetch.Untrusted`, `fetch.BadCertificate` and `fetch.Unverified`, which the lookups ask too, so each names the same cause, and devvm's own mise asks `fetch.Untrusted`.
|
||||
|
||||
What came stays in `<sha256>.img.part` 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 (`ubuntu_download_failed`), as do 100 tries in all, however much each brought. A failure that trying again in the same run won'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's gone fails with `ubuntu_release_gone`, which names `devvm rebuild base`, 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'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'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's, and a file that doesn't check out is downloaded again from nothing once before it fails (`ubuntu_image_checksum`).
|
||||
|
||||
One devvm downloads at a time, holding `~/.local/share/devvm/images/locks/ubuntu-image`, and another waits for it under a status line (`ubuntu_image_waiting`). Before it downloads, devvm takes the image from Lima's own download cache when that holds it with the pin'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's address. devvm copies the file into a new file of its own, `<sha256>.img.import`, which only you can read, hashes the bytes as it writes them and keeps the copy only once they're the pin's. It never links to Lima's file or changes Lima's cache. Lima 2.3 and newer check the file devvm gives it against the pin's SHA-256 too, before they copy the file into the VM's disk, and refuse one that doesn't match. A `file://` address, which only a test build's `DEVVM_UBUNTU_URL` can name, goes the same way, read from disk, and devvm refuses any other address that isn't https.
|
||||
|
||||
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 `--from` base's conversion boots the pinned image too, and pins one only when none is.
|
||||
|
||||
An image devvm pinned in the same run that doesn't boot, so that the backend fails to start base's build VM, gets one second chance. devvm says so (`origin_no_boot`), 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's doesn't stop new machines' 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't boot stays, stopped, as a [failed build](../using/troubleshooting.md#a-build-fails) does.
|
||||
|
||||
The pin is part of base's recipe, so base's key hashes the release, the file and its SHA-256, and a new pin makes a new base. base'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's gone can still be used, but building it again needs Lima's cached copy of the image.
|
||||
The pin is part of base's recipe, so base's key hashes the release, the file and its SHA-256, and a new pin makes a new base. base'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's gone can still be used, but building it again needs devvm's copy of the image, or Lima's. `devvm gc --caches` deletes devvm's copies that no image's record names and that aren't pinned now, with a stopped download's `.part` and a stopped copy's `.import`, and those of any image once its `.img` is there, unless one changed in the last hour. When devvm can't read the pin, `devvm gc --caches` fails rather than delete a copy the pin may name.
|
||||
|
||||
`devvm gc --caches` deletes an entry of Lima's cache only when devvm's own state shows that a build of devvm's left it there and none needs it now: an image'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't changed in the last hour. An entry that no record names stays, because the user'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's own templates name, which devvm reads from the `share/lima/templates` folder beside the `limactl` on `PATH`, as `limactl start` with Lima's templates starts from it, and devvm frees no entry of Lima's when it can't read them, with a line in the run log that names the folder and why.
|
||||
|
||||
## Base's settings and pins
|
||||
|
||||
Base'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 ([base's size](#bases-size)). On Lima, `assets/base.yaml` holds base's other VM settings. `assets/layers/base.sh` installs base, and the optional [features](../using/customizing.md) you chose follow it.
|
||||
Base'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 ([base's size](#bases-size)). On Lima, base's Lima template holds base's other VM settings. Base's script installs base, and the optional [features](../using/customizing.md) you chose follow it.
|
||||
|
||||
Each download in `assets/layers/base.sh` is pinned to a version and a SHA-256 at the top of the script, and the build fails if a checksum doesn't match. Each feature pins its downloads in the same way, at the top of its script, `assets/features/<name>.sh` in the repo, which is built into devvm. apt's packages are pinned per image key, as [base's packages](#bases-packages) describes.
|
||||
Each download in base'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'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 ([the packages](../contributing/structure.md#the-packages) has where each script is). apt's packages are pinned per image key, as [base's packages](#bases-packages) describes.
|
||||
|
||||
### The scripts' prelude
|
||||
|
||||
`assets/prelude.sh` comes first in each script that a build runs with bash: `assets/layers/base.sh` and `apt.sh`, the built-in layers and features, your own layers, `assets/shared-tools/build.sh`, and a `--from` conversion's `assets/oci/build.sh`. devvm puts it before the script on the script's standard input, and for the conversion, in the copy of `build.sh` that it writes into the conversion's own temporary folder, so no copy of either is kept anywhere else. The prelude sets no shell options and runs only `uname` and `command -v`. It gives the script three things:
|
||||
devvm's prelude, `prelude.sh`, comes first in each script that a build runs with bash: `base.sh` and `apt.sh`, the built-in layers and features, your own layers, the shared tools' `build.sh`, and a `--from` conversion's `build.sh`. devvm puts it before the script on the script's standard input, and for the conversion, in the copy of `build.sh` that it writes into the conversion's own temporary folder, so no copy of either is kept anywhere else. The prelude sets no shell options and runs only `uname` and `command -v`. It gives the script three things:
|
||||
|
||||
- `$devvm_arch` is the VM's architecture as the pins name it, `arm64` or `amd64`. On any other architecture, the prelude stops the script.
|
||||
- `$devvm_libc` is the VM's C library, `musl` on Alpine, where `apk` is, and `gnu` everywhere else.
|
||||
@@ -103,19 +121,19 @@ Your own layer gets the prelude in the same way, so it can pin its downloads as
|
||||
|
||||
## Base's packages
|
||||
|
||||
base's recipe runs `assets/layers/apt.sh begin` as root before `base.sh`, and `apt.sh end` after the last feature. Both are steps of the recipe, so base's key hashes the script. What the build gives the script in `/var/cache/devvm/packages/in` decides where apt's packages come from:
|
||||
base's recipe runs `apt.sh begin` as root before `base.sh`, and `apt.sh end` after the last feature. Both are steps of the recipe, so base's key hashes the script. What the build gives the script in `/var/cache/devvm/packages/in` decides where apt's packages come from:
|
||||
|
||||
- **A first build of a key records them.** devvm sends `in/mirrors`, which holds the mirror that [`ubuntu-mirror`](../using/settings.md#an-ubuntu-mirror) sets, or nothing. `apt.sh begin` points each of the image's sources at an apt `mirror+file:` list of that mirror and then the source's own archive (`archive.ubuntu.com`, or `ports.ubuntu.com` on arm64), so apt tries them in that order, and it keeps every package it downloads. apt also installs phased updates (`APT::Get::Always-Include-Phased-Updates`), 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's signature with Ubuntu's archive key, which the image has, whichever mirror answers. At the end, `apt.sh end` moves each downloaded package to `out/<sha256>.deb` and writes its entry from apt's package lists, which apt checked against that signature, to `out/Packages`. The script fails the build when the lists have no entry with the file's SHA-256. It also copies each `InRelease` file and package list that apt used to `out/<n>.InRelease` or `out/<n>.Packages`, so devvm can check them on this machine. apt keeps those lists uncompressed while base builds (`Acquire::GzipIndexes "false"`), as they're signed.
|
||||
- **Every later build of the key replays them.** devvm sends the files the key recorded, from its cache, and `in/Packages`, their entries, each naming its file. `apt.sh begin` moves the image's sources aside and gives apt only that folder, so `base.sh` and the features install exactly what the first build did, with no network for them.
|
||||
- **A `--from` base gets neither.** Its packages come from the container image's own sources as they are when it builds, and they aren't pinned.
|
||||
|
||||
Both ends put the image's own sources back, remove devvm's apt settings, empty apt'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 `sudo apt update`, and each layer's recipe starts with `apt.sh lists`, as root, which fetches them from the image's own sources when there are none, so a layer's script installs as it would on any Ubuntu. `apt.sh` turns apt's retries off and makes a source that sends nothing for 30 seconds fail, and when no source answers, it exits 75, which the backend reports as `build_sources_unreachable`, not as a script that failed.
|
||||
Both ends put the image's own sources back, remove devvm's apt settings, empty apt'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 `sudo apt update`, and each layer's recipe starts with `apt.sh lists`, as root, which fetches them from the image's own sources when there are none, so a layer's script installs as it would on any Ubuntu. `apt.sh` makes a source that sends nothing for 30 seconds fail. While it fetches the package lists, it turns apt's retries off, and when no source answers, it exits 75, which the backend reports as `build_sources_unreachable`, not as a script that failed. Once a source has answered, apt tries a package'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 (`Acquire::Languages "none"`, and the `DEP-11` and `CNF` targets off), which is about a third less than an update fetches, and the image keeps none of them.
|
||||
|
||||
The backend sends the build'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 `out/` and deletes the folder (`backend.Packages`). On Lima, both run as root over `limactl shell`. What comes back is the build VM's, so devvm checks it before it keeps anything (`packages_refused`). It takes only regular files named `Packages`, `<64 hex digits>.deb`, `<n>.InRelease` or `<n>.Packages`, each package'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 `InRelease` 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.
|
||||
The backend sends the build'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 `out/` and deletes the folder, which is the backend's packages role ([how a backend plugs in](../contributing/extending.md#how-a-backend-plugs-in)). On Lima, both run as root over `limactl shell`. What comes back is the build VM's, so devvm checks it before it keeps anything (`packages_refused`). It takes only regular files named `Packages`, `<64 hex digits>.deb`, `<n>.InRelease` or `<n>.Packages`, each package'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 `InRelease` 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.
|
||||
|
||||
devvm doesn't take the build VM's word for the entries, because anything with root in that VM could write them. It checks each `InRelease` file's clearsigned signature itself, in Go, against Ubuntu's archive key, which devvm's own files hold (`assets/layers/ubuntu-archive.gpg`, fingerprint `F6ECB3762474EDA9D21B7022871920D1991BC93C`), and refuses one that doesn't check out or isn't one of the suites an Ubuntu 26.04 image's sources name: `resolute`, `resolute-updates`, `resolute-security` and `resolute-backports`, never `resolute-proposed`. It tries at most 4 signatures in each file, because each one hashes the whole file. It also refuses an `InRelease` whose `Date:` is older than the archive state the pinned cloud image was built from, because Ubuntu's `InRelease` files carry no `Valid-Until`, so a mirror that stopped updating still serves validly signed ones. The release pocket, `resolute`, which Ubuntu stopped changing at release, must be dated no earlier than that day, 2026-04-23 (`ubuntu.Released`). Every other pocket (`resolute-updates`, `resolute-security`, `resolute-backports`) must be dated no more than a day before the pinned release's date (`release-YYYYMMDD`). devvm names the mirror that [`ubuntu-mirror`](../using/settings.md#an-ubuntu-mirror) sets (`packages_stale_mirror`), or Ubuntu's archive when none is set (`packages_stale`). devvm compares the lists with the cloud image's date, not with today's, so a mirror that's behind, or one that's lying, can't serve lists older than that, but a mirror that fell behind after that date can still give base packages older than Ubuntu's, which is why [`ubuntu-mirror`](../using/settings.md#an-ubuntu-mirror) should name only a mirror you trust to keep up. Each package list must have the SHA-256 and size that a verified `InRelease` gives for one of its `Packages` lists, which devvm checks before it reads the list, and each package's SHA-256 must be in one of those lists, as the same package, version, architecture and size that apt's entry says. devvm then keeps the archive's own entry for the package, not apt's.
|
||||
devvm doesn't take the build VM's word for the entries, because anything with root in that VM could write them. It checks each `InRelease` file's clearsigned signature itself, in Go, against Ubuntu's archive key, which devvm's own files hold (fingerprint `F6ECB3762474EDA9D21B7022871920D1991BC93C`), and refuses one that doesn't check out or isn't one of the suites an Ubuntu 26.04 image's sources name: `resolute`, `resolute-updates`, `resolute-security` and `resolute-backports`, never `resolute-proposed`. It tries at most 4 signatures in each file, because each one hashes the whole file. It also refuses an `InRelease` whose `Date:` is older than the archive state the pinned cloud image was built from, because Ubuntu's `InRelease` files carry no `Valid-Until`, so a mirror that stopped updating still serves validly signed ones. The release pocket, `resolute`, which Ubuntu stopped changing at release, must be dated no earlier than that day, 2026-04-23, which devvm's code records. Every other pocket (`resolute-updates`, `resolute-security`, `resolute-backports`) must be dated no more than a day before the pinned release's date (`release-YYYYMMDD`). devvm names the mirror that [`ubuntu-mirror`](../using/settings.md#an-ubuntu-mirror) sets (`packages_stale_mirror`), or Ubuntu's archive when none is set (`packages_stale`). devvm compares the lists with the cloud image's date, not with today's, so a mirror that's behind, or one that's lying, can't serve lists older than that, but a mirror that fell behind after that date can still give base packages older than Ubuntu's, which is why [`ubuntu-mirror`](../using/settings.md#an-ubuntu-mirror) should name only a mirror you trust to keep up. Each package list must have the SHA-256 and size that a verified `InRelease` gives for one of its `Packages` lists, which devvm checks before it reads the list, and each package's SHA-256 must be in one of those lists, as the same package, version, architecture and size that apt's entry says. devvm then keeps the archive's own entry for the package, not apt's.
|
||||
|
||||
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's, and record an older version than `resolute-updates` or `resolute-security` has. A recording must give back the `InRelease` files of `resolute-updates` and `resolute-security` with lists for the architectures whose lists have the recorded packages, such as `binary-arm64`, so another archive's `InRelease`, such as `archive.ubuntu.com`'s on arm64, where `ports.ubuntu.com` has the lists, doesn't count. For each `InRelease` it gives back, it must also give back every package list that the file gives for those architectures, in every component (`main`, `restricted`, `universe` and `multiverse`). An empty list is the one exception, because it lists nothing. When one is missing, devvm names the suite and keeps nothing (`packages_lists_missing`). devvm then refuses a recorded package when the release pocket's list, `resolute-updates`' or `resolute-security`'s has a newer version of it for that architecture, and it names the package, both versions and the suite (`packages_not_newest`). `resolute-backports` doesn't count, because apt installs its packages only when you ask for them (its `InRelease` says `NotAutomatic`). devvm orders versions as `dpkg --compare-versions` does, in Go (`ubuntu.CompareVersions`): the epoch first, then the upstream version, then the Debian revision, with letters before other characters and `~` before everything, even the end, so `1.0~rc1` is older than `1.0`.
|
||||
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's, and record an older version than `resolute-updates` or `resolute-security` has. A recording must give back the `InRelease` files of `resolute-updates` and `resolute-security` with lists for the architectures whose lists have the recorded packages, such as `binary-arm64`, so another archive's `InRelease`, such as `archive.ubuntu.com`'s on arm64, where `ports.ubuntu.com` has the lists, doesn't count. For each `InRelease` it gives back, it must also give back every package list that the file gives for those architectures, in every component (`main`, `restricted`, `universe` and `multiverse`). An empty list is the one exception, because it lists nothing. When one is missing, devvm names the suite and keeps nothing (`packages_lists_missing`). devvm then refuses a recorded package when the release pocket's list, `resolute-updates`' or `resolute-security`'s has a newer version of it for that architecture, and it names the package, both versions and the suite (`packages_not_newest`). `resolute-backports` doesn't count, because apt installs its packages only when you ask for them (its `InRelease` says `NotAutomatic`). devvm orders versions as `dpkg --compare-versions` does, in its own Go code: the epoch first, then the upstream version, then the Debian revision, with letters before other characters and `~` before everything, even the end, so `1.0~rc1` is older than `1.0`.
|
||||
|
||||
A recording that gives back no packages needs no lists. devvm writes the files into a folder of the build's own in the cache while it checks them, and once the image is built, it moves each into the cache, `~/.local/share/devvm/packages/<sha256>.deb`, and writes the key's set, `~/.local/share/devvm/packages/sets/<key>.json`: each package'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's copy and notes that in the run log. That happens before the image's record, under a lock, `~/.local/share/devvm/images/locks/packages`, and a build that fails keeps nothing.
|
||||
|
||||
@@ -133,15 +151,15 @@ base also drops the server extras that Ubuntu's cloud image comes with, which ar
|
||||
|
||||
## The desktop layer
|
||||
|
||||
The built-in [`desktop` layer](../using/images.md#desktop)'s script is `assets/layers/desktop.sh`, and its allowlist is `assets/layers/desktop.policy`, which has no rules, because the layer downloads nothing of its own and its packages come from the distribution's archive, which base's allowlist has. base's image has no package lists, so the layer's `apt.sh lists` step fetches them first, and its packages are the archive's as they are when the layer builds, which aren't pinned. On `--from alpine`, the script installs Alpine's own packages, which aren't pinned either. Besides Xfce and TigerVNC, the script writes `/usr/local/bin/devvm-desktop`, which [`devvm desktop`](desktop.md#in-the-vm) 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.
|
||||
The built-in [`desktop` layer](../using/images.md#desktop)'s script is `desktop.sh`, and its allowlist, `desktop.policy`, has no rules, because the layer downloads nothing of its own and its packages come from the distribution's archive, which base's allowlist has. base's image has no package lists, so the layer's `apt.sh lists` step fetches them first, and its packages are the archive's as they are when the layer builds, which aren't pinned. On `--from alpine`, the script installs Alpine's own packages, which aren't pinned either. Besides Xfce and TigerVNC, the script writes `/usr/local/bin/devvm-desktop`, which [`devvm desktop`](desktop.md#in-the-vm) 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.
|
||||
|
||||
## The docker layer
|
||||
|
||||
The built-in [`docker` layer](../using/images.md#built-in-layers)'s script is `assets/layers/docker.sh`, embedded in devvm, and its [allowlist](../safety/network.md#allowlists) is `assets/layers/docker.policy`. The script pins the checksum of the signing key of Docker's apt repository and each package's version at the top. On `--from alpine`, it installs Alpine's own packages, which aren't pinned. Running Docker's engine in a VM is a backend feature of its own, `docker-layer` ([features](backends.md#features)).
|
||||
The built-in [`docker` layer](../using/images.md#built-in-layers)'s script is `docker.sh`, embedded in devvm, and its [allowlist](../safety/network.md#allowlists) is `docker.policy`. The script pins the checksum of the signing key of Docker's apt repository and each package's version at the top. On `--from alpine`, it installs Alpine's own packages, which aren't pinned. Running Docker's engine in a VM is a backend feature of its own, `docker-layer` ([features](backends.md#features)).
|
||||
|
||||
## The nix layer
|
||||
|
||||
The built-in [`nix` layer](../using/images.md#nix)'s script is `assets/layers/nix.sh`, and its allowlist is `assets/layers/nix.policy`. The script pins Nix's release tarball, the direnv binary and nix-direnv's `direnvrc` at the top, each with its version and SHA-256, which are per architecture for Nix and direnv, and fetches them with `devvm-fetch`. `scripts/bump.sh nix direnv nix-direnv` moves them. Nix's version is the one nixos.org's installer fetches, at least 2.35.3, which fixes the scripted installer's store ownership (GHSA-hf6w-2rg9-v84g) and the daemon's store corruption through `repair` (CVE-2026-110450). Nix's newer releases come with another installer, from artifacts.nixos.org, so the layer's pins change shape when it moves to one of them.
|
||||
The built-in [`nix` layer](../using/images.md#nix)'s script is `nix.sh`, and its allowlist is `nix.policy`. The script pins Nix's release tarball, the direnv binary and nix-direnv's `direnvrc` at the top, each with its version and SHA-256, which are per architecture for Nix and direnv, and fetches them with `devvm-fetch`. The repo's bump script moves them ([updating pinned versions](../contributing/maintaining.md#updating-pinned-versions)). Nix's version is the one nixos.org's installer fetches, at least 2.35.3, which fixes the scripted installer's store ownership (GHSA-hf6w-2rg9-v84g) and the daemon's store corruption through `repair` (CVE-2026-110450). Nix's newer releases come with another installer, from artifacts.nixos.org, so the layer's pins change shape when it moves to one of them.
|
||||
|
||||
The script runs the tarball's own installer as `install --daemon --yes --no-channel-add`, which copies the tarball's store into `/nix`, downloading nothing, makes the `nixbld` build users and, under systemd, starts `nix-daemon`. On OpenRC, which a base `--from alpine` runs, the script adds a service of devvm's, `/etc/init.d/nix-daemon`, to the default runlevel and starts it, and before the install it adds Alpine's `xz`, unpinned, which GNU tar needs for the tarball. Nix'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 `nix` command and keep `trusted-users = root`, so only root can choose caches and signing keys. They also set `sandbox = true` and `sandbox-fallback = false`, so a build fails where the kernel can'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's proxy into the image, so the script runs it without them. It points Nix at the system's CAs, which hold devvm's and yours. After the install, the script checks that every path in the store is root's, and it fails otherwise.
|
||||
|
||||
@@ -153,8 +171,8 @@ The daemon doesn't read `/etc/environment`, so the [VM's setup](network.md#the-v
|
||||
|
||||
With `--from`, devvm turns the container image into a disk in a throwaway VM, `devvm-oci-build`, which it makes from Ubuntu's cloud image with `base.yaml`'s settings and base's size. No Docker is needed:
|
||||
|
||||
1. [crane](https://github.com/google/go-containerregistry/tree/main/cmd/crane) downloads exactly the [digest](#digests) in `base`'s key, for this machine's architecture, and flattens its layers. crane is pinned like every download: its version and SHA-256 are at the top of `assets/oci/build.sh`, checked with `sha256sum`.
|
||||
2. `assets/oci/bootify.sh`, 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 `bootify.sh` first removes a user of the image's that has it, such as Ubuntu's own `ubuntu` (uid 1000, the uid a Linux host's first user usually has).
|
||||
1. [crane](https://github.com/google/go-containerregistry/tree/main/cmd/crane) downloads exactly the [digest](#digests) in `base`'s key, for this machine's architecture, and flattens its layers. crane is pinned like every download: its version and SHA-256 are at the top of the conversion's `build.sh`, checked with `sha256sum`.
|
||||
2. `bootify.sh`, 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 `bootify.sh` first removes a user of the image's that has it, such as Ubuntu's own `ubuntu` (uid 1000, the uid a Linux host's first user usually has).
|
||||
3. `mke2fs` writes the image's files into a raw ext4 disk, and `base` grows it to base's 100 GiB disk.
|
||||
|
||||
`build.sh` also writes down the image's C library, from its `/etc/os-release`, and for a glibc image, its glibc version, which `getconf GNU_LIBC_VERSION` prints in a chroot of the image. devvm checks both, keeps them in the record of `base` and of every image on it (`libc` and `glibc`), and checks each shared tool against that glibc version ([building tools](#building-tools)).
|
||||
@@ -185,19 +203,23 @@ When the registry doesn't give devvm the image ([images only Docker has](../usin
|
||||
|
||||
## Versions
|
||||
|
||||
devvm doesn't pin the shared tools' versions ([shared tools](../using/images.md#shared-tools)). Instead, `assets/shared-tools/mise.toml` 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's newest release and writes that into the tools lock, `~/.local/share/devvm/mise.lock`, with each download's checksum for every platform that VMs run (Linux, with glibc and with musl). Builds install exactly the lock's versions and check them against those checksums. Resolving needs this machine to be online once, and until it has been, devvm says so (`tools_need_resolve`).
|
||||
devvm doesn't pin the shared tools' versions ([shared tools](../using/images.md#shared-tools)). Instead, the shared tools' `mise.toml`, 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's newest release and writes that into the tools lock, `~/.local/share/devvm/mise.lock`, with each download's checksum for every platform that VMs run (Linux, with glibc and with musl). Builds install exactly the lock's versions and check them against those checksums. Resolving needs this machine to be online once, and until it has been, devvm says so (`tools_need_resolve`).
|
||||
|
||||
mise's registry decides where a tool comes from, and a mise release can change its choice, so `assets/shared-tools/mise.toml` names the backend of every tool that isn't one of mise's own `core:` tools in its `[tool_alias]` table. Claude Code, Codex, pnpm and uv come from their GitHub releases through [aqua](https://aquaproj.github.io/), and opencode comes from its GitHub releases directly (`github:anomalyco/opencode`), because only that gives musl VMs opencode's own musl build. pi comes from its GitHub releases directly too (`github:earendil-works/pi`), 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's. Its releases have no musl build, so mise locks the glibc download for musl as well, and `tools.HasBuilds` refuses pi for a musl VM before any build (`tool_glibc_only`), as `image.ToolDef.GlibcOnly` marks it. Without the alias, mise'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's mise config gets the same `[tool_alias]` table, so the VM's mise finds each tool where its image came from.
|
||||
mise's registry decides where a tool comes from, and a mise release can change its choice, so that `mise.toml` names the backend of every tool that isn't one of mise's own `core:` tools in its `[tool_alias]` table. Claude Code, Codex, pnpm and uv come from their GitHub releases through [aqua](https://aquaproj.github.io/), and opencode comes from its GitHub releases directly (`github:anomalyco/opencode`), because only that gives musl VMs opencode's own musl build. pi comes from its GitHub releases directly too (`github:earendil-works/pi`), 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'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 (`tool_glibc_only`), because the shared tools' registry marks it as glibc only. Without the alias, mise'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's mise config gets the same `[tool_alias]` table, so the VM's mise finds each tool where its image came from.
|
||||
|
||||
The resolving runs on this machine with a mise of devvm's own. That mise is a pinned release, which devvm downloads once into `~/.local/share/devvm/cache/mise/<version>` and checks against its SHA-256 before it runs it (`mise_checksum`). 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 (`mise_download_failed`). 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 `cache/mise/<version>` holds only the binary. `devvm gc` deletes the folders of other versions (`Versions.StaleMise`), unless one changed in the last hour.
|
||||
The resolving runs on this machine with a mise of devvm's own. That mise is a pinned release, which devvm downloads once into `~/.local/share/devvm/cache/mise/<version>` as its `.tar.gz`, a third of the binary's size, and checks against its SHA-256 before it takes the binary out and runs it (`mise_checksum`). 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 (`mise_download_failed`). One devvm downloads it at a time, holding `~/.local/share/devvm/cache/mise/download.lock`, and another waits for it under a status line (`mise_waiting`) 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 `cache/mise/<version>` holds only the binary. `devvm gc` deletes the folders of other versions, unless one changed in the last hour.
|
||||
|
||||
Sometimes a tool's newest version isn'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. devvm then takes the newest of the next five older versions that is published everywhere, and says so (`tool_stepped_back`). When none of them is, devvm says that too (`tool_no_download`). The next check tries the newest version again.
|
||||
A new VM's tools resolve while its image builds, as neither needs the other. The resolve starts once an image starts to build, after the build'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' lines in the run log with `[resolve]`. 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 (`resolving_tools`). When the resolve fails, devvm says so once, after the build, and the launch fails, and when the build fails, devvm stops the resolve.
|
||||
|
||||
A new VM gets the lock'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 (`tools_check_failed`). When `assets/shared-tools/mise.toml` 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 `devvm gc` deletes them.
|
||||
Sometimes a tool's newest version isn'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'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's missing it. A tool whose newest version has no download on any platform gets no entry, and resolving fails (`tools_resolve_failed`). For a tool without every download, devvm takes the newest of the next five older versions that is published everywhere, and says so (`tool_stepped_back`), 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 (`tool_no_download`). The next check tries the newest version again.
|
||||
|
||||
A new VM gets the lock'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 (`tools_check_failed`). When the shared tools' `mise.toml` 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 `devvm gc` deletes them.
|
||||
|
||||
## Building tools
|
||||
|
||||
devvm builds the tool images that a VM's shared tools need when it makes the VM, after its image, and when `devvm tools add`, `devvm tools update` or `devvm update` gives a VM new ones, unless the share already has them (`Launch.buildTools`). `devvm build` builds images alone, never tool images. Each tool image builds in a throwaway VM of its own, one after another, which devvm makes from a base image and confines like an image build. Which base it makes the VM from depends on the C library the images are for, because any VM whose tools need an image's key mounts it:
|
||||
devvm builds the tool images that a VM's shared tools need when it makes the VM, after its image, and when `devvm tools add`, `devvm tools update` or `devvm update` gives a VM new ones, unless the share already has them. `devvm build` 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'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's running VMs have, and as many as the backend's disks have room for, each build VM counted as a whole copy of base ([free space](#free-space)). When the backend can't list its VMs, they build one at a time. Each build VM running at once has a name of its own on Lima, `devvm-tools-build` and then `devvm-tools-build-2` to `devvm-tools-build-4`, and the first one's build deletes what a killed run left in the others that this run doesn't use. A build that runs alone gets base's size.
|
||||
|
||||
Side by side, one status line covers the builds (`building_tools_together`), and each line of a build's commands in the run log starts with its tool's name, such as `[node]`. The first failure stops the others, which are cancelled, and is what devvm reports, with the end of that tool's own lines in the run log rather than the others' that came after. Every write of a build's commands to the run log starts with its tool's name, a line that a progress bar's `\r` ends included, so no build can pass a line off as another's. A failed build's VM is deleted once devvm has shown that end, when devvm takes the share's lock again for it. While another devvm holds that lock, whether for a build, `devvm gc` 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 `devvm gc` does once it holds the share's lock, without asking but naming each one (`tools_build_vms_deleted`), because a build VM holds nothing of yours. That lock is the data folder's, so two devvms with data folders of their own and one Lima home (`DEVVM_LIMA_HOME`) don't keep out each other's builds: a tools build or `devvm gc` in one can delete a build VM that the other is still using, and that build fails until it's run again. Don't build tools or run `devvm gc` 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's key mounts it:
|
||||
|
||||
- **glibc:** devvm's own base from Ubuntu's cloud image, on the VM's backend, whatever base the VM has. A VM on a `--from` Debian or Ubuntu image gets images built there too, so the container image's code never runs in the build of images that other VMs mount. When that base isn't built yet, devvm says so (`tools_need_own_base`) and builds it first, pinning the cloud image on its first build as usual ([Ubuntu's cloud image](#ubuntus-cloud-image)).
|
||||
- **musl:** the VM's own `--from` base, as it is now, because musl builds need Alpine. Its key hashes that base's digest, so the images are only ever another VM's on the same container image. `devvm tools add`, `devvm tools update` and `devvm update` build that base first, looking up its digest, so the keys they work out are those of the base that the images build in.
|
||||
@@ -206,13 +228,13 @@ Before a build, devvm reads the record of the base it's about to clone and refus
|
||||
|
||||
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'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 `readelf`, which base's `build-essential` installs, and writes the newest `GLIBC_` version they name into `<image>.glibc`, or nothing when none needs one. It leaves out folders named `testdata`, because Go's has ELF files from other systems that nothing runs. devvm takes that file only as a plain file holding one version (`tool_bad_output`) and keeps the version in the image's record (`glibc`). Before it gives a VM its tools, devvm compares each image's version with the glibc of the VM's `--from` base, and an older base refuses the tool, naming it and both versions (`tool_needs_glibc`). It checks the same way when `devvm tools add`, `devvm tools update` or `devvm update` gives an existing VM tools, against the glibc its state recorded when it was made. A base from Ubuntu's cloud image has no glibc version in its record, so its tools aren'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's lock, `~/.local/share/devvm/tools.lock`, outside the share that VMs mount. Another devvm waits for it under a status line (`share_waiting`) 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.
|
||||
|
||||
Each tool image is named `<tool>-<version>-<key>.erofs`. Its key hashes the tool's entry in the tools lock (its version, its downloads and their checksums), `assets/shared-tools/build.sh` with [the prelude](#the-scripts-prelude) before it, the `[settings]` table of `assets/shared-tools/mise.toml`, the version of mise that `assets/layers/base.sh` pins, the C library the image is built for, the base it builds in (devvm's own for glibc, and for musl the digest of the `--from` base), and the backend's format. The build VM is made from base, so base's mise is the one that installs the tool, and a new mise builds every tool image it installs again. A tool that `build.sh` installs itself, without mise, doesn't have mise's version in its key, because mise doesn't install it: rustup installs rust, and dotnet comes from Microsoft's own archive ([dotnet's download](#dotnets-download)). The tests check that `base.sh` 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'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 `python.compile`, 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's format is `build.sh`'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's musl, gets an image of its own, and so would a VM on another backend. Every glibc image's key names devvm's own base, because glibc images build only there, so a VM on Ubuntu's base and one on a `--from` Debian image share them. A musl image's key has its base's digest, so when the container image's tag moves to a new image, its VMs' next tools build again in the new base. When the lock has no download of a tool for the VM's platform, devvm doesn't build it and says to try again later (`tool_unbuilt`).
|
||||
Each tool image is named `<tool>-<version>-<key>.erofs`. Its key hashes the tool's entry in the tools lock (its version, its downloads and their checksums), the shared tools' `build.sh` with [the prelude](#the-scripts-prelude) before it, the `[settings]` table of their `mise.toml`, the version of mise that `base.sh` pins, the C library the image is built for, the base it builds in (devvm's own for glibc, and for musl the digest of the `--from` base), and the backend's format. The build VM is made from base, so base's mise is the one that installs the tool, and a new mise builds every tool image it installs again. A tool that `build.sh` installs itself, without mise, doesn't have mise's version in its key, because mise doesn't install it: rustup installs rust, and dotnet comes from Microsoft's own archive ([dotnet's download](#dotnets-download)). The tests check that `base.sh` 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'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 `python.compile`, 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's format is `build.sh`'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's musl, gets an image of its own, and so would a VM on another backend. Every glibc image's key names devvm's own base, because glibc images build only there, so a VM on Ubuntu's base and one on a `--from` Debian image share them. A musl image's key has its base's digest, so when the container image's tag moves to a new image, its VMs' next tools build again in the new base. When the lock has no download of a tool for the VM's platform, devvm doesn't build it and says to try again later (`tool_unbuilt`).
|
||||
|
||||
An image is base and its layers alone, and a VM's shared tools are a list in its state (the `tools` section's `names`) beside its image. `build.Names` refuses a shared tool's name in an image name (`tool_not_layer`), so `devvm build`, `devvm rebuild` and `devvm images rm` refuse one, because shared tools aren't images and their versions come from the lock.
|
||||
An image is base and its layers alone, and a VM's shared tools are a list in its state (the `tools` section's `names`) beside its image. devvm's check of an image name refuses a shared tool's name in it (`tool_not_layer`), so `devvm build`, `devvm rebuild` and `devvm images rm` refuse one, because shared tools aren't images and their versions come from the lock.
|
||||
|
||||
### dotnet's download
|
||||
|
||||
mise resolves dotnet's version like any tool's, but it locks the version alone, without a download, because its installer runs Microsoft's install script, which nothing pins. So devvm adds each platform's SDK archive to the lock itself (`withSDKDownloads` in `internal/tools/dotnet.go`). For each dotnet entry that lacks a platform's download, it fetches the channel's list of releases, `https://builds.dotnet.microsoft.com/dotnet/release-metadata/<channel>/releases.json`, over HTTPS and capped at 32 MB, and it records that platform's `dotnet-sdk-<rid>.tar.gz` with its SHA-512. It keeps a file only when its URL is under `https://builds.dotnet.microsoft.com/dotnet/` and its hash is 128 hex digits, and a version that Microsoft doesn't list gets no download, so devvm doesn't build it. The image's key hashes that lock entry, its URLs and checksums included, as it does every tool's.
|
||||
mise resolves dotnet's version like any tool's, but it locks the version alone, without a download, because its installer runs Microsoft's install script, which nothing pins. So devvm adds each platform's SDK archive to the lock itself ([the packages](../contributing/structure.md#the-packages) names the code). For each dotnet entry that lacks a platform's download, it fetches the channel's list of releases, `https://builds.dotnet.microsoft.com/dotnet/release-metadata/<channel>/releases.json`, over HTTPS and capped at 32 MB, and it records that platform's `dotnet-sdk-<rid>.tar.gz` with its SHA-512. It keeps a file only when its URL is under `https://builds.dotnet.microsoft.com/dotnet/` and its hash is 128 hex digits, and a version that Microsoft doesn't list gets no download, so devvm doesn't build it. The image's key hashes that lock entry, its URLs and checksums included, as it does every tool's.
|
||||
|
||||
`build.sh` gets the URL and the SHA-512 from devvm and downloads the archive with `devvm-fetch`, 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 `dotnet --list-sdks` names the locked version. The SDK's folder is read-only in VMs, so the script puts a `userlocal` marker in its `metadata/workloads/<band>` folder, for its feature band (10.0.400 for 10.0.403), which makes `dotnet workload install` install into `~/.dotnet` in the VM. In the VM, `sync.sh` writes the shared SDK's folder into `/etc/dotnet/install_location`, where .NET'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's `dotnet.isolated`, which gives each SDK a folder of its own, so the shared one runs from its image.
|
||||
|
||||
@@ -220,17 +242,17 @@ The trust root is Microsoft's `releases.json`, read over HTTPS, which is the sam
|
||||
|
||||
## A company's CA in builds
|
||||
|
||||
Build VMs trust the CA certificates in `~/.config/devvm/ca` ([a company's CA](../using/settings.md#a-companys-ca)) while they build, and images never keep them. [Network tiers](network.md#a-companys-ca) describes how devvm reads them and how `assets/guest/ca.sh` installs them.
|
||||
Build VMs trust the CA certificates in `~/.config/devvm/ca` ([a company's CA](../using/settings.md#a-companys-ca)) while they build, and images never keep them. [Network tiers](network.md#a-companys-ca) describes how devvm reads them and how the guest's `ca.sh` installs them.
|
||||
|
||||
A build's `ImageSpec.Trust` holds two scripts made from `ca.sh`, which run as root: `Add`, which writes the certificates from heredocs to a temporary folder and installs them, and `Remove`, which is `ca.sh` without a folder. Each script of the build, `build.sh` of a tools build too, also gets the Trust's `Env` at its start, which exports `trust.Env`, 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's proxy variables. Each backend runs `Add` before anything in the build VM downloads, and `Remove` once the scripts are done, before the VM stops:
|
||||
A build carries two scripts made from `ca.sh`, 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 `ca.sh` without a folder. Each script of the build, `build.sh` of a tools build too, also gets an environment at its start that exports the CAs' 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's proxy variables ([the packages](../contributing/structure.md#the-packages) 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:
|
||||
|
||||
- **Lima:** `Add` runs right after the start, through `sudo sh`, then base's or the layer's scripts, then `Remove`, before the final `sync` and the stop.
|
||||
- **Lima with `--from`:** the conversion's build VM, which is deleted afterwards, also runs `Add`. `oci/build.sh` gets `ca.sh`, from devvm's `guest/` folder mounted read-only, and runs it in the image's chroot with the CAs before `bootify.sh` and without them after it, so that Alpine's `apk` reaches its HTTPS mirrors. The converted base then builds as Lima's does.
|
||||
- **Shared tools:** `ToolsSpec.Trust.Add` runs before `build.sh`. devvm deletes the build VM and keeps only its output folder, so it needs no `Remove`.
|
||||
- **Lima:** the add script runs right after the start, through `sudo sh`, then base's or the layer's scripts, then the remove script, before the final `sync` and the stop.
|
||||
- **Lima with `--from`:** the conversion's build VM, which is deleted afterwards, also runs the add script. `oci/build.sh` gets `ca.sh`, from devvm's `guest/` folder mounted read-only, and runs it in the image's chroot with the CAs before `bootify.sh` and without them after it, so that Alpine's `apk` reaches its HTTPS mirrors. The converted base then builds as Lima's does.
|
||||
- **Shared tools:** the add script runs before `build.sh`. devvm deletes the build VM and keeps only its output folder, so it needs no remove script.
|
||||
|
||||
An image is therefore the same with or without CAs, which is why its key holds none of them, and a tool image's key stays its lock entry, `build.sh`, mise's settings, the C library and the base it builds in. When there are CAs, the build's numbered steps include the two scripts. A layer script that copies the system's bundle elsewhere keeps that copy.
|
||||
|
||||
**End-to-end checks** (`tests/e2e`, `images`): 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's CA files.
|
||||
**End-to-end checks** (the `images` section, [the tests behind it](../contributing/tests.md#the-tests-behind-how-it-works)): 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's CA files.
|
||||
|
||||
## The share
|
||||
|
||||
@@ -254,13 +276,13 @@ Listing never resolves the tools lock. Before there is a lock, no tool image is
|
||||
|
||||
A tool image's name doesn't say which backend and C library it's built for, so `LIBC` comes from its record, which also names the backend that built it, as `devvm images --json` shows in `backend`. An image without a record shows `-`, and has no `backend` or `libc`.
|
||||
|
||||
`devvm images rm` deletes images with their records. `devvm gc` deletes stale and unfinished images with their records, and unused tool images with theirs. With `--tool-images`, it also deletes the current tool images that no VM's state lists and that have a record (`Share.NoVM`), however recently they were built.
|
||||
`devvm images rm` deletes images with their records. `devvm gc` deletes stale and unfinished images with their records, and unused tool images with theirs. With `--tool-images`, it also deletes the current tool images that no VM's state lists and that have a record, however recently they were built.
|
||||
|
||||
A VM'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, `~/.local/share/devvm/making.lock` (`Dirs.MakingLock`, held through `tools.Making`). Each devvm that makes a VM holds it shared from before it picks the VM's tools, and `devvm tools add`, `devvm tools update` and `devvm update` hold it until the VM's state lists the new tools. A new VM's devvm keeps it until just before the VM's first shell. Any number of devvms hold it at once, on every backend, because it's taken before the backend does anything. `devvm gc --tool-images` and retention's `tools.unused-age` (`retainTools`) take it exclusively without waiting (`flock` with `LOCK_NB`), after the share's lock, and hold it until they'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 (`making_waiting`). In a terminal, gc holds it while it asks. Every tool image build (`Share.Build`) runs for one of those devvms, under the making lock, and holds the share's lock while it builds and moves the images in, so gc, which takes the share's lock first, waits for a build in progress and then finds the making lock held until the VM's state lists what it built.
|
||||
A VM'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, `~/.local/share/devvm/making.lock`. Each devvm that makes a VM holds it shared from before it picks the VM's tools, and `devvm tools add`, `devvm tools update` and `devvm update` hold it until the VM's state lists the new tools. A new VM's devvm keeps it until just before the VM's first shell. Any number of devvms hold it at once, on every backend, because it's taken before the backend does anything. `devvm gc --tool-images` and retention's `tools.unused-age` take it exclusively without waiting (`flock` with `LOCK_NB`), after the share's lock, and hold it until they'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 (`making_waiting`). 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's lock while it builds and moves the images in, so gc, which takes the share's lock first, waits for a build in progress and then finds the making lock held until the VM's state lists what it built.
|
||||
|
||||
When a VM is being made, `devvm gc --tool-images` keeps every current tool image that no VM's state lists and names them (`gc_tools_making`), after the same filters, and deletes the rest of its list. Retention deletes no tool images in that run and leaves their records' `idle_since` 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's place inherit it. gc and retention never wait for it, so they can't block, and the order the two locks are taken in can't deadlock: a devvm making a VM takes the making lock and then the share's, and gc and retention take the share's and only try the making lock. Retention at a command's start doesn't wait for the share's lock either: while another devvm holds it, as a tool build does, that run deletes no tool images (`ShareBusy`), and they wait for the next day's run.
|
||||
When a VM is being made, `devvm gc --tool-images` keeps every current tool image that no VM's state lists and names them (`gc_tools_making`), after the same filters, and deletes the rest of its list. Retention deletes no tool images in that run and leaves their records' `idle_since` 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's place inherit it. gc and retention never wait for it, so they can't block, and the order the two locks are taken in can't deadlock: a devvm making a VM takes the making lock and then the share's, and gc and retention take the share's and only try the making lock. Retention at a command's start doesn't wait for the share'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's run.
|
||||
|
||||
When a tool image that a new VM's state lists is gone by the VM's setup, `devvm-tools` can't mount it, the setup fails with `tools_unmounted`, 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 `devvm tools update` builds the missing images, as `Launch.buildTools` builds whatever the share lacks.
|
||||
When a tool image that a new VM's state lists is gone by the VM's setup, `devvm-tools` can't mount it, the setup fails with `tools_unmounted`, 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 `devvm tools update` builds the missing images, as a launch builds whatever the share lacks.
|
||||
|
||||
gc holds the share's lock throughout, so no tool build or `devvm tools update` 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 `current` is for the C library of the base that new VMs get, the musl tool images of an Alpine VM are unused once it's gone, unless you give gc that `--from`.
|
||||
|
||||
@@ -270,4 +292,4 @@ gc also trims the [shared Nix cache](network.md#the-shared-nix-cache) to its cap
|
||||
|
||||
Before each build and each new VM, devvm checks the free space on the disk that will hold it, and [free space](../using/ports-size.md#free-space) lists what each step needs. devvm checks the disk that holds the images and VMs, which is the disk of devvm's Lima home. Shared tool images come out into devvm's data folder, so a tools build also checks that folder'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's data folder is on a small temporary disk, such as a tmpfs `/tmp` on Linux, devvm checks that disk.
|
||||
|
||||
The numbers leave a margin over what each step took when devvm's tests measured the free space before, during and after it. Most of a step's space is only needed while it runs. On Lima on macOS, base took about 1 GiB with Ubuntu's cloud image already downloaded, and downloading the image takes up to another 0.9 GiB. base'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's disk, but a new VM's disk holds only its own changes. A VM then grows as you work in it, and its disk never shrinks.
|
||||
The numbers leave a margin over what each step took when devvm's tests measured the free space before, during and after it. Most of a step's space is only needed while it runs. On Lima on macOS, base took about 1 GiB with Ubuntu's cloud image already downloaded, and downloading the image takes up to another 0.9 GiB, which devvm keeps in its data folder ([Ubuntu's cloud image](#ubuntus-cloud-image)). A tools build counts its build VMs' 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'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's disk, but a new VM's disk holds only its own changes. A VM then grows as you work in it, and its disk never shrinks.
|
||||
@@ -11,7 +11,7 @@ This page explains what devvm's install script downloads and checks, what `devvm
|
||||
The script installs the release it comes with, or the one that `--version` names, which may be a prerelease, such as `0.2.0-rc.1`. Without either, it installs the latest release, never a prerelease. Before it downloads anything, it checks whether Homebrew installed devvm, which it does when `brew` is on `PATH`. The check never runs `brew`, because Homebrew can download its own Ruby when it runs. Instead, the script looks for a version folder in `Cellar/devvm` or `Cellar/devvm-rc`, the kegs of Homebrew's two formulas, in each place Homebrew keeps its Cellar: the folder next to the `brew` it found on `PATH` (`<brew's folder>/../Cellar`), `HOMEBREW_CELLAR` and `HOMEBREW_PREFIX/Cellar` when they're set, and the Cellar in `/opt/homebrew`, `/usr/local` and `/home/linuxbrew/.linuxbrew`. When Homebrew has devvm, the script stops with an error that says to run `brew upgrade devvm`, or `brew uninstall devvm` first, each naming `devvm-rc` for its keg, and exits with status 1, in a terminal or without one. `--force` skips this check. Then it installs in four steps:
|
||||
|
||||
1. It downloads the archive for this machine and the release's `SHA256SUMS`, over HTTPS only. The archive is `devvm-<version>-<os>-<arch>.tar.gz`, where the OS is `darwin` or `linux` and the processor is `arm64` or `amd64`. On Apple silicon, the script picks `arm64` even when it runs under Rosetta.
|
||||
2. It checks the signature of `SHA256SUMS`, then the archive's checksum, as [the signature](#the-signature-and-what-it-trusts) describes. When either check fails, it installs nothing.
|
||||
2. It checks the signatures of `SHA256SUMS`, then the archive's checksum, as [the signature](#the-signature-and-what-it-trusts) describes. When either check fails, it installs nothing.
|
||||
3. It puts devvm, which is one binary with its README, changelog and license, in `~/.local/lib/devvm/<version>`, and links `~/.local/bin/devvm` to it. When `~/.local/bin` isn't on `PATH`, the script says how to add it.
|
||||
4. Unless you pass `--no-deps`, it runs `devvm doctor --json` and offers the [fixes](#devvm-doctor---json) that devvm reports, asking before each one. Then it runs `devvm doctor`, which shows doctor's warnings too, even when nothing is missing.
|
||||
|
||||
@@ -34,7 +34,9 @@ flowchart TD
|
||||
formula["Homebrew's formula,<br>in a repository of its own"] -- "checks its checksum" --> archive
|
||||
```
|
||||
|
||||
The release's `SHA256SUMS` lists the checksums of its archives and of its `install.sh`, and it's signed in `SHA256SUMS.minisig`, made with the maintainer's minisign key. The key's public half is in the script and in `packaging/minisign.pub`. Without [minisign](https://jedisct1.github.io/minisign/) (`brew install minisign`), the script says so, prints the command to check the signature by hand, and checks only the checksum. A script that isn't from a release has no key, and it also checks only the checksum.
|
||||
The release's `SHA256SUMS` lists the checksums of its archives and of its `install.sh`, and minisign signatures beside it say who made it. devvm has room for three release keys, CI's, the co-signer's and a recovery key, and a script that holds them accepts `SHA256SUMS` when any two of them signed it, each in its own file, `SHA256SUMS.ci.minisig`, `SHA256SUMS.cosign.minisig` or `SHA256SUMS.recovery.minisig`. Each signature must check out with its own file's key, two different keys must have made them, and each one's trusted comment, which minisign's global signature covers, must be `devvm-release <version>` for the version being installed, so a `SHA256SUMS` signed for another release is refused. The script also accepts the signature of the old release key, the maintainer's minisign key, which has signed every release so far, in `SHA256SUMS.minisig`, with the trusted comment `devvm <version>`. 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.
|
||||
|
||||
The release keys aren't made yet, so the script holds none, and it checks the old key's signature alone, never downloading the release keys' signatures. Once they're made, their public halves are in the script, and the old key's is in the script that comes with a release. Without [minisign](https://jedisct1.github.io/minisign/) (`brew install minisign`), the script says that only the checksum is checked, which can't tell who made the release, prints the commands to check the signatures by hand, and checks only the checksum. A script that isn't from a release has no old key, so for a release without the release keys' 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.
|
||||
|
||||
The signature catches an archive or a `SHA256SUMS` that someone replaced, which the checksum alone can't. It can't catch a release that was replaced whole, because `curl … | bash` runs the `install.sh` from that same release, key included, so the one-liner trusts GitHub's release files. Homebrew doesn't trust them, because the formula's checksum lives in a repository of its own, and a replaced GitHub release wouldn't match it. You can also download `install.sh`, read it and [check it](#checking-the-install-script) with the key from these docs before you run it, which catches a replaced release too, because that key doesn't come from the release.
|
||||
|
||||
@@ -73,8 +75,8 @@ It warns in these cases:
|
||||
- the disk that devvm's images and VMs go on has less free space than building base needs ([free space](../using/ports-size.md#free-space)),
|
||||
- this machine has less than the 8 GiB of memory or the 4 CPUs that devvm recommends ([requirements](../getting-started/install.md#requirements)),
|
||||
- a line of your policy files isn't a rule, which VMs' proxies skip ([rules](../safety/network.md#rules)),
|
||||
- a VM's state, its `vm.json`, can't be read, or has a section that its package can't read, as every command checks the VM it finds for a folder, which doctor names by the VM, or by its folder when the file can't be read, with the reason, which names the file, and leaves as it is; a value that reads but that a launch refuses, such as a size that isn't a number, isn't checked ([a file devvm can't read](../using/troubleshooting.md#a-file-devvm-cant-read)),
|
||||
- a running VM's proxy runs without its sandbox, or with only part of it, as the proxy wrote in the VM's `run/proxy.confined` once it started, such as on a Linux kernel whose Landlock is older than ABI 6, which doctor names, or a proxy with no such file that another devvm binary started, by its config's `devvm_sha256`, which is an older devvm's one process, without a sandbox. A proxy that this devvm started and that hasn't written the file yet is still starting, and gets no warning ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
- a VM's state, its `vm.json`, can't be read, or has a section that the package which owns that section can'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't be read, and gives the reason, which names the file, and it leaves the file as it is. It doesn't check a value that reads but that a launch refuses, such as a size that isn't a number ([a file devvm can't read](../using/troubleshooting.md#a-file-devvm-cant-read)),
|
||||
- a running VM'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's confined in the VM's `run/proxy.confined` 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 `devvm_sha256` in the proxy's config, because that's an older devvm's single process, which has no sandbox. A proxy that this devvm started and that hasn't written the file yet is still starting, so it gets no warning ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
It also gives a tip, which isn't a warning, when `safe.bareRepository` isn't `explicit` in your global or system git config, or in the files that `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` 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 ([bare repos](../safety/git-protection.md#bare-repos)). doctor only reads the setting.
|
||||
|
||||
@@ -157,11 +159,16 @@ It follows the links of the running binary's path, and it reads only that path,
|
||||
- It's Homebrew's when the path has `Cellar/devvm/` in it, a keg of Homebrew's `devvm` formula, or `Cellar/devvm-rc/`, a keg of its `devvm-rc` formula, which follows prereleases.
|
||||
- Anything else is another way. A devvm whose version isn't a release's, such as a checkout's pseudo-version or `(devel)`, was built from the source. One with a release's version that wasn't set when it was built, as `go install` gives, was installed with `go install`. One that has a release's version is a copy of a release somewhere else.
|
||||
|
||||
### The release key and the signature
|
||||
### The release keys and the signatures
|
||||
|
||||
The release key's public half is built into devvm from `packaging/minisign.pub`, the same file the script gets its key from, so devvm upgrade trusts the key in the devvm you have, never one that comes with the release. A build without that file has no key, and devvm upgrade refuses to install a release with it.
|
||||
The public halves of the three release keys, CI's, the co-signer's and the recovery key's, are built into devvm from `packaging/keys`, the same keys the script holds, once they'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's public half is built in too, from `packaging/minisign.pub`, 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'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.
|
||||
|
||||
devvm checks minisign's signature itself. `SHA256SUMS.minisig` holds a signature and a trusted comment, each signed with the key. devvm accepts only minisign's default, prehashed signature, marked `ED`, which is Ed25519 over the BLAKE2b-512 hash of `SHA256SUMS`, and refuses the legacy one, marked `Ed`, over the file itself. The signature's key ID must be the release key's, and the global signature, Ed25519 over the signature followed by the trusted comment, must verify too. The trusted comment must be `devvm <version>`, as the release script writes it, so a `SHA256SUMS` signed for one release can't stand in for another's. Then the archive for this machine, `devvm-<version>-<os>-<arch>.tar.gz` for the binary's own OS and processor, must match its line in `SHA256SUMS`.
|
||||
devvm checks minisign's signatures itself. Each signature file holds a signature and a trusted comment, each signed with the file's key. devvm accepts only minisign's default, prehashed signature, marked `ED`, which is Ed25519 over the BLAKE2b-512 hash of `SHA256SUMS`, and refuses the legacy one, marked `Ed`, over the file itself. The signature's key ID must be its key's, and the global signature, Ed25519 over the signature followed by the trusted comment, must verify too. devvm accepts `SHA256SUMS` in either of two ways:
|
||||
|
||||
- **Two of the three release keys, in a devvm that has them:** it downloads `SHA256SUMS.ci.minisig`, `SHA256SUMS.cosign.minisig` and `SHA256SUMS.recovery.minisig`, and checks each against its own role's key, never another's. Two of them must check out, with the trusted comment `devvm-release <version>` exactly, and two different keys must have made them, as each role's key is a different key with a different key ID.
|
||||
- **The old release key, while releases bridge from it:** when two of the release keys' signatures don't check out, it downloads `SHA256SUMS.minisig` and checks it against the old key, with the trusted comment `devvm <version>`, 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.
|
||||
|
||||
Either way, a `SHA256SUMS` signed for one release can't stand in for another's, and a signature of one form can't stand in for the other's, because their trusted comments differ. When neither way checks out, devvm upgrade installs nothing, and it says the signatures couldn't be downloaded when none of them could. Then the archive for this machine, `devvm-<version>-<os>-<arch>.tar.gz` for the binary's own OS and processor, must match its line in `SHA256SUMS`.
|
||||
|
||||
The archive is unpacked into `<prefix>/lib/devvm/.<version>.new.<pid>`, 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.
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ An image is a stopped VM in devvm's Lima home, named `devvm-img-<key>`. devvm ma
|
||||
|
||||
devvm sets these in each VM's Lima config:
|
||||
|
||||
- **Mounts:** the project folder (read-write), agents' folders (read-only), and the shared tools at `/mnt/devvm-tools` (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's templates mount. On macOS, where Lima runs VMs with `vz`, the project folder'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's disk anew, as `location: /.vol/<device>/<inode>` with `mountPoint` set to the folder's path. macOS's `/.vol` 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 ([an existing VM](overview.md#an-existing-vm)). 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 "Operation not permitted" in the VM until its next start. QEMU's 9p on Linux has nothing like `/.vol`, so there the mount is by the folder's path, with the cache mode the VM's state records as its `9p: cache:` option: `none` for a new VM, and nothing for a VM whose mode nobody chose, which keeps Lima's `mmap` ([why](design.md#the-9p-cache-on-linux)). The read-only mounts keep Lima's `fscache`, and a build VM's writable output folder gets `none`. The start that changes a VM'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 `/etc/fstab`, and it then checks the mount: a folder left unmounted fails the start ([why](design.md#the-9p-cache-on-linux)). A start that rewrites the mounts, for a folder that moved, another cache mode or other agents' folders, keeps each mount's settings that devvm doesn't set, such as its other 9p and sshfs options, where they differ from Lima's defaults, and leaves the defaults out for Lima to fill in.
|
||||
- **ssh:** agent forwarding on or off, and the host port, which Lima always listens on at `127.0.0.1`. devvm chooses the port and records it, so no other VM's forwarded ports take it, and only from the 17 ports that every browser engine refuses every request, navigations and WebSockets included: the Fetch standard's bad ports from 1024 up that Chromium blocks too (1719, 1720, 1723, 2049, 3659, 4045, 5060, 5061, 6000, 6566, 6665 to 6669, 6697 and 10080). Fetch also lists 4190 and 6679, but Chromium'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 `http://localhost:PORT` would reach a server the VM controls with the cookies of the apps you use on `localhost`, 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 (`ports_ssh_limit`, or `ports_ssh_limit_all` 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 (`ports_ssh_limit_others`). devvm's other host ports, a VM's proxy port and desktop port, are never one of these, and one an older devvm chose moves at the VM's next start. A VM that forwards every port never forwards one of the 17 either; a VM that lists one forwards it, which `devvm ports` and each launch warn of (`ports_ssh_listed`), whatever set the list, and keeps it from VMs' ssh while it runs, as any program on this machine that has one does. A stopped VM keeps its port at its next start while it'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't on the list, as an older devvm chose it. A new port is one no VM's state records, or else one a stopped VM's state records, which that VM gives up, getting another at its own next start. A build VM's port is never the one its clone kept from its image while another is free. The start's one `limactl edit` sets a new port, and the VM's host keys are pinned again, as at every start. A start holds its port, kept or new, for a minute, in `run/ports.ssh-hold` in the VM's folder, as its backend binds it as the start begins, so no other start or build takes it meanwhile. The hold is time-limited: a start whose backend takes longer than that minute to bind the port can lose it to another start that chooses it then, and 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 (`ports_ssh_old`).
|
||||
- **Mounts:** the project folder (read-write), agents' folders (read-only), and the shared tools at `/mnt/devvm-tools` (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's templates mount. On macOS, where Lima runs VMs with `vz`, the project folder'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's disk anew, as `location: /.vol/<device>/<inode>` with `mountPoint` set to the folder's path. macOS's `/.vol` 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 ([an existing VM](overview.md#an-existing-vm)). 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 "Operation not permitted" in the VM until its next start. QEMU's 9p on Linux has nothing like `/.vol`, so there the mount is by the folder's path, with the cache mode the VM's state records as its `9p: cache:` option: `none` for a new VM, and nothing for a VM whose mode nobody chose, which keeps Lima's `mmap` ([why](../contributing/design.md#the-9p-cache-on-linux)). The read-only mounts keep Lima's `fscache`, and a build VM's writable output folder gets `none`. The start that changes a VM'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 `/etc/fstab`, and it then checks the mount: a folder left unmounted fails the start ([why](../contributing/design.md#the-9p-cache-on-linux)). A start that rewrites the mounts, for a folder that moved, another cache mode or other agents' folders, keeps each mount's settings that devvm doesn't set, such as its other 9p and sshfs options, where they differ from Lima's defaults, and leaves the defaults out for Lima to fill in.
|
||||
- **ssh:** agent forwarding on or off, and the host port, which Lima always listens on at `127.0.0.1`. devvm chooses the port and records it, so no other VM'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'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'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 `http://localhost:PORT` would reach a server the VM controls with the cookies of the apps you use on `localhost`, 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 (`ports_ssh_limit`, or `ports_ssh_limit_all` 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 (`ports_ssh_limit_others`). devvm's other host ports, a VM's proxy port and desktop port, are never one of these, and one an older devvm chose moves at the VM'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 `devvm ports` and each launch warn of it (`ports_ssh_listed`), and while that VM runs, it keeps the port from VMs' ssh, as any program on this machine that holds one does. A stopped VM keeps its port at its next start while it'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't one of the 17, because an older devvm chose it. A new port is one no VM's state records, or else one a stopped VM's state records, which that VM gives up, getting another at its own next start. A build VM's port is never the one its clone kept from its image while another is free. The start's one `limactl edit` sets a new port, and the VM's host keys are pinned again, as at every start. A start holds its port, kept or new, for a minute, in `run/ports.ssh-hold` in the VM'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 (`ports_ssh_old`).
|
||||
- **Ports:** none, because Lima's own forwards are off and devvm's forwarder forwards the VM's ports instead ([below](#ports)).
|
||||
- **Size:** CPUs, memory and disk.
|
||||
- **Guest environment:** Lima's `env:`, which Lima writes to `/etc/environment` at every boot. On every tier it holds the VM's proxy's address and its settings, and Lima doesn't pass the host's proxy settings in. A confined VM reaches the proxy as Lima's host address on macOS and as QEMU's `guestfwd` address on Linux, and an open VM reaches it at Lima's host address on both, which is this machine's loopback as Lima's network has it, with `host.lima.internal` added to its `NO_PROXY`. `limactl edit` sets the proxy's URL with a stand-in for the password (`devvm-proxy-password`), and devvm then replaces the stand-in in the VM's `lima.yaml`, which it rewrites with mode 600, so the password is in no process's arguments. Its `NO_PROXY` and `no_proxy` name the VM alone, and never its [links](design.md#links-between-vms), which its HTTP clients reach through the proxy, so links never change it. A start runs `limactl edit` 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's host keys at every start and pins them again once it runs, so devvm's ssh config, its own connections and your editors keep working.
|
||||
- **Guest environment:** Lima's `env:`, which Lima writes to `/etc/environment` at every boot. On every tier it holds the VM's proxy's address and its settings, and Lima doesn't pass the host's proxy settings in. A confined VM reaches the proxy as Lima's host address on macOS and as QEMU's `guestfwd` address on Linux, and an open VM reaches it at Lima's host address on both, which is this machine's loopback as Lima's network has it, with `host.lima.internal` added to its `NO_PROXY`. `limactl edit` sets the proxy's URL with a stand-in for the password (`devvm-proxy-password`), and devvm then replaces the stand-in in the VM's `lima.yaml`, which it rewrites with mode 600, so the password is in no process's arguments. Its `NO_PROXY` and `no_proxy` name the VM alone, and never its [links](../contributing/design.md#links-between-vms), which its HTTP clients reach through the proxy, so links never change it. A start runs `limactl edit` 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's host keys at every start and pins them again once it runs, so devvm's ssh config, its own connections and your editors keep working.
|
||||
- **Proxy settings and DNS:** Lima's `propagateProxyEnv`, which writes this machine's proxy settings into the guest, is on only for a VM on Lima's own network without devvm's proxy, so they never reach a VM that goes through devvm's proxy. A VM confined to its proxy has Lima's host resolver off (`hostResolver.enabled: false`) and `dns: ["127.0.0.1"]`, because its names resolve in the proxy ([confinement](#confinement)). An open VM keeps Lima's own resolver and DNS.
|
||||
|
||||
Lima changes only a stopped VM'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's size where it differs from its image's. Each start of a stopped VM compares the VM's config, as `limactl list` shows it, with what the VM's state asks for and with how the VM starts. That covers its size, its project folder's path, which changes once the folder moved ([a moved folder](overview.md#a-moved-folder)), on macOS the device and inode its mount names, which change in that same edit once a boot gave the folder's disk another device number, and on Linux its cache mode where one was chosen, its agents' folders, its agent forwarding, its ssh port, its environment, Lima's proxy settings (`propagateProxyEnv`), its DNS (`hostResolver` and `dns`) and its ports rules. devvm then changes whatever differs in one `limactl edit`, and runs none when nothing does, because each edit gives the VM new ssh host keys at its next boot. Lima can't shrink a disk, so a start that asks for a smaller disk than the VM has fails before it changes anything (`disk_shrink`).
|
||||
@@ -38,7 +38,15 @@ devvm leaves Lima's `mountInotify` off, so file watchers in the VM see only the
|
||||
|
||||
## A shell's colors
|
||||
|
||||
devvm opens a VM's shell, and runs an agent's login, with `limactl shell`, which asks ssh to send your terminal's `COLORTERM`. That request never reaches the VM, because the session goes over the ssh connection that Lima shares between all of a VM's sessions, which was opened without it ([lima-vm/lima#2208](https://github.com/lima-vm/lima/issues/2208)). Closing that connection would end every session and the VM's SSH agent relay with it, so devvm sets `COLORTERM` in the command it runs in the VM instead. It passes only `truecolor` and `24bit`, the two values that say a terminal shows 24-bit color, quoted for the VM's shell, because devvm sends a VM only values it knows, though quoting alone would make any value safe. It passes nothing for any other value or when `COLORTERM` isn't set, and then the shell starts as `limactl shell` starts it by itself.
|
||||
devvm opens a VM's shell, and runs an agent's login, with `limactl shell`, which asks ssh to send your terminal's `COLORTERM`. That request never reaches the VM, because the session goes over the ssh connection that Lima shares between all of a VM's sessions, which was opened without it ([lima-vm/lima#2208](https://github.com/lima-vm/lima/issues/2208)). Closing that connection would end every session and the VM's SSH agent relay with it, so devvm sets `COLORTERM` in the command it runs in the VM instead. It passes only `truecolor` and `24bit`, the two values that say a terminal shows 24-bit color, and it quotes them for the VM'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 `COLORTERM` isn't set, and then the shell starts as `limactl shell` starts it by itself.
|
||||
|
||||
## A stopped VM's shell
|
||||
|
||||
Every `limactl shell` that devvm runs says `--start=false`. In a terminal, `limactl shell` of a stopped VM asks whether to start it, and the question's default is yes, but that start skips every check of devvm'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's path, a folder that replaced it included, and Lima would make the folder again if it's gone. So a VM that stops while devvm works with it, such as one whose guest shut itself down, makes devvm's shell or command fail, and devvm's next launch starts it with every check.
|
||||
|
||||
## A command's output
|
||||
|
||||
devvm closes the output of each command that it runs in a VM, apart from a shell and an image build's steps, a second after the command ends or its time limit runs out, because the ssh that `limactl shell` runs can leave a process behind that holds the output open. So a VM can't keep devvm waiting past a command's time limit, and a command whose output was cut short that way fails.
|
||||
|
||||
## Confinement
|
||||
|
||||
@@ -65,7 +73,7 @@ On macOS, devvm starts the VM's Lima process, its hostagent, under a macOS sandb
|
||||
|
||||
- The profile lets the process connect to the VM's ssh port and its proxy on the host's loopback, to the unix sockets in the VM's Lima folder (ssh's control socket and the VM's network), and to the socket of the ssh agent the VM forwards, which is its proxy's relay of your agent or devvm's own ([the SSH agents](processes.md#the-ssh-agents)). It connects nowhere else, so other sockets on the host, such as Docker's, stay out of the hostagent's reach. The profile limits only the network, so a compromised hostagent can still write your files, and through them run code as you.
|
||||
- The profile lets the process listen only on the VM's ssh port, over TCP, and on unix sockets in the VM's Lima folder, so it can't open a port of the VM's on the host even if Lima ignored its rules ([ports](#ports)).
|
||||
- Names resolve in the proxy, so Lima's own DNS server for the VM is off, and the guest's DNS points at `127.0.0.1`, which only [transparent mode](network.md#tools-that-skip-the-proxy) answers, inside the VM, with no upstream. Without it, nothing listens there, and a lookup through the system's resolver, as `getent` and curl make one, which asks `127.0.0.1` itself ([the VM's resolver](network.md#the-vms-resolver)), fails at once on macOS and on a Linux host alike. The guest reaches the proxy at `192.168.5.2`, which is the host as Lima's network sees it.
|
||||
- Names resolve in the proxy, so Lima's own DNS server for the VM is off, and the guest's DNS points at `127.0.0.1`, which only [transparent mode](network.md#tools-that-skip-the-proxy) answers, inside the VM, with no upstream. Without it, nothing listens there, and a lookup through the system's resolver, such as the ones `getent` and curl make, asks `127.0.0.1` itself ([the VM's resolver](network.md#the-vms-resolver)) and fails at once on macOS and on a Linux host alike. The guest reaches the proxy at `192.168.5.2`, which is the host as Lima's network sees it.
|
||||
|
||||
On Linux, Lima starts every VM's QEMU through a wrapper that devvm writes (`~/.local/share/devvm/run/qemu/`) and that runs devvm. It runs QEMU in a namespace that makes `.git`'s hooks and config read-only, for a VM whose [.git protection](git-protection.md#on-linux-hosts) is on. For a confined VM, the wrapper adds QEMU's `restrict=on` to Lima's network, so no traffic goes in or out but Lima's own forwards. It also adds one address, `192.168.5.4:3128`, which QEMU connects to the VM's proxy through a process for each connection, at most 256 at once ([the QEMU wrapper](processes.md#the-qemu-wrapper-and-its-keeper)). If Lima's QEMU arguments aren't the shape devvm expects, with one `-netdev user,id=net0,…` and no other network, the wrapper refuses to start QEMU (`qemu_refused`), so QEMU never runs unrestricted. DNS points at `127.0.0.1` in the guest, which only transparent mode answers, and without it lookups fail at once.
|
||||
|
||||
@@ -73,13 +81,13 @@ An open VM isn't confined: on macOS its hostagent runs without a profile, and on
|
||||
|
||||
A process can't leave its sandbox, so devvm records the hostagent it started (`started` in the VM's run folder) and checks that the VM still runs on it ([the self-check](network.md#the-self-check)). A VM started another way, such as with `limactl start`, runs unconfined, and `devvm ls` shows it as `unenforced`. The VM's proxy follows the hostagent's pid file (`ha.pid` in the VM's Lima folder) and exits with it. devvm writes the record only once `limactl start` returns, while the hostagent runs on its own from early in the start, so an interrupt during the start stops the VM ([how long a proxy runs](network.md#how-long-a-proxy-runs)). Interrupted before the hostagent answers, the VM is one Lima reports as `Broken`, which `limactl stop` refuses, so devvm stops a broken VM with `limactl stop --force`. 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 `--force` 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 `--force` first.
|
||||
|
||||
Builds are also confined, because they run code devvm didn't write. On macOS a build's Lima process runs under a profile that reaches either the internet but not the host's loopback, where other VMs' 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's loopback, its own proxy's ([a company proxy](design.md#a-company-proxy)). On Linux only a build with no network is confined. QEMU can't keep the internet while dropping the host's loopback, so other builds reach services on the host's `localhost`. Builds forward no ports. A build with the internet reaches your LAN on both hosts, this machine's own address on it included, because the macOS profile keeps only the loopback from it.
|
||||
Builds are also confined, because they run code devvm didn't write. On macOS a build's Lima process runs under a profile that reaches either the internet but not the host's loopback, where other VMs' 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's loopback, its own proxy's ([a company proxy](../contributing/design.md#a-company-proxy)). On Linux only a build with no network is confined. QEMU can't keep the internet while dropping the host's loopback, so other builds reach services on the host's `localhost`. Builds forward no ports. A build with the internet reaches your LAN on both hosts, this machine's own address on it included, because the macOS profile keeps only the loopback from it.
|
||||
|
||||
`sandbox-exec` 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.
|
||||
|
||||
## Ports
|
||||
|
||||
devvm's forwarder forwards a Lima VM's ports by the rules that [Port forwarding](ports.md) sets out. On Lima this is an emulation, and it's reviewed ([design](design.md#ports-on-lima)). devvm doesn't use Lima's own forwards because they listen with `SO_REUSEADDR`, and on macOS such a forward takes `127.0.0.1:PORT` while a program on the host has `*:PORT`, along with that program's `localhost` connections.
|
||||
devvm's forwarder forwards a Lima VM's ports by the rules that [Port forwarding](ports.md) sets out. On Lima this is an emulation, and it's reviewed ([design](../contributing/design.md#ports-on-lima)). devvm doesn't use Lima's own forwards because they listen with `SO_REUSEADDR`, and on macOS such a forward takes `127.0.0.1:PORT` while a program on the host has `*:PORT`, along with that program's `localhost` connections.
|
||||
|
||||
So Lima forwards nothing. Each VM's `portForwards` are rules that ignore every guest port, TCP and UDP, on `127.0.0.1` (which also covers `::1`), `0.0.0.0` and `::`. Lima's own ssh is its VM driver'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't rely on the rules alone, because its sandbox refuses the Lima process every port but its ssh port ([confinement](#confinement)).
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ This page explains how devvm confines a VM to its proxy on each tier, what the p
|
||||
|
||||
## Starting a VM on its tier
|
||||
|
||||
A VM's state records its tier in its `net` section, as `"tier"`: `open`, `internet`, `allowlist` or `none` ([network tiers](../safety/network.md#network-tiers)). A section without a tier reads as `allowlist`, and one with a tier devvm doesn't know can't be read, so devvm refuses the VM rather than take it as open. The tier decides the VM's confinement (`confinementFor`): on every tier but open, the VM starts confined to its proxy (`backend.NetProxy`); an open VM starts on its backend's own network (`backend.NetDirect`) with its proxy's port and password in its confinement, so its guest's proxy settings name the proxy all the same (`Confinement.GuestProxy`). A running VM keeps the confinement it started with until its next start.
|
||||
A VM's state records its tier in its `net` section, as `"tier"`: `open`, `internet`, `allowlist` or `none` ([network tiers](../safety/network.md#network-tiers)). A section without a tier reads as `allowlist`, and one with a tier devvm doesn't know can't be read, so devvm refuses the VM rather than take it as open. The tier decides the VM's confinement: on every tier but open, the VM starts confined to its proxy, and an open VM starts on its backend's own network with its proxy's port and password in its confinement, so its guest's proxy settings name the proxy all the same ([how a backend plugs in](../contributing/extending.md#how-a-backend-plugs-in)). A running VM keeps the confinement it started with until its next start.
|
||||
|
||||
When devvm starts a VM on a confined tier, it takes these steps in order:
|
||||
|
||||
@@ -31,7 +31,7 @@ A VM whose backend can't confine it to its proxy (`egress-proxy`) can only be op
|
||||
|
||||
One proxy runs for each VM. It runs on the host as `devvm _proxy`, 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.
|
||||
|
||||
The proxy is two processes. `devvm _proxy`, the broker, keeps 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's links' sockets, reads the files that change while the proxy runs, relays the VM's SSH agent, follows the VM's lifeline, and looks up the names and opens the connections that the child asks for. Its child, `devvm _proxy-child`, does everything this section describes with the VM'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't make the broker act for another VM, another secret or another file. No byte of the VM's requests crosses that socket: the broker hands the child each connection, so it adds a hop to opening one, but none to what it carries. On Linux the child confines itself with Landlock and a seccomp filter before it reads a byte of the VM's, to its logs and the Nix cache, with no connection of its own, no unix socket and no program to run, so a child that a VM took over can't read your files, reach an ssh master's socket or connect to this machine's loopback, and on macOS a Seatbelt profile does the same ([the child's sandbox](#the-childs-sandbox)). [Processes](processes.md#a-vms-proxy) has what each holds, reads and writes, and [the proxy's broker](design.md#the-proxys-broker) has the protocol and its threat check. The one other way out of the VM is the [links](ports.md#links-between-vms) you add to it, which this machine carries over ssh to the ports your other VMs publish, so they don't use the VM's network. The proxy is a second entrance to those links, for the VM's HTTP clients ([links through the proxy](#links-through-the-proxy)).
|
||||
The proxy is two processes. `devvm _proxy`, 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's links' sockets, reads the files that change while the proxy runs, relays the VM's SSH agent, follows the VM's lifeline, and looks up the names and opens the connections that the child asks for. Its child, `devvm _proxy-child`, does everything this section describes with the VM'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't make the broker act for another VM, another secret or another file. No byte of the VM'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'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 ([the child's sandbox](#the-childs-sandbox)). So a child that a VM took over can't read your files, reach an ssh master's socket or connect to this machine's loopback. [Processes](processes.md#a-vms-proxy) has what each holds, reads and writes, and [the proxy's broker](../contributing/design.md#the-proxys-broker) has the protocol and its threat check. The one other way out of the VM is the [links](ports.md#links-between-vms) you add to it, which this machine carries over ssh to the ports your other VMs publish, so they don't use the VM's network. The proxy is a second entrance to those links, for the VM's HTTP clients ([links through the proxy](#links-through-the-proxy)).
|
||||
|
||||
Other programs on the host can also reach that port, so the port alone doesn't identify the VM. Every request must carry the VM's password in `Proxy-Authorization`, with the user `devvm`, or it gets `407`. 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 ([devvm _proxy](#devvm-_proxy)). The VM's settings also get the password through files ([Lima](lima.md#a-lima-home-of-its-own)).
|
||||
|
||||
@@ -39,9 +39,9 @@ For each connection, the proxy does the following:
|
||||
|
||||
- It sends a request for one of the VM's own links to that link before any rule, and passes its bytes on as they are ([links through the proxy](#links-through-the-proxy)).
|
||||
- It checks `CONNECT host:port` and absolute-form requests (`GET http://host/…`) against the VM's [policy files](#policy-files), and then tunnels or forwards the allowed ones untouched.
|
||||
- It takes only host names, made of letters, digits, `-`, `_` and `.`, and addresses. It lowercases a name and drops one trailing dot, and the name that's left may have no empty label, so `evil.test..`, `evil..test` and `.evil.test` get `400` too, because a company proxy that drops trailing dots would otherwise reach a host that a deny of `evil.test` never matched. It lowercases ASCII alone: a name with any other character keeps it, and gets `400`, because Unicode's case folding turns some letters into ASCII ones, such as the Kelvin sign into `k`, so the host it judged wouldn't be the one the VM named. An address is bare, or an IPv6 address in one pair of brackets, so `[evil.com]:443`, `[1.2.3.4]:443` and a stray bracket get `400` too. An IPv6 address with a zone, such as `[fe80::1%en0]`, gets `400`, and so does one with an empty zone. An address keeps its trailing dot, because the dot can only be its zone's, and dropping it would leave an empty zone, which Go's address parser reads as no address but a resolver may read as the address alone. Anything else gets `400` before the policy or the log sees it. Everything else that reads a host reads it in the same form: a rule's host, a secret's hosts, `NO_PROXY`, `devvm network lock`'s risks and ticks, a secret's `--host`, an MCP server's host, `--from`'s registry and a partial clone's remotes.
|
||||
- It takes only host names, made of letters, digits, `-`, `_` and `.`, and addresses. It lowercases a name and drops one trailing dot, and the name that's left may have no empty label, so `evil.test..`, `evil..test` and `.evil.test` get `400` too, because a company proxy that drops trailing dots would otherwise reach a host that a deny of `evil.test` never matched. It lowercases only ASCII, so a name with any other character keeps that character and gets `400`, because Unicode's case folding turns some letters into ASCII ones, such as the Kelvin sign into `k`, so the host it judged wouldn't be the one the VM named. An address is bare, or an IPv6 address in one pair of brackets, so `[evil.com]:443`, `[1.2.3.4]:443` and a stray bracket get `400` too. An IPv6 address with a zone, such as `[fe80::1%en0]`, gets `400`, and so does one with an empty zone. An address keeps its trailing dot, because the dot can only be its zone's, and dropping it would leave an empty zone, which Go's address parser reads as no address but a resolver may read as the address alone. Anything else gets `400` before the policy or the log sees it. Everything else that reads a host reads it in the same form: a rule's host, a secret's hosts, `NO_PROXY`, `devvm network lock`'s risks and ticks, a secret's `--host`, an MCP server's host, `--from`'s registry and a partial clone's remotes.
|
||||
- It refuses `devvm.proxy`, its own domain, and any name under it, in a `CONNECT` and as a host, with `403`, before the links, the policy or a company proxy see the name, on every tier. Only a request in absolute form for `http://devvm.proxy/` itself reaches its endpoints, and `CONNECT transparent.devvm.proxy:PORT` is [transparent mode](#tools-that-skip-the-proxy)'s. It refuses the stand-in address, `198.18.0.1`, with a reason that says the tool resolved the name itself.
|
||||
- It resolves names itself and dials the addresses it checked, through its broker, which checks each address again before it connects ([the child's sandbox](#the-childs-sandbox)). It looks each name up absolute, with a trailing dot, so this machine's resolver never adds its DNS search domain, which macOS takes from the network's settings and Linux from `/etc/resolv.conf`'s `search`: otherwise, with `api.corp.example.com` denied and `**` allowing the rest, `CONNECT api:443` would reach `api.corp.example.com`, a name that no rule judged, and so would `api.eu` reach `api.eu.corp.example.com` when `api.eu` itself has no address. It refuses the host's own addresses and internal ones unless a rule names the address. Internal addresses are loopback, private, link-local, multicast, unspecified, CGNAT `100.64.0.0/10` and the other ranges that aren't the public internet, among them IPv4's documentation ranges `192.0.2.0/24`, `198.51.100.0/24` and `203.0.113.0/24` and the old 6to4 relays' `192.88.99.0/24`, and IPv6's Teredo `2001::/32`, documentation `2001:db8::/32` and `3fff::/20`, discard-only `100::/64`, benchmarking `2001:2::/48`, ORCHID `2001:10::/28` and ORCHIDv2 `2001:20::/28`, SRv6 `5f00::/16` and IPv4-translated `::ffff:0:a.b.c.d`. An address with an IPv6 zone is internal too, whatever its address, because a zone ties it to one of this machine's links. An address with an IPv4 address in it counts as that IPv4 address, both a NAT64 address `64:ff9b::a.b.c.d` and a 6to4 address in `2002::/16`, such as `2002:a00:1::1` for `10.0.0.1`, and the 6to4 network, a `/48`, of one of the host's own 6to4 addresses counts as the host'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'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't read them, so a broad IPv6 allow such as `::/0` lets in the Teredo form of a denied IPv4 address.
|
||||
- It resolves names itself and dials the addresses it checked, through its broker, which checks each address again before it connects ([the child's sandbox](#the-childs-sandbox)). It looks each name up absolute, with a trailing dot, so this machine's resolver never adds its DNS search domain, which macOS takes from the network's settings and Linux from `/etc/resolv.conf`'s `search`. Otherwise, with `api.corp.example.com` denied and `**` allowing the rest, `CONNECT api:443` would reach `api.corp.example.com`, a name that no rule judged, and so would `api.eu` reach `api.eu.corp.example.com` when `api.eu` itself has no address. It refuses the host's own addresses and internal ones unless a rule names the address. Internal addresses are loopback, private, link-local, multicast, unspecified, CGNAT `100.64.0.0/10` and the other ranges that aren't the public internet, among them IPv4's documentation ranges `192.0.2.0/24`, `198.51.100.0/24` and `203.0.113.0/24` and the old 6to4 relays' `192.88.99.0/24`, and IPv6's Teredo `2001::/32`, documentation `2001:db8::/32` and `3fff::/20`, discard-only `100::/64`, benchmarking `2001:2::/48`, ORCHID `2001:10::/28` and ORCHIDv2 `2001:20::/28`, SRv6 `5f00::/16` and IPv4-translated `::ffff:0:a.b.c.d`. An address with an IPv6 zone is also internal, whatever its address, because a zone ties it to one of this machine's links. An address with an IPv4 address in it counts as that IPv4 address, both a NAT64 address `64:ff9b::a.b.c.d` and a 6to4 address in `2002::/16`, such as `2002:a00:1::1` for `10.0.0.1`, and the 6to4 network, a `/48`, of one of the host's own 6to4 addresses counts as the host'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'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't read them, so a broad IPv6 allow such as `::/0` lets in the Teredo form of a denied IPv4 address.
|
||||
- It requires a TLS ClientHello in a tunnel to name the `CONNECT` host in its SNI, in ASCII, letters' case aside. The proxy doesn't see the `Host` inside the encrypted traffic, so a CDN that routes by it can reach other sites it serves.
|
||||
- For a host with a bound secret, it replaces the placeholder in one header with the real value, as [how the proxy puts them in](#how-the-proxy-puts-them-in) describes.
|
||||
- For a host whose rules narrow it to some methods or paths, it decrypts the host's HTTPS and checks each request, as [requests by method and path](#requests-by-method-and-path) describes. Everything else passes unread.
|
||||
@@ -77,11 +77,11 @@ flowchart TD
|
||||
|
||||
A tunnel that the proxy doesn'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's bytes end, or when the proxy can't pass them on because the VM's connection has gone, and then the proxy closes both connections. In a tunnel to a host the policy allows, the far end'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'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't make it hold 64 KiB for each of its tunnels, nor hold a slot by sending its ClientHello a byte at a time.
|
||||
|
||||
The proxy carries at most 1024 `CONNECT` tunnels for the VM at once, counting tunnels to links and intercepted ones too, from the request until the tunnel ends. That'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's 15 sockets or uv's 50 downloads, so several installs and builds at once fit. Each tunnel holds two of the proxy's file descriptors, so the limit keeps a VM that opens tunnels without end from taking them all. A `CONNECT` past the limit gets `503`, which a client may retry, and the reason `1024 tunnels open already`, logged as a refused block, so neither the VM's prompt nor `devvm network log` suggests an allow rule. The proxy's own log, `proxy.log`, says when the VM reaches the limit, once until a tunnel ends.
|
||||
The proxy carries at most 1024 `CONNECT` tunnels for the VM at once, including tunnels to links and intercepted ones, from the request until the tunnel ends. That'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's 15 sockets or uv's 50 downloads, so several installs and builds at once fit. Each tunnel holds two of the proxy's file descriptors, so the limit keeps a VM that opens tunnels without end from taking them all. A `CONNECT` past the limit gets `503`, which a client may retry, and the reason `1024 tunnels open already`, logged as a refused block, so neither the VM's prompt nor `devvm network log` suggests an allow rule. The proxy's own log, `proxy.log`, says when the VM reaches the limit, once until a tunnel ends.
|
||||
|
||||
The proxy also holds at most 2048 of the VM'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's twice the tunnels' limit, so a `CONNECT` past the tunnels' limit still gets its `503` first. A connection counts from its first request with the VM's password, and a request on a connection past the limit gets `503`, 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 `503` before it reaches the proxy ([the QEMU wrapper](processes.md#the-qemu-wrapper-and-its-keeper)).
|
||||
|
||||
Every program on this machine can reach the proxy's port, an open VM's included, so a connection that hasn't sent the VM's password yet never takes the VM'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't take the VM'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's queue of connections waiting to be accepted ([design](design.md#transparent-mode)).
|
||||
Every program on this machine can reach the proxy's port, an open VM's included, so a connection that hasn't sent the VM's password yet never takes the VM'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't take the VM'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's queue of connections waiting to be accepted ([design](../contributing/design.md#transparent-mode)).
|
||||
|
||||
The proxy also has at most 2048 requests to hosts under way at once, plain HTTP's and those inside intercepted tunnels together. Each is a connection of its own to the host, so the tunnels' HTTP/2 requests, 100 at once in each, can't add up to more connections than the proxy can open. A request past the limit gets `503`, which a client may retry.
|
||||
|
||||
@@ -91,7 +91,7 @@ Nothing bounds how long a request or a tunnel lasts, so a long download, a WebSo
|
||||
|
||||
- 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.
|
||||
- A request without the VM's password gets `407`, and the proxy closes its connection after it, so nothing without the password keeps a connection open.
|
||||
- A request takes at most 64 KiB of headers, in an intercepted tunnel, a transparent connection and the `403` page's TLS connection too.
|
||||
- A request takes at most 64 KiB of headers, including in an intercepted tunnel, a transparent connection and the `403` page's TLS connection.
|
||||
- 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.
|
||||
- A plain HTTP request in absolute form goes on when its client half-closes after sending, because some clients do, so the proxy can'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't leave a request waiting on a host that never answers.
|
||||
|
||||
@@ -111,11 +111,11 @@ The proxy logs nothing for a link's connection that it passes on, because `devvm
|
||||
|
||||
When devvm starts a VM's proxy, it reads `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY` from its own environment, each in capitals first and then in lowercase, as Go's clients do. When its environment sets neither `HTTPS_PROXY` nor `HTTP_PROXY`, it reads `config.toml`'s `[proxy]` table instead, its `https`, `http` and `no-proxy`, and never a mix of the two. It writes them into the proxy's config, `proxy.json` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, as `upstream`, so a password in the environment's URL is in a file only you can read and in no process's arguments. devvm checks the settings first: a proxy URL is `http://user:password@host:port`, or `host:port` alone, and a proxy without a port is on port 80. devvm refuses an `https://` or `socks5://` proxy (`upstream_proxy_scheme`) and a setting it can't read (`upstream_proxy_invalid`), so a VM doesn't start until you change it.
|
||||
|
||||
A `config.toml` URL never holds a password (`proxy_password_in_config`, as it's read), because people copy that file between machines and keep it with their dotfiles. When its URL names a user, `upstream` gets `"secret": "proxy"`, and the proxy looks the `proxy` secret up as it starts, through the same lookup as the [secrets it puts in](#where-secrets-are-saved), the Keychain or `~/.local/share/devvm/secrets/proxy`, and uses it as the password of each URL that names a user and none of its own. So `proxy.json` never holds that password. A proxy whose lookup fails doesn't start, and devvm checks that the secret is saved before it makes a new VM, starts a VM's proxy, or builds an image or the shared tools (`proxy_password_missing`), and before it stops a running VM to start it again, as `devvm restart` does, so a refused restart leaves the VM running. It also checks before it changes a running VM's tier between `internet`, `allowlist` and `none`, which the VM's proxy applies at once, so the VM's state never names a tier that its proxy doesn't enforce. Each of these checks is `settings.CompanyProxy.Upstream`, which `netpolicy.Proxy.Refusal` runs with the check of your CAs before a VM is made, stopped to start again, or given another confined tier while it runs.
|
||||
A `config.toml` URL never holds a password (`proxy_password_in_config`, as it's read), because people copy that file between machines and keep it with their dotfiles. When its URL names a user, `upstream` gets `"secret": "proxy"`, and the proxy looks the `proxy` secret up as it starts, through the same lookup as the [secrets it puts in](#where-secrets-are-saved), the Keychain or `~/.local/share/devvm/secrets/proxy`, and uses it as the password of each URL that names a user and none of its own. So `proxy.json` never holds that password. A proxy whose lookup fails doesn't start, and devvm checks that the secret is saved before it makes a new VM, starts a VM's proxy, or builds an image or the shared tools (`proxy_password_missing`), and before it stops a running VM to start it again, as `devvm restart` does, so a refused restart leaves the VM running. It also checks before it changes a running VM's tier between `internet`, `allowlist` and `none`, which the VM's proxy applies at once, so the VM's state never names a tier that its proxy doesn't enforce. Each of these is one check of the company proxy'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 ([the packages](../contributing/structure.md#the-packages)).
|
||||
|
||||
devvm's own requests on this machine go through the same company proxy. They are the download of its own mise, the list of Ubuntu's cloud images, and the registries `--from` asks for digests. When the environment sets the proxy, their clients use Go's own environment proxy. When `config.toml` sets it, `settings.CompanyProxy.Route` is their transport's proxy. At the first request, it looks the `proxy` secret up and puts it in each URL that names a user and none of its own. It routes each request as a VM's proxy does: `HTTPS_PROXY`'s for HTTPS, `HTTP_PROXY`'s for plain HTTP, and directly for `NO_PROXY`'s hosts, `localhost` and loopback addresses. Go sends the user and password only to the company proxy, in `Proxy-Authorization`. A missing password fails the request without a retry. The mise that devvm runs on this machine inherits devvm's environment, so it uses the environment's proxy as it is. With `config.toml`'s proxy, devvm adds `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY` to mise's environment, in capitals and in lowercase, with the password in each URL that names a user. mise takes a proxy's password only in its URL, so its environment is the one place it can go. It's never in mise's arguments or in a file.
|
||||
devvm's own requests on this machine go through the same company proxy. They are the download of its own mise, the list of Ubuntu's cloud images, and the registries `--from` asks for digests. When the environment sets the proxy, their clients use Go's own environment proxy. When `config.toml` sets it, devvm's route to the company proxy is their transport's proxy. At the first request, the route looks the `proxy` secret up and puts it in each URL that names a user and none of its own. It routes each request as a VM's proxy does: `HTTPS_PROXY`'s for HTTPS, `HTTP_PROXY`'s for plain HTTP, and directly for `NO_PROXY`'s hosts, `localhost` and loopback addresses. Go sends the user and password only to the company proxy, in `Proxy-Authorization`. A missing password fails the request without a retry. The mise that devvm runs on this machine inherits devvm's environment, so it uses the environment's proxy as it is. With `config.toml`'s proxy, devvm adds `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY` to mise's environment, in capitals and in lowercase, with the password in each URL that names a user. mise takes a proxy's password only in its URL, so its environment is the one place it can go. It's never in mise's arguments or in a file.
|
||||
|
||||
A VM's proxy refreshes Codex's and opencode's OAuth logins through the company proxy it sends the VM's requests through, its `upstream`, whether that came from the environment or from `config.toml`. As it starts, it makes that upstream's route for its own requests, with the `proxy` secret it looked up as the password, as `proxy.Upstream.WithPassword` and `proxy.Upstream.Route` do for devvm's own requests. It gives the route to each lookup in the lookup's context (`proxy.WithRoute`), and `agentlogin` sets it as the refresh's transport proxy (`proxy.RouteOf`). A VM's proxy without an upstream sends the refresh directly, as it does the VM's requests.
|
||||
A VM's proxy refreshes Codex's and opencode's OAuth logins through the company proxy it sends the VM's requests through, its `upstream`, whether that came from the environment or from `config.toml`. As it starts, it makes that upstream's route for its own requests, with the `proxy` secret it looked up as the password, as devvm makes the route for its own requests. It carries the route in each lookup's context, and the login's refresh takes it from there as its transport's proxy. A VM's proxy without an upstream sends the refresh directly, as it does the VM's requests.
|
||||
|
||||
An open VM's proxy goes through the company proxy as a confined VM's does. Its guest gets no proxy settings of devvm's environment: Lima's `propagateProxyEnv` is off for every VM whose guest names devvm's proxy, so neither the shell's nor `config.toml`'s password reaches the guest.
|
||||
|
||||
@@ -130,54 +130,54 @@ The proxy decides each request as it does without a company proxy, by the host n
|
||||
|
||||
`NO_PROXY` is a comma-separated list, which the proxy reads as Go's clients read it. In it, `*` matches every host, and an address or a CIDR matches addresses. A name matches itself and its subdomains, while a name with a leading `.` or `*.` 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 `git.test:0`, or whose port isn't in plain decimal, such as `git.test:080`, matches nothing. The proxy reads a name in `NO_PROXY` 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't printable ASCII matches no host, because Unicode's case folding would turn the Kelvin sign into `k`.
|
||||
|
||||
The company proxy resolves the names it's sent, so the proxy can't hold it to the addresses it checked, and the floor changes for those requests. An address in the VM's request is checked as before, and a host whose last label is all digits or starts with `0x`, such as `127.1`, gets `400`, because a company proxy may read it as an address. For a name, the proxy asks this machine'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't resolve, which is common behind a company proxy, goes to the company proxy unchecked when a rule names it, as itself or under `*.domain`. When only `**` allows it, the proxy refuses it with `403`, and the event log says that this machine can't resolve it and only `**` allows it. The proxy reads at most 64 KiB of the company proxy's answer to `CONNECT`. [The design note](design.md#a-company-proxy) explains what that leaves open, which [Attack vectors](../safety/attack-vectors.md#network) lists, and how builds reach the company proxy through a proxy of their own.
|
||||
The company proxy resolves the names it's sent, so the proxy can't hold it to the addresses it checked, and the floor changes for those requests. An address in the VM's request is checked as before, and a host whose last label is all digits or starts with `0x`, such as `127.1`, gets `400`, because a company proxy may read it as an address. For a name, the proxy asks this machine'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't resolve, which is common behind a company proxy, goes to the company proxy unchecked when a rule names it, as itself or under `*.domain`. When only `**` allows it, the proxy refuses it with `403`, and the event log says that this machine can't resolve it and only `**` allows it. The proxy reads at most 64 KiB of the company proxy's answer to `CONNECT`. [The design note](../contributing/design.md#a-company-proxy) explains what that leaves open, which [Attack vectors](../safety/attack-vectors.md#network) lists, and how builds reach the company proxy through a proxy of their own.
|
||||
|
||||
The event log's `upstream` field names the company proxy, by host and port, for each tunnel and request that went through it, and `devvm network log` adds `through host:port` to the line. The proxy's own log names both company proxies by host and port when it starts. Neither holds the user or the password.
|
||||
|
||||
### How long a proxy runs
|
||||
|
||||
The proxy exits when the VM's Lima hostagent does, which it learns from the hostagent's pid file, the VM's lifeline (`lifeline` 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'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 `devvm stop` stops it at once. It's the broker that follows the lifeline, and its child ends with it, as [processes](processes.md#a-vms-proxy) 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'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's next command starts its proxy again, as after any proxy's crash. `devvm stop`, `devvm rm` and `devvm gc --orphans` also stop a child that outlived its broker, by `run/proxy-child.pid` and its arguments.
|
||||
The proxy exits when the VM's Lima hostagent does, which it learns from the hostagent's pid file, the VM's lifeline (`lifeline` 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'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 `devvm stop` stops it at once. It's the broker that follows the lifeline, and its child ends with it, as [processes](processes.md#a-vms-proxy) 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'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's next command starts its proxy again, as after any proxy's crash. `devvm stop`, `devvm rm` and `devvm gc --orphans` also stop a child that outlived its broker, by `run/proxy-child.pid` and its arguments.
|
||||
|
||||
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 (`proxy.Config.Sum`). The config holds everything that, changed, starts the proxy again: the VM's list of policies, the VM'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's binary, so a proxy from another devvm binary counts, the [CAs in your CA folder](#a-companys-ca), the [company proxy](#through-a-company-proxy) settings in devvm's environment and the [shared Nix cache](#the-shared-nix-cache)'s cap. A config that's gone, or that the proxy wouldn't read, counts as one that differs. To start a new proxy, devvm stops the old one with `SIGTERM`, and with `SIGKILL` when it'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 `proxy_port_taken`. `SIGKILL` goes only to a process whose arguments devvm can still read as the proxy's, so a proxy still ending gets none, and neither does another process given its pid since, even one whose arguments devvm can't read. If it still runs two seconds after that, devvm stops with `proxy_stop_failed` and starts nothing, because the old proxy would go on with its old settings.
|
||||
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's list of policies, the VM'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's binary, so a proxy from another devvm binary counts, the [CAs in your CA folder](#a-companys-ca), the [company proxy](#through-a-company-proxy) settings in devvm's environment and the [shared Nix cache](#the-shared-nix-cache)'s cap. A config that's gone, or that the proxy wouldn't read, counts as one that differs. To start a new proxy, devvm stops the old one with `SIGTERM`, and with `SIGKILL` when it'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 `proxy_port_taken`. `SIGKILL` goes only to a process whose arguments devvm can still read as the proxy's, so a proxy still ending gets none, and neither does another process given its pid since, even one whose arguments devvm can't read. If it still runs two seconds after that, devvm stops with `proxy_stop_failed` and starts nothing, because the old proxy would go on with its old settings.
|
||||
|
||||
devvm counts a proxy as started only once the proxy says it's listening on the VM's port and is still running, because a program that took the port first would otherwise get the VM's traffic. The proxy says so in a status file of its own in the VM's run folder (`vms/<hash>/run/proxy.status`), which devvm names to it when it starts it and removes before each start. The file holds the proxy'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't ended, and its arguments are the VM's proxy's, `_proxy -config` with the VM's `proxy.json`, or still devvm's own, or can't be read yet. On Linux, a process that has just started shows devvm's own arguments for a moment, then none, because the kernel lets devvm go on as the new program begins to replace devvm's copy, and shows the program's arguments only once it has loaded. If the proxy doesn't start, devvm stops and names the proxy's log (`proxy_start_failed`). When a stopped VM's port was taken by another program, devvm chooses a new free port. A running VM's backend holds the port it started with, so when a running VM's proxy is gone and another program took its port, devvm can't start the proxy again (`proxy_port_taken`). devvm then stops the VM (`net_proxy_down_stopped`), 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's runs, because a confined VM never runs on without its proxy. The next `devvm` starts both. A running VM's old proxy has the VM's port, so it can't be kept while the new one starts. On a launch, a link's change or a `devvm network` change, what can refuse the proxy's start is checked before the old one stops: the company proxy and its password, your CAs, and the VM's CA and secret files. A refusal there leaves the VM and its old proxy running as they were, and devvm says so (`net_proxy_kept`, `netpolicy.Proxy.PrepareRunning`), but only while the old proxy enforces what the VM's state asks for now: the same built-in policies, policy files and deny files for the VM's tier, open or not, from the same devvm binary. An old proxy with a looser tier than the state's, or from another devvm binary, whose built-in policies' 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. `devvm restart` checks only the company proxy and your CAs before it stops the VM (`netpolicy.Proxy.Refusal`), and its start checks the rest. An interrupt during the start of a confined VM stops the VM and its proxy too (`interrupted_start`, a cleanup that `starter.start` registers around the backend's `Start`), because a backend can leave the VM running while its start still waits for it: Lima's hostagent keeps running the VM after `limactl start` ends, and devvm records the confined start only once `limactl start` returns. Without the stop, the VM would run with no record of its confined start, so `devvm ls` would show it as `unenforced` and its next launch would offer to restart it.
|
||||
devvm counts a proxy as started only once the proxy says it's listening on the VM's port and is still running, because a program that took the port first would otherwise get the VM's traffic. The proxy says so in a status file of its own in the VM's run folder (`vms/<hash>/run/proxy.status`), which devvm names to it when it starts it and removes before each start. The file holds the proxy'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't ended, and its arguments are the VM's proxy's, `_proxy -config` with the VM's `proxy.json`, or still devvm's own, or can't be read yet. On Linux, a process that has just started shows devvm's own arguments for a moment, then none, because the kernel lets devvm go on as the new program begins to replace devvm's copy, and shows the program's arguments only once it has loaded. If the proxy doesn't start, devvm stops and names the proxy's log (`proxy_start_failed`). When a stopped VM's port was taken by another program, devvm chooses a new free port. A running VM's backend holds the port it started with, so when a running VM's proxy is gone and another program took its port, devvm can't start the proxy again (`proxy_port_taken`). devvm then stops the VM (`net_proxy_down_stopped`), 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's runs, because a confined VM never runs on without its proxy. The next `devvm` starts both. A running VM's old proxy has the VM's port, so it can't be kept while the new one starts. On a launch, a link's change or a `devvm network` change, what can refuse the proxy's start is checked before the old one stops: the company proxy and its password, your CAs, and the VM's CA and secret files. A refusal there leaves the VM and its old proxy running as they were, and devvm says so (`net_proxy_kept`), but only while the old proxy enforces what the VM's state asks for now: the same built-in policies, policy files and deny files for the VM's tier, open or not, from the same devvm binary. An old proxy with a looser tier than the state's, or from another devvm binary, whose built-in policies' 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. `devvm restart` 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 (`interrupted_start`, a cleanup that the start registers around the backend's start), because a backend can leave the VM running while its start still waits for it. Lima's hostagent keeps running the VM after `limactl start` ends, and devvm records the confined start only once `limactl start` returns. Without the stop, the VM would run with no record of its confined start, so `devvm ls` would show it as `unenforced` and its next launch would offer to restart it.
|
||||
|
||||
### The child's sandbox
|
||||
|
||||
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's floor kept or to a company proxy, and the broker hands it the connection, as it hands it a link's. The broker connects to an address only once its own read of the VM's policy files and of this machine's addresses allows it, as the floor does, and it looks at the policy files at each connection, so a rule such as `devvm network allow 127.0.0.1:5432` applies from the next connection, as it always has. So even a child that a VM took over reaches this machine'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's network whose address is public, such as a printer's global IPv6 address, and whatever a company proxy reaches, which it speaks to with its password, this machine'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's loopback, such as a VPN client's, works. It looks names up through this machine'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's confined, so it can't keep every connection the broker hands it ([the design note](design.md#the-proxys-broker)).
|
||||
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's floor kept or to a company proxy, and the broker hands it the connection, as it hands it a link's. The broker connects to an address only once its own read of the VM's policy files and of this machine's addresses allows it, as the floor does, and it looks at the policy files at each connection, so a rule such as `devvm network allow 127.0.0.1:5432` applies from the next connection. So even a child that a VM took over reaches this machine'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's network whose address is public, such as a printer's global IPv6 address, and whatever a company proxy reaches, which it speaks to with its password, this machine'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's loopback, such as a VPN client's, works. It looks names up through this machine'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's confined, so it can't keep every connection the broker hands it ([the design note](../contributing/design.md#the-proxys-broker)).
|
||||
|
||||
On macOS, the broker starts its child through `/usr/bin/sandbox-exec`, with a Seatbelt profile that denies everything the child doesn't need, so the child is confined from its first instruction, before it reads a byte of the VM's. The broker writes the profile for each start from what the child needs, and passes it to `sandbox-exec` as an argument, so it's never a file on disk. It runs devvm'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:
|
||||
|
||||
- **devvm's binary:** running it and reading it, for its SHA-256, and the metadata of its folder, which CoreFoundation looks at for the program's bundle before Security checks a certificate.
|
||||
- **The system:** the rules that the system's own `dyld-support.sb` profile gives a program to start, reading the system's libraries in `/usr/lib` and `/System/Library` and the time zone, the metadata of the links `/etc`, `/var` and `/tmp`, through which those paths lead, and reading `sysctl`, which the floor reads the host's addresses with, except the process table's `kern.proc` names.
|
||||
- **Its folders:** reading and writing in the VM's logs folder and the shared Nix cache, where it can make regular files alone, 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's folders before the child starts, as the child can't make a folder. A build's child gets its own `logs/` folder.
|
||||
- **Its folders:** reading and writing in the VM'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's folders before the child starts, as the child can't make a folder. A build's child gets its own `logs/` folder.
|
||||
- **The files that change:** the metadata of your policy files, the VM's bindings and the links' list, which the child looks at with `stat` alone, and of their targets when they're links, and of every link on the way to any of those files or folders.
|
||||
- **Checking certificates:** the mach services `com.apple.trustd` and `com.apple.trustd.agent`, which check certificates for Go's `crypto/x509`.
|
||||
- **The network:** 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 `connect` and every send with an address.
|
||||
- **Signals and processes:** signals to itself, and looking only at itself.
|
||||
|
||||
So the child can't read your home folder or devvm's other folders, its run folder, its config and the other VMs' among them, and can't reach the Keychain, whose service `com.apple.SecurityServer` the profile never allows, nor any unix socket, such as an ssh master's control socket or an SSH agent's. It can't bind a port, fork or run a program, signal another process, list the processes, or read another process's path, details or arguments (`process-info`, `kern.proc`). macOS answers a process's arguments (`kern.procargs2`) to a sandboxed process only within its own process group, and the child runs alone in a session of its own, so that leaves it none but its own. A policy file that's a link to another file is looked at where it pointed as the proxy started, and when it points elsewhere later, the child's `stat` is refused, so the child asks the broker for the file at every request instead, which reads it as before.
|
||||
So the child can't read your home folder or devvm's other folders, its run folder, its config and the other VMs' among them, and can't reach the Keychain, whose service `com.apple.SecurityServer` the profile never allows, nor any unix socket, such as an ssh master's control socket or an SSH agent's. It can't bind a port, fork or run a program, signal another process, list the processes, or read another process's path, details or arguments (`process-info`, `kern.proc`). macOS answers a process's arguments (`kern.procargs2`) 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's a link to another file is looked at where it pointed as the proxy started, and when it points elsewhere later, the child's `stat` is refused, so the child asks the broker for the file at every request instead, which reads it as before.
|
||||
|
||||
On Linux, the child confines itself, once it has opened its logs and the Nix cache and loaded the system's roots and its time zone, and before it says it's ready, so before it reads a byte of the VM's. It sets `no_new_privs` on every thread, restricts every thread with Landlock, and installs a seccomp filter on every thread. Landlock and `prctl` change only the thread that calls them, and Go's runtime runs the child on several threads, so the child makes each call on every thread at once through `syscall.AllThreadsSyscall`, which works only in a binary without cgo, as devvm's releases are. From Landlock's ABI 8 it restricts every thread in one call instead (`LANDLOCK_RESTRICT_SELF_TSYNC`), and the filter goes on every thread in one call (`SECCOMP_FILTER_FLAG_TSYNC`). Landlock holds the child to these files, whatever their permissions:
|
||||
On Linux, the child confines itself once it has opened its logs and the Nix cache and loaded the system's roots and its time zone. It does so before it says it's ready, so before it reads a byte of the VM's. It sets `no_new_privs` on every thread, restricts every thread with Landlock, and installs a seccomp filter on every thread. Landlock and `prctl` change only the thread that calls them, and Go's runtime runs the child on several threads, so the child makes each call on every thread at once through Go's call for all of a process's threads, which works only in a binary without cgo, as devvm's releases are. From Landlock's ABI 8 it restricts every thread in one call instead (`LANDLOCK_RESTRICT_SELF_TSYNC`), and the filter goes on every thread in one call (`SECCOMP_FILTER_FLAG_TSYNC`). Landlock holds the child to these files, whatever their permissions:
|
||||
|
||||
- **Its folders:** the VM'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's ABI 2, which lets the cache rename a file from its top folder into `nar/`. It makes no folder, link, FIFO, socket or device there, and nothing in them runs.
|
||||
- **Nothing else:** it can't read, write or list any other file, your home folder, devvm's folders and `/etc` included, or run a program. Landlock doesn't restrict `stat`, 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. Neither does it restrict a file's mode, owner, extended attributes or times, nor a truncation by path below ABI 3, so the seccomp filter refuses those.
|
||||
- **Nothing else:** it can't read, write or list any other file, your home folder, devvm's folders and `/etc` included, or run a program. Landlock doesn't restrict `stat`, 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't restrict a file's mode, owner, extended attributes or times, or, below ABI 3, a truncation by path, so the seccomp filter refuses those.
|
||||
|
||||
From ABI 4 Landlock also refuses the child a TCP port'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'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's fix for signals between a process's threads, the child leaves its signals unscoped, because Go's runtime signals each of its threads to restrict itself in turn, and those signals would be refused and hang the start. Landlock's network rules match only ports, so they can't refuse an address alone, and the seccomp filter refuses the child every connection of its own on every kernel.
|
||||
|
||||
The seccomp filter refuses the child, with `EPERM`:
|
||||
|
||||
- **Sockets:** every socket but a netlink route socket (`AF_NETLINK` with `NETLINK_ROUTE`), which the floor reads the host's addresses through and which reaches the kernel alone, a socketpair, `connect`, `listen`, and `sendto`, `sendmsg` and `sendmmsg` with `MSG_FASTOPEN`, which would connect a TCP socket as it sends, such as its listener once a `shutdown` has closed it. So the child has no socket of its own to connect, and can't connect one it holds again, and below Landlock's ABI 9 the filter is also what keeps it from the ssh masters' control sockets, `docker.sock` and your SSH agent's socket.
|
||||
- **Sockets:** every socket but a netlink route socket (`AF_NETLINK` with `NETLINK_ROUTE`), which the floor reads the host's addresses through and which reaches the kernel alone, a socketpair, `connect`, `listen`, and `sendto`, `sendmsg` and `sendmmsg` with `MSG_FASTOPEN`, which would connect a TCP socket as it sends, such as its listener once a `shutdown` has closed it. So the child has no socket of its own to connect, and can't connect one it holds again. Below Landlock's ABI 9, the filter is also what keeps it from the ssh masters' control sockets, `docker.sock` and your SSH agent's socket.
|
||||
- **Calls around the filter:** the three `io_uring` calls, whose operations wouldn't pass it.
|
||||
- **Other processes:** `ptrace`, `process_vm_readv`, `process_vm_writev` and `pidfd_getfd`, which reach another process's memory or descriptors, and what changes how another process runs, which Landlock's scope of signals doesn't cover: `prlimit64` but on the child itself, as a limit such as `RLIMIT_CPU` can kill a process, `setpriority`, `ioprio_set`, `sched_setaffinity`, `sched_setscheduler`, `sched_setparam` and `sched_setattr`.
|
||||
- **Other processes:** `ptrace`, `process_vm_readv`, `process_vm_writev` and `pidfd_getfd`, which reach another process's memory or descriptors, and what changes how another process runs, which Landlock's scope of signals doesn't cover: `prlimit64` other than on the child itself, as a limit such as `RLIMIT_CPU` can kill a process, `setpriority`, `ioprio_set`, `sched_setaffinity`, `sched_setscheduler`, `sched_setparam` and `sched_setattr`.
|
||||
- **Watching files:** `inotify_init`, `inotify_init1`, `inotify_add_watch`, `fanotify_init` and `fanotify_mark`, which would tell it the names of files outside its folders as they change.
|
||||
- **A file's metadata by its path:** `chmod`, `fchmodat` and `fchmodat2`, `chown`, `lchown` and `fchownat`, the extended attributes' `setxattr`, `lsetxattr`, `removexattr`, `lremovexattr`, `setxattrat` and `removexattrat`, `truncate`, and the times' `utime`, `utimes`, `futimesat`, and `utimensat` with a path. The calls on a descriptor that the child opened, which Landlock checked as it opened it, stay: `fchmod`, `fchown`, `ftruncate` and `utimensat` on a descriptor, which its logs and the Nix cache use.
|
||||
- **The kernel's keyrings:** `add_key`, `request_key` and `keyctl`.
|
||||
- **What it never does:** running a program (`execve`, `execveat`), a process of its own (`fork` and `vfork`, and `clone` for anything but a thread), a namespace (`unshare`, `setns`, and `clone` with a namespace's flag), `bpf`, `userfaultfd` and `perf_event_open`. `clone3` gets `ENOSYS`, as a kernel without it answers, because its flags are behind a pointer that the filter can't read, so a caller falls back to `clone`, whose flags it can.
|
||||
|
||||
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, `socketcall` among them, can't get around it. The child needs none of these: 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's runtime starts its threads with `clone` and the thread's flag. The broker sets itself undumpable (`PR_SET_DUMPABLE`), so on a kernel without Landlock, where nothing else would, the child can't read the broker's memory or open its descriptors through `/proc`. Other processes of yours stay readable through `/proc` there, unless the kernel's Yama restricts `ptrace`, as Ubuntu's does. Once confined, the child checks that it lists its own folders, that it fails to list `/` and to read `/etc/hosts` with Landlock, and that it fails to make a unix or an IPv4 socket, to connect, to listen and to send with `MSG_FASTOPEN` with the filter. It also reads the host'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's 4, and a confinement or a check that fails fails the start, which devvm reports as the proxy failing to start (`proxy_start_failed`). 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.
|
||||
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, `socketcall` among them, can'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's runtime starts its threads with `clone` and the thread's flag. The broker sets itself undumpable (`PR_SET_DUMPABLE`), so on a kernel without Landlock, where nothing else would, the child can't read the broker's memory or open its descriptors through `/proc`. Other processes of yours stay readable through `/proc` there, unless the kernel's Yama restricts `ptrace`, as Ubuntu's does. Once confined, the child checks that it lists its own folders, that it fails to list `/` and to read `/etc/hosts` with Landlock, and that it fails to make a unix or an IPv4 socket, to connect, to listen and to send with `MSG_FASTOPEN` with the filter. It also reads the host'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's 4, and a confinement or a check that fails fails the start, which devvm reports as the proxy failing to start (`proxy_start_failed`). 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.
|
||||
|
||||
On both systems, the child checks that what confines its files holds before it says it's ready: it opens its broker'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 says how it's confined, which the broker writes to `run/proxy.confined`, one line of a level, `full`, `partial` or `none`, then what confines it and, for a child that isn't fully confined, why, from a fixed set of words, so devvm never prints what a child wrote:
|
||||
On both systems, the child checks that what confines its files holds before it says it's ready. It opens its broker'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's confined, and the broker writes that to `run/proxy.confined` as one line of a level, `full`, `partial` or `none`, then what confines it and, for a child that isn't fully confined, why, from a fixed set of words, so devvm never prints what a child wrote:
|
||||
|
||||
| `run/proxy.confined` | What |
|
||||
| --- | --- |
|
||||
@@ -186,7 +186,7 @@ On both systems, the child checks that what confines its files holds before it s
|
||||
| `none sandbox-exec-missing` | there's no `/usr/bin/sandbox-exec`, so the broker started the child unconfined |
|
||||
| `none sandbox-exec-failed` | `sandbox-exec` failed to start the child under its profile, so the broker started it again unconfined |
|
||||
| `none unsupported` | devvm doesn't confine the child on this system, or this devvm, built with cgo as the tests' race detector is, can't reach its threads |
|
||||
| `full landlock` | 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 |
|
||||
| `full landlock` | 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 |
|
||||
| `partial landlock landlock-signals` | this kernel'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 |
|
||||
| `partial landlock landlock-below-abi4` | this kernel's Landlock is ABI 2 or 3, which refuses no TCP of the child's, though the filter refuses it every socket and connection of its own |
|
||||
| `partial landlock no-seccomp` | this kernel has no seccomp filters, so only Landlock confines the child, which below ABI 4 can connect anywhere itself, this machine's loopback included |
|
||||
@@ -194,11 +194,11 @@ On both systems, the child checks that what confines its files holds before it s
|
||||
| `none no-landlock-or-seccomp` | this kernel has neither, so the child runs with the broker's access, and can connect anywhere itself |
|
||||
| `none landlock check-failed` | the child confined itself, but could open its broker's config |
|
||||
|
||||
The broker starts the child again unconfined only when `sandbox-exec` failed before devvm's code ran: when the child had already ended before it answered, either with `sandbox-exec`'s own exit status, 65 for a profile it refused or 71 for a program it couldn't run, or killed by `SIGABRT` or `SIGKILL`, 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's can cause those failures, so the second start, which has what's left of the broker's 4 seconds, never trades a confined child for an unconfined one at a VM's request. A program of yours that sent the child one of those signals in that moment could, and the proxy's log and devvm doctor then say the child runs unconfined. A child that answers `failed`, ends any other way, or doesn't answer in time fails the start, as it would unconfined, because what it read by then could be a VM's. A ready that names a sandbox the broker didn't start the child under, or another than the one it did, breaks the protocol's rules, so a child can't claim more than it was given. The broker writes a warning in `proxy.log` for each child that isn't fully confined, and devvm doctor warns of each running VM whose proxy says so ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)). A proxy that hasn't written `run/proxy.confined` yet, such as one still starting or one that a devvm before the broker started, gets no warning.
|
||||
The broker starts the child again unconfined only when `sandbox-exec` failed before devvm's code ran. That's when the child had already ended before it answered, either with `sandbox-exec`'s own exit status, 65 for a profile it refused or 71 for a program it couldn't run, or killed by `SIGABRT` or `SIGKILL`, 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's can cause those failures, so the second start, which has what's left of the broker's 4 seconds, never trades a confined child for an unconfined one at a VM's request. A program of yours that sent the child one of those signals in that moment could, and the proxy's log and devvm doctor then say the child runs unconfined. A child that answers `failed`, ends any other way, or doesn't answer in time fails the start, as it would unconfined, because what it read by then could be a VM's. A ready that names a sandbox the broker didn't start the child under, or another than the one it did, breaks the protocol's rules, so a child can't claim more than it was given. The broker writes a warning in `proxy.log` for each child that isn't fully confined, and devvm doctor warns of each running VM whose proxy says so ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)). A proxy that hasn't written `run/proxy.confined` yet, such as one still starting or one that a devvm from before the broker started, gets no warning.
|
||||
|
||||
## Policy files
|
||||
|
||||
On the allowlist tier, a VM's proxy reads these policies, in this order, as one list. [Allowlists](../safety/network.md#allowlists) describes what they allow and the rules they hold. The other tiers read fewer, as `netpolicy.Policies` lists them for each:
|
||||
On the allowlist tier, a VM's proxy reads these policies, in this order, as one list. [Allowlists](../safety/network.md#allowlists) describes what they allow and the rules they hold. The other tiers read fewer, and one list of devvm's makes each tier's:
|
||||
|
||||
- **internet:** one built-in policy, `network/internet.policy`, which holds `**:*`, every host and address on any port, then `secrets.policy`, then your files below, whose denies alone apply. The proxy's config lists those files in `deny_policies`, and the proxy drops their allows as it reads them, keeping their denies and a broken deny. `**` lifts no floor, so internal addresses and this machine's stay refused.
|
||||
- **none:** the built-in policies of the VM's agents, each agent's `shared-tools/<agent>.policy`, such as `shared-tools/claude.policy`, and no other built-in one, then `secrets.policy`, then your files as denies alone. The VM's links come before every rule, as on every tier.
|
||||
@@ -214,32 +214,32 @@ On the allowlist tier, a VM's proxy reads these policies, in this order, as one
|
||||
| `~/.local/share/devvm/vms/<hash>/policy` | that VM only |
|
||||
| `~/.local/share/devvm/vms/<hash>/run/secrets.policy` | every VM, which devvm writes with the hosts of the VM's secrets and logins and of its agents' [token endpoints](#logins-made-in-a-vm) |
|
||||
|
||||
The built-in policies are paths in devvm's own files, `assets/` in the repo, which are [built into the binary](install.md#devvms-own-files), and no copy of them is ever on disk. `netpolicy.Policies` lists both kinds for a VM: the built-in ones go in the proxy's config as names in `builtin_policies`, and your files as paths in `policies`. The proxy reads the built-in ones from the binary once, as it starts, ahead of your files in the list, and never again, so only an upgrade of devvm changes them, and an upgrade starts every VM's proxy again because the binary changed. A built-in policy that's missing, or that holds a line that isn't a rule, is a bug in devvm, so the proxy refuses to start rather than run with fewer rules than devvm meant, and devvm stops the VM as for any proxy that doesn't start. A missing file of yours, on the other hand, has no rules. `devvm network` reads the built-in policies from the binary too, and it labels each with its name (`# devvm: layers/base.policy`, and `"builtin"` with `--json`) where it shows your files' paths. Both lists are in the config that a proxy started with, so a change to either starts the proxy again.
|
||||
The built-in policies are paths in devvm's own files, which are [built into the binary](install.md#devvms-own-files), 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's config as names in `builtin_policies`, and your files as paths in `policies`. The proxy reads the built-in ones from the binary once, as it starts, ahead of your files in the list, and never again, so only an upgrade of devvm changes them, and an upgrade starts every VM's proxy again because the binary changed. A built-in policy that's missing, or that holds a line that isn't a rule, is a bug in devvm, so the proxy refuses to start rather than run with fewer rules than devvm meant, and devvm stops the VM as for any proxy that doesn't start. A missing file of yours, on the other hand, has no rules. `devvm network` reads the built-in policies from the binary too, and it labels each with its name (`# devvm: layers/base.policy`, and `"builtin"` with `--json`) where it shows your files' paths. Both lists are in the config that a proxy started with, so a change to either starts the proxy again.
|
||||
|
||||
The proxy, `devvm network` and `devvm doctor` read every policy with one parser, `proxy.ParsePolicy`, which returns each line that holds more than a comment, with its number and whether it's a rule. A line is a rule only when `proxy.ValidRule` takes it, which is exactly what `devvm network allow` and `deny` take. Each time the proxy reads a file, it logs each line that isn't a rule, with its file, number and text, quoted, to its own log, `proxy.log` in the VM's `logs/` folder. It skips such a line, unless the line starts with `!` (`proxy.BrokenDeny`). A broken deny fails closed: while any of the VM's policy files has one, the proxy's policy denies every name and every address, and each request gets `403` and a refused block whose reason names the file and the line, so neither the VM's prompt nor `devvm network log` suggests an allow rule. The VM's links and the proxy's own answers at `devvm.proxy` 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'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's mode or owner alone, with `chmod` or `chown`, changes none of the three, so the proxy doesn't see it until the file'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's log says once. The proxy, `devvm network` and `devvm doctor` read a policy file only when it's a regular file, through a symbolic link if it's one, of at most 1 MiB (`proxy.ReadPolicy`, through `internal/safefile`). They open it without blocking and check the file they opened, so a FIFO or a link to `/dev/zero` in a policy file's place can't hang them, and each refuses it with a named error, `safefile.ErrNotRegular` or `safefile.ErrTooLong`. A leading byte-order mark isn't part of the first line. `netpolicy.PolicyWarnings` warns about each line that isn't a rule, with `policy_broken_deny` for a broken deny and `policy_not_rule` for the others. `netpolicy.Proxy.Prepare` uses it for the VM's policy files at each launch of a confined VM, `devvm network allow`, `deny` and `rm` for the file they change, and `devvm doctor` for the files you edit: `~/.config/devvm/policy`, your layers' and each VM's own. `devvm network` also marks the line, and `--json` lists it in `not_rules`. A unit test parses every policy file that devvm ships and fails on any line that isn't a rule.
|
||||
The proxy, `devvm network` and `devvm doctor` read every policy with one parser, which returns each line that holds more than a comment, with its number and whether it's a rule. A line is a rule only when one check takes it, which is exactly what `devvm network allow` and `deny` take ([the packages](../contributing/structure.md#the-packages)). Each time the proxy reads a file, it logs each line that isn't a rule, with its file, number and text, quoted, to its own log, `proxy.log` in the VM's `logs/` folder. It skips such a line, unless the line starts with `!`, which makes it a broken deny. A broken deny fails closed: while any of the VM's policy files has one, the proxy's policy denies every name and every address, and each request gets `403` and a refused block whose reason names the file and the line, so neither the VM's prompt nor `devvm network log` suggests an allow rule. The VM's links and the proxy's own answers at `devvm.proxy` 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'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's mode or owner alone, with `chmod` or `chown`, changes none of the three, so the proxy doesn't see it until the file'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's log says once. The proxy, `devvm network` and `devvm doctor` read a policy file only when it's a regular file, through a symbolic link if it's one, of at most 1 MiB, through devvm'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 `/dev/zero` in a policy file's place can't hang them, and each refuses it with a named error, one for a file that isn't regular and one for a file that's too long. A leading byte-order mark isn't part of the first line. devvm warns about each line that isn't a rule, with `policy_broken_deny` for a broken deny and `policy_not_rule` for the others. A launch of a confined VM warns about the VM's policy files as it readies the VM's proxy, `devvm network allow`, `deny` and `rm` about the file they change, and `devvm doctor` about the files you edit: `~/.config/devvm/policy`, your layers' and each VM's own. `devvm network` also marks the line, and `--json` lists it in `not_rules`. A unit test parses every policy file that devvm ships and fails on any line that isn't a rule.
|
||||
|
||||
Each change that `devvm network allow`, `deny` or `rm` makes rewrites the file whole, through a link if the file is one, so a proxy never reads half of it.
|
||||
|
||||
### Quiet hosts
|
||||
|
||||
A built-in policy can hold `quiet HOST` or `quiet HOST:PORT` lines, for one exact host name, never `*.name` or `**`, so a quiet line can't hide a whole domain's blocks ([quiet hosts](../safety/network.md#quiet-hosts)). `proxy.ParsePolicy` returns such a line as one that isn't a rule, and `PolicyLine.Quiet` says what it is, so `proxy.ValidRule` and `devvm network allow` never take one. `readBuiltins` keeps it as a rule marked `quiet`, which allows and denies nothing, so `policy.all` leaves it out of the rules a decision reads, and `policy.quiet` matches a host and port against the built-in quiet rules alone, as the proxy matches any rule, but only while no rule covers that host and port (`policy.rulesFor`), whether an allow, a deny or one that narrows, and never on an open policy or one with a broken deny. `loadPolicy` drops a quiet line in any other file and logs it, and `netpolicy.PolicyWarnings` warns about it with `policy_quiet_not_own`. A quiet host is blocked as any host no rule allows, and an allow of yours still lifts it. `server.blocked` marks a block's event `Quiet` only when its reason is `notAllowed`, the one for a host no rule allows, it isn't refused whatever the rules say, and `policy.quiet` holds, for the proxy'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 `"quiet": true` but never counted among the blocks that `/blocked` and `/blocked/new` serve, so neither the VM's prompt nor `devvm-why` sees it, and `blockPage` writes no allow command for it. `netpolicy.Log.Blocks` gives it no `Allow` and a row of its own apart from the same host's other blocks, `devvm network log` ends its line `, quiet`, and `netpolicy.Judge.Quiet`, which is `Allowlist.Quiet`, keeps it out of what `devvm network lock` offers. `devvm network` marks a built-in quiet line with `quietMark`, its `--json` lists the hosts in `quiet` (`RuleFile.Quiet`), and the agents' table on the coding agents page leaves quiet lines out. Each quiet line in devvm's files has a comment that names the host's use and the maker's page that documents it.
|
||||
A built-in policy can hold `quiet HOST` or `quiet HOST:PORT` lines, for one exact host name, never `*.name` or `**`, so a quiet line can't hide a whole domain's blocks ([quiet hosts](../safety/network.md#quiet-hosts)). The policy parser returns such a line as one that isn't a rule, marked as a quiet line, so the check of a rule and `devvm network allow` never take one. The proxy's read of its built-in policies keeps it as a rule marked `quiet`, 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 `policy_quiet_not_own`. A quiet host is blocked as any host no rule allows, and an allow of yours still lifts it. The proxy marks a block's event quiet only when its reason is the one for a host no rule allows, it isn't refused whatever the rules say, and a quiet rule matches, for the proxy'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 `"quiet": true` but never counted among the blocks that `/blocked` and `/blocked/new` serve, so neither the VM's prompt nor `devvm-why` sees it, and the proxy's block page writes no allow command for it. `devvm network log` gives it no allow command and a row of its own apart from the same host's other blocks, and ends its line `, quiet`, and `devvm network lock` leaves it out of what it offers, judging it with the proxy's own match of quiet rules. `devvm network` marks a built-in quiet line, its `--json` lists the hosts in `quiet`, and the agents' table on the coding agents page leaves quiet lines out. Each quiet line in devvm's files has a comment that names the host's use and the maker's page that documents it.
|
||||
|
||||
### Requests by method and path
|
||||
|
||||
A rule for a host name or `*.name` can have its methods and then its path after it, each after spaces or tabs, such as `api.github.com GET,HEAD /repos/` ([rules by method and path](../safety/network.md#rules-by-method-and-path)). `proxy.ParsePolicy` reads such a line as one rule, whose text is its canonical form: the host as before, the methods in capitals in `proxy.Methods`' order, and the path as written, joined by one space. That's what `devvm network allow`, `deny` and `rm` write from `--method` and `--path` (`proxy.NarrowRule`), and what they compare a line by, so `HEAD,get` and `GET,HEAD` are the same rule. A method outside `proxy.Methods`, `CONNECT` among them, an address, a CIDR or `**` with methods or a path, and a path that isn't a pattern (`proxy.PathOK`) aren't rules, so a typo in a deny is a broken deny, which denies everything, rather than a deny of nothing.
|
||||
A rule for a host name or `*.name` can have its methods and then its path after it, each after spaces or tabs, such as `api.github.com GET,HEAD /repos/` ([rules by method and path](../safety/network.md#rules-by-method-and-path)). 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's list of methods, and the path as written, joined by one space. That's what `devvm network allow`, `deny` and `rm` write from `--method` and `--path`, and what they compare a line by, so `HEAD,get` and `GET,HEAD` are the same rule. A method outside that list, `CONNECT` among them, an address, a CIDR or `**` with methods or a path, and a path that isn't a pattern aren't rules, so a typo in a deny is a broken deny, which denies everything, rather than a deny of nothing.
|
||||
|
||||
The proxy judges a host in two steps. For the connection, `CONNECT host:port` or an absolute-form request, a deny that narrows doesn'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 (`policy.judge`) when a rule that narrows covers the host and either it's a deny or no rule allows the whole host (`hostRules.byRequest`). Both come from one read of the policy files (`policy.rulesFor`, a `hostRules`), so a file that changes between the two can't give the connection one rule's verdict and another's way through. Such a host's `CONNECT` on a port the proxy intercepts, `:443`, is intercepted with the VM's CA, as a bound host's is, and on any other port, or without a CA, it's refused with `403`, logged as a refused block, because the proxy can't see the requests in it. An absolute-form request, plain HTTP on any port or `https://`, is judged before it's forwarded.
|
||||
The proxy judges a host in two steps. For the connection, `CONNECT host:port` or an absolute-form request, a deny that narrows doesn'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'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't give the connection one rule's verdict and another's way through. Such a host's `CONNECT` on a port the proxy intercepts, `:443`, is intercepted with the VM's CA, as a bound host's is, and on any other port, or without a CA, it's refused with `403`, logged as a refused block, because the proxy can't see the requests in it. An absolute-form request, plain HTTP on any port or `https://`, is judged before it's forwarded.
|
||||
|
||||
Inside an intercepted tunnel, the proxy'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 (`421` otherwise), then judges it with the rules as they are then (`server.judgeRequest`), 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'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 `Upgrade` to any other protocol, such as `h2c`, whose requests would pass the same way, is refused, and so is a `CONNECT` inside the tunnel. A refused request gets `403`, and the event log gets a `blocked` event with its method and path. A deny's refusal is marked refused, so neither the VM's prompt nor `devvm network log --blocked` suggests an allow, and a request that no allow covers suggests the allow of the whole host. An allowed request's `forward` event names the rule that allowed it, as its `rule`.
|
||||
Inside an intercepted tunnel, the proxy'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 (`421` 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'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 `Upgrade` to any other protocol, such as `h2c`, whose requests would pass the same way, is refused, and so is a `CONNECT` inside the tunnel. A refused request gets `403`, and the event log gets a `blocked` event with its method and path. A deny's refusal is marked refused, so neither the VM's prompt nor `devvm network log --blocked` suggests an allow, and a request that no allow covers suggests the allow of the whole host. An allowed request's `forward` event names the rule that allowed it, as its `rule`.
|
||||
|
||||
`policy.judge` takes the rules that cover the host and port in order. A whole deny refuses, then a `CONNECT` 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't exactly one of `proxy.Methods` (`hostRules.unjudgeable`), 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 [secrets' bindings](#how-the-proxy-puts-them-in) (`proxy.match`):
|
||||
The proxy's judge of a request takes the rules that cover the host and port in order. A whole deny refuses, then a `CONNECT` 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't exactly one of the proxy'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 [secrets' bindings](#how-the-proxy-puts-them-in) ([the packages](../contributing/structure.md#the-packages)):
|
||||
|
||||
- **A path in plain form** (`plainPath`): the path as the proxy forwards it starts with `/`, has nothing percent-encoded, no `\` or `;`, and is clean, with no `.` or `..` 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 `\` as `/`, dropping `;` and what follows it, or not cleaning the path, so a request in any of them could reach a path that the proxy didn't judge.
|
||||
- **A pattern** (`proxy.PathOK`, `matchPath`): its segments are split at `/`, `*` matches any run of characters within one, and `**` as a whole segment matches one segment or more. A pattern's last `/` stands for `/**`, so `/api/` is `/api/**`, which is a binding's path below which the value goes in. A path's one trailing `/` may be there or not. Matching is a table over the pattern's and the path's segments, linear in the path for each of the pattern's at most 32 segments, so a VM's long path can't make it slow.
|
||||
- **The methods a request names** (`overrides`): besides its own, each value of a header that some servers take the method from, `X-HTTP-Method` or any with `method-override` in its name, read in any case and with `_` for `-` (`overrideLike`), as Rack's and CGI's servers turn `-` into `_`, and each `_method` parameter of the query, in any case of its name. A value that isn't exactly one of `proxy.Methods`, trimmed, is odd: a list such as `DELETE, GET`, which servers read apart, lower case or nothing. The proxy reads no body, so a form's `_method` field is the `POST`'s.
|
||||
- **An allow, and a binding,** match strictly (`match.allows`): the request's method, and every method it names besides, as written, must be among the rule's methods, with none odd, and its path must be plain and match the pattern in its own case. A request the matcher can't judge alike for every server is never allowed by a rule with a path.
|
||||
- **A deny** matches broadly (`match.denies`): 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't plain, the path above a pattern that ends with `/` or `/**`, the path with its last segment cut at its first `.`, which frameworks that take a format from a suffix (Rails, Spring) route to the same handler, and the path with each segment's trailing dots dropped, as servers that drop a trailing dot read it (`trimDots`).
|
||||
- **A query servers read apart** (`overrides`): while a rule narrows the host by method, a query with a `;`, which some servers split pairs at and Go's `url.ParseQuery` skips the pair around, or with an escape that doesn't decode, which `ParseQuery` drops, is odd, so a `_method` hidden in it can't pass.
|
||||
- **A path in plain form:** the path as the proxy forwards it starts with `/`, has nothing percent-encoded, no `\` or `;`, and is clean, with no `.` or `..` 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 `\` as `/`, dropping `;` and what follows it, or not cleaning the path, so a request in any of them could reach a path that the proxy didn't judge.
|
||||
- **A pattern:** its segments are split at `/`, `*` matches any run of characters within one, and `**` as a whole segment matches one segment or more. A pattern's last `/` stands for `/**`, so `/api/` is `/api/**`, which is a binding's path below which the value goes in. A path's one trailing `/` may be there or not. Matching is a table over the pattern's and the path's segments, linear in the path for each of the pattern's at most 32 segments, so a VM's long path can't make it slow.
|
||||
- **The methods a request names:** besides its own, each value of a header that some servers take the method from, `X-HTTP-Method` or any with `method-override` in its name, read in any case and with `_` for `-`, as Rack's and CGI's servers turn `-` into `_`, and each `_method` parameter of the query, in any case of its name. A value that isn't exactly one of the proxy's methods, trimmed, is odd: a list such as `DELETE, GET`, which servers read apart, lower case or nothing. The proxy reads no body, so a form's `_method` field is the `POST`'s.
|
||||
- **An allow, and a binding,** match strictly: the request's method, and every method it names besides, as written, must be among the rule's methods, with none odd, and its path must be plain and match the pattern in its own case. A request the matcher can't judge alike for every server is never allowed by a rule with a path.
|
||||
- **A deny** 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't plain, the path above a pattern that ends with `/` or `/**`, the path with its last segment cut at its first `.`, which frameworks that take a format from a suffix (Rails, Spring) route to the same handler, and the path with each segment's trailing dots dropped, as servers that drop a trailing dot read it.
|
||||
- **A query servers read apart:** while a rule narrows the host by method, a query with a `;`, which some servers split pairs at and Go's query parser skips the pair around, or with an escape that doesn't decode, which Go's parser drops, is odd, so a `_method` hidden in it can't pass.
|
||||
|
||||
In a user's terms, the methods a request names work like this. Some servers take a request'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 `X-HTTP-Method-Override` and `X-HTTP-Method` headers and every header with `method-override` in its name, in any case and with `_` for `-`, as some servers read `X_HTTP_METHOD_OVERRIDE`, and the `_method` parameter of the query. While a rule by method covers a host, a request there whose header or parameter isn't exactly one of those methods in capitals, such as `DELETE, GET`, `delete` or nothing at all, is refused, because servers could read it either way, and so is a request whose query has a `;` in it, which some servers split the query at, or a query with an escape that doesn't decode. Otherwise an allow needs the request's own method and every one it names to be among its methods, so an allow of `GET` refuses a `GET` that says it's a `DELETE`, and a deny refuses a request that names any of its methods. The proxy doesn't read a request's body, so a `_method` field in a form that a `POST` sends, which some frameworks take as the method, is judged as the `POST` it is: a deny of `POST` refuses it, and an allow of `POST` lets it through whatever the field says.
|
||||
|
||||
@@ -281,7 +281,7 @@ A blocked TLS host gets a TLS handshake with a certificate for its SNI name from
|
||||
|
||||
**The service.** `devvm-transparent run` is the service, under systemd or OpenRC, as root: it adds `198.18.0.1/32` to `lo`, 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 `SIGHUP` when `/etc/hosts` changes, and fetches the ports every tenth second. dnsmasq runs as the user `devvm-transparent`, and so does each socat connection'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'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's, in `/etc/devvm/transparent`, and the VM's password, which every program in the VM has in its environment already, is in files only, never in a process's arguments. On an open VM, and with transparent mode off, the setup stops and removes all of it, and flushes systemd-resolved'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.
|
||||
|
||||
**What doesn't change.** The host'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's DNS goes nowhere, as for a VM without transparent mode. The [self-check](#the-self-check)'s direct connection is to an address on port 443, so transparent mode never answers it. The VM's names never reach the host's resolver for a blocked host, because the proxy asks the policy before it resolves anything. [Design notes](design.md#transparent-mode) has the threat check.
|
||||
**What doesn't change.** The host'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's DNS goes nowhere, as for a VM without transparent mode. The [self-check](#the-self-check)'s direct connection is to an address on port 443, so transparent mode never answers it. The VM's names never reach the host's resolver for a blocked host, because the proxy asks the policy before it resolves anything. [Design notes](../contributing/design.md#transparent-mode) has the threat check.
|
||||
|
||||
### The VM's resolver
|
||||
|
||||
@@ -291,7 +291,7 @@ systemd-resolved still runs, so `resolvectl` and the programs that ask it over D
|
||||
|
||||
## The shared Nix cache
|
||||
|
||||
VMs with the [nix layer](images.md#the-nix-layer) share their downloads from Nix'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 [design note](design.md#the-shared-nix-cache) says why it's a cache that the host fills rather than a shared store.
|
||||
VMs with the [nix layer](images.md#the-nix-layer) share their downloads from Nix'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 [design note](../contributing/design.md#the-shared-nix-cache) says why it's a cache that the host fills rather than a shared store.
|
||||
|
||||
**In the VM.** devvm starts the VM's proxy with `nix_cache` set to `~/.local/share/devvm/cache/nix-cache` in its config when the VM's image has the nix layer, and the VM's setup puts `http://devvm.proxy/nix` before `https://cache.nixos.org` in Nix's `substituters` ([the VM's setup](#the-vms-setup)). It leaves `trusted-public-keys` as Nix has it, which is cache.nixos.org's key alone. Nix's daemon reaches `devvm.proxy` through its own proxy settings, so its requests are absolute-form `GET`s with the VM's password, and the proxy answers them itself, as it does `/blocked` and `/ca.pem`, 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.
|
||||
|
||||
@@ -299,9 +299,9 @@ VMs with the [nix layer](images.md#the-nix-layer) share their downloads from Nix
|
||||
|
||||
**What the host checks.** Before it keeps a narinfo, the proxy checks that its `StorePath` is the path the VM asked for, and that `cache.nixos.org-1`, whose Ed25519 key devvm pins, signed its fingerprint, `1;StorePath;NarHash;NarSize;References`. The signature doesn't cover the NAR's URL, so the proxy also checks that the URL is named by the narinfo's own `NarHash` or `FileHash`, and no narinfo can put a file in another NAR's place. It fetches a NAR only after it checked a narinfo that names it, never for a `HEAD`, and it keeps the NAR only when its SHA-256 and size are that narinfo's `FileHash` and `FileSize`. The host can't check a NAR's `NarHash`, which is the hash of the archive before compression, because the proxy uses Go's standard library alone, and that has no xz or zstd. Each VM's Nix checks the signature and the `NarHash` 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 `404`, and the proxy keeps nothing of them, so Nix goes to cache.nixos.org itself.
|
||||
|
||||
**The folder and its cap.** 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's cap is the `nix-cache.size` [retention setting](../using/settings.md#retention), 10 GiB when it's off, which devvm puts in the proxy's config as `nix_cache_max` 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'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'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's child that a VM took over could hold it for ever: past that, the request gets `404`, so Nix goes to cache.nixos.org itself, and devvm gc skips the trim and says so (`nix_cache_locked`). devvm gc and the daily retention run trim the cache to its cap too, and `devvm gc --nix-cache` empties it.
|
||||
**The folder and its cap.** 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's cap is the `nix-cache.size` [retention setting](../using/settings.md#retention), 10 GiB when it's off, which devvm puts in the proxy's config as `nix_cache_max` 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'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'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's child that a VM took over could hold it for ever. Past that, the request gets `404`, so Nix goes to cache.nixos.org itself, and devvm gc skips the trim and says so (`nix_cache_locked`). devvm gc and the daily retention run also trim the cache to its cap, and `devvm gc --nix-cache` empties it.
|
||||
|
||||
**What a child could leave there.** A VM's proxy'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 `nar/` only when it'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 `nar/` and sets the cache's folders to yours alone through the folders it opened, never by their paths. Anything at `nar/` that isn't a folder, such as a link, is deleted as itself and a folder made in its place, which the proxy's log warns of, so its change of mode never reaches a folder of yours. Every proxy reads a cached file only when it'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.
|
||||
**What a child could leave there.** A VM's proxy'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 `nar/` only when it'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 `nar/` and sets the cache's folders to yours alone through the folders it opened, never by their paths. The proxy deletes anything at `nar/` that isn'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'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.
|
||||
|
||||
**Logs.** Each request is a `nix-cache` event in the VM's own [log](#log-files), with its path and what came of it: `hit`, `fetched`, or why it wasn't found or was refused. `devvm network log` shows these as `cache`.
|
||||
|
||||
@@ -313,17 +313,17 @@ VMs with the [nix layer](images.md#the-nix-layer) share their downloads from Nix
|
||||
|
||||
The CA certificates in `~/.config/devvm/ca` ([a company's CA](../using/settings.md#a-companys-ca)) reach every project VM, whatever its tier, and the VM's proxy. Builds trust them too, as [Images and caching](images.md#a-companys-ca-in-builds) describes, and so does the mise that resolves the shared tools' versions on this machine, which on macOS trusts them for every connection but its Sigstore client's, as the host's mise below explains.
|
||||
|
||||
**Reading them.** `trust.Read` reads the folder's `*.pem` and `*.crt` files at each launch, each build, each proxy start and each run of the host's mise, and nothing outside the folder. It checks the folder and each of those files with `os.Lstat` and follows no link: a folder that is a link fails with `ca_folder_link`, and a file that is one, dangling or not, with `ca_link`. A link into a project folder would otherwise let that project's VM write the CA that every VM, build and proxy trusts. A file or folder that it can't read fails with `ca_unreadable` or `ca_folder_unreadable`, which name it and carry the error. It decodes every PEM block and refuses a block that isn't `CERTIFICATE` (`ca_not_certificate`), a certificate that `crypto/x509` can't parse (`ca_invalid`) and a certificate without CA basic constraints (`ca_not_ca`). It also refuses a file with no certificate in it. It tells a private key apart by its PEM type, not by the file'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.
|
||||
**Reading them.** devvm reads the folder's `*.pem` and `*.crt` files at each launch, each build, each proxy start and each run of the host'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 `ca_folder_link`, and a file that is one, dangling or not, with `ca_link`. A link into a project folder would otherwise let that project's VM write the CA that every VM, build and proxy trusts. A file or folder that it can't read fails with `ca_unreadable` or `ca_folder_unreadable`, which name it and carry the error. It decodes every PEM block and refuses a block that isn't `CERTIFICATE` (`ca_not_certificate`), a certificate that `crypto/x509` can't parse (`ca_invalid`) and a certificate without CA basic constraints (`ca_not_ca`). It also refuses a file with no certificate in it. It tells a private key apart by its PEM type, not by the file'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.
|
||||
|
||||
**Installing them.** `assets/guest/ca.sh DIR` runs as root and makes devvm's CAs in `/usr/local/share/ca-certificates` exactly DIR's `devvm-*.crt` files: the VM's own CA and its next one, `devvm-proxy.crt` and `devvm-proxy-next.crt`, and the user's `devvm-extra-N.crt`. When anything changed, it runs `update-ca-certificates --fresh`, so a CA that went leaves neither the bundle nor its hashed link. `update-ca-certificates` tells the hooks in `/etc/ca-certificates/update.d` only about the CAs it links, never about a file that was deleted, so `ca.sh` tells them itself. It runs each hook that `run-parts` would run, with a `-/etc/ssl/certs/NAME.pem` line on its input for each CA it removed, as Debian's `update-ca-certificates` does for a CA it deselects. That way Java's `cacerts` (ca-certificates-java's `jks-keystore` hook) and Mono'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 `ca.sh` says so in the run log. It also writes them all to `/etc/ssl/devvm.pem`, for Node. In a system without `update-ca-certificates`, such as a container image before its `ca-certificates` package, it adds them to `/etc/ssl/certs/ca-certificates.crt` itself. It keeps the bundle as it was in `/var/lib/devvm-ca`, 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, `ca.sh` removes every one of devvm's files. Its unit tests run it in a folder that stands for `/` (`DEVVM_CA_ROOT`).
|
||||
**Installing them.** devvm's guest script `ca.sh DIR` runs as root and makes devvm's CAs in `/usr/local/share/ca-certificates` exactly DIR's `devvm-*.crt` files: the VM's own CA and its next one, `devvm-proxy.crt` and `devvm-proxy-next.crt`, and the user's `devvm-extra-N.crt`. When anything changed, it runs `update-ca-certificates --fresh`, so a CA that went leaves neither the bundle nor its hashed link. `update-ca-certificates` tells the hooks in `/etc/ca-certificates/update.d` only about the CAs it links, never about a file that was deleted, so `ca.sh` tells them itself. It runs each hook that `run-parts` would run, with a `-/etc/ssl/certs/NAME.pem` line on its input for each CA it removed, as Debian's `update-ca-certificates` does for a CA it deselects. That way Java's `cacerts` (ca-certificates-java's `jks-keystore` hook) and Mono'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 `ca.sh` says so in the run log. It also writes them all to `/etc/ssl/devvm.pem`, for Node. In a system without `update-ca-certificates`, such as a container image before its `ca-certificates` package, it adds them to `/etc/ssl/certs/ca-certificates.crt` itself. It keeps the bundle as it was in `/var/lib/devvm-ca`, 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, `ca.sh` removes every one of devvm's files. Its unit tests run it in a folder that stands for `/` (`DEVVM_CA_ROOT`).
|
||||
|
||||
**Project VMs.** The setup that devvm sends at each launch carries `ca.sh` and the certificates in `ca/`, and `sync.sh` runs it, so a change applies at the next launch and a running VM needs no restart. Every project VM starts with `trust.Env` 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 (`VMSpec.Env`), and the VM's first start adds its proxy's address to it in the one edit before its first boot. The variables are `NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem`, which is empty when there are none (Node warns only about a missing file), `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE` and `PIP_CERT`, set to the system's bundle, and `UV_SYSTEM_CERTS=1`.
|
||||
**Project VMs.** The setup that devvm sends at each launch carries `ca.sh` and the certificates in `ca/`, and `sync.sh` runs it, so a change applies at the next launch and a running VM needs no restart. Every project VM starts with the CAs' 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's first start adds its proxy's address to it in the one edit before its first boot. The variables are `NODE_EXTRA_CA_CERTS=/etc/ssl/devvm.pem`, which is empty when there are none (Node warns only about a missing file), `SSL_CERT_FILE`, `REQUESTS_CA_BUNDLE` and `PIP_CERT`, set to the system's bundle, and `UV_SYSTEM_CERTS=1`.
|
||||
|
||||
**The proxy.** `netpolicy.Proxy.Prepare` reads the folder too, and writes the bundle into the proxy's config, `proxy.json` in the VM's run folder, as `upstream_cas`, which the proxy adds to the system's roots for its own TLS connections. Each secret lookup's context carries those roots (`proxy.WithRoots`), and an agent's OAuth refresh on the host trusts them (`proxy.RootsOf`, set on its client with `fetch.Client.Trust`), so it goes through a company proxy that inspects TLS as the VM's own requests do. devvm's other host requests, such as registry digests and Ubuntu's image check, use the host's own store, as the host's other programs do. A VM can't change that file or the folder, so the proxy's roots grow only by what you put there. A proxy whose bundle differs from the folder's starts again, as one whose CA was replaced does.
|
||||
**The proxy.** As devvm readies a VM's proxy, it reads the folder too, and writes the bundle into the proxy's config, `proxy.json` in the VM's run folder, as `upstream_cas`, which the proxy adds to the system's roots for its own TLS connections. Each secret lookup's context carries those roots, and an agent'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's own requests do. devvm's other host requests, such as registry digests and Ubuntu's image check, use the host's own store, as the host's other programs do. A VM can't change that file or the folder, so the proxy's roots grow only by what you put there. A proxy whose bundle differs from the folder's starts again, as one whose CA was replaced does.
|
||||
|
||||
**The host's mise.** The client that downloads devvm's own mise adds the folder's CAs to the system's roots (`fetch.Client.Trust`), and a download whose server's certificate it still doesn't trust fails with `tools_untrusted`, in place of `mise_download_failed`. That mise, a release build, uses rustls with the platform's verifier, so it trusts the system's roots, and it falls back to Mozilla's own only when none load. On Linux it reads the system's roots from files, as OpenSSL does. When the environment sets neither `SSL_CERT_FILE` nor `SSL_CERT_DIR`, it reads the first bundle it finds, such as `/etc/ssl/certs/ca-certificates.crt`, and the folders `/etc/ssl/certs` and `/etc/pki/tls/certs`, 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 `MISE_EXTRA_CA_CERTS` names them, which mise adds to its roots on both systems. mise's Sigstore client, which fetches the trust root (`tuf-repo-cdn.sigstore.dev`) that its lock-time provenance checks need, ignores that setting, so on Linux `trust.CAs.Host` also writes a bundle of the system's bundle and the folder's CAs, and `SSL_CERT_FILE` names it, which every client in mise reads. The system's bundle is the file that `SSL_CERT_FILE` names when devvm's environment sets it. When devvm's environment sets neither variable, `SSL_CERT_DIR` names the system's folders, so mise still reads them. Otherwise mise reads the folders that devvm's environment names, and none when it sets only `SSL_CERT_FILE`, so a bundle of your own keeps mise to the CAs that you chose and the folder'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 (`MISE_LOG_FILE`). When a failed resolve's log has rustls's `invalid peer certificate`, devvm fails with `tools_untrusted`, which names the folder, in place of `tools_resolve_failed` or `tools_need_resolve`.
|
||||
**The host's mise.** The client that downloads devvm's own mise adds the folder's CAs to the system's roots, and a download whose server's certificate it still doesn't trust fails with `tools_untrusted`, in place of `mise_download_failed`. That mise, a release build, uses rustls with the platform's verifier, so it trusts the system's roots, and it falls back to Mozilla's own only when none load. On Linux it reads the system's roots from files, as OpenSSL does. When the environment sets neither `SSL_CERT_FILE` nor `SSL_CERT_DIR`, it reads the first bundle it finds, such as `/etc/ssl/certs/ca-certificates.crt`, and the folders `/etc/ssl/certs` and `/etc/pki/tls/certs`, 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 `MISE_EXTRA_CA_CERTS` names them, which mise adds to its roots on both systems. mise's Sigstore client, which fetches the trust root (`tuf-repo-cdn.sigstore.dev`) that its lock-time provenance checks need, ignores that setting, so on Linux devvm also writes a bundle of the system's bundle and the folder's CAs, and `SSL_CERT_FILE` names it, which every client in mise reads. The system's bundle is the file that `SSL_CERT_FILE` names when devvm's environment sets it. When devvm's environment sets neither variable, `SSL_CERT_DIR` names the system's folders, so mise still reads them. Otherwise mise reads the folders that devvm's environment names, and none when it sets only `SSL_CERT_FILE`, so a bundle of your own keeps mise to the CAs that you chose and the folder'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 (`MISE_LOG_FILE`). When a failed resolve's log has rustls's `invalid peer certificate`, devvm fails with `tools_untrusted`, which names the folder, in place of `tools_resolve_failed` or `tools_need_resolve`.
|
||||
|
||||
**End-to-end checks** (`tests/e2e`): in `project`, a VM trusts a test CA from its next launch (`openssl verify` against the system'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't a certificate, and trusts the CA no more once the folder is emptied; in `tools`, Node fetches from that server.
|
||||
**End-to-end checks:** in `project`, a VM trusts a test CA from its next launch (`openssl verify` against the system'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't a certificate, and trusts the CA no more once the folder is emptied; in `tools`, Node fetches from that server.
|
||||
|
||||
## Secrets
|
||||
|
||||
@@ -337,27 +337,27 @@ A [secret of your own](../safety/network.md#your-own-secrets) keeps its value un
|
||||
|
||||
Inside devvm, a secret'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's login file, until the place that uses it. The same goes for a VM's proxy password and the company proxy's password. Printed in any way, in an error, a warning or devvm's run log, that type shows `<redacted>` and never the value, and devvm can'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's file, the proxy's config, the VM's state and the agents' login files ([secrets in the code](../contributing/structure.md#secrets-in-the-code)).
|
||||
|
||||
Each VM's state records, for each secret of yours it uses, the definition's ID and the hosts the secret had when devvm secret use bound it (`secrets.BoundSecret`). The VM's binding has the secret'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's lookup (`Store.Get`) checks every `secret` binding against the secret as it's saved before it gives a value: its hosts within the secret's, and its header, scheme, path, methods, Basic username switch, ID and placeholder the secret's own. A binding that doesn't match gets nothing, and the proxy logs `secret_binding_changed`. Writing the bindings of every running VM again goes on past a VM whose files can't be written and returns every failure together, so one VM never keeps the others' proxies from dropping a secret. A proxy whose bindings file did change drops every value it has cached at once. One whose file couldn'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's name is refused, and a list it can'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'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' names never shadow devvm's own, nor an agent's login's, whose bindings are named after the agent, such as `codex-key` or `pi-openai`, and their placeholders have `secret-` before the name, which no login's placeholder has. `devvm secret rm` 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.
|
||||
Each VM's state records, for each secret of yours it uses, the definition's ID and the hosts the secret had when devvm secret use bound it. The VM's binding has the secret'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's lookup checks every `secret` binding against the secret as it's saved before it gives a value: its hosts within the secret's, and its header, scheme, path, methods, Basic username switch, ID and placeholder the secret's own. A binding that doesn't match gets nothing, and the proxy logs `secret_binding_changed`. Writing the bindings of every running VM again goes on past a VM whose files can't be written and returns every failure together, so one VM never keeps the others' proxies from dropping a secret. A proxy whose bindings file did change drops every value it has cached at once. One whose file couldn'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's name is refused, and a list it can'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'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' names never shadow devvm's own, nor an agent's login's, whose bindings are named after the agent, such as `codex-key` or `pi-openai`, and their placeholders have `secret-` before the name, which no login's placeholder has. `devvm secret rm` 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.
|
||||
|
||||
### How the proxy puts them in
|
||||
|
||||
A secret's hosts join the VM'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't tell those domains from the rest without the public suffix list.
|
||||
|
||||
For each secret that has a value, devvm writes the VM's bindings to `secrets.json` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, as one JSON object, whole and mode 600. It's of `"version": 1` while every binding has no methods and no path but a prefix longer than `/` that ends with `/` and has no `*` (`proxy.BindingList.Encode`), so a proxy that knows only version 1, still running from before an upgrade, keeps the VM's bindings, its agents' 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'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 `/` has none, as `/` is every path. A binding with methods or another path makes it `"version": 2`, 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 (`secrets_other_binary`). A binding holds the secret's name, its kind, its hosts, header and placeholder, sometimes a path and methods, and never its value. The kind is `secret` for one that devvm keeps and `login` for one of an agent'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's a regular file, not a symbolic link, that only you can read or write, and a file it can't read that way has no bindings until devvm writes it again. For a bound host, the proxy intercepts `:443` tunnels instead of passing them through. It terminates TLS with a certificate from [the VM's own CA](#the-vms-ca). Each certificate it makes for a host lasts a day, but never past the CA'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 `*.example.com`, which needs a certificate for each name the VM asks for, can't grow the proxy's memory without end. It then puts the real value in the binding's header and forwards the request over a new TLS connection. Absolute-form `https://` requests get the same.
|
||||
For each secret that has a value, devvm writes the VM's bindings to `secrets.json` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, as one JSON object, whole and mode 600. It's of `"version": 1` while every binding has no methods and no path but a prefix longer than `/` that ends with `/` and has no `*`, so a proxy that knows only version 1, still running from before an upgrade, keeps the VM's bindings, its agents' 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'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 `/` has none, as `/` is every path. A binding with methods or another path makes it `"version": 2`, 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 (`secrets_other_binary`). A binding holds the secret's name, its kind, its hosts, header and placeholder, sometimes a path and methods, and never its value. The kind is `secret` for one that devvm keeps and `login` for one of an agent'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's a regular file, not a symbolic link, that only you can read or write, and a file it can't read that way has no bindings until devvm writes it again. For a bound host, the proxy intercepts `:443` tunnels instead of passing them through. It terminates TLS with a certificate from [the VM's own CA](#the-vms-ca). Each certificate it makes for a host lasts a day, but never past the CA'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 `*.example.com`, which needs a certificate for each name the VM asks for, can't grow the proxy's memory without end. It then puts the real value in the binding's header and forwards the request over a new TLS connection. Absolute-form `https://` requests get the same.
|
||||
|
||||
How the proxy puts the value in depends on the binding's kind. A `secret` binding's placeholder is replaced only when exactly one value of its header holds it, as it is or inside `Basic` credentials, and that value has one of four shapes (`Binding.secretValue`). It's the placeholder alone, or for `Authorization`, `Bearer`, `Token` or the binding's own `scheme` in any case, one space and the placeholder, because `gh` sends the GitHub token after `token`. It's also `Basic` 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 `x-access-token:<token>` that way. With the binding's `basic_user`, 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 `Digest` field are all places that a server can echo when it refuses a request, as Elasticsearch names the user it couldn't authenticate, so those keep the placeholder. A `login` binding's placeholder is replaced only when the header has one value and that value is the placeholder alone, or, for `Authorization`, `Bearer` in any case, one space and the placeholder (`Binding.takes`). Every agent sends its logins that way: an API key alone in `x-api-key` or `x-goog-api-key`, every other key and every OAuth login's access token after `Bearer`, and an MCP server's header as the whole value that the VM's copy replaced. Any other value keeps the placeholder, and so does a header that's sent twice, which a server may join into one value. So code in the VM can'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's, OpenAI's and DeepSeek's errors do, quotes only the placeholder. The proxy's own log names the binding and its header when it leaves a placeholder for that reason, without a value.
|
||||
How the proxy puts the value in depends on the binding's kind. A `secret` binding's placeholder is replaced only when exactly one value of its header holds it, as it is or inside `Basic` credentials, and that value has one of four shapes. It's the placeholder alone, or for `Authorization`, `Bearer`, `Token` or the binding's own `scheme` in any case, one space and the placeholder, because `gh` sends the GitHub token after `token`. It's also `Basic` 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 `x-access-token:<token>` that way. With the binding's `basic_user`, 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 `Digest` field are all places that a server can echo when it refuses a request, as Elasticsearch names the user it couldn't authenticate, so those keep the placeholder. A `login` binding's placeholder is replaced only when the header has one value and that value is the placeholder alone, or, for `Authorization`, `Bearer` in any case, one space and the placeholder. Every agent sends its logins that way: an API key alone in `x-api-key` or `x-goog-api-key`, every other key and every OAuth login's access token after `Bearer`, and an MCP server's header as the whole value that the VM's copy replaced. Any other value keeps the placeholder, and so does a header that's sent twice, which a server may join into one value. So code in the VM can'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's, OpenAI's and DeepSeek's errors do, quotes only the placeholder. The proxy's own log names the binding and its header when it leaves a placeholder for that reason, without a value.
|
||||
|
||||
A binding can also have a path, a pattern as a rule's is, and methods, and then the proxy puts its value in only for a request that they match as a rule's allow does (`match.allows`, the one matcher of [requests by method and path](#requests-by-method-and-path)), 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's `--method`, and a binding without them goes in for every method. A path that ends with `/` matches everything below it. OpenRouter's API keys are bound below `/api/`, because opencode and pi send them only to `openrouter.ai/api/v1/`, so the rest of the site gets the placeholder. They're bound in two headers, each a binding of its own with the same name and placeholder. pi sends the key in `x-api-key` to `/api/v1/messages` for OpenRouter's `anthropic/*` models, which it calls with Anthropic's API, and in `Authorization` after `Bearer` for every other model. opencode sends it in `Authorization` today, and in `x-api-key` for a model whose first API in the models.dev catalog is Anthropic's Messages API, because it uses a model's first API. The proxy compares the path as it forwards it, after a token endpoint's capture has set it, and it takes the path only in a form that every server reads alike: clean already, without a `.` or `..` 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 `;`, which some servers read as a separator or drop with what follows. A request for `/api/../settings`, `/api%2F..%2Fsettings` or `/%61pi/v1` keeps the placeholder. A bindings file with a path that isn't a pattern (`proxy.PathOK`), or with methods that aren't in their canonical form, has no bindings. Each request must name the bound host, and one that names another host gets `421`. 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.
|
||||
A binding can also have a path, a pattern as a rule's is, and methods, and then the proxy puts its value in only for a request that they match as a rule's allow does, with the one matcher of [requests by method and path](#requests-by-method-and-path), 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's `--method`, and a binding without them goes in for every method. A path that ends with `/` matches everything below it. OpenRouter's API keys are bound below `/api/`, because opencode and pi send them only to `openrouter.ai/api/v1/`, so the rest of the site gets the placeholder. They're bound in two headers, each a binding of its own with the same name and placeholder. pi sends the key in `x-api-key` to `/api/v1/messages` for OpenRouter's `anthropic/*` models, which it calls with Anthropic's API, and in `Authorization` after `Bearer` for every other model. opencode sends it in `Authorization` today, and in `x-api-key` for a model whose first API in the models.dev catalog is Anthropic's Messages API, because it uses a model's first API. The proxy compares the path as it forwards it, after a token endpoint's capture has set it, and it takes the path only in a form that every server reads alike: clean already, without a `.` or `..` 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 `;`, which some servers read as a separator or drop with what follows. A request for `/api/../settings`, `/api%2F..%2Fsettings` or `/%61pi/v1` keeps the placeholder. A bindings file with a path that isn't a pattern, or with methods that aren't in their canonical form, has no bindings. Each request must name the bound host, and one that names another host gets `421`. 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.
|
||||
|
||||
The proxy's broker is devvm itself, so it looks a value up in its own process, from the Keychain, devvm's secrets folder or the agent's login file, by the binding'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's bindings file and looks the value up with its own copy of it, so a child can ask for no value that isn'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's arguments. On macOS it asks the Keychain through `security find-generic-password`, 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' logins, and a failed lookup for 5 seconds, so a child can't make it run `security` 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's lookup is that old, and neither logs one. Each keeps a value by its binding'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's own log says why, without the value, such as `agent_refresh_failed` when refreshing a Codex login failed. It refuses with `403` 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.
|
||||
|
||||
**Unit tests:** `TestCheckName`, `TestCheckHost`, `TestCheckHeader`, `TestCheckEnv`, `TestCheckPrefix`, `TestDefine` and `TestChangeApply` (`internal/secrets`) check what a secret of yours may be and what devvm secret set's flags change; `TestReservedEnvAssets` and `TestEnvReservedForSecrets` (`internal/netpolicy`) check that every variable the VM's scripts export, and the proxy's, is one it can't take; `TestInjectSecretShapes` and `TestSchemeOK` (`internal/proxy`) check each shape a secret's value goes in, and each that keeps the placeholder; `TestPathWithin`, `TestForRequestMethods` and `TestInterceptSecretMethods` check that a binding's path and methods let the value in only for the requests they match, each request of a kept-alive or HTTP/2 connection on its own; `TestGetChecksTheBinding` checks that a binding that isn't the secret's as it's saved gets nothing; `TestValueMax` and `TestKeychainLine` (`internal/platform`) check that a value too long for the Keychain's line is refused before anything runs; `TestPlaceholders` checks that every secret's placeholder has one shape, the VM's own, and is never taken as a value; `TestCustomStore`, `TestCustomsUnreadable` and `TestWriteFilesCustom` check the list, its mode and its checks on reading, that no value is in it or in a VM's bindings, and that only a VM that uses the secret gets its binding and hosts; `TestValuesCachedByBinding` (`internal/proxy`) checks that two bindings of one name are cached apart; `TestCustomSecrets` (`internal/vm`) checks use, a new value, and the question that names the VMs before a delete. **CLI tests** (`secret_custom.txtar`, `layout.txtar`): every refusal before anything runs, the value on stdin and at a prompt and never in a command's arguments, the list, `--json`, the binding and the variable a VM gets and the other VM doesn't, and the delete. **End-to-end checks** (`tests/e2e`, `network`): a secret of yours bound to a host that the run's company proxy fakes; the VM's variable is its placeholder, the host gets the real value in the secret'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's proxy password and none of the tokens, keys and logins the section used are in devvm's run logs, its other logs or any VM's proxy logs, as they are or in Basic credentials, and no VM's proxy password is in Lima's logs, `ha.stderr.log` and the serial logs.
|
||||
**Tests:** the unit tests check what a secret of yours may be and what devvm secret set's flags change, that every variable the VM's scripts export, and the proxy's, is one it can't take, each shape its value goes in and each that keeps the placeholder, and that a binding'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't the secret's as it's saved gets nothing, that a value too long for the Keychain's line is refused before anything runs, and that every secret's placeholder has one shape, the VM'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'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's arguments, the list, `--json`, the binding and the variable a VM gets and the other VM doesn't, and the delete ([the tests behind it](../contributing/tests.md#the-tests-behind-how-it-works)). **End-to-end checks** (`network`): a secret of yours bound to a host that the run's company proxy fakes; the VM's variable is its placeholder, the host gets the real value in the secret'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's proxy password and none of the tokens, keys and logins the section used are in devvm's run logs, its other logs or any VM's proxy logs, as they are or in Basic credentials, and no VM's proxy password is in Lima's logs, `ha.stderr.log` and the serial logs.
|
||||
|
||||
### The VM's CA
|
||||
|
||||
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's key can impersonate sites to that VM alone, and no VM'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'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's CAs in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/ca/`: the current CA as `ca.pem` and its key `ca.key`, and the next CA as `next.pem` and its key `next.key`. 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's a regular file, not a symbolic link, and refuses a key that anybody but you may read or write.
|
||||
|
||||
At each launch, `trust.InitCA` readies both CAs before the proxy starts, holding the folder's lock, `lock`, 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'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't follow the current one that way, by ending after it and starting by the time it'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's setup installs both certificates in the VM, so the VM trusts the next CA weeks before the proxy uses it.
|
||||
At each launch, devvm readies both CAs before the proxy starts, holding the folder's lock, `lock`, 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'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't follow the current one that way, by ending after it and starting by the time it'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's setup installs both certificates in the VM, so the VM trusts the next CA weeks before the proxy uses it.
|
||||
|
||||
The proxy holds both CAs, and it signs with the next one from an hour after that CA'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't open again keeps verifying the proxy'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 [how long a proxy runs](#how-long-a-proxy-runs) describes. `/ca.pem` at `devvm.proxy` serves both certificates.
|
||||
|
||||
@@ -367,7 +367,7 @@ The CAs live as long as the VM's folder. A remake keeps the folder, so the VM ke
|
||||
|
||||
In a user's terms: to put a secret in, the proxy shows the VM a certificate from the VM's own CA, which every VM has, an open one's included, and which no other VM trusts, so one VM's proxy can't make certificates that another VM accepts. Each CA lasts 30 days, and its key stays on this machine. Each launch installs the VM'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't open again keeps working for at least 30 days after its last launch with `devvm` in its folder. Connecting with `ssh` alone isn't a launch. When a VM runs past its next CA's end without a launch, its proxy refuses its HTTPS connections to secrets' hosts, and `devvm network log --blocked` gives the reason `devvm's CA has ended`. The VM's other requests keep working. Running `devvm` in the VM's folder installs new CAs, which also starts the VM's proxy again and ends the connections open through it ([saving and binding secrets](../safety/network.md#saving-and-binding-secrets)). `devvm rm` deletes a VM's CAs with the VM, and a VM keeps them when its tier changes.
|
||||
|
||||
**Unit tests:** `TestInitCA`, `TestInitCASwitch` and `TestInitCAReplaced` (`internal/trust`) check the dates, the modes, the switch and each CA that's made again; `TestInitCATogether` and `TestInitCACancelled` check that launches at once take turns on the lock; `TestPrepareOpen` (`internal/netpolicy`) checks that an open VM's proxy has the VM's CAs, salt and secrets file, and that a VM keeps its CAs as its tier changes; `TestNextCASigns` checks that a client trusting both CAs verifies the proxy's certificates before the switch and after it, with the same proxy; `TestLoadCA` checks that the proxy refuses a key others may read and a symbolic link; `TestServersApart` checks that two proxies' certificates come from their own CAs. **CLI tests** (`network.txtar`, `sync.txtar`, `layout.txtar`): each VM's CA files and modes, two VMs' CAs differ, the setup sends both certificates and no key, an open VM's too, and a VM turned off and on again keeps its CAs. **End-to-end checks** (`tests/e2e`, `network`): a second confined VM, whose CAs differ from the first's; each VM trusts its own two and none of the other's; no key is anywhere in the VM; each proxy serves its own CAs at `/ca.pem`, and its certificates verify with its own VM's CAs and not with the other's; `devvm rm` deletes a VM's CA with its folder.
|
||||
**Tests:** the unit tests check the dates, the modes, the switch and each CA that's made again, that launches at once take turns on the lock, that an open VM's proxy has the VM'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'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' certificates come from their own CAs. The CLI tests check each VM's CA files and modes, that two VMs' CAs differ, that the setup sends both certificates and no key, an open VM's too, and that a VM turned off and on again keeps its CAs ([the tests behind it](../contributing/tests.md#the-tests-behind-how-it-works)). **End-to-end checks** (`network`): a second confined VM, whose CAs differ from the first's; each VM trusts its own two and none of the other's; no key is anywhere in the VM; each proxy serves its own CAs at `/ca.pem`, and its certificates verify with its own VM's CAs and not with the other's; `devvm rm` deletes a VM's CA with its folder.
|
||||
|
||||
## Agents' logins and settings
|
||||
|
||||
@@ -376,12 +376,12 @@ Agents' login files also stay on the host, in devvm's agent store, which `devvm
|
||||
Codex's login is `~/.local/share/devvm/logins/codex/.codex/auth.json`, opencode's is `~/.local/share/devvm/logins/opencode/.local/share/opencode/auth.json` and pi's is `~/.local/share/devvm/logins/pi/.pi/agent/auth.json`, the store's copies of `~/.codex/auth.json`, `~/.local/share/opencode/auth.json` and `~/.pi/agent/auth.json`. The VM's copy holds placeholders, shaped like a JWT where the tools read claims, and the bindings put the store's API key or access token into requests for the provider's hosts:
|
||||
|
||||
- For Codex, those are OpenAI's hosts, `api.openai.com`, and `chatgpt.com` for a ChatGPT login.
|
||||
- For opencode, they're the hosts of the API keys of the providers in [API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in), each in the headers that its row names (`agents.Providers`), and of OpenAI and GitHub Copilot logins, but not Copilot Enterprise. opencode keeps one entry per provider, `{"type":"api","key","metadata"}`, `{"type":"oauth","refresh","access","expires","accountId","enterpriseUrl"}` or `{"type":"wellknown","key","token"}`. A bound key's entry reaches the VM as `{"type","key"}` alone, its key the placeholder, so its `metadata` stays on this machine, and a bound OAuth login's keeps only the fields that name its account beside the placeholders (`internal/agentlogin/logins.go`'s `opencodeVM`).
|
||||
- For pi, they're the hosts of the same providers' 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's `?key=`, which the proxy couldn't fill in, because it swaps the placeholder in a header alone. pi keeps one entry per provider, `{"type":"api_key","key","env"}` or `{"type":"oauth","access","refresh","expires"}`, and devvm binds only the first kind, with a key that's a value rather than a `!command` or a `$NAME` or `${NAME}` template, which pi fills in from the entry's `env` or the environment (`$$` is a literal `$`). A bound entry reaches the VM as `{"type","key"}` alone, its key the placeholder, so nothing else of it, its `env` included, leaves this machine (`internal/agentlogin/pi.go`).
|
||||
- For opencode, they're the hosts of the API keys of the providers in [API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in), 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, `{"type":"api","key","metadata"}`, `{"type":"oauth","refresh","access","expires","accountId","enterpriseUrl"}` or `{"type":"wellknown","key","token"}`. A bound key's entry reaches the VM as `{"type","key"}` alone, its key the placeholder, so its `metadata` stays on this machine, and a bound OAuth login's keeps only the fields that name its account beside the placeholders ([the packages](../contributing/structure.md#the-packages)).
|
||||
- For pi, they're the hosts of the same providers' 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's `?key=`, which the proxy couldn't fill in, because it swaps the placeholder in a header alone. pi keeps one entry per provider, `{"type":"api_key","key","env"}` or `{"type":"oauth","access","refresh","expires"}`, and devvm binds only the first kind, with a key that's a value rather than a `!command` or a `$NAME` or `${NAME}` template, which pi fills in from the entry's `env` or the environment (`$$` is a literal `$`). A bound entry reaches the VM as `{"type","key"}` alone, its key the placeholder, so nothing else of it, its `env` included, leaves this machine.
|
||||
|
||||
The store keeps opencode's login in the `auth.json` format of opencode 1: one entry per provider, `{"type":"api","key"}` or `{"type":"oauth","access","refresh","expires"}` with its expiry in milliseconds. opencode 2 keeps its logins in the `credential` table of its SQLite database, `~/.local/share/opencode/opencode.db`, and imports `auth.json` into it once, in the migration that makes the table, so a VM's opencode gets the VM's copy when it first runs there. A VM's placeholders don't change when the host refreshes a login, so the database's copies keep working. After that, the store's opencode logins reach the database through `opencode auth import`, as `auth export` entries with the IDs `cred_devvm_<provider>` (`agentlogin.OpencodeImport`): the placeholder of each API key that the proxy puts in, each key that `[pass-keys]` passes, with its `metadata`, and the OpenAI login's placeholders from one of opencode's Codex logins. The VM's setup sends these entries on every launch, and `devvm agent login opencode --api-key --provider PROVIDER` sends them at once, both on the input of devvm's guest script `opencode.sh`, never in a command's arguments. The script keeps the last entries it got in `~/.local/state/devvm/opencode-import.json` 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's entries from the last ones with `opencode auth logout`, because `opencode auth import` skips an ID it already has, and then imports the new ones and makes each of them its provider's active credential with `opencode auth switch`, 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 `opencode auth switch` 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't always import `auth.json` 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't keep the others out, and `devvm agent login` 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'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.
|
||||
The store keeps opencode's login in the `auth.json` format of opencode 1: one entry per provider, `{"type":"api","key"}` or `{"type":"oauth","access","refresh","expires"}` with its expiry in milliseconds. opencode 2 keeps its logins in the `credential` table of its SQLite database, `~/.local/share/opencode/opencode.db`, and imports `auth.json` into it once, in the migration that makes the table, so a VM's opencode gets the VM's copy when it first runs there. A VM's placeholders don't change when the host refreshes a login, so the database's copies keep working. After that, the store's opencode logins reach the database through `opencode auth import`, as `auth export` entries with the IDs `cred_devvm_<provider>`: the placeholder of each API key that the proxy puts in, each key that `[pass-keys]` passes, with its `metadata`, and the OpenAI login's placeholders from one of opencode's Codex logins. The VM's setup sends these entries on every launch, and `devvm agent login opencode --api-key --provider PROVIDER` sends them at once, both on the input of devvm's guest script `opencode.sh`, never in a command's arguments. The script keeps the last entries it got in `~/.local/state/devvm/opencode-import.json` 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's entries from the last ones with `opencode auth logout`, because `opencode auth import` skips an ID it already has, and then imports the new ones and makes each of them its provider's active credential with `opencode auth switch`, 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 `opencode auth switch` 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't always import `auth.json` 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't keep the others out, and `devvm agent login` 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'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.
|
||||
|
||||
Each VM's placeholders end in its own random value, so no other VM's placeholder gets its secrets. devvm reads a login file only when it's a regular file, so a FIFO or a device in its place can't hold devvm. devvm refreshes OAuth logins on the host, one lookup at a time, and writes them back to the store's file, so a VM never holds the refresh token of a login devvm keeps. Claude Code's logins to MCP servers that you make in a VM are that VM's own ([Claude Code's login](agents.md#claude-codes-login)). 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'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 (`agent_refresh_failed`, `agent_provider_refresh_failed` for one of opencode's providers, `codex_no_key`, `codex_no_chatgpt`), or names the login file it couldn't read (`login_read_failed`). The VM's copy of Codex's `auth.json` holds only the fields that devvm knows, which `agentlogin`'s `codexKeep` lists, as Codex 0.166.0's login code reads them. Its API key and its tokens are placeholders, and the copy keeps `auth_mode` and `last_refresh`, and in `tokens`, `account_id`, `login_owner_id` and the refresh token's `oauth_provenance`, its `issuer` and `client_id`, each a plain value. devvm leaves every other field out, at the top of the file or in `tokens`, Codex's other logins included (`agent_identity`, `personal_access_token`, `bedrock_api_key` and `bedrock_access_keys`), because the proxy has no binding for them, and warns you, naming a field in `tokens` by its path, such as `tokens.zz` (`login_fields_withheld`). `TestFormatsWithholdUnknown` plants a field that no format knows in every object of each kind's login file, as a string, an object and a list, and checks that no VM's copy holds it. opencode's and pi's logins are withheld by default, by the same rule (`agents.Def`'s `PassKeys`): every entry that devvm doesn't bind, an API key, an OAuth login or opencode's well-known login, reaches the VM with only the fields that name its account or how it logs in, `type`, `expires`, `accountId`, `enterpriseUrl`, `projectId`, `email`, `scope`, `scopes` and `clientId`, each a plain value or a list of strings (`agentlogin`'s `withheldEntry`), and devvm warns you (`login_withheld`). opencode skips an entry that lacks its key or its tokens as it reads `auth.json`, so it doesn't use that provider in the VM. The exception is an API-key entry of a provider that `config.toml`'s `[pass-keys]` lists under the agent's name (`settings.PassKeys`), which goes as it is, and devvm notes it (`login_passed`). It'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 (`login_pass_bound`, from `VMFile`'s `PassBound`). The table has one key per agent, so each agent's withheld keys are passed on their own. If devvm can't make the VM's copy of a login, it stops the VM's setup (`login_copy_failed`).
|
||||
Each VM's placeholders end in its own random value, so no other VM's placeholder gets its secrets. devvm reads a login file only when it's a regular file, so a FIFO or a device in its place can't hold devvm. devvm refreshes OAuth logins on the host, one lookup at a time, and writes them back to the store's file, so a VM never holds the refresh token of a login devvm keeps. Claude Code's logins to MCP servers that you make in a VM are that VM's own ([Claude Code's login](agents.md#claude-codes-login)). 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'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 (`agent_refresh_failed`, `agent_provider_refresh_failed` for one of opencode's providers, `codex_no_key`, `codex_no_chatgpt`), or names the login file it couldn't read (`login_read_failed`). The VM's copy of Codex's `auth.json` holds only the fields that devvm knows, as Codex 0.166.0's login code reads them. Its API key and its tokens are placeholders, and the copy keeps `auth_mode` and `last_refresh`, and in `tokens`, `account_id`, `login_owner_id` and the refresh token's `oauth_provenance`, its `issuer` and `client_id`, each a plain value. devvm leaves every other field out, at the top of the file or in `tokens`, Codex's other logins included (`agent_identity`, `personal_access_token`, `bedrock_api_key` and `bedrock_access_keys`), because the proxy has no binding for them, and warns you, naming a field in `tokens` by its path, such as `tokens.zz` (`login_fields_withheld`). A unit test plants a field that no format knows in every object of each kind's login file, as a string, an object and a list, and checks that no VM's copy holds it ([the tests behind it](../contributing/tests.md#the-tests-behind-how-it-works)). opencode's and pi's logins are withheld by default, by the same rule, which each agent's entry in devvm's registry of the agents sets. Every entry that devvm doesn't bind, an API key, an OAuth login or opencode's well-known login, reaches the VM with only the fields that name its account or how it logs in, `type`, `expires`, `accountId`, `enterpriseUrl`, `projectId`, `email`, `scope`, `scopes` and `clientId`, each a plain value or a list of strings, and devvm warns you (`login_withheld`). opencode skips an entry that lacks its key or its tokens as it reads `auth.json`, so it doesn't use that provider in the VM. The exception is an API-key entry of a provider that `config.toml`'s `[pass-keys]` lists under the agent's name, which goes as it is, and devvm notes it (`login_passed`). It'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 (`login_pass_bound`). The table has one key per agent, so each agent's withheld keys are passed on their own. If devvm can't make the VM's copy of a login, it stops the VM's setup (`login_copy_failed`).
|
||||
|
||||
[Coding agents](../using/coding-agents.md) lists which files each agent shares.
|
||||
|
||||
@@ -389,35 +389,35 @@ Each VM's placeholders end in its own random value, so no other VM's placeholder
|
||||
|
||||
A login that an agent makes inside a VM goes to devvm's store too, and the VM gets only placeholders for it. The VM's proxy does this at the agent's OAuth token endpoint, the one request of a login whose reply holds its tokens. Codex and opencode both log in to OpenAI at `auth.openai.com/oauth/token`, whether the code comes from a browser's redirect or from a device code typed into a browser elsewhere. For opencode 2, those are its Codex logins, the methods `chatgpt-browser` and `chatgpt-headless`. Its Sign in with ChatGPT, `chatgpt-token-sharing`, registers a client of its own and gets its tokens from `auth.openai.com/api/accounts/oauth/token`, then checks the `id_token`'s signature against OpenAI's keys, which a placeholder can't pass, so devvm doesn't capture that endpoint, and its replies get `502`, as the next paragraph says. Every VM's proxy config lists that endpoint in `captures`, for Codex and for opencode, whatever the VM's image holds, because a program in the VM could install either agent itself, and the proxy refuses that agent's login rather than let its tokens reach the VM. The endpoint's host joins the VM's `secrets.policy` 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's `:443` tunnels as it does a bound host's, with a certificate from [the VM's CA](#the-vms-ca), and forwards every request to it. Only a request of the endpoint's method to its path is captured, a `POST` for every OAuth token endpoint, and the proxy compares the path once it'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 `/oauth//token`, `/OAuth/Token/`, `/oauth/token;x` or `/x;/../oauth/token` is captured too. A captured request goes to the endpoint's own path whatever the VM's spelling of it, and a `POST` goes without a query. An endpoint can be a `GET` instead, for a login that the agent polls for, whose request is its query. The proxy then refuses a query that isn't a form or that names a field twice, which devvm and the endpoint could read apart, and a `GET` 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 `access_token`, a `refresh_token` or an `id_token` anywhere gets `502`, whatever its type, so no other path there, such as another token endpoint's, hands the VM a login, and so does one that names a field that the endpoint's agent keeps its tokens in, such as `accessToken`. 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't read for that, one that's encoded or longer than 1 MiB, and an upgrade (`101`). No informational reply (`1xx`) 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't already clean too, such as one with path parameters, encoded characters or `..`, because the host could read it as below the guard where devvm doesn't. The API'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's requests to that API carry the agent's real login, which the proxy puts in, so the agent's section names the paths that could.
|
||||
|
||||
The proxy's child judges a captured request by the VM'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's real tokens, a new login's refresh token among them, and the store's `id_token` never reach the child. The broker finds the endpoint in its own config by the request's host, path and method, refusing a request that matches none, names the VM itself, and sends the request to the endpoint's host from its own config, on port 443, through the company proxy when there is one, trusting the system'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's `Accept-Encoding` header from every request to the host, so each reply comes as it is, or as gzip that Go's transport undoes. The request goes on unchanged, with two exceptions. After a code's login, Codex exchanges the login's `id_token` for an API key, with a token-exchange grant that asks for `openai-api-key`. The VM's request carries the VM's placeholder of the `id_token`, so the proxy puts the store's `id_token` in its place, and only when the placeholder is that VM's for the store's current login. An error reply to that request reaches the VM with its OAuth error code alone, such as `{"error":"invalid_grant"}`, in case the endpoint's message quotes the `id_token`. A refresh whose refresh token is the VM's own, `devvm-proxy-managed`, or for opencode its access token's placeholder, goes nowhere, and the VM gets the store's login as placeholders again, because the host refreshes the login itself. devvm refuses any other grant than a code's, a refresh's or Codex's exchange before the request leaves the host, because it couldn'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's longer gets `502`. 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.
|
||||
The proxy's child judges a captured request by the VM'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's real tokens, a new login's refresh token among them, and the store's `id_token` never reach the child. The broker finds the endpoint in its own config by the request's host, path and method, and refuses a request that matches none. It names the VM itself and sends the request to the endpoint's host from its own config, on port 443, through the company proxy when there is one, trusting the system'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's `Accept-Encoding` header from every request to the host, so each reply comes as it is, or as gzip that Go's transport undoes. The request goes on unchanged, with two exceptions. After a code's login, Codex exchanges the login's `id_token` for an API key, with a token-exchange grant that asks for `openai-api-key`. The VM's request carries the VM's placeholder of the `id_token`, so the proxy puts the store's `id_token` in its place, and only when the placeholder is that VM's for the store's current login. An error reply to that request reaches the VM with its OAuth error code alone, such as `{"error":"invalid_grant"}`, in case the endpoint's message quotes the `id_token`. A refresh whose refresh token is the VM's own, `devvm-proxy-managed`, or for opencode its access token's placeholder, goes nowhere, and the VM gets the store's login as placeholders again, because the host refreshes the login itself. devvm refuses any other grant than a code's, a refresh's or Codex's exchange before the request leaves the host, because it couldn'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's longer gets `502`. 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.
|
||||
|
||||
A successful reply never reaches the VM as it is. The broker reads it whole, up to 1 MiB, and `agentlogin.File.Capture` saves its tokens in the store's login file, in the agent's own format, under the file's lock, so a refresh on the host never runs at the same time. Codex's goes in `tokens` of its `auth.json`, with the account from the `id_token`, and the exchange's API key in `OPENAI_API_KEY`. opencode's goes in the `openai` entry of its `auth.json`, as an OAuth login with its expiry in milliseconds and its account. A code's reply replaces the login, and for Codex the API key of the login before it too. A refresh's reply adds to the login, so the store keeps only the newest refresh token. Then devvm writes the VM's bindings again, so its proxy puts the new login into requests at once. When that write fails, the login is saved still, the VM gets its reply, its proxy's own log says why, and the VM's next launch writes its bindings.
|
||||
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's login file, in the agent's own format, under the file's lock, so a refresh on the host never runs at the same time. Codex's goes in `tokens` of its `auth.json`, with the account from the `id_token`, and the exchange's API key in `OPENAI_API_KEY`. opencode's goes in the `openai` entry of its `auth.json`, as an OAuth login with its expiry in milliseconds and its account. A code's reply replaces the login, and for Codex it also replaces the API key of the login before it. A refresh's reply adds to the login, so the store keeps only the newest refresh token. Then devvm writes the VM'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's own log says why, and the VM's next launch writes its bindings.
|
||||
|
||||
The VM gets a reply with placeholders in place of the tokens. Its access token's placeholder is the one the store's login binds, a JWT with the login's account claims, its API key's is the one its binding names, and its refresh token is `devvm-proxy-managed`, 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's reply, so the agent in the VM never refreshes the login itself. Its headers are only `Content-Type`, `Cache-Control`, `Pragma` and `Date`, so no cookie of the endpoint's reaches the VM. A reply that's too long, encoded in another way, or not a login devvm reads, such as one without an access token, gets `502` 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 `login` event for each login saved, which names the agent, and the proxy's own log says why a capture failed, without a value.
|
||||
|
||||
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's endpoint is the agent's that the VM's image has, of Codex and opencode, and in a VM with both, the request's `User-Agent` says whose login it is, through `agentlogin.Pick`. Each login format that captures logins names its endpoints and the starts of its agent's `User-Agent`, and `agentlogin.Endpoints` lists every format's endpoints in the registry's order. opencode runs on Bun, so a request whose `User-Agent` starts with `Bun/` or `opencode/` is opencode's, and any other is Codex's, because Codex's format names none. When the VM's image has neither and its tier reaches the host, its request gets `502` before it leaves this machine, devvm saves nothing, and the proxy's own log says why (`login_capture_refused`).
|
||||
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's endpoint is the agent's that the VM's image has, of Codex and opencode, and in a VM with both, the request's `User-Agent` says whose login it is. Each login format that captures logins names its endpoints and the starts of its agent's `User-Agent`, and devvm lists every format's endpoints in the registry's order. opencode runs on Bun, so a request whose `User-Agent` starts with `Bun/` or `opencode/` is opencode's, and any other is Codex's, because Codex's format names none. When the VM's image has neither and its tier reaches the host, its request gets `502` before it leaves this machine, devvm saves nothing, and the proxy's own log says why (`login_capture_refused`).
|
||||
|
||||
Claude Code logs in at `platform.claude.com/v1/oauth/token`, and older releases at `console.anthropic.com/v1/oauth/token`, so every VM's proxy config lists both in `captures` for Claude Code, and their hosts join the `secrets.policy` of a VM whose image has it. Anthropic doesn't document these requests: devvm reads them from Claude Code 2.1's bundle, so a release that changes them can break the capture, and the `network` end-to-end section drives the real Claude Code's login against a fake endpoint to catch that. Claude Code sends JSON with its public client ID, `9d1c250a-e61b-44d9-88ed-5944d1962f5e`, and PKCE, without a client secret. A code's request holds `grant_type`, `code`, `redirect_uri`, `client_id`, `code_verifier` and `state`, and a refresh's `grant_type`, `refresh_token`, `client_id` and `scope`. The reply holds `access_token`, `refresh_token`, `expires_in` and `scope`, with the account and the organization.
|
||||
|
||||
`claude setup-token` sends a code's request too, with `expires_in` of a year added, and asks only for the `user:inference` scope, so `agentlogin.SetupToken` tells it apart by that field. Its reply's access token, which must start with `sk-ant-oat01-`, becomes the `claude` secret (`secrets.Store.Save`), and the VM gets the secret's placeholder in its place, which `claude setup-token` then prints. Any other code's login goes in the store's `.claude/.credentials.json`, as Claude Code keeps it on Linux: `claudeAiOauth` with `accessToken`, `refreshToken`, `expiresAt` in Unix milliseconds and `scopes`. A new login whose scope lacks `user:inference` gets `502`, because it can't use the model: that's an Anthropic Console login, which Claude Code would use to make an API key at `api.anthropic.com/api/oauth/claude_cli/create_api_key` with the access token the VM never gets. A login or a refresh whose scope has `org:create_api_key` gets `502` too, whatever else it has, because the proxy puts the login into every request to `api.anthropic.com`, so a VM could make an API key with it and get the key itself. The access token must start with `sk-ant-oat01-` and hold no space, quote, backslash or control character, in a capture's reply and in the host's refresh'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's gets `502` and devvm saves nothing. The VM's reply holds `sk-ant-oat01-devvm-proxy-managed-oauth-<salt>` as its access token and `devvm-proxy-managed` as its refresh token, so the Claude login in the VM's `~/.claude/.credentials.json`, which Claude Code writes from it, holds no token. A refresh with `devvm-proxy-managed` goes nowhere, and the VM gets the placeholders again.
|
||||
`claude setup-token` also sends a code's request, with `expires_in` of a year added, and asks only for the `user:inference` scope, so devvm tells it apart by that field. Its reply's access token, which must start with `sk-ant-oat01-`, is saved as the `claude` secret, and the VM gets the secret's placeholder in its place, which `claude setup-token` then prints. Any other code's login goes in the store's `.claude/.credentials.json`, as Claude Code keeps it on Linux: `claudeAiOauth` with `accessToken`, `refreshToken`, `expiresAt` in Unix milliseconds and `scopes`. A new login whose scope lacks `user:inference` gets `502`, because it can't use the model. Such a login is an Anthropic Console login, which Claude Code would use to make an API key at `api.anthropic.com/api/oauth/claude_cli/create_api_key` with the access token the VM never gets. A login or a refresh whose scope has `org:create_api_key` also gets `502`, whatever else it has, because the proxy puts the login into every request to `api.anthropic.com`, so a VM could make an API key with it and get the key itself. The access token must start with `sk-ant-oat01-` and hold no space, quote, backslash or control character, in a capture's reply and in the host's refresh'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's gets `502` and devvm saves nothing. The VM's reply holds `sk-ant-oat01-devvm-proxy-managed-oauth-<salt>` as its access token and `devvm-proxy-managed` as its refresh token, so the Claude login in the VM's `~/.claude/.credentials.json`, which Claude Code writes from it, holds no token. A refresh with `devvm-proxy-managed` goes nowhere, and the VM gets the placeholders again.
|
||||
|
||||
devvm keeps one Claude Code login. Saving the `claude` secret, captured or with `devvm secret set claude`, deletes the store's `.credentials.json`, and capturing an OAuth login deletes the saved `claude` secret, so the newest login wins. Both happen under the lock of the store's `logins/claude` folder, so two at once never leave neither, and a saved token that can't be deleted is a warning in the proxy's log, as the login is saved. A `CLAUDE_CODE_OAUTH_TOKEN` in devvm's environment wins over both, as it does in Claude Code (`secrets.ClaudeOf(store).Login`). A launch gives the VM `CLAUDE_CODE_OAUTH_TOKEN` with its placeholder when there's a token, and otherwise the VM's copy of `.credentials.json`, with that placeholder, no refresh token and an expiry of 2099 (`agentlogin.File.VMCopy`), never both. The copy's `claudeAiOauth` replaces the VM's own in its `~/.claude/.credentials.json`, and the rest of that file, such as Claude Code's logins to MCP servers, stays in the VM ([Claude Code's login](agents.md#claude-codes-login)). The VM's bindings hold both logins' placeholders, the `claude` secret's and `claude-oauth`, whenever devvm keeps either login, and `secrets.Store.Get` 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 `Authorization` for `api.anthropic.com`. Claude Code lists the connectors of the claude.ai account at `api.anthropic.com/v1/mcp_servers`, which needs the login's `user:mcp_servers` scope, and then reaches each connector at `mcp-proxy.anthropic.com/v1/mcp/<id>`, with the login's access token too. So the VM gets a third binding, `claude-connectors`, with `claude-oauth`'s placeholder, which puts the login into `Authorization` for `mcp-proxy.anthropic.com` below `/v1/mcp/` alone (`agentlogin.ClaudeOAuthBindings`). It's a binding of its own because the proxy looks a value up by its binding's name, and `secrets.Store.Get` gives `claude-connectors` only the OAuth login, never a token: while devvm keeps a token, saved or in its environment, that binding's lookup fails and puts nothing in. A token in devvm's environment isn't checked for its scope, so it could hold the connectors' scope, and that's why a token goes to `api.anthropic.com` alone. Claude Code sends the `anthropic-beta` header that names `oauth-2025-04-20` itself, so the proxy only swaps the placeholder.
|
||||
devvm keeps one Claude Code login. Saving the `claude` secret, captured or with `devvm secret set claude`, deletes the store's `.credentials.json`, and capturing an OAuth login deletes the saved `claude` secret, so the newest login wins. Both happen under the lock of the store's `logins/claude` folder, so two at once never leave devvm with neither login, and a saved token that can't be deleted is a warning in the proxy's log, as the login is saved. A `CLAUDE_CODE_OAUTH_TOKEN` in devvm's environment wins over both, as it does in Claude Code. A launch gives the VM `CLAUDE_CODE_OAUTH_TOKEN` with its placeholder when there's a token, and otherwise the VM's copy of `.credentials.json`, with that placeholder, no refresh token and an expiry of 2099, never both. The copy's `claudeAiOauth` replaces the VM's own in its `~/.claude/.credentials.json`, and the rest of that file, such as Claude Code's logins to MCP servers, stays in the VM ([Claude Code's login](agents.md#claude-codes-login)). The VM's bindings hold both logins' placeholders, the `claude` secret's and `claude-oauth`, whenever devvm keeps either login, and the store'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 `Authorization` for `api.anthropic.com`. Claude Code lists the connectors of the claude.ai account at `api.anthropic.com/v1/mcp_servers`, which needs the login's `user:mcp_servers` scope, and then reaches each connector at `mcp-proxy.anthropic.com/v1/mcp/<id>`, with the login's access token too. So the VM gets a third binding, `claude-connectors`, with `claude-oauth`'s placeholder, which puts the login into `Authorization` for `mcp-proxy.anthropic.com` below `/v1/mcp/` alone. It's a binding of its own because the proxy looks a value up by its binding's name, and the store's lookup gives `claude-connectors` only the OAuth login, never a token. While devvm keeps a token, saved or in its environment, that binding's lookup fails and puts nothing in. A token in devvm's environment isn't checked for its scope, so it could hold the connectors' scope, and that's why a token goes to `api.anthropic.com` alone. Claude Code sends the `anthropic-beta` header that names `oauth-2025-04-20` itself, so the proxy only swaps the placeholder.
|
||||
|
||||
The host refreshes the OAuth login when its access token is due, as Codex's is: a JSON refresh to `platform.claude.com/v1/oauth/token` with Claude Code's client ID and the login's scopes, through the company proxy the VM's proxy goes through, written back under the file's lock (`agentlogin.File.Get`). When the refresh fails, the proxy's log says to run `devvm agent login claude` again (`agent_refresh_failed`).
|
||||
The host refreshes the OAuth login when its access token is due, as Codex's is: a JSON refresh to `platform.claude.com/v1/oauth/token` with Claude Code's client ID and the login's scopes, through the company proxy the VM's proxy goes through, written back under the file's lock. When the refresh fails, the proxy's log says to run `devvm agent login claude` again (`agent_refresh_failed`).
|
||||
|
||||
`devvm agent login claude` runs `claude auth login --claudeai` in the VM, or `claude setup-token` with `--setup-token`, without the VM's `CLAUDE_CODE_OAUTH_TOKEN`. Claude Code shows the address that comes back to `platform.claude.com/oauth/code/callback`, which shows the code to paste, so devvm forwards no port. The login runs on your terminal: when devvm's input and output are both terminals, devvm gives the login its output and errors as the files they are (`ui.Terminal`, through `vm.Env.Terminal`), so Lima's `limactl shell` gives it a terminal in the VM with `ssh -t`, as it does devvm's shell. `claude setup-token` 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's output, and with `--setup-token` devvm warns first (`setup_token_no_terminal`). Every agent's login runs the same way, and either way, the login's output goes to devvm'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 `kill`, ends the login in the VM within 10 seconds, for a VM that ends its login when told (`AgentLogin.endLogin`), and until then ssh may hold the terminal in raw mode and write the VM's output to it. devvm saves the terminal'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't leave your terminal that way. Once the store has a new login of the kind asked for (`secrets.ClaudeOf(store).Sums`), devvm sets the VM up again, so its environment and files hold the login devvm keeps now.
|
||||
`devvm agent login claude` runs `claude auth login --claudeai` in the VM, or `claude setup-token` with `--setup-token`, without the VM's `CLAUDE_CODE_OAUTH_TOKEN`. Claude Code shows the address that comes back to `platform.claude.com/oauth/code/callback`, which shows the code to paste, so devvm forwards no port. The login runs on your terminal. When devvm's input and output are both terminals, devvm gives the login its output and errors as the files they are, so Lima's `limactl shell` gives it a terminal in the VM with `ssh -t`, as it does devvm's shell. `claude setup-token` 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's output, and with `--setup-token` devvm warns first (`setup_token_no_terminal`). Every agent's login runs the same way, and either way, the login's output goes to devvm'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 `kill`, 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's output to it. devvm saves the terminal'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't leave your terminal that way. Once the store has a new login of the kind asked for, which devvm tells by the logins' checksums before and after, devvm sets the VM up again, so its environment and files hold the login devvm keeps now.
|
||||
|
||||
Cursor's CLI logs in by polling: `cursor-agent login` shows `cursor.com/loginDeepControl` with a PKCE challenge and a uuid, and asks `GET api2.cursor.sh/auth/poll?uuid=…&verifier=…` until it answers `200` with `accessToken` and `refreshToken`, or gives up. Its endpoint in `captures` is that `GET` (`agentlogin`'s `cursorFormat`, checked against the CLI's Linux package 2026.11.17-f532c45, read but not run). The store's poll is the request's query, as a form, with its `uuid` and its `verifier`, and nothing else. A pending login's `404` passes as it is, and the success replaces the store's `~/.config/cursor/auth.json` with the two tokens. The VM gets `accessToken` as a JWT-shaped placeholder that lasts until 2099, because the CLI reads its `exp`, with the token's `sub`, which the CLI names the repos it indexes by, and `refreshToken` as `devvm-proxy-managed`, with the team that the reply chose. A reply without both tokens, such as an xAI sign-in's, is refused and saves nothing.
|
||||
Cursor's CLI logs in by polling: `cursor-agent login` shows `cursor.com/loginDeepControl` with a PKCE challenge and a uuid, and asks `GET api2.cursor.sh/auth/poll?uuid=…&verifier=…` until it answers `200` with `accessToken` and `refreshToken`, or gives up. Its endpoint in `captures` is that `GET`, as devvm's format for Cursor's login names it, checked against the CLI's Linux package 2026.11.17-f532c45, read but not run). The store's poll is the request's query, as a form, with its `uuid` and its `verifier`, and nothing else. A pending login's `404` passes as it is, and the success replaces the store's `~/.config/cursor/auth.json` with the two tokens. The VM gets `accessToken` as a JWT-shaped placeholder that lasts until 2099, because the CLI reads its `exp`, with the token's `sub`, which the CLI names the repos it indexes by, and `refreshToken` as `devvm-proxy-managed`, with the team that the reply chose. A reply without both tokens, such as an xAI sign-in's, is refused and saves nothing.
|
||||
|
||||
The login's bindings put the token in `Authorization` only for the methods that the CLI's package calls, each one by its whole path, `/package.Service/Method` (`agentlogin`'s `cursorRoutes`): on `api2.cursor.sh`, those of its API's services, such as `DashboardService`'s `GetMe`, never its methods that make API keys, and its traces at `/v1/traces`. On the agent's hosts, `api5.cursor.sh` and `*.api5.cursor.sh`, which `api2.cursor.sh`'s server config names, and on `api2.cursor.sh`, where HTTP/1.1 takes it, only the agent's stream, `Run` and `RunSSE`, and `BidiAppend`. On `repo42.cursor.sh`, its indexing, only its five indexing methods. The package checks the agent's hosts only for being URLs and names none of them, so devvm takes every host below `api5.cursor.sh`, the one Cursor's network docs name. On every one of those hosts the proxy refuses, with `403`, any request below `/auth/` but the poll it captures, so no other login endpoint there hands the VM tokens, and the API's other methods that make, show or exchange a credential (`proxy`'s `cursorMints`): 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 `githubMinting` refuses GitHub's keys and webhooks, though the CLI calls them on the host (`cursorPersists`): installing, updating and removing plugins and marketplaces, applying, deleting, testing and changing automations, setting and deleting cloud agents' environments, starting a cloud agent, and checking Bedrock keys, which devvm doesn't keep. It refuses every method of the agent store's service, `AgentStoreService`, and of any service of any package whose name starts with `AgentStore`, in any case (`cursorStore`), because the agent store isn't the VM's alone: the account'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's store, and a path in a store can be shared with the team or the public. The store's methods also take a token of its own, which `MintAgentStoreToken` 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's and its teams' own state, `DashboardService`, `AutomationsService` and `BackgroundComposerService`, it refuses any method whose name starts with a verb that changes something, such as `Set`, `Install`, `Start`, `Commit`, `Merge`, `Fork`, `Write` or `Pin` (`cursorChanges`), 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 `Submit`, whose `SubmitFeedback` the CLI calls, or `Check` or `Generate`, whose methods also only read, isn't on the list, so `GenerateGrokCollectionDescription`, which drafts a description and only returns it, passes. `Test` matches one method that only reads, `TestAutomationFilter`, a dry run of an automation's filter, and stays on the list for `TestTeamCustomerTelemetryDestinationConnection`, which has Cursor's servers send a request with any headers to any address. It also refuses every path below `/cloud-agent/`, where `cursor-agent worker`, which makes the machine a worker for your cloud agents, gets its identity tokens. That worker connects to `api2direct.cursor.sh`, which has no bindings, with `Host: api2.cursor.sh`, so the proxy doesn't open its tunnel and the login never goes in, and on the allowlist tier the host isn'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 it doesn't have, such as `ResolveReviewThread`, whose verb also starts methods that only read, isn't refused by it, and gets no login from the proxy either. So in a VM, Cursor's CLI can't do those, and you do them from Cursor on your machine. It also refuses any path it can't read as those hosts do, with an escape, path parameters, a backslash, a byte past ASCII'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 (`Range`), as the proxy could then see no more than a part of a token.
|
||||
The login's bindings put the token in `Authorization` only for the methods that the CLI's package calls, each one by its whole path, `/package.Service/Method`: on `api2.cursor.sh`, those of its API's services, such as `DashboardService`'s `GetMe`, never its methods that make API keys, and its traces at `/v1/traces`. On the agent's hosts, `api5.cursor.sh` and `*.api5.cursor.sh`, which `api2.cursor.sh`'s server config names, and on `api2.cursor.sh`, where HTTP/1.1 takes it, only the agent's stream, `Run` and `RunSSE`, and `BidiAppend`. On `repo42.cursor.sh`, its indexing, only its five indexing methods. The package checks the agent's hosts only for being URLs and names none of them, so devvm takes every host below `api5.cursor.sh`, the one Cursor's network docs name. On every one of those hosts the proxy refuses, with `403`, any request below `/auth/` other than the poll it captures, so no other login endpoint there hands the VM tokens. It also refuses the API'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'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' environments, starting a cloud agent, and checking Bedrock keys, which devvm doesn't keep. It refuses every method of the agent store's service, `AgentStoreService`, and of any service of any package whose name starts with `AgentStore`, in any case, because the agent store isn't the VM's alone. The account'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's store, and a path in a store can be shared with the team or the public. The store's methods also take a token of its own, which `MintAgentStoreToken` 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's and its teams' own state, `DashboardService`, `AutomationsService` and `BackgroundComposerService`, it refuses any method whose name starts with a verb that changes something, such as `Set`, `Install`, `Start`, `Commit`, `Merge`, `Fork`, `Write` or `Pin`, 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 `Submit`, whose `SubmitFeedback` the CLI calls, or `Check` or `Generate`, whose methods also only read, isn't on the list, so `GenerateGrokCollectionDescription`, which drafts a description and only returns it, passes. `Test` matches one method that only reads, `TestAutomationFilter`, a dry run of an automation's filter, and stays on the list for `TestTeamCustomerTelemetryDestinationConnection`, which has Cursor's servers send a request with any headers to any address. It also refuses every path below `/cloud-agent/`, where `cursor-agent worker`, which makes the machine a worker for your cloud agents, gets its identity tokens. That worker connects to `api2direct.cursor.sh`, which has no bindings, with `Host: api2.cursor.sh`, so the proxy doesn't open its tunnel and the login never goes in, and on the allowlist tier the host isn'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't have, such as `ResolveReviewThread`, whose verb also starts methods that only read, isn't refused by the list, but it gets no login from the proxy either. So in a VM, Cursor's CLI can't do those, and you do them from Cursor on your machine. It also refuses any path it can't read as those hosts do, with an escape, path parameters, a backslash, a byte past ASCII'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 (`Range`), as the proxy could then see no more than a part of a token.
|
||||
|
||||
`api2.cursor.sh` also serves the CLI's API, whose agent replies stream, so the endpoint's guard is `/auth/`, with the CLI's own token fields, such as `accessToken`, `sessionToken` and `apiKey`, 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's hosts, the proxy drops the VM's `Accept-Encoding`, `Connect-Accept-Encoding` and `Grpc-Accept-Encoding` from each request, so each reply comes as it is, or as gzip that Go's transport undoes. A Connect or gRPC server still compresses a stream's messages with gzip when the request's are, as the CLI's agent stream's are. It drops any `Set-Cookie` 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's gzip, a part of a reply (`206`), and a reply with a JWT's start in any header, its name or its value. A Connect or gRPC stream, which its `Content-Type` names, passes message by message (`proxy`'s `frameScanner`): the proxy reads each message whole, at most 16 MiB as it comes and as it decompresses, gunzips it when its flag says it's compressed, and checks it for a JWT's start before any of it passes, as it came. Connect's end of stream is JSON, and so is every message of a stream whose `Content-Type` says JSON, so the proxy checks those messages' strings as they decode, escapes undone. It refuses gRPC-Web's text variant, a whole body in base64, outright. A token in base64, such as in a `-bin` header or a protobuf `bytes` field of a JSON stream, isn't found, as before. A message with a token, a flag the proxy doesn't know, a compressed message that isn't gzip, one over the limit or an envelope cut off ends the stream there, before that message. Every other reply'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's start, a header and the start of its claims (`proxy`'s `jwtScanner`), passing none of that read. The reply then ends there, so the token's claims and signature never reach the VM, though its header may. At the body's end the reader checks the reply'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'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'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't stopped either. devvm checked the CLI's behaviour against one release of it by reading its code, not against Cursor's servers. devvm doesn't guard Cursor's other hosts either: if one of them also answered `/auth/poll`, a VM could finish a login there and keep its tokens, though none is known to. Unauthenticated requests for `/auth/poll` with an unknown login got `404 Not found` from `api2.cursor.sh`, as a pending login does, and a route-not-found `404` from `agent.api5.cursor.sh`.
|
||||
`api2.cursor.sh` also serves the CLI's API, whose agent replies stream, so the endpoint's guard is `/auth/`, with the CLI's own token fields, such as `accessToken`, `sessionToken` and `apiKey`, 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's hosts, the proxy drops the VM's `Accept-Encoding`, `Connect-Accept-Encoding` and `Grpc-Accept-Encoding` from each request, so each reply comes as it is, or as gzip that Go's transport undoes. A Connect or gRPC server still compresses a stream's messages with gzip when the request's are, as the CLI's agent stream's are. It drops any `Set-Cookie` 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's gzip, a part of a reply (`206`), and a reply with a JWT's start in any header, its name or its value. A Connect or gRPC stream, which its `Content-Type` 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's compressed, and checks it for a JWT's start before any of it passes, as it came. Connect's end of stream is JSON, and so is every message of a stream whose `Content-Type` says JSON, so the proxy checks those messages' strings as they decode, escapes undone. It refuses gRPC-Web's text variant, a whole body in base64, outright. A token in base64, such as in a `-bin` header or a protobuf `bytes` field of a JSON stream, isn't found, as before. A message with a token, a flag the proxy doesn't know, a compressed message that isn't gzip, one over the limit or an envelope cut off ends the stream there, before that message. Every other reply'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's start, a header and the start of its claims, passing none of that read. The reply then ends there, so the token's claims and signature never reach the VM, though its header may. At the body's end the reader checks the reply'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'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'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't stopped either. devvm checked the CLI's behaviour against one release of it by reading its code, not against Cursor's servers. devvm doesn't guard Cursor's other hosts either: if one of them also answered `/auth/poll`, a VM could finish a login there and keep its tokens, though none is known to. Unauthenticated requests for `/auth/poll` with an unknown login got `404 Not found` from `api2.cursor.sh`, as a pending login does, and a route-not-found `404` from `agent.api5.cursor.sh`.
|
||||
|
||||
The CLI never refreshes a login with its refresh token: only an API key is exchanged for a token, at `/auth/exchange_user_api_key`, which the proxy refuses, as devvm keeps no Cursor API key. So the host doesn't refresh it either, and once the access token's `exp` has passed, the lookup fails with `agent_refresh_failed`, which says to log in again.
|
||||
|
||||
Any VM with the agent can replace the store's login, because the store keeps one login for each agent. A VM you don't trust can log your other VMs in to an account of its choosing, and their requests then go to that account. Claude Code'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 `claude /install-github-app`'s, becomes devvm'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 `api.anthropic.com`, beyond the model, such as reading the account's profile, and devvm doesn't limit the paths it goes to there. At `mcp-proxy.anthropic.com`, below `/v1/mcp/`, it can call any of the account'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 `mcp-proxy.anthropic.com` in your rules, on every tier but open, keeps connectors from a VM ([your claude.ai connectors](../safety/attack-vectors.md#the-network)). devvm doesn't guard Anthropic's other hosts either: if one of them also answered `/v1/oauth/token`, a VM could exchange its code there and keep the login'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's tokens itself and devvm saves nothing.
|
||||
Any VM with the agent can replace the store's login, because the store keeps one login for each agent. A VM you don't trust can log your other VMs in to an account of its choosing, and their requests then go to that account. Claude Code'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 `claude /install-github-app`'s, becomes devvm'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 `api.anthropic.com`, beyond the model, such as reading the account's profile, and devvm doesn't limit the paths it goes to there. At `mcp-proxy.anthropic.com`, below `/v1/mcp/`, it can call any of the account'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 `mcp-proxy.anthropic.com` in your rules, on every tier but open, keeps connectors from a VM ([your claude.ai connectors](../safety/attack-vectors.md#the-network)). devvm doesn't guard Anthropic's other hosts either. If one of them also answered `/v1/oauth/token`, a VM could exchange its code there and keep the login'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's tokens itself and devvm saves nothing.
|
||||
|
||||
**Unit tests:** `TestCaptureLogin`, `TestCapturePaths`, `TestCaptureEarlyHintsAnswerAndSaved`, `TestCaptureErrorPasses`, `TestCaptureRefuses` and `TestCaptureGet` (`internal/proxy`) 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 `1xx` 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't be read is refused; `TestCodexCapture`, `TestOpencodeCapture`, `TestClaudeCapture`, `TestClaudeSetupToken`, `TestClaudeOAuthGet`, `TestCaptureRefuses`, `TestEndpoints` and `TestPick` (`internal/agentlogin`) check each agent's file, the VM's placeholders and copies, the exchange, the VM's own refresh, a Console login refused, setup-token's request told apart, the host's refresh of Claude Code's login and repeated fields; `TestOneClaudeLogin`, `TestClaudeBindings` and `TestClaudeOAuthVMCopy` (`internal/secrets`) check that the newest Claude Code login replaces the other, the environment's token wins, both logins' bindings get the login devvm keeps while the connectors' binding gets the OAuth login alone, never a saved token or the environment's, and the VM's copy holds placeholders; `TestCapturer` and `TestCaptureOwnAgents` (`internal/netpolicy`) check that every VM'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't have, and that a capture writes the VM's bindings; `TestAgentLoginTerminal` (`internal/vm`) and `TestTerminal` (`internal/ui`) check that an agent's login gets the terminal's files only when devvm's input and output are both terminals, and pipes otherwise. **End-to-end checks** (`tests/e2e`, `network`): a fake token endpoint behind a company proxy of the run's own, which the VM reaches through its proxy; the store gets the real tokens and the API key, the VM's replies hold placeholders and no refresh token, no log holds a value, and the VM's next launch gets the login as placeholders. For Claude Code, the same company proxy fakes Claude's token endpoint and Anthropic's API: `claude setup-token`'s request makes the `claude` secret and the VM gets its placeholder, the real Claude Code's `claude auth login` through `devvm agent login claude` saves the login in the store and leaves placeholders alone in the VM, `devvm agent login claude --setup-token`, run in a terminal of its own, shows Claude Code's address, the API gets the store's token for the VM's placeholders, `mcp-proxy.anthropic.com` gets only placeholders while devvm keeps the `claude` secret, whichever of the two the VM sends, and a login that's due makes the host refresh it at Claude's endpoint through the company proxy, after which both the API and `mcp-proxy.anthropic.com` get the refreshed access token.
|
||||
**Tests:** 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 `1xx` 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't be read is refused. They check each agent's file, the VM's placeholders and copies, the exchange, the VM's own refresh, a Console login refused, setup-token's request told apart, the host's refresh of Claude Code's login and repeated fields, and that the newest Claude Code login replaces the other, the environment's token wins, both logins' bindings get the login devvm keeps while the connectors' binding gets the OAuth login alone, never a saved token or the environment's, and the VM's copy holds placeholders. They also check that every VM'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't have, that a capture writes the VM's bindings, and that an agent's login gets the terminal's files only when devvm's input and output are both terminals, and pipes otherwise ([the tests behind it](../contributing/tests.md#the-tests-behind-how-it-works)). **End-to-end checks** (`network`): a fake token endpoint behind a company proxy of the run's own, which the VM reaches through its proxy; the store gets the real tokens and the API key, the VM's replies hold placeholders and no refresh token, no log holds a value, and the VM's next launch gets the login as placeholders. For Claude Code, the same company proxy fakes Claude's token endpoint and Anthropic's API: `claude setup-token`'s request makes the `claude` secret and the VM gets its placeholder, the real Claude Code's `claude auth login` through `devvm agent login claude` saves the login in the store and leaves placeholders alone in the VM, `devvm agent login claude --setup-token`, run in a terminal of its own, shows Claude Code's address, the API gets the store's token for the VM's placeholders, `mcp-proxy.anthropic.com` gets only placeholders while devvm keeps the `claude` secret, whichever of the two the VM sends, and a login that's due makes the host refresh it at Claude's endpoint through the company proxy, after which both the API and `mcp-proxy.anthropic.com` get the refreshed access token.
|
||||
|
||||
### MCP servers
|
||||
|
||||
@@ -427,7 +427,7 @@ On each launch, devvm merges the settings and MCP servers from the store's `.cla
|
||||
- devvm removes the servers it copied before that you no longer have.
|
||||
- Servers added in the VM stay.
|
||||
|
||||
The copy holds only your settings, onboarding and account state, and MCP servers. Everything else stays out, such as `primaryApiKey`, `customApiKeyResponses` and your per-project entries, which `devvm agent import` 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, `oauthAccount`, keeps only the fields that Claude Code 2.1.319 writes there, which `agentlogin`'s `claudeAccountKeep` lists: its profile (`accountUuid`, `emailAddress`, `organizationUuid`, `hasExtraUsageEnabled`, `billingType`, `accountCreatedAt`, `subscriptionCreatedAt`, `claudeCodeTrialEndsAt`, `claudeCodeTrialDurationDays`, `seatTier`, `planDisplayName`, `displayName`, `fullName` and `profileFetchedAt`), its roles (`organizationRole`, `workspaceRole` and `organizationName`) and its rate-limit tiers (`organizationType`, `organizationRateLimitTier` and `userRateLimitTier`), each a plain value. Its `ccOnboardingFlags` 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 `oauthAccount` out of the VM's copy and warns you, naming each by its path, such as `oauthAccount.zz` (`login_fields_withheld`), and `TestFormatsWithholdUnknown` checks `~/.claude.json` as it checks the other login files. If devvm can't read the store's `.claude.json`, it stops the VM's setup (`login_copy_failed`).
|
||||
The copy holds only your settings, onboarding and account state, and MCP servers. Everything else stays out, such as `primaryApiKey`, `customApiKeyResponses` and your per-project entries, which `devvm agent import` 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, `oauthAccount`, keeps only the fields that Claude Code 2.1.319 writes there: its profile (`accountUuid`, `emailAddress`, `organizationUuid`, `hasExtraUsageEnabled`, `billingType`, `accountCreatedAt`, `subscriptionCreatedAt`, `claudeCodeTrialEndsAt`, `claudeCodeTrialDurationDays`, `seatTier`, `planDisplayName`, `displayName`, `fullName` and `profileFetchedAt`), its roles (`organizationRole`, `workspaceRole` and `organizationName`) and its rate-limit tiers (`organizationType`, `organizationRateLimitTier` and `userRateLimitTier`), each a plain value. Its `ccOnboardingFlags` 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 `oauthAccount` out of the VM's copy and warns you, naming each by its path, such as `oauthAccount.zz` (`login_fields_withheld`), and the unit test that plants unknown fields checks `~/.claude.json` as it checks the other login files. If devvm can't read the store's `.claude.json`, it stops the VM's setup (`login_copy_failed`).
|
||||
|
||||
On every tier, an HTTPS server's headers become bindings for its host, which must be a DNS name on port 443. devvm replaces these with `devvm-redacted`: env values, plain-HTTP servers' headers, user info and secret-looking values in URLs, and secret-named or key-shaped arguments. A server's `command` and `headersHelper`, which are shell commands, lose the same words as other text in settings files ([keys in settings files](#keys-in-settings-files)).
|
||||
|
||||
@@ -455,7 +455,7 @@ Taking secrets out of a file works only where devvm can tell a secret from the r
|
||||
- **The agents' mounted folders.** devvm mounts Claude Code's `skills`, `agents`, `commands`, `output-styles` and `plugins`, Codex's `prompts` and `skills`, opencode's subfolders, and pi's `extensions`, `skills`, `prompts` and `themes` whole and read-only, so every file in them reaches the VM, a `.env` in `~/.config/opencode/plugin` included. So does a plugin marketplace's git config in `~/.claude/plugins/marketplaces`, 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's config folder's files get, would break them. A copy without files whose names look secret, such as `.env` or `*.pem`, 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's agent store at once. So devvm mounts them as they are, and the [coding agents page](../using/coding-agents.md#mounts) says to keep secrets out of them.
|
||||
- **Free text of an unknown shape.** A key in other text, such as a hook's command, stays when it neither starts like a known key nor follows `Bearer` or `Basic`, because devvm can't tell it from a word.
|
||||
- **Logins devvm can't bind.** opencode's and pi's keys that devvm can't bind, a local model server's among them, are withheld unless `[pass-keys]` lists their provider, and then they go as they are (`login_passed`).
|
||||
- **pi's settings that undo devvm's.** The VM's copy of pi's `settings.json` leaves out `httpProxy`, `sessionDir` and `selfUpdateCommand` (`agentlogin.PiSettings`, `pi_settings_dropped`), and devvm warns when it sets `defaultProjectTrust` to `always` (`pi_trusts_all`). Its other settings stay, with their keys taken out as above.
|
||||
- **pi's settings that undo devvm's.** The VM's copy of pi's `settings.json` leaves out `httpProxy`, `sessionDir` and `selfUpdateCommand` (`pi_settings_dropped`), and devvm warns when it sets `defaultProjectTrust` to `always` (`pi_trusts_all`). Its other settings stay, with their keys taken out as above.
|
||||
|
||||
## The self-check
|
||||
|
||||
@@ -505,21 +505,21 @@ The proxy's own lines, such as what it loaded and what failed upstream, go to `p
|
||||
|
||||
The event log also holds the VM's [links](ports.md#links-between-vms)' connections, which `devvm _links` writes in the same format: `link` for a connection it carried, and `link_refused`, `link_target_stopped` or `link_limit` for one it refused, with the link's name as the host and the target VM in `target`. An open VM's event log holds its proxy's events and its links', but nothing it reached directly.
|
||||
|
||||
The proxy's broker and its child are the only programs that write `proxy.log`, which is the output of both, each line'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's lock, checks the file's size again, copies the file to `proxy.log.1` and empties it, so the two rotate it once. The event log has the child and `devvm _links` as its writers.
|
||||
The proxy's broker and its child are the only programs that write `proxy.log`, which is the output of both, each line'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's lock, checks the file's size again, copies the file to `proxy.log.1` and empties it, so the two rotate it once. The event log has the child and `devvm _links` as its writers.
|
||||
|
||||
The child writes the VM's logs folder, so devvm, `devvm _links`, `devvm network log`, `devvm network lock` and the proxy open the logs there never through a link at their end, and take only a regular file with one link that's yours. A start that finds a link, a FIFO or another file's hard link where a log should be removes that name, never what it leads to, and starts a new log there, and `devvm network log` refuses such a file without waiting on it. The proxy rotates each log before a line would take it past 10 MiB, and `devvm _links` writes the event log with the proxy'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'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 `network.jsonl`, and when the other writer has rotated it, the writer opens the new `network.jsonl` and writes there, so its lines go on reaching the file that `devvm network log --follow` follows. Each writer takes the log's size from the file, so it counts the other writer'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 `network.jsonl` to `network.jsonl.1`, which replaces the one that was there, and starts a new `network.jsonl`. `proxy.log` is also the proxy process's output, where its last error goes when it stops, so the proxy copies it to `proxy.log.1` and empties it instead, and that error still reaches the current file. The proxy takes `proxy.log`'s size from the file before each line, so what reached it as the processes' output counts too, and its HTTP server's errors, such as a handler's panic, go through the child's own lines rather than straight to that output. Every log file and its `.1` file is readable only by you (mode 600).
|
||||
The child writes the VM's logs folder, so devvm, `devvm _links`, `devvm network log`, `devvm network lock` 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's yours. A start that finds a link, a FIFO or another file's hard link where a log should be removes that name, never what it leads to, and starts a new log there, and `devvm network log` refuses such a file without waiting on it. The proxy rotates each log before a line would take it past 10 MiB, and `devvm _links` writes the event log with the proxy'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'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 `network.jsonl`, and when the other writer has rotated it, the writer opens the new `network.jsonl` and writes there, so its lines go on reaching the file that `devvm network log --follow` follows. Each writer takes the log's size from the file, so it counts the other writer'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 `network.jsonl` to `network.jsonl.1`, which replaces the one that was there, and starts a new `network.jsonl`. `proxy.log` is also the proxy process's output, where its last error goes when it stops, so the proxy copies it to `proxy.log.1` and empties it instead, and that error still reaches the current file. The proxy takes `proxy.log`'s size from the file before each line, so what reached it as the processes' output counts too, and its HTTP server's errors, such as a handler's panic, go through the child's own lines rather than straight to that output. Every log file and its `.1` file is readable only by you (mode 600).
|
||||
|
||||
`devvm network log` reads `network.jsonl.1` before `network.jsonl`, so the history it shows and the blocks that `devvm network log --blocked` counts carry on across a rotation. `devvm network log --follow` reads the renamed file to its end and then follows the new one from its start. `devvm rm` deletes the `.1` files with the rest of the VM's logs.
|
||||
|
||||
### Learning from the log
|
||||
|
||||
A VM that [learns the hosts it needs](../safety/network.md#learning-the-hosts-a-vm-needs) is on the internet tier, and its state's `net` section has `learning.since`, the time it started, which any tier set later clears. Its proxy runs as any internet VM's does, so nothing else records what it reaches: `devvm network lock` and each launch's reminder read the event log, both files, with `netpolicy.Log.Learned`. They take each `tunnel`, `intercept` and `forward` event since that time, one row for each host and port, its rule `proxy.ExactRule`'s, which always writes the port, counting its events and the first word of the `User-Agent` its requests sent most, which a CONNECT's event records too, when that word is at most 32 of `[A-Za-z0-9._/+-]` (`agentWord`). The proxy caps an event's path and `User-Agent` at 512 bytes as it records them, and takes no request headers past 64 KiB, so a VM can't bloat the log. An address that isn't public (`proxy.Public`) and a host the policy doesn't take are left out. Each host and port is judged once with the policies the VM would have on the allowlist tier, which `netpolicy.Policies` lists and `proxy.ReadAllowlist` reads as the proxy reads them, its built-in policies from the binary included: `Allowlist.Allows` and `Allowlist.Denies` are the proxy'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 `netpolicy.Tickable` says so: on port 443, it's one of `tickable`'s reviewed registry and vendor names, or under one, each with its reason beside it, and it isn't risky. Nothing of the VM's rules, secrets or own policy file makes a host tickable, so a host one lock added never makes its neighbours tick later, and `TestTickable` 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 `netpolicy.RiskOf`'s: 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'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 "more" lines (`pick_too_small`), 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 `pick_failed` 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's width, and so are the hosts that only events with `"via": "dns"` reached (`Learned.NoProxy`), between the others and the risky ones. The lock re-reads the VM's state under its lock (`VM.Update`) 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. `devvm network learn` and `devvm group join` each check the other's change under the VM's lock too, so a learning VM never ends up in a group. A launch's reminder counts only while both files hold at most 2 MiB (`Log.Countable`). 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 `learn` event into its log with the proxy's own writer (`netpolicy.Log.MarkLearning`), which `devvm network log` doesn't show, and `devvm network lock` warns when that mark is gone.
|
||||
A VM that [learns the hosts it needs](../safety/network.md#learning-the-hosts-a-vm-needs) is on the internet tier, and its state's `net` section has `learning.since`, the time it started, which any tier set later clears. Its proxy runs as any internet VM's does, so nothing else records what it reaches: `devvm network lock` and each launch's reminder read the event log, both files. They take each `tunnel`, `intercept` and `forward` 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 `User-Agent` its requests sent most, which a CONNECT's event records too, when that word is at most 32 of `[A-Za-z0-9._/+-]`. The proxy caps an event's path and `User-Agent` at 512 bytes as it records them, and takes no request headers past 64 KiB, so a VM can't bloat the log. An address that isn't public, by the proxy's one judge of that, and a host the policy doesn'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'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's one of devvm's reviewed registry and vendor names, or under one, each with its reason beside it, and it isn't risky. Nothing of the VM'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'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 "more" lines (`pick_too_small`), 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 `pick_failed` 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's width, and so are the hosts that only events with `"via": "dns"` reached, between the others and the risky ones. The lock re-reads the VM's state under the VM's lock, in the one update of a VM'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. `devvm network learn` and `devvm group join` each check the other's change under the VM's lock too, so a learning VM never ends up in a group. A launch'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 `learn` event into its log with the proxy's own writer, which `devvm network log` doesn't show, and `devvm network lock` warns when that mark is gone.
|
||||
|
||||
## devvm _proxy
|
||||
|
||||
devvm runs the proxy as itself, `devvm _proxy -config FILE`, and nothing else is in its arguments. That's the broker, which runs its child as `devvm _proxy-child -for FILE`, with the same config's path, which the child never opens: it's there so devvm can tell each VM's child apart, by `run/proxy-child.pid` and those arguments, and stop one that outlived its broker. Their flags take one dash or two, and their errors end in one line, `The VM's proxy failed: …` (`proxy_failed`). [Processes](processes.md#a-vms-proxy) has what a VM's proxy holds, what it reads from the VM and its bounds, and [a build's proxy](processes.md#a-builds-proxy) has the build's.
|
||||
devvm runs the proxy as itself, `devvm _proxy -config FILE`, and nothing else is in its arguments. That's the broker, which runs its child as `devvm _proxy-child -for FILE`, with the same config's path, which the child never opens. The path is there so devvm can tell each VM's child apart, by `run/proxy-child.pid` and those arguments, and stop one that outlived its broker. Their flags take one dash or two, and their errors end in one line, `The VM's proxy failed: …` (`proxy_failed`). [Processes](processes.md#a-vms-proxy) has what a VM's proxy holds, what it reads from the VM and its bounds, and [a build's proxy](processes.md#a-builds-proxy) has the build's.
|
||||
|
||||
The config is one JSON file, `proxy.Config`, which a VM's proxy and a build's proxy both run with. For a VM it's `proxy.json` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, and for a build it's `proxy.json` in the build proxy's folder. devvm writes it whole, mode 600, before each start. It holds the VM's password and the company proxy's credentials from the environment, though never `config.toml`'s password, which the proxy looks up itself, so it's never in a process's arguments, which other users can see. The proxy reads it once, as it starts, and refuses to start unless it'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 `"version": 1`, with no field the proxy doesn't know. It also refuses a config without a password, one whose `listen` isn't a loopback address and port, one with `ca` and no `ca_key` or the other way around, and one with a `nix_cache_max` 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.
|
||||
The config is one JSON file, which a VM's proxy and a build's proxy both run with. For a VM it's `proxy.json` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, and for a build it's `proxy.json` in the build proxy's folder. devvm writes it whole, mode 600, before each start. It holds the VM's password and the company proxy's credentials from the environment, though never `config.toml`'s password, which the proxy looks up itself, so it's never in a process's arguments, which other users can see. The proxy reads it once, as it starts, and refuses to start unless it'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 `"version": 1`, with no field the proxy doesn't know. It also refuses a config without a password, one whose `listen` isn't a loopback address and port, one with `ca` and no `ca_key` or the other way around, and one with a `nix_cache_max` 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.
|
||||
|
||||
| Field | What |
|
||||
| --- | --- |
|
||||
@@ -534,7 +534,7 @@ The config is one JSON file, `proxy.Config`, which a VM's proxy and a build's pr
|
||||
| `lifeline` | the hostagent'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 |
|
||||
| `ca`, `ca_key` | the [VM's own CA](#the-vms-ca), for interception: its certificate and key |
|
||||
| `ca_next`, `ca_next_key` | with `ca`: the VM's next CA, which signs from an hour after its start |
|
||||
| `secrets` | the VM's bindings file, read again when it changes; the broker looks each binding's value up in its own process, for the child |
|
||||
| `secrets` | the VM's bindings file, read again when it changes, and the broker looks each binding's value up in its own process, for the child |
|
||||
| `upstream_cas` | the [CAs in your CA folder](#a-companys-ca) (PEM), which the proxy's own TLS connections trust besides the system's |
|
||||
| `upstream` | the [company proxy](#through-a-company-proxy): `https`, `http` and `no_proxy`, as `HTTPS_PROXY`, `HTTP_PROXY` and `NO_PROXY` or `config.toml`'s `[proxy]` had them, and `secret`, 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 |
|
||||
| `upstream_unresolved` | with `upstream`: names this machine can't resolve go there even when only `**` allows them, which builds' proxies get |
|
||||
@@ -543,7 +543,7 @@ The config is one JSON file, `proxy.Config`, which a VM's proxy and a build's pr
|
||||
| `links` | the VM's links' list, which `devvm _links` writes: reach each link through its socket, before any rule ([links through the proxy](#links-through-the-proxy)); a missing list has no links |
|
||||
| `link_sockets` | with `links`: the folder of the links' sockets, devvm's run folder; without it, no link is reached |
|
||||
| `vm_logs` | the logs that the VM's backend writes as the VM runs and the VM can drive, such as its serial console's, which the proxy holds to their cap for as long as it runs ([Lima's hostagent](processes.md#limas-hostagent)) |
|
||||
| `agent`, `agent_socket` | together, as absolute paths: the SSH agent that the VM's start forwards, your own or devvm's, and the VM's own socket in devvm's run folder, `agent-<hash>.sock`, on which the proxy relays it and which the VM's backend forwards instead ([the SSH agents](processes.md#the-ssh-agents)); devvm keeps a running VM's as its start set them |
|
||||
| `agent`, `agent_socket` | together, as absolute paths: the SSH agent that the VM's start forwards, your own or devvm's, and the VM's own socket in devvm's run folder, `agent-<hash>.sock`, on which the proxy relays it and which the VM's backend forwards instead ([the SSH agents](processes.md#the-ssh-agents)). devvm keeps a running VM's as its start set them |
|
||||
| `devvm_sha256`, `ca_sha256`, `ca_next_sha256` | the SHA-256 of devvm's binary, of the VM's CA certificate and of its next CA's that the proxy started with; the proxy doesn't read them, and they're there so that a new binary or a new CA makes another config ([how long a proxy runs](#how-long-a-proxy-runs)) |
|
||||
|
||||
`-config` is the proxy's only flag, and running the proxy is its only mode. What only this machine does for a VM's proxy runs inside devvm itself, never through the proxy's arguments. devvm makes each VM's CAs with `trust.InitCA`, and `internal/agentlogin` makes the VM's copies of agents' logins and settings files, their bindings and their values.
|
||||
`-config` is the proxy's only flag, and running the proxy is its only mode. What only this machine does for a VM's proxy runs inside devvm itself, never through the proxy's arguments. devvm makes each VM's CAs, and the VM's copies of agents' logins and settings files, their bindings and their values, in its own process ([the packages](../contributing/structure.md#the-packages)).
|
||||
@@ -47,16 +47,16 @@ When `devvm tools add`, or `devvm tools` in a terminal, adds shared tools to an
|
||||
|
||||
## Making a VM again
|
||||
|
||||
`devvm layer add LAYER...` makes the folder's VM again from a new image, its own layers with the new ones on top, and keeps devvm's settings for it and its home folder ([adding layers to a VM](../using/images.md#adding-layers-to-a-vm)). `devvm layer rm LAYER...` makes it again from an image of its other layers, in their order ([taking layers out of a VM](../using/images.md#taking-layers-out-of-a-vm)). `devvm update` first moves the VM to the newest shared tools, the step `devvm tools update` takes (`Tools.update`), 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's new build ([outdated VMs](../using/images.md#outdated-vms)), and when the folder's `devcontainer.json` isn't the one the VM was made from, as [reading the devcontainer.json again](#reading-the-devcontainerjson-again) describes. An outdated VM without `--force` or a terminal is refused before the tools step, so a refusal changes nothing. The remake is one path in the VM's lifecycle, which takes the image to make the VM from, so each command only works out that image and its own refusals: `devvm layer add` names the layers the VM has already, `devvm layer rm` names those it lacks (`lacks_layers`) and refuses a name that's no layer's, though it takes out one of the user's whose script is gone, and `devvm update` says the VM is current (`vm_current`) when it had the newest tools and nothing in its chain changed, or names what changed (`vm_changed`) before it asks.
|
||||
`devvm layer add LAYER...` makes the folder's VM again from a new image, its own layers with the new ones on top, and keeps devvm's settings for it and its home folder ([adding layers to a VM](../using/images.md#adding-layers-to-a-vm)). `devvm layer rm LAYER...` makes it again from an image of its other layers, in their order ([taking layers out of a VM](../using/images.md#taking-layers-out-of-a-vm)). `devvm update` first moves the VM to the newest shared tools, the step `devvm tools update` 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's new build ([outdated VMs](../using/images.md#outdated-vms)), and when the folder's `devcontainer.json` isn't the one the VM was made from, as [reading the devcontainer.json again](#reading-the-devcontainerjson-again) describes. An outdated VM without `--force` or a terminal is refused before the tools step, so a refusal changes nothing. The remake is one path in the VM's lifecycle, which takes the image to make the VM from, so each command only works out that image and its own refusals: `devvm layer add` names the layers the VM has already, `devvm layer rm` names those it lacks (`lacks_layers`) and refuses a name that's no layer's, though it takes out one of the user's whose script is gone, and `devvm update` says the VM is current (`vm_current`) when it had the newest tools and nothing in its chain changed, or names what changed (`vm_changed`) before it asks.
|
||||
|
||||
Before anything changes, devvm refuses a name that isn't a layer, a VM made for another folder, one whose creation didn't finish and, except for `devvm clone`, a `--clone` VM, and it checks that the VM's backend has every feature the VM needs with the new image (`Require`) and that the disk has room for a VM. Then it asks (`remake_confirm`, or `remake_confirm_clean_home` with `--clean-home`), and a parent folder's VM only in a terminal (`remake_parent_vm_ask`). The remake then goes in this order:
|
||||
Before anything changes, devvm refuses a name that isn't a layer, a VM made for another folder, one whose creation didn't finish and, except for `devvm clone`, a `--clone` VM, and it checks that the VM's backend has every feature the VM needs with the new image ([missing and unreviewed features](backends.md#missing-and-unreviewed-features)) and that the disk has room for a VM. Then it asks (`remake_confirm`, or `remake_confirm_clean_home` with `--clean-home`), and a parent folder's VM only in a terminal (`remake_parent_vm_ask`). Then it checks what the remake would lose, as `devvm rm` does: the clone for `devvm clone off`, unless `--no-clone-check`, and with `--clean-home` opencode's worktrees, unless `--no-worktree-check` ([opencode's worktrees](agents.md#opencodes-worktrees)). It asks once more when either finds work (`remake_anyway`). The remake then goes in this order:
|
||||
|
||||
1. devvm builds the new image, as for a new VM.
|
||||
2. It exports the agents' history as `devvm rm` does, unless `--no-export`, and saves the VM's home folder, unless `--clean-home`. The VM runs `tar --one-file-system --ignore-failed-read` in its home as its user, and devvm reads that stream on this machine and writes only what it keeps to `home.tar.gz` in the VM's folder ([the home folder's copy](design.md#the-home-folders-copy)). A failure in either keeps the VM as it was (`export_failed_kept`, `remake_home_failed`), but an export over 2 GiB only warns (`history_too_large`), and the remake goes on without one.
|
||||
2. It exports the agents' history as `devvm rm` does, unless `--no-export`, and saves the VM's home folder, unless `--clean-home`. The VM runs `tar --one-file-system --ignore-failed-read` in its home as its user, and devvm reads that stream on this machine and writes only what it keeps to `home.tar.gz` in the VM's folder ([the home folder's copy](../contributing/design.md#the-home-folders-copy)). A failure in either keeps the VM as it was (`export_failed_kept`, `remake_home_failed`), but an export over 2 GiB only warns (`history_too_large`), and the remake goes on without one.
|
||||
3. devvm records the remake in the VM's state (`remake`), stops the VM, its proxy and its link session, and has the backend rename the VM's machine to its aside name, `devvm-<hash>-old`, which is no project VM's name, so nothing else takes it for one. On Lima that's `limactl rename`, which keeps the old disk whole.
|
||||
4. devvm makes the new machine by the VM's name from the new image, with what the state records: its project folder, its agents' 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's section what the VM had of its base's `from`, its shared tools, its ports and its `devcontainer` section (`remake.was`), so an undo can give them back. It clears which of its `devcontainer.json`'s commands ran, so those that run once run again. Then it starts the VM as every start does ([an existing VM](#an-existing-vm), steps 4 to 8), which pins its new host keys.
|
||||
5. devvm puts the saved home folder in, with `tar --skip-old-files` as the VM's user, so what the new image has stays the image's. The new machine is the VM from then on, so devvm records the new `image` and `chain`, and that the new machine is done.
|
||||
6. devvm deletes the old machine and ends the remake, which removes the section, then deletes `home.tar.gz` and opens the VM as an existing VM, setting it up first. The proxy reads the VM's layers from its image, so the new layers' allowlists apply from then, and those of layers taken out no longer do, as what the proxy started with has changed ([the proxy](network.md#the-proxy)). The VM's `id`, its alias and every other field stay as they were ([a VM made again](design.md#a-vm-made-again)).
|
||||
6. devvm deletes the old machine and ends the remake, which removes the section, then deletes `home.tar.gz` and opens the VM as an existing VM, setting it up first. The proxy reads the VM's layers from its image, so the new layers' allowlists apply from then, and those of layers taken out no longer do, as what the proxy started with has changed ([the proxy](network.md#the-proxy)). The VM's `id`, its alias and every other field stay as they were ([a VM made again](../contributing/design.md#a-vm-made-again)).
|
||||
|
||||
Until the new machine has the home folder in step 5, a failure or an interrupt runs the remake's cleanup (`remake_undone`). 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's name is the old one, gives the VM back the `from`, shared tools, ports and `devcontainer` section that step 4 kept, and ends the remake. When it can't, it warns (`remake_undo_failed`) and leaves the remake recorded. The section goes before `home.tar.gz` 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.
|
||||
|
||||
@@ -72,9 +72,9 @@ A VM's `devcontainer` section records more than the file's SHA-256 and what it m
|
||||
|
||||
When the folder's file isn't the one the VM was made from, because it changed, it's gone or it appeared, `devvm update` reads it again as a new VM's file is read and refuses what a new VM refuses (`devcontainer_reread`, or `devcontainer_gone` for a file that's gone). Then it works out what the VM is made again with:
|
||||
|
||||
- **Its parts.** devvm drops the parts in `gave` that the file no longer calls for, and adds the ones the file now calls for that weren't in `parts` and that the VM lacks (`devcontainer.Reread`). A part you took out stays out, and your own parts stay. Layers go into the new image's name, after the layers the VM keeps, and toolchains go into its shared tools.
|
||||
- **Its parts.** devvm drops the parts in `gave` that the file no longer calls for, and adds the ones the file now calls for that weren't in `parts` and that the VM lacks. A part you took out stays out, and your own parts stay. Layers go into the new image's name, after the layers the VM keeps, and toolchains go into its shared tools.
|
||||
- **Its base.** With `from_flag`, the base stays as it is, and devvm says the file'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 `$DEVVM_FROM`, or else from Ubuntu's cloud image.
|
||||
- **Its ports.** In the same way, devvm takes out the ports in `ports_gave` that the file no longer lists, with the rule `devvm ports rm` follows, and adds the ones it lists anew that the VM's ports don't already forward, with the rule `devvm ports add` follows (`filePorts`). A port you took out with `devvm ports rm` stays out, your own ports stay, and with every port forwarded nothing changes. A port of the file's that's part of one of your ranges counts as yours.
|
||||
- **Its ports.** In the same way, devvm takes out the ports in `ports_gave` that the file no longer lists, with the rule `devvm ports rm` follows, and adds the ones it lists anew that the VM's ports don't already forward, with the rule `devvm ports add` follows. A port you took out with `devvm ports rm` stays out, your own ports stay, and with every port forwarded nothing changes. A port of the file's that's part of one of your ranges counts as yours.
|
||||
- **Its variables and commands.** The file's new ones replace the old ones, and the commands that run once run on the new disk.
|
||||
|
||||
The remake records all of this in its section (`remake.reread`): the new base's `from`, the shared tools, the ports and the new `devcontainer` 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 `devvm gc` 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't finish keeps them, so it's finished with what the file said when `devvm update` read it.
|
||||
@@ -97,7 +97,7 @@ Steps 4 to 8 are the one way devvm starts a VM, whatever the command, and only a
|
||||
|
||||
devvm never starts a VM whose creation didn't finish, because the VM would start without its tier (`vm_unfinished`). That happens when devvm was stopped after it made the VM but before it recorded the VM's tier. In a terminal and without `--no-input`, devvm asks whether to delete such a VM and make it again (`remake_unfinished`, `[y/N]`), and yes deletes it as `devvm rm` does, then makes the VM as for a folder without one. Otherwise, and for a parent folder's VM, devvm refuses, and `devvm rm` deletes such a VM.
|
||||
|
||||
devvm also never starts a VM on a project folder that was replaced after the finder found the VM. A parent folder'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's start. On macOS, the Lima backend mounts the folder by the device and inode in the state's `folder` instead ([what devvm sets on a VM](lima.md#what-devvm-sets-on-a-vm)), so Virtualization.framework'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's `.git` checks, which would otherwise act on what the link points to, just before the backend's start, and once the backend's start returns. Each check resolves the path's links (`filepath.EvalSymlinks`), which must give the same path, and compares the folder's identity, its device, inode and birth time, with the state's `folder`. macOS numbers its disks' devices in the order they appear at boot, so after a restart the same folder can be on a device with another number. So before the first check, the start records the folder's identity as it is now in the state's `folder`, under the VM's `lock`, when only its device differs and the folder is still the VM's (`platform.SameFolder`): its identity has its birth time, its file system never gives a new folder a deleted one's inode number (as for [a moved folder](#a-moved-folder)), and devvm reads that identity from the folder opened at its path with no link followed, so a link swapped in for a moment can't pass a copy's identity off as the folder's. The finder takes such a folder as the VM's in the same way. The backend then mounts the folder by the device it's on now, never by the old number, which may be another disk'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 (`project_folder_changed`), and one after it stops the VM and its proxy and refuses (`project_folder_changed_stopped`). The backend'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's network. A running VM's share never follows a link put in the folder's place later: QEMU's 9p share holds the folder it opened at the start, and Virtualization.framework's virtiofs share answers "Operation not permitted" 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 "Operation not permitted" for it until the VM's next start, which the project section of the end-to-end tests checks.
|
||||
devvm also never starts a VM on a project folder that was replaced after the finder found the VM. A parent folder'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's start. On macOS, the Lima backend mounts the folder by the device and inode in the state's `folder` instead ([what devvm sets on a VM](lima.md#what-devvm-sets-on-a-vm)), so Virtualization.framework'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's `.git` checks, which would otherwise act on what the link points to, just before the backend's start, and once the backend's start returns. Each check resolves the path's links, which must give the same path, and compares the folder's identity, its device, inode and birth time, with the state's `folder`. macOS numbers its disks' 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's device differs and the folder is still the VM's, the start records the folder's identity as it is now in the state's `folder`, under the VM's `lock`, before the first check. The folder is still the VM's when its identity has its birth time and its file system never gives a new folder a deleted one's inode number (as for [a moved folder](#a-moved-folder)). devvm reads that identity from the folder opened at its path with no link followed, so a link swapped in for a moment can't pass a copy's identity off as the folder's. The finder takes such a folder as the VM's in the same way. The backend then mounts the folder by the device it's on now, never by the old number, which may be another disk'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 (`project_folder_changed`), and one after it stops the VM and its proxy and refuses (`project_folder_changed_stopped`). The backend'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's network. A running VM's share never follows a link put in the folder's place later: QEMU's 9p share holds the folder it opened at the start, and Virtualization.framework's virtiofs share answers "Operation not permitted" 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 "Operation not permitted" for it until the VM's next start, which the project section of the end-to-end tests checks.
|
||||
|
||||
`devvm` warns about the setup that allows this before it makes or opens a VM that mounts its folder (`project_in_vm_folder`). The finder walks the folders the VM's folder is inside, as it does for [a subfolder's VM](#a-subfolders-vm), and names the nearest one with a state of its own that was made for that folder and isn't a `--clone` VM. It reads only the states and asks no backend, so a stopped parent folder's VM counts too, because it writes to the folder whenever it runs. The warning comes once per run of `devvm`, and no other command gives it.
|
||||
|
||||
@@ -111,7 +111,7 @@ devvm also never starts a VM on a project folder that was replaced after the fin
|
||||
|
||||
After the backend deletes the VM, devvm tears down the rest in one order, which `devvm gc --orphans` follows too. It stops the VM's proxy, port forwarder and link session first. Then it deletes what devvm keeps for the VM outside its folder: a clone's remote and the `.git` locks, other VMs' links to it and the links its group made, its pinned host keys, for `devvm gc --orphans` the backend's own leftovers, and the old machine of a [remake](#making-a-vm-again) that didn't finish. Then it deletes the VM's folder, with every file devvm keeps for it there, and last its ssh config entry.
|
||||
|
||||
For a `--clone` VM, devvm first checks the clone for commits that this repo hasn't fetched and for uncommitted changes, in the clone and in the worktrees inside it ([deleting the VM](../using/clone.md#deleting-the-vm)). It reads every repo of the clone in one command in the VM, a script sent with it that prints each repo's branches, its status and each linked worktree below the project folder with that worktree's status, as length-prefixed records. devvm reads at most 8 MiB of the answer, takes only whole records of the repos it asked for, each worktree's path clean, relative and below the folder, and any other answer fails the check, which keeps the VM. The repo's remote for the VM goes with the VM, and devvm keeps the work fetched from it as local branches, which [saved branches](#saved-branches) names. When the VM's image has an agent, devvm then exports the agents' history from the VM, starting it if it's stopped ([history](../using/coding-agents.md#history)), and it keeps the VM if the export fails. devvm reads the VM's export through a writer that stops at 2 GiB (`bounded`): past that, it stops the VM's command, deletes what it wrote and warns (`history_too_large`), and the delete goes on, as it does for a remake. `devvm rm` asks first in a terminal (`rm_confirm`), and where devvm can't ask it refuses unless `--force`, the question's refusal naming `--force` (`no_input`). `devvm rm --no-export` deletes the VM without the export, the clone's checks still run and ask only in a terminal, and a VM whose creation didn't finish gets neither, because it never ran.
|
||||
For a `--clone` VM, devvm first checks the clone for commits that this repo hasn't fetched and for uncommitted changes, in the clone and in the worktrees inside it ([deleting the VM](../using/clone.md#deleting-the-vm)). It reads every repo of the clone in one command in the VM, a script sent with it that prints each repo's branches, its status and each linked worktree below the project folder with that worktree'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't keep `devvm rm` waiting. It takes only whole records of the repos it asked for, each worktree's path clean, relative and below the folder, and any other answer fails the check, which keeps the VM. The repo's remote for the VM goes with the VM, and devvm keeps the work fetched from it as local branches, which [saved branches](#saved-branches) names. When the VM's image has an agent, devvm then exports the agents' history from the VM, starting it if it's stopped ([history](../using/coding-agents.md#history)), and it keeps the VM if the export fails. devvm reads the VM's export through a writer that stops at 2 GiB (`bounded`): past that, it stops the VM's command, deletes what it wrote and warns (`history_too_large`), and the delete goes on, as it does for a remake. `devvm rm` asks first in a terminal (`rm_confirm`), and where devvm can't ask it refuses unless `--force`, the question's refusal naming `--force` (`no_input`). `devvm rm --no-export` deletes the VM without the export, the clone's checks still run and ask only in a terminal, and a VM whose creation didn't finish gets neither, because it never ran.
|
||||
|
||||
### Saved branches
|
||||
|
||||
@@ -128,7 +128,7 @@ A VM's state records its project folder's path (`dir`) and the folder's identity
|
||||
|
||||
A VM's folder in the data folder, `vms/<hash>/`, is named by the hash at the end of the VM's name, which the backend's machine has too, so neither changes when the project folder moves. What changes is the state's `dir`, and devvm finds a folder's VM by the state that records its path ([a VM's folder](#a-vms-folder)).
|
||||
|
||||
When the folder devvm runs in has no VM, devvm looks through every VM's state for one made for this folder at another path ([listing VMs](#listing-vms)). A state matches when its `folder` identity is this folder's, its `dir` is another path, nothing is at that path any more on the folder's device (`gone`, [a VM whose folder is gone](#a-vm-whose-folder-is-gone)) or only a symlink that resolves to this folder is, its creation finished, and it isn't a `--clone` VM. The folder must be this user's, and its identity must be one that no other folder can have had. It must have the folder'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's inode number. On Linux it must be on ext4, XFS, Btrfs, tmpfs, ZFS, F2FS or bcachefs, local file systems that keep a file's inode number for its life and report its birth time, which devvm reads by the file system's type from `statfs`. 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't either. At another path, the identity must match the state's `folder` with its device too, so a folder that moved after a boot numbered its disk anew, before its VM started again, isn't offered the VM, and `devvm adopt VM` moves the VM to it. When more than one state matches, devvm moves none (`vms_moved_here`).
|
||||
When the folder devvm runs in has no VM, devvm looks through every VM's state for one made for this folder at another path ([listing VMs](#listing-vms)). A state matches when its `folder` identity is this folder's, its `dir` is another path, nothing is at that path any more on the folder's device (`gone`, [a VM whose folder is gone](#a-vm-whose-folder-is-gone)) or only a symlink that resolves to this folder is, its creation finished, and it isn't a `--clone` VM. The folder must be this user's, and its identity must be one that no other folder can have had. It must have the folder'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's inode number. On Linux it must be on ext4, XFS, Btrfs, tmpfs, ZFS, F2FS or bcachefs, local file systems that keep a file's inode number for its life and report its birth time, which devvm reads by the file system's type from `statfs`. 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't either. At another path, the identity must also match the device in the state's `folder`. So a folder that moved after a boot numbered its disk anew, before its VM started again, isn't offered the VM, and you move the VM to it with `devvm adopt VM`. When more than one state matches, devvm moves none (`vms_moved_here`).
|
||||
|
||||
For one match, devvm asks in a terminal (`move_vm`), with no as the default, and refuses without one (`vm_moved_here`). `devvm adopt --force` moves it without asking. A no leaves the folder without a VM, so `devvm` makes a new one. A yes first checks the folder as a new VM's folder is checked ([project folders devvm refuses](../using/settings.md#project-folders-devvm-refuses)). Then devvm takes the [creation locks](#locks) 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 (`move_folder_changed`). A running VM still mounts the old path, so devvm stops it as `devvm stop` does, with its proxy, port forwarder and link session (`stopped`). Last, it records the folder's path and identity under the VM's `lock`, refusing a state whose `dir` or `folder` changed since it was read (`create_running`), and says so (`vm_adopted`). In the same write, it records the old path in the state's `moved` section as `from`, the path that the agents in the VM keep the folder's history under. A second move before the VM's next start keeps the first move's old path there, because the history is still under it, and a move back to that path clears the section. The `.git` protection's record stays as it was, because a folder that moved keeps its `.git`, whose identity and locks move with it, so the next check compares `.git` with what it locked.
|
||||
|
||||
@@ -178,7 +178,7 @@ In the data folder, each VM has a folder of its own, `vms/<hash>/` ([a VM's fold
|
||||
- `agent-keys.json` lists the keys added to [devvm's own SSH agent](../using/ssh.md#devvms-own-agent), with each one's file, fingerprint, `confirm` and `lifetime`, and `agent.sock` is that agent's socket.
|
||||
- `secrets/` holds each [secret](network.md#where-secrets-are-saved) in a file of its own, on hosts without a Keychain.
|
||||
- `custom-secrets.json` holds the definitions of [your own secrets](network.md#where-secrets-are-saved), their hosts, headers, variables and prefixes, never their values.
|
||||
- `images/<key>/record.json` is each image's record, and `images/rebuilds.json` holds the [rebuild counters](images.md#rebuilding), by backend, `--from` and image. `images/ubuntu.json` is the [Ubuntu cloud image](images.md#ubuntus-cloud-image) that base starts from on this machine.
|
||||
- `images/<key>/record.json` is each image's record, and `images/rebuilds.json` holds the [rebuild counters](images.md#rebuilding), by backend, `--from` and image. `images/ubuntu.json` is the [Ubuntu cloud image](images.md#ubuntus-cloud-image) that base starts from on this machine, and `images/ubuntu/` holds the cloud images themselves, each `<sha256>.img`, with a download that stopped as `.img.part` and a copy from Lima's cache that stopped as `.img.import`.
|
||||
- `tools/` holds the [shared tools](images.md#the-share), each image with its record. Beside it are the tools lock, `mise.lock`, the `mise.toml` it was resolved from, `mise.lock.toml`, and `mise.lock.checked`, which says when devvm last [checked](images.md#versions) for newer versions.
|
||||
- `logs/runs/` holds the [run logs](../using/troubleshooting.md#a-command-fails), and `logs/tools-check.log` the daily tools check's output.
|
||||
- `exports/` holds the agents' history that `devvm history export` and `devvm rm` save.
|
||||
@@ -190,13 +190,13 @@ Each write replaces a file whole, so a file is never left half written. devvm ma
|
||||
|
||||
### The run log
|
||||
|
||||
Each run that runs a command has one log, `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, which only you can read. devvm keeps the newest 20, or as many as `logs.runs` sets, and deletes older ones once the logs take more than 256 MiB together, but it never deletes the newest, nor the log of a run whose process still runs, which it reads from the pid in the log's name, so a background process or another devvm never loses the log it's writing ([a command fails](../using/troubleshooting.md#a-command-fails)). In the log, each command appears as a `+` line with its arguments, followed by its output, and a numbered step adds a `# [2/5] <step>` 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's disk with it, and a `devvm: truncated` line marks where devvm left out the rest. A run writes at most 128 MiB to its log in all, as one that lasts, such as `devvm desktop`'s, could otherwise log without end, and a `devvm: truncated` line marks that too.
|
||||
Each run that runs a command has one log, `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, which only you can read. devvm keeps the newest 20, or as many as `logs.runs` 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's name, so a background process or another devvm never loses the log it's writing ([a command fails](../using/troubleshooting.md#a-command-fails)). In the log, each command appears as a `+` line with its arguments, followed by its output, and a numbered step adds a `# [2/5] <step>` 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's disk with it, and a `devvm: truncated` 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 `devvm desktop`'s, could otherwise log without end, and a `devvm: truncated` line also marks where that limit cut the log.
|
||||
|
||||
A VM's proxy key and the build proxy's password are written as `devvm:<key>@`. Any other password in a URL, in a command's arguments or its output, is written as `user:<password>@`, and so is the password in a proxy's address without a scheme, such as `user:[email protected]:8080`, when the address has a port. So a company proxy's password from your shell's `HTTPS_PROXY`, 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's setup or a `devcontainer.json`'s commands.
|
||||
|
||||
With `-v`, the lines devvm shows are the log's own, so a VM'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't move the cursor or change your terminal.
|
||||
|
||||
Lima keeps a log of its own for each VM, `ha.stderr.log` in the VM's folder in devvm'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's serial consoles there, `serial.log`, `serialp.log` or `serialv.log`, and its boot scripts write the VM's proxy URL, with the VM's proxy password, to the console as they set up the VM's environment. Once Lima has started the VM, devvm replaces each password in those logs with as many `*`, so the log keeps its length and Lima goes on writing to it. If devvm can't change the file, it warns you and names it, and you can delete the file, which Lima makes again at the VM'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't leave the password in the console's log. It holds the disk space each of these logs takes to 10 MiB too, with a `.1` file of as much, on a file system with holes ([Lima's hostagent](processes.md#limas-hostagent)), and a rotation's copy, such as `ha.stderr.log.1`, has each password replaced, whether the start had ended or not.
|
||||
Lima keeps a log of its own for each VM, `ha.stderr.log` in the VM's folder in devvm'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's serial consoles there, `serial.log`, `serialp.log` or `serialv.log`, and its boot scripts write the VM's proxy URL, with the VM's proxy password, to the console as they set up the VM's environment. Once Lima has started the VM, devvm replaces each password in those logs with as many `*`, so the log keeps its length and Lima goes on writing to it. If devvm can't change the file, it warns you and names it, and you can delete the file, which Lima makes again at the VM'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't leave the password in the console's log. The proxy also holds the disk space that each of these logs takes to 10 MiB, with a `.1` file of as much, on a file system with holes ([Lima's hostagent](processes.md#limas-hostagent)). A rotation's copy, such as `ha.stderr.log.1`, has each password replaced, whether the start had ended or not.
|
||||
|
||||
### A VM's folder
|
||||
|
||||
@@ -208,7 +208,7 @@ Each VM's folder, `vms/<hash>/`, is named by the hash at the end of the VM's nam
|
||||
| `lock` | the lock that each change to `vm.json` holds ([locks](#locks)) |
|
||||
| `policy` | the VM's own [network rules](network.md#policy-files), which `devvm network allow`, `deny` and `rm` change |
|
||||
| `run/` | what the VM's runs leave: its [host keys](security.md#ssh-into-vms) for its current start (`known_hosts`), which every ssh of devvm's to the VM checks, its [port forwarder](ports.md#its-process-and-files)'s `ports.pid`, `ports.status` and `ports.lock`, its [proxy](network.md#the-proxy)'s config, `proxy.json`, which holds everything the proxy started with, its password and the [company proxy](network.md#through-a-company-proxy)'s from the environment among it ([devvm _proxy](network.md#devvm-_proxy)), and its `proxy.pid` and `proxy.status`, its broker's child's `proxy-child.pid` and how the child is confined, `proxy.confined` ([processes](processes.md#a-vms-proxy)), the VM's own [CA](network.md#the-vms-ca) and the next one in `ca/` (`ca.pem` and `ca.key`, `next.pem` and `next.key`, and their `lock`), whose keys never leave this machine, its [secrets](network.md#how-the-proxy-puts-them-in)' bindings (`secrets.json`, `secrets.policy`), its [link session](ports.md#the-link-session)'s `links.pid` and `links.json`, the [remake lock](#making-a-vm-again) (`remake.lock`), the hostagent it was started on (`started`), the [ssh port](lima.md#what-devvm-sets-on-a-vm) its last start held for a minute (`ports.ssh-hold`), and on macOS the hostagent's [sandbox profile](lima.md#confinement) (`sandbox.sb`) |
|
||||
| `logs/` | its proxy's decisions (`network.jsonl`) and its proxy's broker's and child's own output (`proxy.log`), which the [log files](network.md#log-files) describe, its link session's output (`links.log`) and its port forwarder's (`ports.log`), each held to 1 MiB with one `.1` file. The proxy's child writes this folder, so devvm opens the files in it never through a link |
|
||||
| `logs/` | its proxy's decisions (`network.jsonl`) and its proxy's broker's and child's own output (`proxy.log`), which the [log files](network.md#log-files) describe, its link session's output (`links.log`) and its port forwarder's (`ports.log`), each held to 1 MiB with one `.1` file. The proxy's child writes this folder, so devvm never opens the files in it through a link |
|
||||
| `home.tar.gz` | the VM's home folder, only while devvm [makes the VM again](#making-a-vm-again) |
|
||||
|
||||
devvm finds a folder's VM by the state that records the folder's path as its `dir`, first in the VM folder that the hash of that path names and then in every other VM's ([a moved folder](#a-moved-folder)), 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's limit, and when the VM folder that the path's hash names holds another VM's state, the new VM's name ends with the hash of the path and a number instead, the first whose folder is free. The VM's folder lasts as long as the VM, because `devvm rm` and `devvm gc --orphans` stop what runs for the VM, delete what devvm keeps for it outside the folder, and then delete the folder whole ([deleting a VM](#deleting-a-vm)), so the next devvm in that folder starts fresh.
|
||||
@@ -241,7 +241,7 @@ A new VM's whole state is written once, with everything you asked for, before it
|
||||
|
||||
### Locks
|
||||
|
||||
Reading a VM's state takes no lock, because each write replaces the file whole. Each change takes the VM's `lock`, reads the file again, makes the change and writes the file once, so a command's changes land together or not at all, and two devvms changing one VM at once lose neither's change. Deleting a VM's folder takes the VM's `lock` too, so a change that another devvm is making to the VM'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's lock at a time. A change to other VMs, such as removing every link to a VM that `devvm rm` deletes, lets go of the first VM's lock and then takes each other VM's lock in turn, reading each one's state again before it changes it. What no two VMs may have, a new VM's ssh alias and the host ports devvm chooses, is chosen under the claims lock, `run/claims.lock`, which devvm takes after the VM's own lock and holds until the VM'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 `run/build-ports/<name>` while the VM starts, which keeps any other VM from getting that port until Lima has bound it. Each project VM's start records the ssh port it holds in the VM's own folder, as `run/ports.ssh-hold`, which the next choice reads for a minute while Lima binds the port, so no other start or build takes it, whether the start kept the VM's port or chose a new one ([the ssh port](lima.md#what-devvm-sets-on-a-vm)). The port is never the one that the build VM's config kept from the image it's a clone of, so its start always sets the new port and a build's numbered steps are the same each time. The devvm that starts the build holds a file lock on the record while it'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's ssh, devvm deletes it the next time it chooses a port.
|
||||
Reading a VM's state takes no lock, because each write replaces the file whole. Each change takes the VM's `lock`, reads the file again, makes the change and writes the file once, so a command's changes land together or not at all, and two devvms changing one VM at once lose neither's change. Deleting a VM's folder takes the VM's `lock` too, so a change that another devvm is making to the VM'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's lock at a time. A change to other VMs, such as removing every link to a VM that `devvm rm` deletes, lets go of the first VM's lock and then takes each other VM's lock in turn, reading each one's state again before it changes it. What no two VMs may have, a new VM's ssh alias and the host ports devvm chooses, is chosen under the claims lock, `run/claims.lock`, which devvm takes after the VM's own lock and holds until the VM'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 `run/build-ports/<name>` while the VM starts, which keeps any other VM from getting that port until Lima has bound it. Each project VM's start records the ssh port it holds in the VM's own folder, as `run/ports.ssh-hold`. 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's port or chose a new one ([the ssh port](lima.md#what-devvm-sets-on-a-vm)). The port is never the one that the build VM's config kept from the image it's a clone of, so its start always sets the new port and a build's numbered steps are the same each time. The devvm that starts the build holds a file lock on the record while it'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's ssh, devvm deletes it the next time it chooses a port.
|
||||
|
||||
A folder's creation lock, `run/create-<hash>.lock`, keeps two devvms from making one folder's VM at once. It lives outside the VM's folder because a new VM's creation deletes that folder and makes it again. When `devvm` finds that the folder has no VM, or has its own VM whose creation didn't finish, it takes the lock before the new VM's questions and reads the VM'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'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 (`create_running`) and never waits on the first one's questions. `devvm rm` takes the lock too before it deletes a VM, because a VM whose creation didn'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's state changed once it has the lock. `devvm gc --orphans` and retention's `orphans.age` 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.
|
||||
|
||||
@@ -256,10 +256,13 @@ Every lock devvm takes is an OS file lock on an open file, which the system lets
|
||||
| `run/create-<hash>.lock` | the devvm making a project folder's [new VM](#a-new-vm), from before its questions until it has recorded that it made the VM, and `devvm rm` deleting a VM, which a second devvm finds held and refuses |
|
||||
| `images/locks/<key>` | the devvm [building an image](images.md#building) |
|
||||
| `images/locks/rebuilds` | a devvm [changing a rebuild counter](images.md#rebuilding) |
|
||||
| `images/locks/ubuntu` | the devvm [pinning Ubuntu's cloud image](images.md#ubuntus-cloud-image) |
|
||||
| `images/locks/ubuntu-image` | the devvm [downloading Ubuntu's cloud image](images.md#ubuntus-cloud-image) or taking it from Lima's cache |
|
||||
| `cache/mise/download.lock` | the devvm [downloading its own mise](images.md#versions) |
|
||||
| `oci-build.lock` | a Lima build of a base [from a container image](images.md#how-its-converted) |
|
||||
| `tools.lock` | a devvm [writing to the share](images.md#building-tools) or swapping the tools lock |
|
||||
| `making.lock` | each devvm making a VM or giving one new shared tools, shared, and `devvm gc --tool-images --force`, alone ([cleaning up](images.md#listing-and-cleaning-up)) |
|
||||
| `groups.lock` | a devvm [joining or leaving a group](design.md#groups), or working its links out again |
|
||||
| `groups.lock` | a devvm [joining or leaving a group](../contributing/design.md#groups), or working its links out again |
|
||||
| `agents.lock` | a devvm writing the agent store: [an import, a save, or a start cleaning Claude Code's plugins](agents.md#importing) |
|
||||
| `custom-secrets.lock` | a devvm [saving or deleting a secret of yours, or binding a VM to one](network.md#where-secrets-are-saved) |
|
||||
| `retention.lock` | the devvm applying the [retention settings](../using/settings.md#retention) |
|
||||
|
||||
@@ -18,7 +18,7 @@ The forwarder never forwards a server on an address in `127.77.0.0/16`, on any V
|
||||
|
||||
The forwarder never takes a port that a program on this machine has on any address. That program keeps the port and its `localhost` connections, and the forward waits until the VM's server stops and starts again.
|
||||
|
||||
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's own ssh port. devvm chooses and records every VM's ssh port, whatever its tier, so no forwarder takes it in the seconds before Lima binds it ([the threat check](design.md#ports-on-lima)), and chooses it only from the 17 ports every browser refuses ([the ssh port](lima.md#what-devvm-sets-on-a-vm)), which devvm'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't take the ports other VMs' 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's listed ports stay free for it.
|
||||
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's own ssh port. devvm chooses and records every VM's ssh port, whatever its tier, so no forwarder takes it in the seconds before Lima binds it ([the threat check](../contributing/design.md#ports-on-lima)). It chooses that port only from the 17 ports that every browser refuses ([the ssh port](lima.md#what-devvm-sets-on-a-vm)), which devvm'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't take the ports other VMs' 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's listed ports stay free for it.
|
||||
|
||||
When a start, or a change of a running VM's ports, finds that a program on this machine has a listed port, devvm doesn't forward that port and warns you (`ports_taken`). The VM starts or runs on all the same, and the next start or change that finds the port free forwards it again. [Ports](../using/ports-size.md#ports) says what happens to a program that binds a port on all addresses after the forwarder has forwarded it.
|
||||
|
||||
@@ -54,7 +54,7 @@ flowchart TD
|
||||
|
||||
The forwarder is devvm's own, the same on every backend. The backend only says how the forwarder reaches a running VM's sshd, which is a user, a key and a port on this machine's loopback, and which file the forwarder follows to know the VM still runs, as Lima's [Ports](lima.md#ports) section describes.
|
||||
|
||||
Each forwarded connection gets an ssh process of its own, which carries it over the forwarder'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, and its log gets only the first failure of each run. When a forward closes, because the VM's server stopped or its port is now another VM's, the forwarder closes that forward's open connections and ends their ssh processes too. A VM that never closes its end of a connection therefore can't keep that connection's ssh process, or one of the 256, after its port's forward has gone.
|
||||
Each forwarded connection gets an ssh process of its own, which carries it over the forwarder'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's server stopped or its port is now another VM's, the forwarder closes that forward's open connections and ends their ssh processes too. A VM that never closes its end of a connection therefore can't keep that connection's ssh process, or one of the 256, after its port's forward has gone.
|
||||
|
||||
A connection'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 `nc -N` in front of a slow database query, has its connection cut. The same holds for every link's connections ([each connection](#each-connection)).
|
||||
|
||||
@@ -76,13 +76,13 @@ When a running forwarder tries a listed port and can't take it, it logs the port
|
||||
|
||||
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's next report.
|
||||
|
||||
The forwarder listens on both `127.0.0.1` and `::1`, and it treats an error on `::1` as it would treat one on `127.0.0.1`, closing the port's `127.0.0.1` listener as well. A program on `::1` makes the port in use, and any other error has the port tried 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 `127.0.0.1` alone, and so does one that refuses the forwarder `::1` while it allows `127.0.0.1`, such as a security module denying IPv6 sockets, which the forwarder logs.
|
||||
The forwarder listens on both `127.0.0.1` and `::1`, and it treats an error on `::1` as it would treat one on `127.0.0.1`, closing the port's `127.0.0.1` listener as well. A program that listens on the port's `::1` 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 `127.0.0.1` alone, and so does one that refuses the forwarder `::1` while it allows `127.0.0.1`, such as one whose security module denies IPv6 sockets, and the forwarder logs that.
|
||||
|
||||
`devvm ports` reads these from the forwarder'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't one of these, so it gets `ports_held` instead. A record that the running forwarder didn't write, or none, gives none of these warnings, and neither does a record from an older devvm's forwarder after an upgrade, which lists every port it couldn't take on one line, without saying why, so devvm never says a port is in use when it may not be.
|
||||
|
||||
## Links between VMs
|
||||
|
||||
A [link between VMs](../using/links.md) carries a client VM'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's network, so no backend's confinement changes and a confined VM still reaches nothing past its proxy over its own network. [The design note](design.md#links-between-vms) has the rules, the threat check and what the prototype showed.
|
||||
A [link between VMs](../using/links.md) carries a client VM'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's network, so no backend's confinement changes and a confined VM still reaches nothing past its proxy over its own network. [The design note](../contributing/design.md#links-between-vms) has the rules, the threat check and what the prototype showed.
|
||||
|
||||
### The addresses
|
||||
|
||||
@@ -132,4 +132,4 @@ When a link goes, `devvm _links` stops listening for it and ends the connections
|
||||
|
||||
### Groups
|
||||
|
||||
A [group](../using/links.md#groups) is recorded in each of its VMs' 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's state like the ones `devvm link add` makes, marked as the group's, so the link session, the proxy's list and every check of a connection treat them alike. devvm works out each VM's group links again from its own links and the other VMs' 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 [above](#when-links-change). [The design note](design.md#groups) has the rules and the threat check.
|
||||
A [group](../using/links.md#groups) is recorded in each of its VMs' 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's state like the ones `devvm link add` makes, marked as the group's, so the link session, the proxy's list and every check of a connection treat them alike. devvm works out each VM's group links again from its own links and the other VMs' 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 [above](#when-links-change). [The design note](../contributing/design.md#groups) has the rules and the threat check.
|
||||
@@ -25,54 +25,54 @@ Every process here runs as you. devvm runs its own long-running processes as its
|
||||
|
||||
## How devvm starts them
|
||||
|
||||
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 (`daemon.Detach`). Each gets no input and devvm's environment without `SSH_AUTH_SOCK`, 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's proxy, which relays the agent that the VM's start forwards, named in its config ([the SSH agents](#the-ssh-agents)). 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 ([things learned](design.md#things-learned)).
|
||||
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 ([the packages](../contributing/structure.md#the-packages)). Each gets no input and devvm's environment without `SSH_AUTH_SOCK`, 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's proxy, which relays the agent that the VM's start forwards, named in its config ([the SSH agents](#the-ssh-agents)). 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 ([things learned](../contributing/design.md#things-learned)).
|
||||
|
||||
devvm finds such a process again by its pid file and its arguments, and it signals a process only while both still say it's that process, so a pid that the system gave another program since is never signalled (`daemon.Proc`). A stop sends `SIGTERM`, waits two seconds, and sends `SIGKILL` only to a process whose arguments are still the ones devvm started. Each signal goes to the process's group, which its own session makes it the leader of, so what it started ends with it, such as the forwarder's and the link session's ssh masters and relays, even when it's killed and can't stop them itself (`daemon.SignalGroup`). A forwarder or a link session that gets `SIGTERM` from anything else, such as `kill`, 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'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 ([how long a proxy runs](network.md#how-long-a-proxy-runs)).
|
||||
devvm finds such a process again by its pid file and its arguments, and it signals a process only while both still say it's that process, so a pid that the system gave another program since is never signalled. A stop sends `SIGTERM`, waits two seconds, and sends `SIGKILL` only to a process whose arguments are still the ones devvm started. Each signal goes to the process's group, which its own session makes it the leader of, so what it started ends with it, such as the forwarder's and the link session's ssh masters and relays, even when it's killed and can't stop them itself. A forwarder or a link session that gets `SIGTERM` from anything else, such as `kill`, 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'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 ([how long a proxy runs](network.md#how-long-a-proxy-runs)).
|
||||
|
||||
The run that starts a process reaps it if it ends first, and once that run ends, nothing on this machine waits for it. Each one ends on its own instead: the proxy and the forwarder follow the VM's hostagent through its pid file, `ha.pid`, which is the VM's lifeline, the link session asks the VM's backend every 5 seconds whether the VM still runs the start it was made for, and `devvm stop`, `devvm rm` and `devvm gc --orphans` stop a VM's proxy, forwarder and link session while they still run.
|
||||
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's hostagent through its pid file, `ha.pid`, which is the VM's lifeline, and the link session asks the VM's backend every 5 seconds whether the VM still runs the start it was made for. `devvm stop`, `devvm rm` and `devvm gc --orphans` stop a VM's proxy, forwarder and link session while they still run.
|
||||
|
||||
## devvm itself
|
||||
|
||||
- **Holds:** everything you keep with devvm. It reads secrets from the macOS Keychain with the `security` command or from files only you can read, and it writes each VM's proxy password and the company proxy's credentials into files only you can read, never into a process's arguments ([where secrets are saved](network.md#where-secrets-are-saved)).
|
||||
- **Reads from a VM:** the output of the commands it runs there, such as a VM'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's `devcontainer.json`. It reads such a file never 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's settings and 2 GiB for a history export ([coding agents](agents.md#saving-a-vms-settings)).
|
||||
- **Writes:** its run log, `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, 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 `logs.runs` sets, and deletes older ones once the logs take more than 256 MiB together, but never the newest, nor a log whose run still runs, which it reads from the pid in the log's name. It writes state files whole, renamed into place ([state files](overview.md#state-files)).
|
||||
- **Reads from a VM:** the output of the commands it runs there, such as a VM'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's `devcontainer.json`. 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's settings and 2 GiB for a history export ([coding agents](agents.md#saving-a-vms-settings)).
|
||||
- **Writes:** its run log, `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, 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 `logs.runs` 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's name. It writes state files whole, renamed into place ([state files](overview.md#state-files)).
|
||||
- **Listens:** only in `devvm desktop` ([the desktop relay](#the-desktop-relay)) and while `devvm agent login` waits for a browser's login ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Confinement:** none. devvm needs your Keychain and your files, and it's the program you chose to run.
|
||||
|
||||
## A VM's proxy
|
||||
|
||||
Each running VM's proxy is two processes, so the code that reads every byte the VM sends never holds what only the host should: a broker, `devvm _proxy -config FILE`, with the VM's `proxy.json` in its run folder, `~/.local/share/devvm/vms/<hash>/run/`, and its child, `devvm _proxy-child -for FILE`, which the broker starts and which reads the VM's network ([the proxy](network.md#the-proxy)). The child asks the broker over a socketpair between them for a bound value, a changed file, a connection to a link, a login's token exchange, a name'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's ([the proxy's broker](design.md#the-proxys-broker) has the design and its threat check).
|
||||
Each running VM'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, `devvm _proxy -config FILE`, with the VM's `proxy.json` in its run folder, `~/.local/share/devvm/vms/<hash>/run/`, and its child, `devvm _proxy-child -for FILE`, which the broker starts and which reads the VM's network ([the proxy](network.md#the-proxy)). The child asks the broker over a socketpair between them for a bound value, a changed file, a connection to a link, a login's token exchange, a name'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's ([the proxy's broker](../contributing/design.md#the-proxys-broker) has the design and its threat check).
|
||||
|
||||
**The broker:**
|
||||
|
||||
- **Holds:** the VM's password and the company proxy's credentials, which it reads from the config and hands the child as it starts. It looks up each bound secret's value itself, through the Keychain or the secret's file, keeps a value for 5 minutes, an agent's login for 30 seconds and a failed lookup for 5 seconds, and drops them all when the VM's bindings change. It reads the agents' login files in devvm's store and refreshes their OAuth logins there, and it sends each login that the VM makes to the agent's token endpoint itself, saves it into the store and rewrites the VM's bindings, so a login's real tokens never reach the child ([logins made in a VM](network.md#logins-made-in-a-vm)).
|
||||
- **Reads from the VM:** the child's frames, each at most 2 MiB, and through them a login's token request, at most 64 KiB of headers and 64 KiB of body, and its endpoint's reply, at most 1 MiB. It also reads your policy files and the VM's bindings, each at most 1 MiB, and the links' list, `links.json`, at most 1 MiB, which `devvm _links` writes, for the child once they change, and the bindings and the links' list again at each request that uses them, and the policy files again at each connection it opens for the child. For a VM that forwards an SSH agent, it reads the agent's requests that the VM sends, each at most 256 KiB ([the SSH agents](#the-ssh-agents)).
|
||||
- **Writes:** its own lines in `proxy.log`, its child's pid file, `run/proxy-child.pid`, and how the child is confined, `run/proxy.confined`, and the login files and bindings above. It also holds the logs that the VM's backend writes as the VM runs to 10 MiB each, with a `.1` file of as much, the VM's serial console's among them, looking at each every second in a goroutine of its own ([Lima's hostagent](#limas-hostagent)), because they're in the backend's folder for the VM, beside its disk, which the child must never write. A proxy that a devvm before this one started doesn't, so a VM that's running when you upgrade gets this once its next devvm command starts its proxy again.
|
||||
- **Reads from the VM:** the child's frames, each at most 2 MiB, and through them a login's token request, at most 64 KiB of headers and 64 KiB of body, and its endpoint's reply, at most 1 MiB. It also reads your policy files and the VM's bindings, each at most 1 MiB, and the links' list, `links.json`, at most 1 MiB, which `devvm _links` writes. It reads them for the child once they change, reads the bindings and the links' 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's requests that the VM sends, each at most 256 KiB ([the SSH agents](#the-ssh-agents)).
|
||||
- **Writes:** its own lines in `proxy.log`, its child's pid file, `run/proxy-child.pid`, and how the child is confined, `run/proxy.confined`, and the login files and bindings above. It also holds the logs that the VM's backend writes as the VM runs to 10 MiB each, with a `.1` file of as much, the VM's serial console's among them, looking at each every second in a goroutine of its own ([Lima's hostagent](#limas-hostagent)), because they're in the backend's folder for the VM, beside its disk, which the child must never write. A proxy that an older devvm started doesn't hold them, so a VM that's running when you upgrade gets this once its next devvm command starts its proxy again.
|
||||
- **Bounds:** 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.
|
||||
- **Connects:** for the child, to an address only once its own read of the VM's policy files and of this machine's addresses allows it, as the floor does, and to the company proxy of its config, each within 15 seconds, and it looks up names through this machine's resolver for the child, each within 20 seconds.
|
||||
- **Listens:** on the VM's agent socket, `~/.local/share/devvm/run/agent-<hash>.sock`, for a VM that forwards an SSH agent. It opens the VM's proxy port, and hands the listener to its child ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Connects:** for the child, to an address only once its own read of the VM's policy files and of this machine'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's resolver for the child, each within 20 seconds.
|
||||
- **Listens:** on the VM's agent socket, `~/.local/share/devvm/run/agent-<hash>.sock`, for a VM that forwards an SSH agent. It also opens the VM's proxy port and hands the listener to its child ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Confinement:** none. It runs as you, with your Keychain and your files.
|
||||
- **Starts and ends:** devvm starts it before each start of the VM, on every tier, and waits up to 5 seconds for it to say it's listening, which it says once its child said it's ready, within 4 seconds of the broker's start. It exits when the hostagent it follows ends, or 15 minutes after it starts if the hostagent never appears, and when its child ends, and `devvm stop` stops it ([how long a proxy runs](network.md#how-long-a-proxy-runs)).
|
||||
- **Starts and ends:** devvm starts it before each start of the VM, on every tier, and waits up to 5 seconds for it to say it's listening. The broker says so once its child has said it's ready, within 4 seconds of the broker'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 `devvm stop` also stops it ([how long a proxy runs](network.md#how-long-a-proxy-runs)).
|
||||
|
||||
**The child:**
|
||||
|
||||
- **Holds:** the VM's password, the VM's CA and the next one, with their keys, the company proxy's credentials, and each value that the broker gave it, until the broker's lookup is as old as the broker keeps it.
|
||||
- **Reads from the VM:** every request the VM sends. It takes at most 64 KiB of a request's headers, in an intercepted or transparent connection too, within 30 seconds, requires the VM's password before anything else, and 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 `stat` alone and asks the broker for one once it changed.
|
||||
- **Holds:** the VM's password, the VM's CA and the next one, with their keys, the company proxy's credentials, and each value that the broker gave it, until the broker's lookup of that value is as old as the broker keeps one.
|
||||
- **Reads from the VM:** every request the VM sends. It takes at most 64 KiB of a request's headers within 30 seconds, also in an intercepted or transparent connection, and it requires the VM'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 `stat` alone and asks the broker for one once it changed.
|
||||
- **Writes:** its event log, `network.jsonl`, and its own lines in `proxy.log`, in the VM's logs folder, `~/.local/share/devvm/vms/<hash>/logs/`, each rotated before it passes 10 MiB, with one `.1` file kept ([log files](network.md#log-files)). Its HTTP server's errors go to `proxy.log` too, and so does what reaches either process's error output, which counts toward the 10 MiB. For a VM with the nix layer, it fills the [shared Nix cache](network.md#the-shared-nix-cache), at most 10 GiB unless its config sets another cap. It reads and writes nothing else of yours or devvm's.
|
||||
- **Bounds:** at most 8448 open files, a limit it sets on itself before it's confined, at most 1024 `CONNECT` tunnels at once, at most 2048 connections of every kind with the VM's password, plain HTTP and idle ones included, at most 128 more that haven't sent the password yet, and at most 2048 requests to hosts under way, its tunnels' 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's password gets its `407` 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 ([the proxy](network.md#the-proxy)). Nothing bounds how long a request or a tunnel lasts, so long downloads, WebSockets and slow streams go on.
|
||||
- **Listens:** on `127.0.0.1`, on the VM's proxy port, through the listener the broker opened ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Connects:** 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's loopback, its own addresses and the private and link-local ranges only where a rule names the address, or through a company proxy ([the child's sandbox](network.md#the-childs-sandbox)).
|
||||
- **Inherits:** standard input from the null device, `proxy.log` 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 `TZ`, `SSL_CERT_FILE`, `SSL_CERT_DIR` and `GODEBUG`. Run by hand without those two sockets, it refuses to start.
|
||||
- **Confinement:** on macOS, a Seatbelt profile that denies everything but what the child needs, from its first instruction, because the broker starts it through `/usr/bin/sandbox-exec` with the profile as an argument, never as a file ([the child's sandbox](network.md#the-childs-sandbox)). The profile lets it run and read devvm's binary, write regular files in its logs folder and the shared Nix cache, look at the changing files with `stat`, and ask `trustd` to check certificates. It refuses it your home folder, devvm'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's ready, and it says how it's confined in `run/proxy.confined`, which is `full seatbelt` 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's broker left behind when, after a downgrade, an older devvm started the VM's proxy, and it names that proxy as one an older devvm started. When doctor can't read when the running broker started, it says it can't tell whether the proxy runs in its sandbox. Where `sandbox-exec` is missing or fails to start it, the broker starts it unconfined, writes a warning in `proxy.log`, and devvm doctor warns while the VM runs ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)). On Linux it confines itself before it reads a byte of the VM's, setting `no_new_privs`, with Landlock to the same folders, and with a seccomp filter that refuses it every socket but a netlink route socket, `connect`, TCP Fast Open, a listen, `io_uring`, the calls that reach another process, a change to a file's metadata by its path, the kernel's keyrings, a program, a process or a namespace of its own, and it says `full landlock` when the kernel has Landlock'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.
|
||||
- **Starts and ends:** the broker starts it, devvm's own binary, by its real path on macOS and as `/proc/self/exe` on Linux, and on Linux the system kills it when the broker's thread that started it ends. It ends when it reads the end of its socket to the broker: it stops listening and closes every connection it accepted, the tunnels it carries and the WebSocket upgrades it passes on included, and refuses one that arrives after that. It then waits for the handlers to return, 5 seconds at most, because Go'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. `devvm stop`'s `SIGTERM` reaches the broker, which sends the child `SIGTERM`, which ends it at once, and kills it if it hasn't ended within a second. A child that ends, however it ends, ends its broker, and neither starts the other again.
|
||||
- **Confinement:** on macOS, a Seatbelt profile that denies everything but what the child needs, from its first instruction, because the broker starts it through `/usr/bin/sandbox-exec` with the profile as an argument, never as a file ([the child's sandbox](network.md#the-childs-sandbox)). The profile lets it run and read devvm's binary, write regular files in its logs folder and the shared Nix cache, look at the changing files with `stat`, and ask `trustd` to check certificates. It denies the child your home folder, devvm'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's ready, and it says how it's confined in `run/proxy.confined`, which is `full seatbelt` 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's broker left behind when, after a downgrade, an older devvm started the VM's proxy, and it names that proxy as one an older devvm started. When doctor can't read when the running broker started, it says it can't tell whether the proxy runs in its sandbox. Where `sandbox-exec` is missing or fails to start it, the broker starts it unconfined, writes a warning in `proxy.log`, and devvm doctor warns while the VM runs ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)). On Linux it confines itself before it reads a byte of the VM's. It sets `no_new_privs`, limits itself to the same folders with Landlock, and installs a seccomp filter that refuses it every socket but a netlink route socket, `connect`, TCP Fast Open, a listen, `io_uring`, the calls that reach another process, a change to a file's metadata by its path, the kernel's keyrings, a program, a process or a namespace of its own. It says `full landlock` when the kernel has Landlock'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.
|
||||
- **Starts and ends:** the broker starts it, devvm's own binary, by its real path on macOS and as `/proc/self/exe` on Linux, and on Linux the system kills it when the broker'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'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. `devvm stop`'s `SIGTERM` reaches the broker, which sends the child `SIGTERM`, which ends it at once, and kills it if it hasn't ended within a second. A child that ends, however it ends, ends its broker, and neither starts the other again.
|
||||
|
||||
## A build's proxy
|
||||
|
||||
A build gets a proxy of its own only behind a company proxy, because a build VM otherwise reaches the internet directly ([a company proxy](design.md#a-company-proxy)). It's the same `devvm _proxy` broker and its child, with a config in the build VM's `run/build-proxy` folder, which devvm makes again for each build.
|
||||
A build gets a proxy of its own only behind a company proxy, because a build VM otherwise reaches the internet directly ([a company proxy](../contributing/design.md#a-company-proxy)). It's the same `devvm _proxy` broker and its child, with a config in the build VM's `run/build-proxy` folder, which devvm makes again for each build.
|
||||
|
||||
- **Holds:** a password made for the build, and the company proxy's credentials. It has no CA, no secrets, no links and no Nix cache, so its broker looks up only the `proxy` secret, when `config.toml`'s company proxy names one.
|
||||
- **Reads from the build:** its requests, in the child, with the same checks as a VM's proxy, under a policy that allows any host on ports 80 and 443, but not this machine's own or internal addresses.
|
||||
- **Writes:** `events.jsonl` and `proxy.log`, in the build proxy's `logs/` folder, which its child writes and nothing else of the build proxy's is in, each rotated as a VM's proxy rotates its own. devvm deletes the build proxy's folder after a build that succeeds and keeps it after one that fails. The build VM's own logs are held to their caps by the build's devvm process, with a company proxy or without one, as a VM's proxy holds a VM's.
|
||||
- **Writes:** `events.jsonl` and `proxy.log`, in the build proxy's `logs/` folder, which its child writes and which holds nothing else of the build proxy's, each rotated as a VM's proxy rotates its own. devvm deletes the build proxy's folder after a build that succeeds and keeps it after one that fails. The build's devvm process holds the build VM's own logs to their caps, with a company proxy or without one, as a VM's proxy holds a VM's.
|
||||
- **Confinement:** none for the broker. Its child is confined as a VM's proxy'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's `logs/` folder.
|
||||
- **Starts and ends:** the build starts its broker, keeps its process and stops it when the build ends, which ends the child as `devvm stop` does, and a cleanup stops it when the build fails or is interrupted. It also follows the build VM's hostagent, as a VM's proxy does.
|
||||
|
||||
@@ -82,7 +82,7 @@ One forwarder runs for each running project VM that forwards ports, as `devvm _p
|
||||
|
||||
- **Holds:** the key that the backend logs in to the VM with, which on Lima is Lima's `_config/user`, and the VM's host keys for its current start. Its ssh uses no agent.
|
||||
- **Reads from the VM:** the VM'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' records of their ports.
|
||||
- **Writes:** `ports.forwarded` in the VM's run folder, and its log, `ports.log`, in the VM'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'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: its end goes to `ports.log.1`, 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.
|
||||
- **Writes:** `ports.forwarded` in the VM's run folder, and its log, `ports.log`, in the VM'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'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's end goes to `ports.log.1`, 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.
|
||||
- **Bounds:** 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's forward do.
|
||||
- **Listens:** on `127.0.0.1` and `::1` for each forwarded port ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Confinement:** none. Its ssh processes get the higher limit of open files that devvm runs with.
|
||||
@@ -118,7 +118,7 @@ Each connection that the forwarder or the link session carries gets an ssh proce
|
||||
On Linux hosts, Lima starts each VM's QEMU through a wrapper that devvm writes into `~/.local/share/devvm/run/qemu/`, which runs `devvm _qemu exec` ([confinement](lima.md#confinement)).
|
||||
|
||||
- **`devvm _qemu exec`** reads Lima's arguments for QEMU and adds `restrict=on` to Lima'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 `guestfwd` to that proxy. It refuses arguments of any other shape (`qemu_refused`). It then runs QEMU in its place, or, for a VM with `.git` pins, which a VM whose [.git protection](git-protection.md#on-linux-hosts) is on has, starts the keeper and waits for it. Only such a VM gets a user namespace.
|
||||
- **The keeper, `devvm _qemu pinned`,** 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 `.git`'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 `git-pins.jsonl` in the VM's run folder, and on QEMU's error output, which Lima logs. Past 1 MiB, the file takes no more events, but a line for each saying it went unrecorded, up to 64 KiB more, which the next check names. It starts QEMU through `devvm _qemu drop`, which clears its ambient, permitted, effective and inheritable capabilities, keeping the bounding set, sets `no_new_privs`, and runs QEMU.
|
||||
- **The keeper, `devvm _qemu pinned`,** 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 `.git`'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 `git-pins.jsonl` in the VM's run folder, and on QEMU'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 `devvm _qemu drop`, which clears its ambient, permitted, effective and inheritable capabilities, keeping the bounding set, sets `no_new_privs`, and runs QEMU.
|
||||
- **`devvm _qemu probe DIR`** checks, in a namespace of its own, that a file in DIR can be pinned.
|
||||
- **`devvm _qemu connect`** is what QEMU's `guestfwd` runs for each connection that the VM makes to `192.168.5.4:3128`. It connects to the VM'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'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 `proxy.slots` folder of the VM's run folder. A connection past that gets a `503` and is closed before it reaches the proxy, and QEMU's error output, which Lima logs, says so at most once a minute (`qemu_connects_full`). 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.
|
||||
|
||||
@@ -152,9 +152,9 @@ A VM whose [SSH agent](../using/ssh.md#agent-forwarding) choice is `on` gets you
|
||||
- **Reads from the VM:** only the requests that the VM's proxy passes on. A VM can use the keys while it's connected, and it can't copy them.
|
||||
- **Starts and ends:** devvm starts it when a VM that uses it starts, or when you add a key, and doesn't stop it, so it runs until you log out or restart this machine. devvm keeps no pid file for it.
|
||||
|
||||
A VM that devvm starts never reaches either agent's socket itself, and the exceptions are below. `ssh-agent` 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's own socket could remove every key with `ssh-add -D`, lock the agent with a password of its own with `ssh-add -x`, 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's proxy's broker, never its child, listens on a socket of the VM's own, `~/.local/share/devvm/run/agent-<hash>.sock`, mode 600, and the VM's start forwards that socket, as devvm's own connections to the VM and its [ssh entry](../using/ssh.md#ssh-access-by-name) do, so an editor forwards it too. The proxy passes on only three requests to the agent: listing its keys, signing with one, and `[email protected]`, which ssh sends as it forwards an agent and as it logs in with one, so a key you added with destination constraints (`ssh-add -h`) keeps them. It answers any other request with `SSH_AGENT_FAILURE` 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's keys never reach the agent. It reads each message whole, at most 256 KiB, as `ssh-agent` does, and ends a connection that sends a longer one. Each VM'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's own, not the agent's, so VMs that share an agent can hold 16 connections each, and enough of them could still use up the agent's open files, 256 by default on macOS. A request that the agent asks you about, for a key added with `--confirm`, waits as long as the agent does, and `ssh-agent` answers one request at a time, so while it waits for your answer, every other VM that shares the agent, and you, wait too.
|
||||
Apart from the exceptions below, a VM that devvm starts never reaches either agent's socket itself. `ssh-agent` 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's own socket could remove every key with `ssh-add -D`, lock the agent with a password of its own with `ssh-add -x`, 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's proxy's broker, never its child, listens on a socket of the VM's own, `~/.local/share/devvm/run/agent-<hash>.sock`, mode 600, and the VM's start forwards that socket, as devvm's own connections to the VM and its [ssh entry](../using/ssh.md#ssh-access-by-name) do, so an editor forwards it too. The proxy passes on only three requests to the agent: listing its keys, signing with one, and `[email protected]`, which ssh sends as it forwards an agent and as it logs in with one, so a key you added with destination constraints (`ssh-add -h`) keeps them. It answers any other request with `SSH_AGENT_FAILURE` 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's keys never reach the agent. It reads each message whole, at most 256 KiB, as `ssh-agent` does, and ends a connection that sends a longer one. Each VM'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's own, not the agent's, so VMs that share an agent can hold 16 connections each, and enough of them could still use up the agent's open files, 256 by default on macOS. A request that the agent asks you about, for a key added with `--confirm`, waits as long as the agent does, and `ssh-agent` answers one request at a time, so while it waits for your answer, every other VM that shares the agent, and you, wait too.
|
||||
|
||||
devvm records in the VM's state the start it made, and that a start whose choice forwards an agent forwarded the relay, even a start that devvm ran without `SSH_AUTH_SOCK`, which has no agent to relay. For such a start, devvm'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's own socket, even when a later command runs from a shell that has one. A VM running a start that devvm didn't record, such as one started with `devvm limactl start`, gets no agent in its ssh entry, and devvm's own connections get its proxy's relay of the agent that devvm last started it with, or none, never the agent's own socket. Only a VM that an earlier devvm started without the relay keeps the agent's own socket, in devvm's connections and its ssh entry, until its next start.
|
||||
devvm records in the VM'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 `SSH_AUTH_SOCK` and so had no agent to relay. For such a start, devvm'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's own socket, even when a later command runs from a shell that has one. A VM running a start that devvm didn't record, such as one started with `devvm limactl start`, gets no agent in its ssh entry, and devvm's own connections get its proxy's relay of the agent that devvm last started it with, or none, never the agent's own socket. Only a VM that an earlier devvm started without the relay keeps the agent's own socket, in devvm's connections and its ssh entry, until its next start.
|
||||
|
||||
The proxy relays the agent that the VM's start chose, and it keeps relaying that agent until the VM'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's backend. The proxy deletes the socket when it ends with the VM's hostagent, devvm deletes it when it stops the proxy, and `devvm gc --orphans` deletes one that a killed proxy left, which nothing listens on.
|
||||
|
||||
@@ -164,9 +164,9 @@ Each running VM has a hostagent, `limactl hostagent`, which `limactl start` runs
|
||||
|
||||
- **Holds:** Lima's login key, `_config/user` in devvm's Lima home, which every VM there authorizes, and the VM's disk.
|
||||
- **Reads from the VM:** everything the VM's network sends, on macOS. On Linux, QEMU carries it.
|
||||
- **Writes:** its logs, `ha.stdout.log` and `ha.stderr.log`, in the VM's Lima folder, which also get QEMU's errors on Linux, and the VM's serial console logs there, `serial.log`, `serialv.log` and `serialp.log`, which QEMU or Apple's Virtualization framework writes for it and which the VM's root writes to through `/dev/hvc0` and the other consoles. Each start writes them anew. devvm replaces each proxy password in `ha.stderr.log` and the serial consoles' logs with as many `*` 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'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's boot scripts again and writes the password to the console again, and it rotates a log once it holds more than 10 MiB. A look reads a line that hasn't ended yet again from its start when that's within 64 KiB of where the last look stopped, and otherwise from 64 KiB before, where it stars what runs on to an `@` as the rest of a secret, so a line that never ends costs at most 64 KiB more than what's new in it, and a secret of any length is found. A rotation copies the log's last 10 MiB, from a line's start, to the log's `.1` file, replacing the one there, with each password and proxy key in it replaced, and the start of one that the copy cuts before its `@` masked, and empties the log. The rest of that one, which the writer goes on with, is starred at the next look, up to its `@`. So each of these logs takes at most 10 MiB and 10 MiB more in its `.1` file, plus what a VM writes in a second. Its writer goes on at its own offset, past a hole that takes no disk, so what's capped is the space the log takes on disk, not its length, which keeps growing, and only on a file system with holes, such as APFS, ext4, XFS and btrfs, as 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's Virtualization framework ends a VM that restarts.
|
||||
- **Listens:** on the VM's ssh port on this machine's loopback, on macOS, where on Linux QEMU listens. It also listens on unix sockets in the VM's Lima folder and, for an open VM or a build, on loopback ports for Lima's DNS resolver ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Confinement:** on macOS, a confined VM's hostagent and a build's run under a Seatbelt profile, `sandbox.sb` in the VM's run folder, which denies `com.apple.dnssd.service`. A confined VM's profile lets it connect only to the VM's ssh port and its proxy on the host's loopback, to the unix sockets in the VM's Lima folder and, when the VM forwards an agent, to that SSH agent, and it lets the hostagent listen only on the VM's ssh port and those unix sockets. A build's profile reaches either the internet but not the host's loopback, apart from its ssh port and its build proxy's port, or nothing, and it doesn'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's hostagent and every hostagent on Linux run unconfined, and on Linux, QEMU's restricted network confines a confined VM instead ([confinement](lima.md#confinement)).
|
||||
- **Writes:** its logs, `ha.stdout.log` and `ha.stderr.log`, in the VM's Lima folder, which also get QEMU's errors on Linux, and the VM's serial console logs there, `serial.log`, `serialv.log` and `serialp.log`, which QEMU or Apple's Virtualization framework writes for it and which the VM's root writes to through `/dev/hvc0` and the other consoles. Each start writes them anew. devvm replaces each proxy password in `ha.stderr.log` and the serial consoles' logs with as many `*` 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'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'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't ended yet, the next look reads it again from its start if that'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 `@` as the rest of a secret. So a line that never ends costs at most 64 KiB more than what's new in it, and a secret of any length is found. A rotation copies the log's last 10 MiB, from a line's start, to the log's `.1` 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 `@` masked. The next look stars the rest of that one, which the writer goes on with, up to its `@`. So each of these logs takes at most 10 MiB and 10 MiB more in its `.1` file, plus what a VM writes in a second. The log'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's Virtualization framework ends a VM that restarts.
|
||||
- **Listens:** on macOS, on the VM's ssh port on this machine's loopback, which QEMU listens on instead on Linux. It also listens on unix sockets in the VM's Lima folder and, for an open VM or a build, on loopback ports for Lima's DNS resolver ([listeners](#listeners-a-vm-reaches)).
|
||||
- **Confinement:** on macOS, a confined VM's hostagent and a build's run under a Seatbelt profile, `sandbox.sb` in the VM's run folder, which denies `com.apple.dnssd.service`. A confined VM's profile lets it connect only to the VM's ssh port and its proxy on the host's loopback, to the unix sockets in the VM's Lima folder and, when the VM forwards an agent, to that SSH agent, and it lets the hostagent listen only on the VM's ssh port and those unix sockets. A build's profile lets it reach either the internet, but not the host's loopback apart from its ssh port and its build proxy's port, or nothing, and it doesn'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's hostagent and every hostagent on Linux run unconfined, and on Linux, QEMU's restricted network confines a confined VM instead ([confinement](lima.md#confinement)).
|
||||
- **Starts and ends:** devvm records the hostagent it started in `started` in the VM's run folder and checks that the VM still runs on it ([the self-check](network.md#the-self-check)), and the proxy and the forwarder follow its `ha.pid`. Nothing waits for it, and `limactl stop`, which `devvm stop` runs, ends it.
|
||||
|
||||
## Listeners a VM reaches
|
||||
@@ -191,7 +191,7 @@ A forwarded port and the login's port carry whatever connects to them into the V
|
||||
|
||||
## Why Go
|
||||
|
||||
devvm stays in Go, and its own history shows why. None of its first 712 commits fixes a memory-safety bug, devvm's own code imports `unsafe` only for a few raw system calls on Linux, which confine the proxy's child and set a file's times through its descriptor, and it builds without cgo, and none fixes a data race that got past Go's race detector, which every test run uses. Its security and reliability fixes fall mostly into five classes, which a language's types don't prevent:
|
||||
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's race detector, which every test run uses. devvm's own code imports `unsafe` only for a few raw system calls on Linux, which confine the proxy's child and set a file's times through its descriptor, and it builds without cgo. Its security and reliability fixes fall mostly into five classes, which a language's types don't prevent:
|
||||
|
||||
- **Lifecycles and resources,** such as a relay that outlived its link, a VM's QEMU left running without its hostagent, and a VM that could make devvm read more than it should.
|
||||
- **Policy semantics,** such as a 6to4 address judged by its IPv4 address, and a placeholder swapped only when it's the whole value.
|
||||
|
||||
@@ -19,15 +19,15 @@ devvm refuses a project folder that would hand the VM more than the project:
|
||||
- A folder that is or holds your home folder, devvm's settings (`~/.config/devvm`), its state (`~/.local/share/devvm`, which holds its binaries and other VMs' disks) or its Lima home (`unsafe_folder`).
|
||||
- A folder inside devvm's own folders (`unsafe_folder_inside`). A VM in `~/.config/devvm/layers` could rewrite the scripts that every image build runs, and a VM in devvm's data folder could rewrite the files devvm runs on the host.
|
||||
|
||||
devvm compares each of these folders with the project folder by path and by the folder itself: the project folder, or a folder above it, is the same folder as one of devvm's, by device and inode, or the other way round. So on a volume that ignores case, as a Mac's does by default, a project at `~/.Config/devvm/layers` is inside `~/.config/devvm`, although the two paths differ. `--unsafe-folder` mounts such a folder anyway, and devvm says so. A `--clone` VM mounts nothing, so devvm doesn't refuse its folder.
|
||||
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's by device and inode, or the other way round. So on a volume that ignores case, as a Mac's does by default, a project at `~/.Config/devvm/layers` is inside `~/.config/devvm`, although the two paths differ. `--unsafe-folder` mounts such a folder anyway, and devvm says so. A `--clone` VM mounts nothing, so devvm doesn't refuse its folder.
|
||||
|
||||
A project folder inside a coding agent's folder in your home folder, such as `~/.claude/skills/mine`, or one that holds an agent's folder, such as `~/.pi` for pi's `~/.pi/agent`, gives its VM read-write access to that agent's settings on this machine, such as Claude Code's hooks, which run on the host. devvm doesn'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's folder it overlaps (`project_agent_folder`), by the same comparison, and by the agent folder's name too, so a folder the VM could make later counts. A `--clone` VM gets no warning.
|
||||
A project folder inside a coding agent's folder in your home folder, such as `~/.claude/skills/mine`, or one that holds an agent's folder, such as `~/.pi` for pi's `~/.pi/agent`, gives its VM read-write access to that agent's settings on this machine, such as Claude Code's hooks, which run on the host. devvm doesn'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's folder it overlaps (`project_agent_folder`). devvm finds them by the same comparison and also by the agent folder's name, so a folder that the VM could make later counts. A `--clone` VM gets no warning.
|
||||
|
||||
### One VM per folder
|
||||
|
||||
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' 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'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's inode number, 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's own. devvm reads the folder'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't pass such a copy off as the folder. For a VM whose state records the folder'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's inode and birth time, mounted at the folder's own path, is another folder. A copy that keeps the volume ID too, as `dd` makes, still matches, as below. The VM'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 ([an existing VM](overview.md#an-existing-vm)). 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's VM, so the new folder never quietly gets what's in the old VM's disk. `devvm rm` deletes the old VM and `devvm adopt` gives it to the new folder, and each does so only after you confirm ([a folder made again](../using/vms.md#a-folder-made-again)). 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 ([a moved or renamed folder](../using/vms.md#a-moved-or-renamed-folder)). 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.
|
||||
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' 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'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's inode number. That'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's own. devvm reads the folder'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't pass such a copy off as the folder. For a VM whose state records the folder'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's inode and birth time, mounted at the folder's own path, is another folder. A copy that keeps the volume ID too, as `dd` makes, still matches, as below. The VM'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 ([an existing VM](overview.md#an-existing-vm)). 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's VM, so the new folder never quietly gets what's in the old VM's disk. `devvm rm` deletes the old VM and `devvm adopt` gives it to the new folder, and each does so only after you confirm ([a folder made again](../using/vms.md#a-folder-made-again)). 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 ([a moved or renamed folder](../using/vms.md#a-moved-or-renamed-folder)). 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.
|
||||
|
||||
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't name it. So the VM's state also records the folder's volume, which no renumbering changes: on macOS its volume UUID, as `diskutil info` gives it for the folder's mount point, and on Linux the file system's own ID (`f_fsid`) 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's mount point, its device and its file system's ID from the folder opened with no link on its path, and on macOS it takes `diskutil`'s answer only when it names that mount point and that device, so a volume mounted there meanwhile isn'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'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, a record whose volume is unchecked only once the volume is read and is the one recorded, with the conditions above, and looks the volume up only once the inode and birth time match. A command looks each mount's volume up once, and none after one lookup fails, within 1 second when a launch records it or when `devvm ls` and `devvm space` 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. A renumbered folder whose volume can't be told is judged by the rule above, as one whose state records no volume, and the launch records its new device with the volume it had, marked unchecked (`folder_unchecked` in `vm.json`), so each later launch looks the volume up again, and takes the folder for another one when it's on another volume, until a lookup finds the volume recorded and clears the mark. On Linux, where the folder'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's path is another folder even on the device the original had. A copy made with `dd` or an LVM snapshot of ext4 keeps the volume's UUID, and so its ID, as above. A Btrfs snapshot rolled back at the folder's path is another subvolume, with an ID of its own, so its folder is another folder, which `devvm adopt` gives the VM, and so is the folder after you give its volume a new UUID, as `tune2fs -U` does. devvm reads the folder's owner, which the offer of a move needs, from the same open folder as its identity, so the folder that'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 `asr` or `dd`, 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'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: at another path, an offer of the VM that you confirm, and at the folder's own path, where it has to be mounted, the VM. Nothing in a VM can make one ([a folder's volume](design.md#a-folders-volume)). 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't taken for an unmounted one ("not connected"). The state records the volume when the VM is made, adopted or moved, and, for a VM made before, at its first launch that finds its folder.
|
||||
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't name it. So the VM's state also records the folder's volume, which no renumbering changes. On macOS that's its volume UUID, as `diskutil info` gives it for the folder's mount point, and on Linux it's the file system's own ID (`f_fsid`) 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's mount point, its device and its file system's ID from the folder opened with no link on its path, and on macOS it takes `diskutil`'s answer only when it names that mount point and that device, so a volume mounted there meanwhile isn'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'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'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's volume up once, and looks up none after one lookup fails. A lookup has 1 second when a launch records it or when `devvm ls` and `devvm space` 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't tell a renumbered folder's volume, it judges the folder by the rule above, as one whose state records no volume. The launch then records the folder's new device with the volume it had, marked unchecked (`folder_unchecked` in `vm.json`), so each later launch looks the volume up again and takes the folder for another one when it's on another volume, until a lookup finds the volume recorded and clears the mark. On Linux, where the folder'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's path is another folder even on the device the original had. A copy made with `dd` or an LVM snapshot of ext4 keeps the volume's UUID, and so its ID, as above. A Btrfs snapshot rolled back at the folder's path is another subvolume, with an ID of its own, so its folder is another folder, which `devvm adopt` gives the VM, and so is the folder after you give its volume a new UUID, as `tune2fs -U` does. devvm reads the folder's owner, which the offer of a move needs, from the same open folder as its identity, so the folder that'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 `asr` or `dd`, 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'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's own path, where it has to be mounted. Nothing in a VM can make one ([a folder's volume](../contributing/design.md#a-folders-volume)). 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't taken for an unmounted one ("not connected"). The state records the volume when the VM is made, adopted or moved, and, for a VM whose state doesn't record one yet, at its first launch that finds its folder.
|
||||
|
||||
### A project's devcontainer.json
|
||||
|
||||
@@ -63,8 +63,8 @@ ssh and editors reach a running VM by name through the entries that devvm writes
|
||||
- **Only host keys go into the record.** 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 `@cert-authority`, patterns and anything else. So the VM can't add a line that would make ssh trust another host, or trust a key for another name.
|
||||
- **Each connection is its own.** The entries set `ControlMaster no`, so a session never rides on a connection that another program opened. Of Lima's own ssh settings for the VM, devvm copies only the address, port, user and login key, because Lima's settings turn host key checks off.
|
||||
- **The entries turn off everything else your ssh could share with the VM.** They set `ForwardX11 no`, `ForwardX11Trusted no`, `Tunnel no`, `PermitRemoteOpen none`, `AddKeysToAgent no`, `ProxyJump none`, `ProxyCommand none`, `UpdateHostKeys no` and `HashKnownHosts no`, whatever your own `Host *` says. That turns off X11, tunnels, remote SOCKS forwards and adding keys to an agent. `PermitRemoteOpen` needs OpenSSH 8.7 or newer (`ssh -V`), and an older ssh refuses the entries.
|
||||
- **Of your environment, the entries send only `COLORTERM`** (`SendEnv COLORTERM`), which says whether your terminal shows 24-bit color. The VM gets it only where its sshd accepts it, as Ubuntu's does in devvm's base, and devvm doesn't set that itself, so a VM made `--from` a container image whose sshd doesn't accept it, such as Alpine's, gets none. ssh sends it as your terminal has it, and it adds to the variables your own `Host *` sends, such as macOS's `LANG` and `LC_*`, rather than replacing them.
|
||||
- **Your agent is forwarded only as the VM's [SSH agent](../using/ssh.md#agent-forwarding) choice says.** devvm's own connections to a VM follow the same choice, the one the VM's current start was made with, and each carries that VM's agent alone. devvm finds the VM's agent, which is yours, devvm's own or none, and the VM's proxy relays it on a socket of the VM's own, passing on only listing keys, signing and binding a session to a host, so the VM can't remove the agent's keys, lock it or add keys to it ([the SSH agents](processes.md#the-ssh-agents)). devvm gives that socket to the backend's start of the VM, to its shell and to the commands that set it up, such as the setup devvm sends and the `devcontainer.json` commands. The backend's other commands get no agent, and neither do the reads of a VM's host keys, the [self-check](network.md#the-self-check)'s probe, the checks of a `--clone` VM's clone or `devvm paste`'s writes and counts. devvm never changes its own environment, so when one run reaches several VMs, such as a group's links, no VM gets another VM's agent. devvm's background processes, such as the proxy and the port forwarder, start without an agent in their environment, the proxy reaching only the one its config names, and its own ssh to a VM uses the VM's login key alone. `devvm limactl` runs without your agent too, because Lima'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 `devvm limactl shell` could open that connection and pass your agent to devvm's later sessions of a VM whose choice is devvm's agent or none.
|
||||
- **Of your environment, the entries send only `COLORTERM`** (`SendEnv COLORTERM`), which says whether your terminal shows 24-bit color. The VM gets it only where its sshd accepts it, as Ubuntu's does in devvm's base. devvm doesn't set that up itself, so a VM made `--from` a container image whose sshd doesn't accept it, such as Alpine's, gets none. ssh sends it as your terminal has it, and it adds to the variables your own `Host *` sends, such as macOS's `LANG` and `LC_*`, rather than replacing them.
|
||||
- **Your agent is forwarded only as the VM's [SSH agent](../using/ssh.md#agent-forwarding) choice says.** devvm's own connections to a VM follow the same choice, the one the VM's current start was made with, and each carries that VM's agent alone. devvm finds the VM's agent, which is yours, devvm's own or none, and the VM's proxy relays it on a socket of the VM's own, passing on only listing keys, signing and binding a session to a host, so the VM can't remove the agent's keys, lock it or add keys to it ([the SSH agents](processes.md#the-ssh-agents)). devvm gives that socket to the backend's start of the VM, to its shell and to the commands that set it up, such as the setup devvm sends and the `devcontainer.json` commands. The backend's other commands get no agent, and neither do the reads of a VM's host keys, the [self-check](network.md#the-self-check)'s probe, the checks of a `--clone` VM's clone or `devvm paste`'s writes and counts. devvm never changes its own environment, so when one run reaches several VMs, such as a group's links, no VM gets another VM's agent. devvm'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's own ssh to a VM uses the VM's login key alone. `devvm limactl` runs without your agent too, because Lima'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 `devvm limactl shell` could open that connection and pass your agent to devvm's later sessions of a VM whose choice is devvm's agent or none.
|
||||
|
||||
A session carries the VM's connections through your machine only where your ssh asks for it. The entries can't turn off a `RemoteForward` of yours without also refusing an `ssh -R` you type, so a `RemoteForward` still applies. The VM's sshd allows local forwarding (`-L` and `-D`, which VS Code uses), and it allows remote forwards only on addresses in `127.77.0.0/16`, which devvm keeps for links between VMs, so a remote forward on the VM's `localhost`, as `ssh -R` asks by default, is refused. It allows no tunnels or X11. Root in the VM can change all of that, so it's your ssh that decides, and [remote forwards you add](../safety/attack-vectors.md#the-network) says what's left open.
|
||||
|
||||
|
||||
@@ -0,0 +1,497 @@
|
||||
---
|
||||
title: devvm 0.2.0
|
||||
explainer: Every change in 0.2.0 and its release candidates
|
||||
weight: 10
|
||||
---
|
||||
|
||||
This page covers 0.2.0 and its release candidates, so far 0.2.0-rc.1, and it's written as 0.2.0 is made, so each release candidate adds its changes here. 0.2.0-rc.1 adds to 0.1.1-rc.3, and 0.2.0 takes 0.1.1's place, because its breaking changes need a new minor version. Install the release candidate with `devvm upgrade --to 0.2.0-rc.1`, the install script's `--version 0.2.0-rc.1`, or `brew install devvmhq/tap/devvm-rc`, while Homebrew's `devvm` stays on 0.1.0.
|
||||
|
||||
Each change below has a section of its own, which says what was wrong or missing, how it showed, how devvm works now and what you do. The changelog's entry for each release gives each of the same changes in one sentence, sorted by who notices it, and its What to do section lists what to do once you've upgraded.
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### At most 17 VMs run at once
|
||||
|
||||
Root in a VM could make the VM's ssh port answer as a web server, and because that port is on `localhost`, a page it served could get the cookies of the apps you use on `localhost`, even in a VM that forwards no ports. Each VM's ssh now uses one of the 17 ports from 1024 up that every browser refuses, so no page in your browser reaches a server in a VM through that port.
|
||||
|
||||
So at most 17 VMs run at once. A start past 17 fails and names the VMs that run on those ports, so stop one of them first ([too many VMs at once](../using/troubleshooting.md#too-many-vms-at-once)).
|
||||
|
||||
A VM that forwards every port leaves out those 17 ports, so that a VM can't take the ports that other VMs' ssh needs. A server in the VM on one of them, such as an X server on 6000, reaches this machine only when you list its port with `devvm ports`, and `devvm ports` and each launch warn when a VM's list names one of them ([ports](../using/ports-size.md#ports)).
|
||||
|
||||
Each existing VM's ssh moves to one of those ports at the VM's next start. That's the one change devvm makes to the VM's Lima config, and like any change there, it gives the VM new ssh host keys. A VM that runs as you upgrade keeps its old port until then, and devvm warns of it at each launch, so run `devvm stop` in its folder, and its next start moves it.
|
||||
|
||||
### Names are looked up as they're written
|
||||
|
||||
The proxy used to look names up with this machine's DNS search domain, which macOS takes from the network's settings and Linux from `/etc/resolv.conf`. When either host had a public address, no rule judged the name that the search domain made, so with `api.corp.example.com` denied and `**` allowing the rest, a VM could reach that host as `api`, or `api.eu.corp.example.com` as `api.eu`.
|
||||
|
||||
The proxy now looks each name up as it's written, and it no longer adds this machine's DNS search domain, so a short host name no longer reaches a host through the proxy. A tool in a VM that reached a host on your company's network by a name such as `jenkins` now needs the host's full name, such as `jenkins.corp.example.com`, and a block for a name without a dot says to use its full name ([a name that doesn't resolve](../using/troubleshooting.md#a-name-that-doesnt-resolve)).
|
||||
|
||||
### Claude Code's plugins in the agent store
|
||||
|
||||
devvm 0.1.0's `devvm agent import` copied your whole `~/.claude/plugins` into devvm's agent store, where every VM with Claude Code could read it, plugins' data included. The store now keeps only what a seed has of Claude Code's plugins, as [Claude Code's plugins in a VM](#claude-codes-plugins-in-a-vm) describes.
|
||||
|
||||
If you imported Claude Code's settings with devvm 0.1.0, the first start of any VM takes your plugins' data out of the store, along with the folder's other entries that are this machine's own, such as `installed_plugins.json`. It warns once, naming what it took, and it leaves your own `~/.claude/plugins` as it is ([Claude Code's plugins](../using/coding-agents.md#claude-codes-plugins)).
|
||||
|
||||
If the store's plugins folder is a link, or below one, which only a store you made yourself can be, no VM with Claude Code starts until you make it a folder of its own, because a VM's mount would follow the link.
|
||||
|
||||
If a plugin's data held a login of the plugin's own, every VM with Claude Code could read that login, so sign in to that plugin again where you don't trust those VMs. A VM that runs as you upgrade loses the store's entries that are this machine's own from its mount at the first start of any VM, so Claude Code there may not find the store's plugins until that VM's next launch. On a Linux host, the VM can keep seeing what it had read of them until its next start.
|
||||
|
||||
### A linked agent store is refused
|
||||
|
||||
`devvm agent import` and `devvm agent save` used to write through a link in devvm's agent store and take out whatever they hadn't written in the folder it led to, which for a link to your home folder deleted your files.
|
||||
|
||||
Now they refuse a linked store: they fail before they change anything, naming the link, when a folder on the way to what they write in the store is a link, from `~/.config/devvm/agents` down, such as `~/.config/devvm/agents/claude` linked into a dotfiles repo. Make that folder one of its own, then run the command again ([devvm's agent store](../using/coding-agents.md#devvms-agent-store)).
|
||||
|
||||
## Changes
|
||||
|
||||
### Each VM's proxy runs as two processes
|
||||
|
||||
A VM's proxy used to be one process, which read every byte the VM sent and held all of your secrets. It's now two. Only `devvm _proxy` reads your Keychain, your agents' login files and your other files, and `devvm _proxy-child`, which reads the VM's network, asks `devvm _proxy` for the rest, such as each connection and each value bound to the VM.
|
||||
|
||||
So besides the VM's own proxy password and CAs and your company proxy's password, the code that reads every byte a VM sends holds only the values that the VM's own bindings name, each for a few minutes after it was last asked for, and never a new login's tokens, its refresh token among them ([a VM's proxy](../internals/processes.md#a-vms-proxy)).
|
||||
|
||||
With the split, an error reply from an agent's token endpoint reaches the VM as it is up to 1 MiB, and gets `502` past that, and a build's proxy writes its logs to a `logs/` folder of their own in its folder.
|
||||
|
||||
A VM's proxy that runs as you upgrade stays one process, without a sandbox, until the VM's next launch. That launch starts it again as two processes, because a launch starts a VM's proxy again for every new devvm, and until then, `devvm doctor` names each VM whose proxy an older devvm started ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
### The child's sandbox on macOS
|
||||
|
||||
On macOS, `devvm _proxy-child` starts under `sandbox-exec`, with a profile that lets it write only its VM's logs and the shared Nix cache and look at your policy files. A bug that a VM drove there couldn't read your files, reach the Keychain or connect to this machine's unix sockets, such as ssh's and Docker's ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
### The child's sandbox on Linux
|
||||
|
||||
On Linux, before it reads a byte of the VM's, `devvm _proxy-child` confines itself with Landlock and a seccomp filter. A bug that a VM drove there could read and write only its VM's logs and the shared Nix cache, and couldn't change any other file's mode, owner, attributes or times, run a program, or connect to a unix socket, such as an ssh master's, Docker's or your SSH agent's. It could still learn whether a file of yours exists, its size and when it changed ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
### A child without its whole sandbox
|
||||
|
||||
A proxy that can't get its whole sandbox keeps the VM's network, and `devvm doctor` warns. On macOS, if `sandbox-exec` is missing or fails to start the child, the child runs without the sandbox. On Linux, a kernel without Landlock or seccomp filters, or whose Landlock is older than ABI 6 or lacks its fix for signals between threads, confines the child only in part. Either way the VM keeps its network, and `devvm doctor` warns for each VM whose proxy runs that way, naming what the kernel lacks on Linux ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
### The child connects only through `devvm _proxy`
|
||||
|
||||
Wherever its sandbox runs, a bug that a VM drove in the child can't reach this machine's services on `localhost`, such as your dev servers, Docker's published ports and other VMs' proxies, nor this machine's own addresses or your LAN's private addresses, unless a rule names the address, just as the VM can't.
|
||||
|
||||
A rule such as `devvm network allow 127.0.0.1:5432` still applies from the next connection, and a company proxy on `localhost` still works, though the child reaches whatever that company proxy reaches, as the VM does. Because `devvm _proxy` looks up the child's names, the child reads no file below `/etc` on Linux and doesn't talk to mDNSResponder on macOS ([the child's sandbox](../internals/network.md#the-childs-sandbox)).
|
||||
|
||||
### devvm doctor checks every VM's state
|
||||
|
||||
`devvm doctor` warns once of each VM whose state devvm can't read, naming the VM, the file and why, even when it can't read the VM's folder, and it changes nothing. It reads each VM's `vm.json` as every command on a VM does. Such a VM used to hide doctor's warnings about the other VMs' policy files, and the warnings that `devvm network` gives for every VM, and it no longer does ([a file devvm can't read](../using/troubleshooting.md#a-file-devvm-cant-read)).
|
||||
|
||||
### Credentials in a copied marketplace
|
||||
|
||||
A Claude Code marketplace can have a password or an access token in its clone's git config or in its source in `known_marketplaces.json`, and every VM with Claude Code can read it once it's in devvm's agent store. `devvm agent import` and `devvm agent save` now warn when they copy such a marketplace. The warning names the marketplace, the store's file and the keys, and the marketplace is copied as before ([mounts](../using/coding-agents.md#mounts)).
|
||||
|
||||
### devvm agent import's bounds
|
||||
|
||||
`devvm agent import` copies at most 20,000 files, folders and links, 128 MiB, and 16 MiB in one file, of each agent's folder. An agent's folder that holds more, such as one that a VM's project inside it filled, fails the import before the store changes, naming the folder, so take out what it doesn't need and import again ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### A failed import changes nothing
|
||||
|
||||
A failed `devvm agent import` leaves the store as it was. That holds whether the import fails while it reads, such as at a file that changed meanwhile, or while it puts the settings and logins in place, such as at a login it can't save. In the rare case that putting the store back fails too, the import names what it kept ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### A project in an agent's folder
|
||||
|
||||
When a VM's project folder is inside a coding agent's folder on this machine, such as a skill you work on in `~/.claude/skills/mine`, or holds one, such as `~/.pi`, code in the VM can change that agent's settings on this machine, and so the settings that `devvm agent import` copies for every VM.
|
||||
|
||||
Each launch of the VM now warns of it in one line, and so does the import, which also leaves out an agent's folder that a link in a VM's project folder leads elsewhere ([project folders devvm refuses](../using/settings.md#project-folders-devvm-refuses)).
|
||||
|
||||
### An import while a VM's state can't be read
|
||||
|
||||
`devvm agent import` can't tell where a VM's project folder is while it can't read that VM's state, so it follows no links then. It warns of each VM whose state it can't read, naming the state. Until that's fixed, it leaves out every link out of an agent's folder, and an agent's folder or login whose path leads through a link, one on the way to your home folder included unless only root can change it, so run `devvm doctor` and import again ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### Cursor's CLI and your Cursor account
|
||||
|
||||
Cursor's CLI in a VM can change less of your Cursor account. Its proxy refuses more of the methods that change your account, your team or your cloud agents, such as merging a cloud agent's pull request, forking or pinning a cloud agent, or writing to its machine, and every call that the CLI itself makes still passes. Do those from Cursor on your machine ([Cursor CLI login](../using/coding-agents.md#cursor-cli-login)).
|
||||
|
||||
### Pins
|
||||
|
||||
mise is 2026.11.10, in base and on this machine, the docker layer's Docker is 29.10.0 and its compose 5.8.0, and Cursor's CLI is 2026.11.17-f532c45. The new mise and Docker change what goes into the images, so base, every image built on it and every shared tool that mise installs are built again once.
|
||||
|
||||
Run `devvm update` in each existing VM's folder. Until you do, a VM made from an older image says it's outdated, and every existing VM says there are newer shared tools at the same versions. The first update or new VM builds base and each of its shared tools again, one at a time, which takes several minutes.
|
||||
|
||||
### Pins since 0.2.0-rc.1
|
||||
|
||||
mise is 2026.11.14, in base and on this machine, the nix layer's Nix is 2.36.0, and the docker layer's buildx is 0.39.1 and its model plugin 1.2.10. The new mise changes what goes into base, so base, every image built on it and every shared tool that mise installs are built again once, as they were for 0.2.0-rc.1's pins.
|
||||
|
||||
Run `devvm update` in each existing VM's folder, and give the first one several minutes.
|
||||
|
||||
### A faster first run
|
||||
|
||||
A first run with the defaults took about two and a half minutes on a fast link, and a third of that came after base was built. The shared tool images built one after another, and the tools' versions were resolved only once base was done. Now up to four tool images build side by side, each in a build VM of 2 GiB and 2 CPUs. devvm runs only as many as this machine has room for after keeping 6 GiB and 2 CPUs for itself and the memory of devvm's running VMs, and as many as the free disk allows. The tools' versions now resolve while base builds. On an M4 Mac mini the defaults' first run went from 156 to 118 seconds, and on an x86_64 Linux host from 159 to 125 ([building tools](../internals/images.md#building-tools)).
|
||||
|
||||
A first run also downloads about 210 MB less on arm64 and about 280 MB less on amd64. devvm's own mise comes as its `.tar.gz`, in base and on this machine, a third of the binary's size, and base's build fetches only the package lists apt installs from, with no translations, AppStream components or command-not-found metadata.
|
||||
|
||||
While tool images build side by side, one status line covers them, and each line of a build's commands in the run log starts with its tool's name, such as `[node]`. When one fails, devvm stops the others and shows the end of that tool's own lines. Each build VM has a name of its own on Lima, `devvm-tools-build` and then `devvm-tools-build-2` to `devvm-tools-build-4`, and a later build or `devvm gc` deletes any of them that a killed or failed run left, and gc names each one it deletes.
|
||||
|
||||
These changes, and the next section's, change what goes into base, every layer and every shared tool, so they're built again once, with the pins since 0.2.0-rc.1. Run `devvm update` in each existing VM's folder, as for those pins.
|
||||
|
||||
### A first run on a bad network
|
||||
|
||||
A first run failed at the first connection that was cut or stalled, in Lima's download of Ubuntu's cloud image, which neither retried nor timed out, or in any of the downloads in base's build and the tool images' builds, which gave up at once or tried again from nothing. Now each of them goes on, and a first run on a network that cut or stalled a connection every 250 MB came through seven faults ([building](../internals/images.md#building)):
|
||||
|
||||
- **Ubuntu's cloud image:** devvm downloads it itself, and a download that's cut or stalls goes on from where it stopped, in the same run or the next ([Ubuntu's cloud image in devvm's folder](#ubuntus-cloud-image-in-devvms-folder)).
|
||||
- **`devvm-fetch`**, which base and every layer download through, gives up on a connection slower than 1 KB/s for 30 seconds and goes on from where it stopped, five tries in all, and a file that doesn't match its checksum is fetched again from nothing once. Your own layers' `devvm-fetch` downloads get the same.
|
||||
- **apt** tries a package's download again three times, **crane** five times and **mise** six times, in tool builds and on this machine, and **oh-my-bash**'s clone gets five tries in all.
|
||||
- **`tldr --update`**, in the `cli-tools` feature, gives up after a minute, where a stalled download held base's build for two minutes.
|
||||
|
||||
### Ubuntu's cloud image in devvm's folder
|
||||
|
||||
devvm downloads the pinned Ubuntu cloud image itself into `~/.local/share/devvm/images/ubuntu/<sha256>.img`, checks it against the pin and gives Lima that file, so Lima's download cache no longer grows with each release. On a Mac that cache kept 3.3 GB for each release, the image and a copy converted to a raw disk, and devvm keeps the 943 MB image alone. The first build of base after the upgrade takes the image from Lima's cache when that holds the pinned one, so a release that Ubuntu has since removed still builds, and it never changes Lima's cache ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)).
|
||||
|
||||
The download, and the lookups of Ubuntu's dated releases, go through your company proxy and trust the CAs in `~/.config/devvm/ca`, as devvm's own mise does, where Lima's download went straight to Ubuntu and the lookups trusted this machine's CAs alone. When the lookups or the download meet a certificate that this machine doesn't trust, devvm names that folder, where the lookups used to say only to check that you're online, and when a certificate is out of date or for another host, devvm says to check this machine's date and time and what answers for the host on this network. Any other certificate that fails to verify is named by its reason, and none of these is tried again. Behind a company proxy whose rules block large downloads, a first build that used to reach Ubuntu directly now fails, saying that downloading Ubuntu's cloud image failed, so ask for cloud-images.ubuntu.com to be let through ([a company's CA](../using/settings.md#a-companys-ca)). When Ubuntu no longer has the pinned release and Lima's cache doesn't hold it either, devvm says that the release is gone and names `devvm rebuild base`, where Lima's own error came before.
|
||||
|
||||
`devvm space` shows devvm's copies as `cloud images`, kept as state, since a release that Ubuntu removed can't be downloaded again. `devvm gc --caches` frees those that no image's record names and that aren't pinned now. Of Lima's cache, it frees only an entry that an image record of devvm's names, as an earlier release's build of base left it, once devvm has its own copy of that image, and never one that Lima's own templates use. So run it once after the upgrade to free the copy that Lima's cache holds of the release your current base was built from, 3.3 GB on a Mac and 862 MB on Linux, unless the installed Lima's own templates use that release, which most do today, and an older release's copy, whose record a later `devvm rebuild base` replaced, stays. `limactl prune` frees the rest, your own downloads included ([Ubuntu's cloud images](../using/space.md#ubuntus-cloud-images)). It now fails when it can't read the pin, `~/.local/share/devvm/images/ubuntu.json`, rather than free an image the pin may name, so delete that file, which base can't build from either, and the next build of base pins Ubuntu's newest release.
|
||||
|
||||
### Status lines for slow steps
|
||||
|
||||
Some of devvm's slow steps used to show nothing while they ran. In a terminal, devvm now shows a status line that says what it's waiting for during these steps ([a command fails](../using/troubleshooting.md#a-command-fails)):
|
||||
|
||||
- finding the folder's VM, checking it before a start, checking its network and reading its host keys, setting it up, running a `devcontainer.json`'s commands, looking up a folder's disk, checking Lima, deleting a VM or an image, applying the retention settings and installing an upgrade
|
||||
- `devvm ls` reading the VMs, `devvm doctor` checking this machine, `devvm agent import` reading your agents' folders and copying them into the store, and `devvm agent save` reading and comparing the VM's settings
|
||||
- `devvm clone add`, `clone fetch`, `clone on` and `clone off`, `devvm git-protect`, `devvm stop`, a `--clone` VM's check before `devvm rm`, a history export or import, and `devvm ports` as it starts a running VM's port forwarder again
|
||||
- `devvm link` as it asks about the VMs its links lead to, `link add`, `link rm`, `link publish` and `link unpublish`, `devvm group join` and `group leave`, and `devvm rm` of a VM that others link to, as they give each running VM its changed links and check the VMs that links lead to
|
||||
- `devvm network learn` and `network lock` as they give a running VM's proxy its new tier
|
||||
- every stop of a VM, as for `devvm restart` or a restart you agree to after changing a setting
|
||||
|
||||
### Status lines while devvm waits
|
||||
|
||||
While devvm waits for another devvm that's changing the same thing, such as a VM's state, its folders' layout, a group, an image's build or the shared tools, a status line says so, and only while it waits. Some of those waits used to show nothing, and others printed a line after a few seconds that stayed. A run with `-v`, or with its output piped, no longer prints that line, because a status line shows only in a terminal without `-v` ([a command fails](../using/troubleshooting.md#a-command-fails)).
|
||||
|
||||
### opencode's worktrees before a VM goes
|
||||
|
||||
opencode makes its worktrees in `~/.local/share/opencode/worktree` in the VM, and a history export now leaves that folder out, because a git repository's config can name a command that git runs ([opencode's automations and permissions in history](#opencodes-automations-and-permissions-in-history)). So the uncommitted changes in those worktrees went with the VM, with nothing to say so.
|
||||
|
||||
`devvm rm`, and a command that makes the VM again with `--clean-home`, now check those worktrees first, starting a stopped VM for the check. devvm shows each worktree's uncommitted changes under its path and asks before they go, and it asks too about a detached HEAD's commits that nothing else in the VM has, a worktree that git can't read, and more than 100 worktrees. `--force` never answers that question, so without a terminal devvm refuses and keeps the VM. When only the worktrees have work, its refusal names `--no-worktree-check`, a new flag that warns and goes ahead without the check. A remake's messages name the command with `--clean-home`, because `--no-worktree-check` works only with it, and so do the clone check's messages for `devvm clone off --clean-home`. For a VM whose folder is gone, `devvm rm VM` reads the worktrees from the running VM, and it refuses a stopped one, even with `--no-export`, naming `devvm rm VM --no-export --no-worktree-check`, because starting it would make its folder again. If a script deletes such VMs, or remakes them with `--clean-home`, give it `--no-worktree-check` where losing those changes is fine ([opencode's worktrees](../using/coding-agents.md#opencodes-worktrees)).
|
||||
|
||||
### Reproducible release builds
|
||||
|
||||
Two builds of the same release on two machines gave different archives, because each archive recorded the owner and group of the files on the machine that built it, and the binary's version came from whichever tags that machine's clone of the repo held. Now every release file but the signature is built in one container image, pinned by its digest, with no network, no capabilities, bounded processes and memory, and a time limit kept outside it, with the Go and GoReleaser that the release's `mise.lock` pins, from a repository that holds only the release's commit and its own tag, and each archive file's owner, group, mode and time are set. So the same tag, built on an arm64 Mac or on an x86_64 Linux machine, gives byte-identical archives, source tarball, `install.sh` and `SHA256SUMS`. On each change, CI builds the release twice, once under podman as root and once under Docker as another user, from a repository with a stray tag, and checks that the two builds agree and that every archive's files are root's. `scripts/release.sh --tag` builds a published release again, unsigned, so another builder can compare its `SHA256SUMS` with the release's. Nothing changes for you ([Reproducible releases](../contributing/maintaining.md#reproducible-releases)).
|
||||
|
||||
### Releases signed by two of three keys
|
||||
|
||||
Every release so far was signed by one minisign key, so whoever had that key could sign a release that devvm upgrade and the install script would install. devvm can now check a release against three release keys, one for GitHub's CI, which builds each release, one for a co-signer, a machine of the maintainer's that builds the same bytes again, and a recovery key kept offline. Once a devvm has the keys built in, devvm upgrade and its install script accept a release's `SHA256SUMS` when any two of them signed it, each in a file of its own, `SHA256SUMS.ci.minisig`, `SHA256SUMS.cosign.minisig` or `SHA256SUMS.recovery.minisig`, with the trusted comment `devvm-release <version>`, which must match the release being installed. Each file is checked only against its own key, and two signatures by one key count once.
|
||||
|
||||
The keys themselves aren't made yet, so this release has none built in, and its install script holds none. Until a release carries them, devvm upgrade and the install script check each release with the old key alone, as before, and a release that only the new keys signed is refused. The release that brings the keys is signed by the old key too, so this release upgrades to it.
|
||||
|
||||
They still accept the old key's signature, in `SHA256SUMS.minisig`, while releases bridge from it, so devvm 0.1 and 0.2, which know only that key, can upgrade to a release that the three keys sign, which carries the old key's signature too, and devvm upgrade `--to` and the install script's `--version` can still install a 0.1 or 0.2 release. While the bridge lasts, the old key alone still signs a release, as before. The install script also checks the old key's trusted comment now, `devvm <version>`, where it took any `SHA256SUMS` that the key signed, so a release's files signed for another version are refused. Without minisign, the script now says that only the checksum is checked, which can't tell who made the release, and prints the commands to check the signatures by hand: two of the three once it has the release keys, and the old key's until then. Nothing changes for you ([the release keys and the signatures](../internals/install.md#the-release-keys-and-the-signatures), [Release keys](../contributing/maintaining.md#release-keys)).
|
||||
|
||||
### A co-signer for releases
|
||||
|
||||
Two builders that build the same bytes can check each other only if the second one really rebuilds each release and refuses one that differs, and only if nothing else can publish. devvm now has that second builder, `devvm-cosign`, a program of its own that a systemd timer runs hourly on a Linux machine of the maintainer's. CI can only read the repo, so it hands each release's files and its signature over as a workflow artifact. The co-signer checks CI's signature and every file against `SHA256SUMS`, checks the tag's SSH signature against the signers its own config pins, rebuilds the tag with its own pinned copy of `scripts/release.sh`, and signs `SHA256SUMS` only when both builds match, writing a report when they don't. Then it makes the GitHub release itself, and once two of the three release keys signed it, publishes it and commits to the tap the Homebrew formulas it renders from the signed `SHA256SUMS` and the tag's template, through a GitHub App's token. Any release published since its state began that it didn't make is an alert, whatever its tag. A build that fails three runs in a row is refused as a mismatch is, so it can't hold up the releases behind it, and an older release made GitHub's latest is an alert too. A refused build and an alert fail every run, and run a notify command of the maintainer's, until the maintainer clears them with `devvm-cosign retry` or `ack`. It never signs an older version than one it signed, nor two manifests for one version, and a failed upload or publish is safe to run again. Its keys are root's and reach it only as systemd's credentials, and the podman service its builds run in sees neither them, nor its state, nor its processes, starts empty for each run, and lives for one build, though it still runs as the same user. It handles a published base the same way, re-signing an unchanged base without a rebuild, though never one built from an Ubuntu snapshot more than 60 days old, and it can't rebuild a base yet. Nothing changes for you ([The co-signer](../contributing/cosigner.md)).
|
||||
|
||||
### Releases through CI and the co-signer
|
||||
|
||||
Every release so far was built, signed and published from the maintainer's machine, so that one machine decided what every user installed. Now the maintainer's part of a release is signing its tag and pushing it, with `scripts/publish.sh`. GitHub's CI then builds the release in its Release workflow, once the maintainer approves the run in a protected environment. The workflow checks the tag's SSH signature against signers kept in that environment, never a list in the tagged commit, builds the release in its pinned container, signs `SHA256SUMS` with CI's release key, adds a GitHub artifact attestation of every file, and hands the build to the co-signer. Its token can only read the repo, so CI can't publish anything. The co-signer rebuilds the release, signs it only when its build matches CI's byte for byte, makes the draft release, and publishes it with the tap's formulas. Each release published this way carries CI's signature and the co-signer's, which devvm upgrade and the install script check, and the old release key's signature too, which the maintainer adds by hand with `scripts/publish.sh --sign-legacy`, because devvm 0.1 and 0.2 check only that key. Releases go this way once the maintainer has set up GitHub for it, and until then they're built and published from the maintainer's machine as before, with `scripts/publish.sh --local`. Nothing changes for you until the old key's bridge ends, and that release's notes will say what to do ([CI's release workflow](../contributing/maintaining.md#cis-release-workflow), [the bridge](../contributing/maintaining.md#the-bridge-from-the-old-release-key)).
|
||||
|
||||
## Fixes
|
||||
|
||||
### A project folder devvm can't read
|
||||
|
||||
When you, or code in a VM that mounts it, took away your read permission on a project folder, devvm used to say that the folder's VM was made for an earlier folder that was deleted or replaced, and offer `devvm rm` and `devvm adopt`. devvm now names the folder and why it can't be read, so make it readable again ([a folder made again](../using/vms.md#a-folder-made-again)).
|
||||
|
||||
### Warnings and the status line
|
||||
|
||||
A warning used to be written onto the status line's own line, and the status line's next redraw could erase a question's prompt and what you typed. A message that devvm prints during a slow step now prints above the status line, which comes back below it, and a question, the picker and an agent's login in the VM take the status line away until they're done ([a command fails](../using/troubleshooting.md#a-command-fails)).
|
||||
|
||||
### Claude Code's setup-token login
|
||||
|
||||
`devvm agent login claude --setup-token` showed nothing and waited, as [#57](https://github.com/devvmhq/devvm/issues/57) reported. The login in the VM got no terminal, so `claude setup-token`, which draws full-screen, showed nothing. When devvm runs in a terminal, an agent's login in the VM now gets a terminal of its own, as devvm's shell does, so Claude Code shows the address to open and the prompt for its code. Without a terminal, `--setup-token` warns that the login may show nothing ([Claude Code login](../using/coding-agents.md#claude-code-login)).
|
||||
|
||||
### Ctrl-C in an agent's login
|
||||
|
||||
In a terminal, Ctrl-C now goes to the agent's login in the VM and ends it, and devvm then says that the login ended or saved nothing. devvm puts the terminal back as it was before the login, even when a signal ends devvm itself ([Claude Code login](../using/coding-agents.md#claude-code-login)).
|
||||
|
||||
### 24-bit color in a VM
|
||||
|
||||
Programs in a VM, such as coding agents, fell back to fewer colors, as [#54](https://github.com/devvmhq/devvm/issues/54) reported, because devvm's shell in a VM never got your terminal's `COLORTERM`, and neither did an agent's login or `ssh` to a VM by name.
|
||||
|
||||
devvm's shell in a VM and an agent's login with `devvm agent login` now get your terminal's `COLORTERM` when it's `truecolor` or `24bit`, and no other value ([opening a VM](../using/vms.md#opening-a-vm)). The ssh config entries for reaching a VM by name now send it as your terminal has it, from the next time devvm launches or stops a VM, which writes them again. A VM made with `--from` gets it over ssh only when its image's sshd accepts it ([ssh access by name](../using/ssh.md#ssh-access-by-name)).
|
||||
|
||||
### MCP servers' logins
|
||||
|
||||
Claude Code keeps its logins to MCP servers in the VM's `~/.claude/.credentials.json`, the file where devvm puts the Claude login. Each launch and each `devvm agent login claude` used to write devvm's copy of the login over the whole file, as [#62](https://github.com/devvmhq/devvm/issues/62) reported. So a login to an MCP server that you started with `/mcp` in a VM failed when devvm set the VM up again before it finished, such as when you ran devvm in its folder from another terminal, and one that finished was gone at the VM's next launch.
|
||||
|
||||
With your subscription's login, devvm now replaces only the Claude login in that file and keeps the rest, so the MCP servers' logins you make in a VM stay in that VM, and they never reach this machine or another VM. With a Claude Code token, the VM's file stays as it is ([MCP servers' logins](../using/coding-agents.md#mcp-servers-logins)).
|
||||
|
||||
### Your claude.ai connectors
|
||||
|
||||
The connectors you added in claude.ai didn't work in a VM, as [#61](https://github.com/devvmhq/devvm/issues/61) reported. The proxy put your subscription's login only into requests to `api.anthropic.com`, so the connectors' requests held the login's placeholder and were refused.
|
||||
|
||||
With your subscription's login, the VM's proxy now also puts the login into requests to `mcp-proxy.anthropic.com` below `/v1/mcp/`, which carry the connectors' traffic, from each VM's next launch. So a VM with Claude Code can use every connector you added in claude.ai, as Claude Code on this machine can. A Claude Code token, from `claude setup-token` or in devvm's environment, still goes only to `api.anthropic.com` ([Claude Code login](../using/coding-agents.md#claude-code-login)).
|
||||
|
||||
Code in the VM can now read and act through your connectors, so disconnect the ones you don't want VMs to use, or deny `mcp-proxy.anthropic.com` with `devvm network deny` ([your claude.ai connectors](../safety/attack-vectors.md#the-network)).
|
||||
|
||||
### Claude Code's plugins in a VM
|
||||
|
||||
Each VM's `~/.claude/plugins` used to be devvm's agent store's folder, mounted read-only, so whatever Claude Code writes there failed, such as a plugin's data in `${CLAUDE_PLUGIN_DATA}`, installing a plugin and updating a marketplace, as [#56](https://github.com/devvmhq/devvm/issues/56) reported.
|
||||
|
||||
Each VM's `~/.claude/plugins` is now its own folder, so all of those work. The store's plugins are Claude Code's read-only seed at `~/.claude/plugins-seed`, so they load as before, a plugin keeps its data in the VM, and a plugin you install in a VM stays in that VM until `devvm agent save` copies it into the store. A store that devvm 0.1.0's import filled keeps only what a seed has, as [Claude Code's plugins in the agent store](#claude-codes-plugins-in-the-agent-store) says ([Claude Code's plugins](../using/coding-agents.md#claude-codes-plugins)).
|
||||
|
||||
Each VM gets its own `~/.claude/plugins` at its next launch, without a restart, in place of its link to the store's folder. Claude Code started in a shell that was open before that launch finds none of the store's plugins, so start it in a new shell.
|
||||
|
||||
### A project folder after your Mac restarts
|
||||
|
||||
After a restart, an unchanged folder could be on a device with another number, and devvm took it for another folder, as [#60](https://github.com/devvmhq/devvm/issues/60) reported. So every command on its VM refused it as made for an earlier folder at its path, a stopped VM's start refused it as replaced, and the next check of `.git` called it replaced.
|
||||
|
||||
A folder at the same path, with no link on it and with the same inode and birth time, is now the same folder on whichever device it's on. The VM's next start records the folder on its new device before it mounts it, in the one change devvm makes to its Lima config. A folder that moved after a restart, before its VM started again, isn't offered the VM, so `devvm adopt VM` moves it ([one VM per folder](../internals/security.md#one-vm-per-folder)).
|
||||
|
||||
### A folder moved across a restart
|
||||
|
||||
devvm used to miss a folder that moved while a restart gave its disk another device number, and make it a second VM, and it called the gone folder of a VM whose disk was renumbered not connected. Each VM now records its folder's volume, which no renumbering changes, so devvm finds such a folder. Once the VM has recorded its volume, devvm offers a moved folder its VM by its volume, inode and birth time, and calls a VM's gone folder gone ([a moved or renamed folder](../using/vms.md#a-moved-or-renamed-folder)).
|
||||
|
||||
Each VM records its project folder's volume at its first launch that finds the folder. Until then, a folder that moves while a restart gives its disk another device number still needs `devvm adopt VM`, and after a restart, the VM's gone folder can still be called not connected. Both stay true for a VM whose folder was already gone before the upgrade, because it never records a volume.
|
||||
|
||||
### A folder on another volume
|
||||
|
||||
A folder at the VM's own path whose disk was renumbered, but on another volume than the one recorded, such as a copy of the disk with a volume ID of its own mounted there, is another folder, so devvm gives it the VM only after `devvm adopt`. On Linux, every launch checks the volume, so a Btrfs snapshot rolled back at the folder's path, or the folder after you give its volume a new UUID, also needs `devvm adopt` ([a folder made again](../using/vms.md#a-folder-made-again)). When devvm can't read the volume at the launch after a renumbering, such as when `diskutil` doesn't answer, each launch looks it up until it can ([one VM per folder](../internals/security.md#one-vm-per-folder)).
|
||||
|
||||
### Two devvms at the agent store
|
||||
|
||||
Two devvms could write the agent store at once, so their files used to mix, or one could fail partway. `devvm agent import`, `devvm agent save` and a start that cleans Claude Code's plugins out of the store now take turns, so a second one says it's waiting and goes on once the first is done. A save that finds the store changed since it showed what differs now saves nothing instead of writing over an import ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### A failed save changes nothing
|
||||
|
||||
A save that failed partway, such as at a file it couldn't write in one agent's store or at the Claude Code login it saves last, used to leave the agents it had saved before the failure saved and the rest not. A failed `devvm agent save` now leaves the store as it was, because a save saves all or nothing, as an import does, and in the rare case that putting the store back fails too, it names what it kept. A file in the VM where the store has a folder, or the other way round, now fails the save before anything changes, naming the store's path ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### opencode's lock files in a save
|
||||
|
||||
`devvm agent save` refused a VM whose `~/.config/opencode` held a lock file, such as the `bun.lock` that opencode's plugins' installs write or a `package-lock.json`, or another file the store doesn't keep, such as `.gitignore` or `.DS_Store`. The VM sent every file in that folder, while devvm's store keeps none of these, so devvm took each as a path outside the agents' settings and saved nothing. The VM now doesn't send them, so they stay in the VM, and the save goes on ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### devvm agent save and a new Claude Code login
|
||||
|
||||
`devvm agent save` and a VM's new Claude Code login take turns. While it saves Claude Code's part of `~/.claude.json`, the save holds the lock on Claude Code's logins, the lock that a VM's proxy holds while it saves a Claude Code login made in that VM. Ctrl-C while the save waits for either lock ends the wait ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### Names that differ only in case
|
||||
|
||||
On a Mac, when the VM, or your home folder for `devvm agent import`, had a file whose name differed from the store's only in case, such as `foo.md` where the store has `Foo.md`, `devvm agent save` and `devvm agent import` used to delete the store's file and report success. They now treat such a file as one file, as macOS's volume does, so the store's file gets the new content and keeps its name, and the save's diff shows it as changed.
|
||||
|
||||
Two names in the VM that differ only in case, such as `A.md` and `a.md`, would be one file in the store, so the save now saves nothing and names both, and so does an import of two such names from a home folder on a volume that tells case apart ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### Names you choose in an agent's settings
|
||||
|
||||
devvm used to take a plugin, a marketplace or an MCP server whose name had `key`, `token`, `secret` or `passw` in it, such as `tokeneconomizer` or `secret-scanner`, for a secret, as [#55](https://github.com/devvmhq/devvm/issues/55) reported. It put `devvm-redacted` in place of all its settings in the VM's copy, so Claude Code refused the VM's `settings.json` whole and every plugin was off in the VM.
|
||||
|
||||
devvm now knows the agents' tables of names, such as Claude Code's `mcpServers`, and judges only the fields under a name, so a server named `secret-scanner` keeps its command and still loses its `env` and its `apiKey` ([keys in settings files](../internals/network.md#keys-in-settings-files)).
|
||||
|
||||
If a VM's copy of an agent's settings file had `devvm-redacted` under a name you chose, such as a plugin's marketplace, the VM's next launch writes the whole copy over the VM's own. Until then, `devvm agent save` leaves that file out and warns, so make any change to it in devvm's agent store, or launch the VM again and make the change there.
|
||||
|
||||
Thanks to @jspiro for the report and @dhruv1220 for the tests' idea in [#58](https://github.com/devvmhq/devvm/pull/58).
|
||||
|
||||
### Folder names with separators in a row
|
||||
|
||||
devvm used to turn each character other than letters and digits in a folder's name into its own dash, and Lima refuses a name with dashes in a row, so a folder named `x--y`, `foo (copy)` or `C++ stuff` got no VM, as [#52](https://github.com/devvmhq/devvm/issues/52) reported. devvm now turns each run of such characters into one dash, so those folders get a VM, and `foo (copy)` gets `devvm-foo-copy-<hash>`. The state that such a folder's failed VM left is replaced when you run devvm there again ([VM names](../internals/backends.md#vm-names)). Thanks to @se6a for the report.
|
||||
|
||||
### Host keys whatever a VM's ports
|
||||
|
||||
When other programs on this machine, such as your own dev servers, held every port a VM lists, or the VM forwarded none with `devvm ports none`, a start that went no further than starting the VM, such as `devvm clone fetch` on a stopped `--clone` VM, used to leave the VM's ssh host keys unpinned. devvm's own ssh to the VM then failed until something else pinned them, so `devvm clone fetch` and `devvm rm`'s fetch failed with `clone_fetch_failed`.
|
||||
|
||||
devvm now pins a VM's ssh host keys each time it starts the VM, whatever the VM forwards, and a command that finds the VM running without them pins them first ([ssh into VMs](../internals/security.md#ssh-into-vms)).
|
||||
|
||||
### A removed link's connections
|
||||
|
||||
Removing a link with `devvm link rm` used to stop only the link's new connections, so a target that never closed its end kept each open connection's ssh process on this machine, and one of the 256 connections a client's links carry at once, until the client or the target stopped. Removing a link now ends its open connections within a few seconds, and when a target starts again, the connections still open through its earlier start end as well ([removing a link](../using/links.md#removing-a-link)).
|
||||
|
||||
### A settings file that's one string
|
||||
|
||||
When an agent's settings file in the VM was a single JSON string holding a placeholder, `devvm agent save` used to crash, and it now puts the saved value back in it. A login file on this machine that holds only `null` is now refused as not a JSON object, where saving a Codex or opencode login made in a VM failed on it ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### Forwarded ports over IPv6
|
||||
|
||||
When this machine briefly couldn't listen on a port's IPv6 address, such as when it ran out of open files, the forwarder used to forward the port on `127.0.0.1` alone until the server in the VM restarted. So a client that connects only over IPv6, such as `http://[::1]:PORT` or a tool that doesn't fall back to `127.0.0.1`, didn't reach the VM, and another program on this machine could take `::1` on that port and get those connections instead. The forwarder now tries the port again at the VM's next report and forwards it on both addresses ([when it can't forward](../internals/ports.md#when-it-cant-forward)).
|
||||
|
||||
### A forwarder after a burst
|
||||
|
||||
When the port forwarder ran out of open files while accepting a connection, it used to stop accepting connections on that port while it still listened there, so the port took connections that nothing answered until the server in the VM restarted. It now tries again shortly after, and so do a link's socket and a browser login's forward, which also carries at most 16 connections at once ([how it reaches the VM](../internals/ports.md#how-it-reaches-the-vm)).
|
||||
|
||||
### Plain WebSockets
|
||||
|
||||
A plain `ws://` WebSocket now connects through the proxy, where it used to get `502` ([the proxy](../internals/network.md#the-proxy)).
|
||||
|
||||
### A pin that meets git's rename on Linux
|
||||
|
||||
On Linux hosts, `.git/config` could seem to lose its pin. When git on this machine replaced `.git/config` just as devvm pinned it again, the pin used to fail, and devvm warned that the file lost its pin and couldn't be pinned again, then that it was pinned again, at the VM's next check, and a VM's start could fail the same way. devvm now pins the file that the rename left, and warns only that it was pinned again ([how a Linux host locks .git](../internals/git-protection.md#on-linux-hosts)).
|
||||
|
||||
### Stopped forwarders and link sessions
|
||||
|
||||
devvm stopping a VM's port forwarder or link session, or a `kill` of either, used to leave its ssh connection to the VM running on this machine, with its control socket in devvm's run folder. Each signal that devvm sends either one now also reaches what the process started, and either one stops its ssh before it exits. `devvm gc --orphans` also deletes a forwarder's socket that nothing listens on ([how devvm starts them](../internals/processes.md#how-devvm-starts-them)).
|
||||
|
||||
### Lookups with transparent mode off
|
||||
|
||||
In a VM confined to its proxy, with transparent mode off or stopped, a lookup through the system's resolver on a Linux host used to wait out its timeout, because systemd-resolved's stub kept retrying a name server where nothing listened, and workerd under `wrangler dev` waited about 40 seconds for each lookup.
|
||||
|
||||
The VM's programs now ask the VM's own name server, at `127.0.0.1`, directly, from each VM's next launch, so a lookup through the system's resolver, such as `getent`'s or curl's, fails at once, and so does workerd's. A VM on the open tier keeps systemd-resolved's stub ([the VM's resolver](../internals/network.md#the-vms-resolver)).
|
||||
|
||||
### A Nix package downloaded twice
|
||||
|
||||
When two requests for a package that wasn't in the shared Nix cache yet came close together, the second could download it again after the first had kept it, and the cache counted it twice against its cap. devvm now looks in the cache again before it downloads a package, so each package is downloaded once ([the shared Nix cache](../internals/network.md#the-shared-nix-cache)).
|
||||
|
||||
### A refused launch
|
||||
|
||||
When `config.toml`'s proxy named a user and no `proxy` secret was saved, `devvm` in the folder of a running VM used to refuse, as it should, but also stop the VM, and `devvm restart` stopped it before it refused. The same happened when your CAs folder couldn't be used, or the VM's CA or secret files couldn't be readied.
|
||||
|
||||
On a launch or a `devvm network` change, devvm now checks the company proxy, your CAs, the VM's CA and its secret files before it stops the VM's proxy, and when it refuses, it says it left the VM and its proxy running as they were. `devvm restart` checks the company proxy and your CAs before it stops the VM ([the proxy](../internals/network.md#the-proxy)).
|
||||
|
||||
### devvm desktop after a burst
|
||||
|
||||
When `devvm desktop`'s relay ran out of open files while accepting a viewer, `devvm desktop` used to end with an error, and the desktop's port with it. The relay now tries again shortly, as the port forwarder does ([the desktop relay](../internals/processes.md#the-desktop-relay)).
|
||||
|
||||
### A size that isn't a number
|
||||
|
||||
When a VM's state file held a size devvm couldn't read as a number, such as `"cpus": "four"` after an edit by hand, the VM used to start with the image's size without a word. devvm now refuses to start the VM or show its size, names the value, and says to set it again with `devvm size`. `--cpus`, `--memory`, `--disk`, `config.toml` and `devvm size -g` also refuse a number too big for devvm to read, which for a disk reached Lima as infinity ([size](../using/ports-size.md#size)).
|
||||
|
||||
### opencode's machine key in history exports
|
||||
|
||||
opencode 2.4 keeps a private key in `~/.local/state/opencode/machine/home-key`, which it makes when it first needs one, such as when you pair a machine with `opencode machine add`. Every machine it pairs trusts that key, and opencode never replaces it. It sits in opencode's state folder beside its prompt history, so `devvm history export`, and the export that `devvm rm` and a VM made again write, used to copy it into the export, and `devvm history import` put it into the VM it imported into. The export also held the password of opencode's background service, which its state folder keeps in `service.json`, or in `service-<channel>.json` for another channel's opencode, with the handoff tickets and temporary files beside it. It held the access tokens of opencode's terminals' daemons too, which opencode keeps in the state folder's `pty`, as releases before 2.4 do as well. The copy of opencode's database also kept its `machine` table, which holds the public keys that the paired machines log in with.
|
||||
|
||||
An export now leaves them out and empties that table, and an import never writes them, even from an older export, so the new VM's opencode makes its own. A VM made again keeps its own, because it's the same machine ([what an export holds](../internals/agents.md#history-exports)).
|
||||
|
||||
If an export of a VM with opencode 2.4 or later holds `.local/state/opencode/machine/home-key`, which `tar -tzf FILE` lists, that VM's key is in it, and it may be in each VM you imported it into, unless that VM's opencode had made a key of its own first. In each such VM that's still there:
|
||||
|
||||
1. Quit opencode, its TUI and any `opencode serve` included, and stop its service with `opencode service stop`, because a running opencode keeps the key in memory.
|
||||
2. Delete `~/.local/state/opencode/machine/home-key`, so opencode makes a new key when it next needs one.
|
||||
3. Pair each machine you paired there again with `opencode machine add NAME --replace`, which prints a new join string for that machine to join with. In a VM you imported the export into, remove the machines it brought with `opencode machine remove NAME`.
|
||||
|
||||
For a VM that you've deleted, unpair each machine it had paired, on that machine. Once the key is replaced, the old exports in `~/.local/share/devvm/exports` hold a key that nothing trusts.
|
||||
|
||||
### opencode's service settings in VMs
|
||||
|
||||
opencode 2 keeps its background service's settings in `~/.config/opencode/service.json`, or in `service-<channel>.json` on another channel. They hold the service's password, which the service makes when the file has none, and with remote access on, the secret route that the service's address is served on and your consent to remote access, beside its port, host name, CORS origins and environment. `devvm agent import` copied every file in `~/.config/opencode` into devvm's agent store, these included, and every VM with opencode got a copy at each launch, with `devvm-redacted` in place of the password and of each value of the environment, and with the route as it was. So each such VM's opencode service took `devvm-redacted` as its password, which anyone who knows devvm knows. `devvm agent save` copied a VM's own file into the store in the same way, and from there into every VM.
|
||||
|
||||
`devvm agent import` and `devvm agent save` now leave these files out, and no VM gets them, even from a store that holds them. A VM's start takes them out of the store and warns once, and each VM's setup takes out the copy that an earlier devvm gave it, which it knows by the `devvm-redacted` in it, so each VM's opencode makes a password of its own the next time its service starts. `opencode service get password` shows it in the VM ([opencode's service](../using/coding-agents.md#opencodes-service)).
|
||||
|
||||
If you ran `devvm agent import` or `devvm agent save` for opencode, your VMs got such a copy. A service that's running keeps its password until it stops, so restart each running VM that has opencode, with `devvm restart` in its folder. If this machine's opencode has remote access on, its route reached the store and your VMs, so turn remote access off and on again on this machine, which gives its service a new route:
|
||||
|
||||
```sh
|
||||
opencode service set remote false # on this machine: drop the route that your VMs got
|
||||
opencode service set remote true # and get a new one
|
||||
```
|
||||
|
||||
When this machine's service had remote access on but hadn't started since, its file held a route and no password, so the copy held no `devvm-redacted` and stays in the VM. Once this machine's route is new, that copy's route leads nowhere. A password you set yourself with `opencode service set password` reached your VMs as it was, with no `devvm-redacted` to mark the copies, when it looked to devvm like a variable's name or a number, which is any of these:
|
||||
|
||||
- capital letters, digits and `_`, starting with a letter
|
||||
- at most five digits
|
||||
- `true` or `false`
|
||||
|
||||
If yours is one, set a new password on this machine first, because that's the one your VMs got, then delete `~/.config/opencode/service.json` in each VM with opencode and restart the VM.
|
||||
|
||||
### Base's packages that don't come out
|
||||
|
||||
When the packages base downloaded couldn't be taken out of its build VM, devvm said so, but the run log didn't say why, because the VM's tar's error output went nowhere. That output now goes to the run log, with a line that names the tar's failure and the failure to read what it sent ([a build fails](../using/troubleshooting.md#a-build-fails)).
|
||||
|
||||
### A clone check that never ends
|
||||
|
||||
Before `devvm rm` or `devvm clone off` lets a `--clone` VM's clone go, devvm reads what the VM has of it. devvm kept at most 8 MiB of the answer, but it went on reading the rest and waited for the VM's command to end, so a VM that wrote without end, or never answered, kept the command waiting until you pressed Ctrl+C. devvm now stops the VM's command once it sends more than 8 MiB, and it waits at most 2 minutes for the answer, the same bounds as its read of opencode's worktrees. Either way the check fails, and devvm keeps the VM and names `--no-clone-check` ([deleting the VM](../using/clone.md#deleting-the-vm)).
|
||||
|
||||
On Lima, the ssh that `limactl shell` runs can leave a process behind that holds a command's output open, and such a process could keep devvm waiting past `devvm paste`'s time limit. devvm now closes a command's output a second after the command ends or its time limit runs out, so such a process can't outlast that limit or the clone check's 2 minutes, and a command whose output was cut short that way fails ([a command's output](../internals/lima.md#a-commands-output)).
|
||||
|
||||
### A tool release without every download
|
||||
|
||||
Since 0.2.0-rc.1, the mise that devvm resolves the shared tools with downloads some files as it locks them, and it fails the whole lock when one of them isn't there. So when a shared tool's newest release wasn't published for every platform yet, as Node 24.23.0's musl builds weren't for days after its release, resolving the shared tools failed. A first run then stopped and said to get online, while the daily check and `devvm tools update` kept the versions they had. devvm now locks each tool on its own after such a failure, and it locks a tool that still fails one platform at a time, so it uses that tool's newest older version that's published everywhere and says so, as it did before. A tool whose newest version has no download on any platform fails the resolve ([a new tool release isn't there yet](../using/troubleshooting.md#a-new-tool-release-isnt-there-yet)).
|
||||
|
||||
## Hardening
|
||||
|
||||
These fixes close ways that code in a VM, or a file it wrote, could reach past what devvm lets a VM do. Most of them change nothing you see.
|
||||
|
||||
### devvm's own folders in another case
|
||||
|
||||
On a Mac, where a name's case doesn't count, a project at `~/.Config/devvm/layers` used to get a VM with read-write access to devvm's settings and layer scripts, because devvm compared a project folder with your home folder and its own folders by name alone. It now compares them by the folders themselves as well, so it refuses that project as it refuses `~/.config/devvm/layers`. A VM already made in such a folder still mounts it, so delete it with `devvm rm` there. devvm also refuses an SSH key in a folder that a VM mounts by a name in another case ([project folders devvm refuses](../using/settings.md#project-folders-devvm-refuses)).
|
||||
|
||||
### Passwords in Lima's console logs
|
||||
|
||||
Lima's boot scripts write the VM's proxy settings, with the VM's own proxy password, to the VM's serial console, which Lima keeps in its console logs for the VM, `serial.log`, `serialp.log` or `serialv.log` in the VM's folder in devvm's Lima home. devvm used to take the passwords out of Lima's `ha.stderr.log` only. Once the VM has started, devvm now replaces each password with as many `*` in Lima's console log for the VM as well, as it does in `ha.stderr.log` ([the run log](../internals/overview.md#the-run-log)).
|
||||
|
||||
### A VM and its SSH agent
|
||||
|
||||
A VM that forwarded your agent or devvm's own used to be able to remove every key from it with `ssh-add -D`, lock it with a password of its own with `ssh-add -x`, or add keys to it, and every VM that shares devvm's agent lost it then, and with your own agent, so did you.
|
||||
|
||||
A VM now reaches its agent only through its proxy, which passes on listing keys, signing and binding a session to a host, and refuses everything else, so `ssh-add` in a VM can still list and use the keys, but not remove, lock or add them. An editor's connection gets the same agent as devvm's shell, the one the VM started with ([the SSH agents](../internals/processes.md#the-ssh-agents)).
|
||||
|
||||
A VM that forwards an SSH agent and runs as you upgrade keeps the agent as it was until its next start, so it can still remove, lock or add keys, and devvm warns of it each time it opens the VM or changes its links. Run `devvm restart` in its folder to give it the relay at once ([agent forwarding](../using/ssh.md#agent-forwarding)).
|
||||
|
||||
### Links inside an agent's folder
|
||||
|
||||
`devvm agent import` used to copy a link inside an agent's folder as the file it led to, wherever that file was in the folder, so a link in `~/.claude/skills` or `~/.claude/plugins/cache` could put your history, `~/.claude/.credentials.json` or a plugin's data into the store, where every VM with the agent reads it. It now copies such a link only when it leads to one of the settings the import copies, and leaves any other out with a warning that names where it leads ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### Your plugins' data stays on this machine
|
||||
|
||||
`devvm agent import` used to copy all of `~/.claude/plugins` into the store, so every VM with Claude Code got the data that your plugins keep on this machine, which can hold their own logins. From that folder, it now copies only the marketplaces, their records and the plugins' cache, and `devvm agent save` copies only those from a VM ([importing from this machine](../using/coding-agents.md#importing-from-this-machine)).
|
||||
|
||||
### A history export's names
|
||||
|
||||
`devvm history import` used to leave out the agents' logins and the files that devvm's setup writes by their names as the export wrote them, so an export that spelled one another way, such as `.claude/./settings.json` or `.claude//plugins`, got it into the VM's home. It now refuses a name with a `.` or empty part, and once the export is unpacked, it deletes what it leaves out by its path ([importing history](../internals/agents.md#importing-history)).
|
||||
|
||||
### Every host in one form
|
||||
|
||||
A few of devvm's checks used to read a host in a way of their own. `devvm secret set --host`, an MCP server's URL and a `NO_PROXY` entry took a name with a letter that isn't plain ASCII, such as the Kelvin sign, which Unicode's case folding turns into `k`, as the ASCII name it folds into. `--from` took a registry's host with such a letter, or an address in brackets before a trailing dot such as `[::1].`, as one on the internet.
|
||||
|
||||
Every host is now read as the proxy reads it. The proxy refuses a host with such a letter, so now:
|
||||
|
||||
- `devvm secret set` refuses it
|
||||
- an MCP server with one gets no secret
|
||||
- a `NO_PROXY` entry with one matches no host
|
||||
- `--from` doesn't take such a registry as public
|
||||
- `devvm network rm` with it never removes the rule with the plain letter
|
||||
|
||||
The proxy also answers `400` to a host with brackets around anything but an IPv6 address, such as `[evil.com]:443`, and a partial clone's warnings now read a remote's host without its trailing dot, so they name `example.com`, not `example.com.`, and a remote at `localhost.` gets the same warning as one at `localhost` ([how the proxy reads a host](../internals/network.md#the-proxy)).
|
||||
|
||||
### Connections to the proxy on Linux hosts
|
||||
|
||||
Each connection that a VM confined to its proxy makes to the proxy starts a devvm process on a Linux host, and with no limit, a VM that opened connections without end could start thousands of them and fill the host with processes. devvm now carries at most 256 of a VM's connections to its proxy at once, and answers any past that with `503` before it reaches the proxy. A VM that's running when you upgrade has no limit until its next start ([the QEMU wrapper](../internals/processes.md#the-qemu-wrapper-and-its-keeper)).
|
||||
|
||||
### A closed connection's ssh process
|
||||
|
||||
When a VM never closed its end of a forwarded port's or a link's connection, that connection's ssh process used to stay on this machine after the program here, or in the client, had closed its side, so a hostile VM could take all 256 connections that a forwarder or a client's links carry at once. The ssh process now ends once its client has closed and the VM has sent nothing for 30 seconds. So a program that stops sending and waits more than 30 seconds for an answer to begin, such as `nc -N` in front of a slow query, has its connection cut ([how it reaches the VM](../internals/ports.md#how-it-reaches-the-vm)).
|
||||
|
||||
### What a VM's proxy holds
|
||||
|
||||
A VM's proxy used to count only its tunnels toward its limit, keep idle connections open without end, keep a plain HTTP request running after its client had gone, and take 1 MiB of a request's headers inside an intercepted tunnel, so a VM could make it hold more and more. It now:
|
||||
|
||||
- holds at most 2048 of the VM's connections of every kind at once, where one without the VM's password doesn't count, and has at most 2048 requests to hosts under way at once
|
||||
- closes a connection that waits 10 minutes for its next request, or that lacked the VM's password
|
||||
- ends a plain HTTP request a minute after its client has stopped sending and nothing has come back
|
||||
- takes at most 64 KiB of headers everywhere, and carries at most 100 HTTP/2 requests at once in a tunnel
|
||||
- lets long downloads, WebSockets and slow streams go on as long as they last ([the proxy](../internals/network.md#the-proxy))
|
||||
|
||||
### A `NO_PROXY` address with a zone
|
||||
|
||||
An IPv6 address with a zone in your company proxy's `NO_PROXY`, such as `fe80::1%eth0`, used to send that address past the company proxy without its zone, as [#59](https://github.com/devvmhq/devvm/issues/59) reported. Such an entry now matches nothing, as it does in Go's HTTP clients ([behind a company proxy](../safety/network.md#behind-a-company-proxy)).
|
||||
|
||||
### A `NO_PROXY` entry's port
|
||||
|
||||
The proxy used to read `git.test:0` as `git.test` on every port, so it sent those hosts directly instead of through your company proxy, and it read `git.test:080` or `git.test:+80` as port 80, which Go's clients don't. An entry whose port no request has, such as `git.test:0`, or whose port isn't in plain decimal, now matches no host, as one past 65535 already didn't ([through a company proxy](../internals/network.md#through-a-company-proxy)).
|
||||
|
||||
### A VM never runs without its proxy
|
||||
|
||||
A `devvm network` change could leave a VM running without its proxy. A change between `internet`, `allowlist` and `none` on a running VM is now refused before the VM's tier changes, so its tier never says one thing while its proxy enforces another. A VM whose proxy doesn't enforce the tier the VM has now, or whose proxy is stopped for new settings and then can't start again, is still stopped, and a `devvm network` change now stops it in that case as well ([the proxy](../internals/network.md#the-proxy)).
|
||||
|
||||
### A VM's logs and their caps
|
||||
|
||||
Root in a VM could write to its serial console, `/dev/hvc0`, without end, and the console log grew until this machine's disk was full, and so could Lima's own logs for the VM until its next start. While a VM runs, its proxy now keeps the disk space that Lima's console log for the VM and Lima's own logs for the VM each take under 10 MiB, with a `.1` file of up to 10 MiB more, and replaces the VM's proxy password in them as they grow. A VM that's running when you upgrade gets this once a devvm command starts its proxy again ([Lima's hostagent](../internals/processes.md#limas-hostagent)).
|
||||
|
||||
### devvm's other logs
|
||||
|
||||
devvm's other logs are held to their caps as well:
|
||||
|
||||
- The port forwarder's and the link session's logs now stay under 1 MiB while they run, not only from their next start, and a link's warnings take turns with the session's other lines.
|
||||
- The build proxy's log stays under 10 MiB, as a VM's proxy's does.
|
||||
- A run writes at most 128 MiB to its run log, and the run logs take at most 256 MiB together, though devvm never deletes the newest or one that a running devvm still writes ([the run log](../internals/overview.md#the-run-log)).
|
||||
|
||||
### How deep a save goes
|
||||
|
||||
A chain of thousands of folders used to keep `devvm agent save` busy for a long time while it held the agent store's lock. The save now has an import's bounds on depth, so a VM that sends folders nested more than 128 deep, or a path of more than 4,096 bytes, gets nothing saved, as an import of such folders does ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
|
||||
|
||||
### opencode's automations and permissions in history
|
||||
|
||||
opencode 2.4 keeps its automations in its database, each with a schedule or an event that triggers it and a shell command that it runs, which opencode asks you to approve once, as the automation is made, and then runs without asking again. The database also keeps the requests you said always to allow in a project, and each session's own permission rules. A copy of the database in a history export kept all of them, so a hostile VM could write an automation, an allow rule or a session that allows every command into its database, and `devvm history import` would put it into the VM you imported the export into, where opencode would run its command without asking. The same went for what opencode's service starts by itself when it starts: a suspended session's turn, a subagent's job and a message queued for a session's next turn. A project's start command, which opencode runs for each worktree it makes, was in the copy too. opencode's git repositories in `~/.local/share/opencode`, its snapshots, its cache of repositories and its worktrees, were in the export too, and a repository's config can name a command that opencode's own git commands then run.
|
||||
|
||||
The copy in an export, and the copy that an import makes of a database in any export, now has:
|
||||
|
||||
- no automations, subagents' jobs or queued messages
|
||||
- no requests you said always to allow, and each session keeps only its deny and ask rules, each written again as sqlite3 reads it
|
||||
- no suspended sessions, so no turn resumes on its own
|
||||
- no project commands
|
||||
|
||||
The copy drops every view and refuses a table with a generated column, which could hide rows from these steps, and its own check counts what's left and leaves the database out unless nothing is. An export also leaves out opencode's `snapshot`, `repos` and `worktree` folders, and an import never writes them, so an export doesn't hold opencode's worktrees. The worktrees' commits are in your project's own repository, and `devvm rm`, which deletes their folders with the VM, now checks them for uncommitted changes first ([opencode's worktrees before a VM goes](#opencodes-worktrees-before-a-vm-goes)). An export also leaves out the project plugins you approved in opencode's native client, which doesn't ship yet: `plugin-approvals.json` and the `plugin-staged` folder in `~/.local/state/opencode`. That client runs the staged copies without checking their hash again, so without this a hostile VM's export could approve a plugin for the VM you import it into. In the new VM, make again any automation you want, and opencode asks again before the requests you had always allowed. A VM made again keeps its own, because its home folder's copy isn't an export ([what an export holds](../internals/agents.md#history-exports)).
|
||||
|
||||
### A stopped VM's shell
|
||||
|
||||
In a terminal, `limactl shell` of a stopped VM asks whether to start it, yes by default. When a VM shut itself down as devvm opened its shell or ran a command in it, you could get that question, and a yes, or just Enter, started the VM as Lima does: unconfined and without its proxy, mounting a folder that replaced the project folder, or making the project folder again if it was gone. devvm's own start refuses each of these. Every `limactl shell` that devvm runs now says not to start the VM, so the shell or command fails, and devvm's next launch starts the VM with every check ([a stopped VM's shell](../internals/lima.md#a-stopped-vms-shell)).
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
title: Releases
|
||||
explainer: What changed in each release, and what to do about it
|
||||
weight: 25
|
||||
---
|
||||
|
||||
Each release has a page here with the full story of every change it makes: what was wrong or missing, how it showed, how devvm now works, and what you do about it. The changelog on GitHub, which is each release's notes, keeps one or two sentences for each change, with a link to its section here, its issue and the commit that made it.
|
||||
|
||||
- [0.2.0](0.2.0.md): VMs' ssh on ports that browsers refuse, the proxy split into two processes with a sandbox around the one that reads the VM's network, Claude Code's plugins and MCP servers' logins in a VM, project folders after your Mac restarts, status lines for slow steps, and many hardening fixes.
|
||||
|
||||
These are the one part of the docs that describes what changed. Every other page describes how devvm works now.
|
||||
@@ -30,7 +30,7 @@ Some protections hold only on some [network tiers](network.md#network-tiers) or
|
||||
- **Secrets, on every tier.** Every VM, an open one included, gets a placeholder instead of each secret, such as your GitHub token or Claude Code's token, and the proxy on this machine puts the real value only into requests for that secret's own hosts ([secrets](network.md#secrets)). A placeholder copied out of the VM is worthless elsewhere, because it ends in a random value of that VM's own, and an open VM that sends a request around its proxy sends only the placeholder.
|
||||
- Another VM, or another user's program on this machine, can't spend the secret through the proxy either, because the proxy needs the VM's own password, which only you can read. A program that runs as you can read it, though, as it can read the rest of your files.
|
||||
- Codex and opencode logins and the MCP secrets that Claude Code gets from this machine work the same way, and devvm refreshes those OAuth logins on this machine, so a VM never holds their refresh tokens.
|
||||
- A login to an MCP server that you make with `/mcp` in a VM is that VM's own: Claude Code keeps its real tokens in the VM, where code in the VM can read them, and they never leave it ([MCP servers' logins](../using/coding-agents.md#mcp-servers-logins)).
|
||||
- A login to an MCP server that you make with `/mcp` in a VM is that VM's own. Claude Code keeps its real tokens in the VM, where code in the VM can read them, and they never leave it ([MCP servers' logins](../using/coding-agents.md#mcp-servers-logins)).
|
||||
|
||||
### Git running code on this machine
|
||||
|
||||
@@ -55,7 +55,7 @@ Some protections hold only on some [network tiers](network.md#network-tiers) or
|
||||
- **Other projects and other VMs.** Each project folder gets its own VM with its own disk, and a VM mounts only its own project folder. Each VM's proxy has its own password, so one VM can't use another's secrets. A VM reaches a service in another VM only through a [link between VMs](../using/links.md) that you add in its folder, to a port that the other VM's folder publishes. A link joins the two VMs' trust, because code in one can often run code in the other through its service, so a VM links only to a VM on its own tier or a stricter one, and nothing in a VM can add a link ([links between VMs](network.md#links-between-vms)).
|
||||
- **Images, layers and devvm itself.** Malware could try to make itself permanent by editing an image, a layer script or devvm's own files. devvm builds images with nothing from this machine mounted, and the shared tools are read-only in every VM. devvm also refuses a project folder that holds its own folders or sits inside them, so a VM can't reach the layer scripts that every build runs or the files devvm runs on this machine ([only the project folder](../internals/security.md#only-the-project-folder)).
|
||||
- **A folder made again.** If you delete a repo and clone another at the same path, the new folder never gets the old VM's disk or anything left in it. devvm knows a folder by its inode and birth time as well as its path, which nothing in a VM can give a new folder, so it refuses and offers `devvm rm` or `devvm adopt` ([a folder made again](../using/vms.md#a-folder-made-again)).
|
||||
- **A devcontainer.json that reaches this machine.** Other tools run a devcontainer's `initializeCommand` on the host. devvm never runs it, refuses `${localEnv:…}`, adds no mounts from the file and doesn't follow a link out of the folder ([devcontainer.json](../using/devcontainer.md#security)). devvm uses the file's `image` only when the image's registry gives it to anyone who asks, and it refuses a registry on this machine or its network. Behind a company proxy, devvm looks the image up through the company proxy and checks only the registry's name, so a company proxy that reaches this machine or its network for a name that looks public takes the lookup there ([the design note](../internals/design.md#devcontainerjson)).
|
||||
- **A devcontainer.json that reaches this machine.** Other tools run a devcontainer's `initializeCommand` on the host. devvm never runs it, refuses `${localEnv:…}`, adds no mounts from the file and doesn't follow a link out of the folder ([devcontainer.json](../using/devcontainer.md#security)). devvm uses the file's `image` only when the image's registry gives it to anyone who asks, and it refuses a registry on this machine or its network. Behind a company proxy, devvm looks the image up through the company proxy and checks only the registry's name, so a company proxy that reaches this machine or its network for a name that looks public takes the lookup there ([the design note](../contributing/design.md#devcontainerjson)).
|
||||
- **Impersonating a VM.** ssh checks a VM against host keys that devvm reads through the VM's backend instead of over the network, so a program that answers on the VM's port in its place is refused ([ssh access by name](../using/ssh.md#ssh-access-by-name)).
|
||||
|
||||
## Kept inside the VM
|
||||
@@ -95,7 +95,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
|
||||
- A bound API key can make credentials too. With Google Gemini's key, code in the VM can ask `generativelanguage.googleapis.com` for an ephemeral token for Gemini's Live API, which lasts up to about 20 hours and allows as many uses as the VM asks for. With xAI's key it can ask `api.x.ai` for a realtime client secret that lasts as long as the VM chooses, and with OpenAI's key it can ask `api.openai.com` for one that lasts up to 2 hours.
|
||||
- These credentials work without the proxy, and the proxy allows the requests that make them, because opencode's experimental voice mode makes them itself ([API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in)). If a VM may have done this, rotate the secret and check the service's keys, access tokens and runners.
|
||||
- **Keys devvm can't tell apart.** devvm takes the keys out of the VM's copies of your agents' settings and logins only where it can tell a key from the rest. A key in other text, such as a hook's command, stays when it neither starts like a known key nor follows `Bearer` or `Basic`. opencode's and pi's keys that devvm can't bind, such as a local model server's, stay on this machine unless you list their provider in `config.toml`'s `[pass-keys]`, and then they go in as they are. The agents' folders that the VM mounts whole, such as `~/.claude/skills` or `~/.config/opencode/plugin`, reach the VM with every file in them, so a `.env` in one is in the VM, and so is a private plugin marketplace's git config with a password or an access token in its URL. Keep secrets out of those folders ([what stays in the VM's copies](../internals/network.md#what-stays-in-the-vms-copies)).
|
||||
- **Your SSH agent.** While [agent forwarding](../using/ssh.md#agent-forwarding) is on, anything in the VM can use the agent's keys to push, log in to servers or sign any data, though it can't copy them. It can't remove the agent's keys, lock the agent or add keys to it either, so it can't take the agent away from you or from other VMs ([the SSH agents](../internals/processes.md#the-ssh-agents)). A VM that has run since before you upgraded devvm to this release still can, until its next start, so restart such VMs with `devvm restart`. The VM has the agent while you're connected. `devvm ssh-agent devvm` limits it to the keys you add to [devvm's own agent](../using/ssh.md#devvms-own-agent), and an agent that asks you to approve each use, such as 1Password's or Secretive, narrows it further.
|
||||
- **Your SSH agent.** While [agent forwarding](../using/ssh.md#agent-forwarding) is on, anything in the VM can use the agent's keys to push, log in to servers or sign any data, though it can't copy them. It also can't remove the agent's keys, lock the agent or add keys to it, so it can't take the agent away from you or from other VMs ([the SSH agents](../internals/processes.md#the-ssh-agents)). A VM that has run since before you upgraded devvm to this release can still do those until its next start, so restart such VMs with `devvm restart`. The VM has the agent while you're connected. `devvm ssh-agent devvm` limits it to the keys you add to [devvm's own agent](../using/ssh.md#devvms-own-agent), and an agent that asks you to approve each use, such as 1Password's or Secretive, narrows it further.
|
||||
|
||||
### Git
|
||||
|
||||
@@ -115,7 +115,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
|
||||
- **What a VM does through a link.** A [link between VMs](../using/links.md) joins the two VMs' trust. Code in the client can often run code in the target through the service it reaches, such as Postgres's `COPY … TO PROGRAM`, and it then has the target's network, the secrets it may use and its project folder. devvm limits a link to the ports the target publishes, on the target's loopback, and a client to targets on its own tier or a stricter one, but it doesn't limit what the service does. In a [group](../using/links.md#groups), every VM trusts every other in the same way, and a VM that joins later gets the same reach ([links between VMs](network.md#links-between-vms)).
|
||||
- **History imported from a less strict tier.** An export of agents' history carries what the old VM's agents read, so importing one from an open VM into a VM on the allowlist tier can bring in credentials and data that the new VM couldn't reach itself, along with any instructions planted in them. devvm warns before such an import, and before importing an export whose tier it has no record of, but it imports all the same. Import history only from a VM you trusted as much as the new one ([importing history](../using/coding-agents.md#importing-history)).
|
||||
- **What one VM learns of another through the shared Nix cache.** VMs with the nix layer share one cache of Nix's packages on this machine. A VM can tell by how fast the cache answers whether some VM fetched a public package. The packages are public, and a project's `flake.lock` names the ones it needs, so this tells a VM only that another project on this machine uses a package. A VM that fetches many packages can also fill the cache up to its cap and push other VMs' packages out, so they download them again, but it can't fill the disk past the cap or keep anything that cache.nixos.org didn't sign ([the shared Nix cache](../internals/network.md#the-shared-nix-cache)).
|
||||
- **Through a company proxy.** The company proxy looks up the names it's sent itself, and it may get another answer than this machine did, or a later one, so the VM's proxy can't check every address a name leads to there. Under a name that an allowlist names, a VM reaches whatever the company proxy reaches, such as your company's internal hosts and the company proxy's own host, which is this machine's loopback when the company proxy runs on this machine, as a VPN client's does. A name that the VM's allowlist doesn't allow never reaches the company proxy ([the design note](../internals/design.md#a-company-proxy)).
|
||||
- **Through a company proxy.** The company proxy looks up the names it's sent itself, and it may get another answer than this machine did, or a later one, so the VM's proxy can't check every address a name leads to there. Under a name that an allowlist names, a VM reaches whatever the company proxy reaches, such as your company's internal hosts and the company proxy's own host, which is this machine's loopback when the company proxy runs on this machine, as a VPN client's does. A name that the VM's allowlist doesn't allow never reaches the company proxy ([the design note](../contributing/design.md#a-company-proxy)).
|
||||
- **Which names resolve to internal addresses.** When the proxy refuses a name because this machine's lookup gives it an internal address, its refusal says so, so a VM can learn which names this machine's DNS resolves to internal addresses. The refusal never names the address, this machine's DNS server or the company proxy, which stay in the proxy's own log ([log files](../internals/network.md#log-files)).
|
||||
|
||||
### This machine
|
||||
@@ -128,7 +128,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
|
||||
- **The proxy's CA keys.** Inside a VM, its CA vouches for any site, so someone with a copy of its key and a place on your network could impersonate sites to that VM. Each VM has CAs of its own, so a copy reaches one VM and no other. Only you can read the keys, they never leave this machine, and devvm keeps them out of Time Machine. Each CA lasts 30 days, so a copy goes stale, but the next CA's key is on disk for up to 23 days before that CA starts, so a copy of it taken then works until that CA ends, up to 53 days later. Keep `~/.local/share/devvm/vms` out of other backup and sync tools as well, and on Linux, which has no Time Machine, out of your backups ([the VM's CA](../internals/network.md#the-vms-ca)).
|
||||
- **Your company proxy's password.** No VM gets the company proxy's settings: an open VM goes through its own proxy, which goes through the company proxy for it.
|
||||
- devvm keeps the password out of its run logs only where it can tell it's a password, so one in an address with neither a scheme nor a port, one with a raw `/`, `?`, `#` or `@` in it, or one in a run of more than 4 KiB without a space that a command writes in pieces can stay.
|
||||
- Lima's own log for the VM holds the password until the VM has started, when devvm replaces it with as many `*`, so the log still shows its length. If devvm is killed before then, or you run `limactl start` outside devvm, the log keeps it. Lima's logs of the VM's serial consoles hold the VM's own proxy password in the same way, until the VM has started. A reboot inside the VM writes it to the console's log again, and while the VM runs, its proxy replaces it within about a second of its line ending, so for that second, or for as long as the proxy isn't running, the log holds it ([Lima's hostagent](../internals/processes.md#limas-hostagent)). With `config.toml`'s proxy, the mise that devvm runs on this machine gets the password in its environment, where programs that run as you can read it ([open VMs and builds](network.md#open-vms-and-builds), [the run log](../using/troubleshooting.md#a-command-fails)).
|
||||
- Lima's own log for the VM holds the password until the VM has started, when devvm replaces it with as many `*`, so the log still shows its length. If devvm is killed before then, or you run `limactl start` outside devvm, the log keeps it. Lima's logs of the VM's serial consoles hold the VM's own proxy password in the same way, until the VM has started. A reboot inside the VM writes it to the console's log again, and while the VM runs, its proxy replaces it within about a second of its line ending. So the log holds it for that second, or for as long as the proxy isn't running ([Lima's hostagent](../internals/processes.md#limas-hostagent)). With `config.toml`'s proxy, the mise that devvm runs on this machine gets the password in its environment, where programs that run as you can read it ([open VMs and builds](network.md#open-vms-and-builds), [the run log](../using/troubleshooting.md#a-command-fails)).
|
||||
|
||||
## Left to you
|
||||
|
||||
@@ -161,6 +161,6 @@ The VM can write anything in the project folder, and devvm locks only `.git`. An
|
||||
- **`.git` on Linux hosts.** devvm makes hooks and config read-only in the VM's view, but a git command on this machine that replaces `.git/config` while the VM runs leaves the new file the VM's to change, replace or open for writing until devvm locks it again, which devvm names only when the VM stops ([when git replaces a locked file](git-protection.md#when-git-on-this-machine-replaces-a-locked-file)). Where the kernel doesn't let devvm use a user namespace, such as on Ubuntu 23.10 and newer, VMs have no `.git` protection, and the VM can change hooks and config that run on the host, so use `--clone` there ([Linux hosts](git-protection.md#linux-hosts)).
|
||||
- **What a build reaches.** A build, such as a [`--from`](../using/from.md) image's or a layer's, reaches the internet and your local network as well, this machine's own address on it included, so a service of yours that listens on every address is in its reach. On macOS that's all it reaches of this machine, because its loopback is out of reach, but on Linux the build reaches the services on this machine's `localhost` too, such as other VMs' proxies and dev servers. Build images only from container images and layers you trust ([confinement](../internals/lima.md#confinement)).
|
||||
- **Escaping the VM.** A bug in Lima, Apple's Virtualization framework or QEMU could let code out of the VM. So could a bug in devvm's own programs on this machine that read what a VM sends, which are the VM's proxy, the port forwarder, the sessions of links between VMs, `devvm agent save` and the export of agents' history that `devvm history export` and `devvm rm` save.
|
||||
- The part of the VM's proxy that reads the VM's network runs in a sandbox, macOS's on macOS and Landlock with a seccomp filter on Linux, so a bug there reaches the secrets bound to that VM, the company proxy's password, the VM's logs, the shared Nix cache and the public internet, but not your files, the Keychain, other VMs' secrets, this machine's unix sockets, such as ssh's and Docker's, or its services on `localhost`, its own addresses and your LAN's private addresses, unless a rule names the address or a company proxy reaches them. On Linux it can also learn whether a file of yours exists, and an older kernel confines it less ([what it still reaches](../internals/network.md#the-childs-sandbox)). devvm doctor warns when a VM's proxy runs without its sandbox, or with only part of it ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
- The part of the VM's proxy that reads the VM's network runs in a sandbox, which is macOS's on macOS and Landlock with a seccomp filter on Linux. A bug there reaches the secrets bound to that VM, the company proxy's password, the VM's logs, the shared Nix cache and the public internet. It doesn't reach your files, the Keychain, other VMs' secrets, or this machine's unix sockets, such as ssh's and Docker's. Nor does it reach this machine's services on `localhost`, its own addresses or your LAN's private addresses, unless a rule names the address or a company proxy reaches them. On Linux it can also learn whether a file of yours exists, and an older kernel confines it less ([what it still reaches](../internals/network.md#the-childs-sandbox)). devvm doctor warns when a VM's proxy runs without its sandbox, or with only part of it ([the proxy runs without a sandbox](../using/troubleshooting.md#the-proxy-runs-without-a-sandbox)).
|
||||
|
||||
Found a way out of a VM? See [SECURITY.md](https://github.com/devvmhq/devvm/blob/main/SECURITY.md).
|
||||
@@ -485,7 +485,7 @@ On the none tier, a VM with Claude Code gets Claude Code's built-in policy whole
|
||||
|
||||
Every login in the VM has the proxy settings in its environment (`HTTP_PROXY`, `HTTPS_PROXY` and their lowercase forms, `NO_PROXY` for the VM itself, and `NODE_USE_ENV_PROXY`), and the [CA variables](../using/settings.md#a-companys-ca) that every VM has point the tools that don't read the system's store at the VM's own CAs. devvm also points apt, sudo, ssh and Docker at the proxy ([how](../internals/network.md#the-vms-setup)), on every tier.
|
||||
|
||||
On a confined tier, a direct connection to an address fails at once, even as root, and no DNS query leaves the VM. Names resolve in the proxy, as the tool wrote them, without this machine's DNS search domain added, so to reach a host on your network, use its full name, such as `jenkins.corp.example.com` rather than `jenkins`. Inside the VM, every name resolves to one stand-in address, which leads to the proxy too, so a tool that skips the proxy settings still reaches the hosts the rules allow over HTTPS and HTTP ([tools that ignore the proxy](#tools-that-ignore-the-proxy)). Such a tool's connection to another port of a name is refused at once, and nothing reaches the log for it ([what to do](../using/troubleshooting.md#a-tool-that-skips-the-proxy-fails)).
|
||||
On a confined tier, a direct connection to an address fails at once, even as root, and no DNS query leaves the VM. Names resolve in the proxy as the tool wrote them, without this machine's DNS search domain added, so to reach a host on your network, use its full name, such as `jenkins.corp.example.com` and not `jenkins`. Inside the VM, every name resolves to one stand-in address, which leads to the proxy too, so a tool that skips the proxy settings still reaches the hosts the rules allow over HTTPS and HTTP ([tools that ignore the proxy](#tools-that-ignore-the-proxy)). Such a tool's connection to another port of a name is refused at once, and nothing reaches the log for it ([what to do](../using/troubleshooting.md#a-tool-that-skips-the-proxy-fails)).
|
||||
|
||||
A blocked request gets `403`, and the response names the host, the reason and the rule that would allow it, but for a [quiet host](#quiet-hosts). The proxy also answers at `http://devvm.proxy/`:
|
||||
|
||||
@@ -544,7 +544,7 @@ The company proxy's address and password follow these rules:
|
||||
- The company proxy needs an `http://` address, such as `http://user:[email protected]:8080` in `HTTPS_PROXY`, and a proxy without a port is on port 80. devvm doesn't start a VM's proxy while `HTTPS_PROXY`, `HTTP_PROXY` or a `[proxy]` key names an `https://` or `socks5://` proxy, and it tells you which setting to change.
|
||||
- The company proxy's password stays on this machine. The VM never gets it, and devvm writes it into no log, no image and no process's arguments.
|
||||
- `config.toml` never holds the password, because it's a file you might copy to other machines or keep with your dotfiles, and devvm refuses a `[proxy]` URL that has one. Put only the user in the URL, as `http://[email protected]:8080`, and save the password with `devvm secret set proxy`, which keeps it as it keeps the other [secrets](#saving-and-binding-secrets). devvm's proxies look it up themselves when they start, so no file of devvm's holds it in the clear.
|
||||
- devvm doesn't make a new VM, start a VM's proxy, or build an image or the shared tools while `config.toml`'s proxy names a user and no password is saved, and it checks before anything starts or stops, so `devvm` or `devvm restart` in the folder of a running VM leaves the VM and its proxy running as they were, as long as that proxy still enforces the VM's network tier. When it doesn't, devvm stops the VM ([the proxy](../internals/network.md#the-proxy)).
|
||||
- devvm doesn't make a new VM, start a VM's proxy, or build an image or the shared tools while `config.toml`'s proxy names a user and no password is saved, and it checks before anything starts or stops. So `devvm` or `devvm restart` in the folder of a running VM leaves the VM and its proxy running as they were, as long as that proxy still enforces the VM's network tier, and otherwise devvm stops the VM ([the proxy](../internals/network.md#the-proxy)).
|
||||
- A VM's proxy reads the password only when it starts, so after you change it, run `devvm restart` in each VM's folder. No VM ever gets the `proxy` secret, and `devvm secret use proxy` refuses.
|
||||
|
||||
```sh
|
||||
|
||||
@@ -328,7 +328,7 @@ Before `devvm rm` deletes a `--clone` VM, it checks the clone for work you'd los
|
||||
2. **Uncommitted changes** in the clone or a worktree inside its folder. devvm lists the first 20 of them in all, with each worktree's changes under its path, and asks before deleting them along with the VM:
|
||||
- **The changes devvm copied in** from this machine don't count while the VM leaves them as they came, because they're your work, not the VM's, even if you've changed or undone them here since. Once the VM changes one of those files, its permissions or what's staged for it, devvm lists it as the VM's work.
|
||||
- **A worktree whose HEAD is detached** at commits that nothing else in the clone has, no branch, tag or remote-tracking branch, counts the same way: devvm names it and asks, because those commits go with the VM. To keep them, run `git switch -c NAME` in that worktree, then fetch the branch.
|
||||
- **Worktrees it skips:** one whose folder is gone or that git would prune, and those outside the clone's folder. When the clone has more than 100 worktrees inside its folder, devvm checks the first 100 and asks before deleting the VM, even if none of them has changes. Worktrees outside the folder don't count towards the 100.
|
||||
- **Worktrees it skips:** one whose folder is gone or that git would prune, and those outside the clone's folder. When the clone has more than 100 worktrees inside its folder, devvm checks the first 100 and asks before deleting the VM, even if none of them has changes. Worktrees outside the folder don't count towards the 100. The worktrees that opencode makes in the VM's home folder are checked apart, as for any VM with opencode, and devvm asks about them in the same question ([opencode's worktrees](coding-agents.md#opencodes-worktrees)).
|
||||
|
||||
If either check finds something and there's no terminal to ask in, or you give `--no-input`, devvm refuses and keeps the VM. These questions are asked only in a terminal, because only you can judge the work, so `--force` never answers them ([questions devvm asks](command-line.md#questions-devvm-asks)). Without a terminal, when the clone has work this repo hasn't fetched, devvm's refusal names `devvm clone fetch`: run it first, and the check finds every branch, a detached HEAD's commits and the VM's stash entries fetched, in every repo of a folder of repos too. Two cases check more:
|
||||
|
||||
@@ -346,7 +346,7 @@ Once the checks pass, devvm deletes the VM. If the remote still points at the VM
|
||||
| `--no-export` | the export of the agents' history, and it leaves both checks as they are |
|
||||
| `--no-clone-check` | both checks, so the VM goes with the commits this repo hasn't fetched and the uncommitted changes, and devvm warns you of that first |
|
||||
|
||||
Use `--no-clone-check` when a check can't read the clone, such as when git in the VM is broken, and devvm refuses and keeps the VM. Use it too when the VM doesn't start for the check, such as when its tier isn't enforced, because devvm then says what kept it from starting and keeps the VM. devvm still asks whether to delete the VM unless you also give `--force`, and it still keeps the `devvm/*` branches you fetched as `saved/devvm/` branches.
|
||||
Use `--no-clone-check` when a check can't read the clone, such as when git in the VM is broken or the VM doesn't answer within 2 minutes, and devvm refuses and keeps the VM. Use it too when the VM doesn't start for the check, such as when its tier isn't enforced, because devvm then says what kept it from starting and keeps the VM. devvm still asks whether to delete the VM unless you also give `--force`, and it still keeps the `devvm/*` branches you fetched as `saved/devvm/` branches.
|
||||
|
||||
## Switching a VM that exists
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ devvm keeps the agents' settings and logins on this machine in a store of its ow
|
||||
|
||||
The store has two folders for each agent, and each one holds the agent's files at the same paths below it as the agent keeps them in a home folder:
|
||||
|
||||
- **Settings** go in `~/.config/devvm/agents/<agent>/`, such as `~/.config/devvm/agents/claude/.claude/settings.json` and `~/.config/devvm/agents/claude/.claude/skills`. You can edit these files and make or delete these folders yourself, and a VM gets the change on its next launch, as [mounts](#mounts) and [copies](#copies) describe. Keep each folder on the way a folder of its own, not a link: `devvm agent import` and `devvm agent save` never write the store through a link, and when one is on the way to what they'd write, from `~/.config/devvm/agents` down, they fail and name it before they change anything.
|
||||
- **Settings** go in `~/.config/devvm/agents/<agent>/`, such as `~/.config/devvm/agents/claude/.claude/settings.json` and `~/.config/devvm/agents/claude/.claude/skills`. You can edit these files and make or delete these folders yourself, and a VM gets the change on its next launch, as [mounts](#mounts) and [copies](#copies) describe. Keep every folder from `~/.config/devvm/agents` down a real folder, because `devvm agent import` and `devvm agent save` never write the store through a link. When a link is on the path to what they'd write, they fail and name it before they change anything.
|
||||
- **Logins** go in `~/.local/share/devvm/logins/<agent>/`, such as `~/.local/share/devvm/logins/codex/.codex/auth.json` and `~/.local/share/devvm/logins/claude/.claude.json`, and so does a login that you make inside a VM, such as Codex's ([Codex and opencode logins](#codex-and-opencode-logins)) or Claude Code's in `~/.local/share/devvm/logins/claude/.claude/.credentials.json` ([Claude Code login](#claude-code-login)). Only you can read them, because devvm makes each agent's logins folder yours alone (mode 700) and each login file mode 600. On macOS, devvm keeps each agent's logins folder out of Time Machine's backups.
|
||||
|
||||
Each VM gets its agents' settings and logins from the store, but never your history. Transcripts, sessions and databases aren't in the store, and each VM's own stay in that VM. Before you leave an agent running unattended, read [staying safe](../safety/_index.md#the-habits) and [rogue agents](../safety/attack-vectors.md#rogue-agents).
|
||||
@@ -99,7 +99,7 @@ Each row lists the agent's paths in the VM's home, and the store keeps each one
|
||||
| --- | --- | --- |
|
||||
| claude | `~/.claude/{skills,agents,commands,output-styles}`, and the store's `~/.claude/plugins` at `~/.claude/plugins-seed` ([Claude Code's plugins](#claude-codes-plugins)) | `~/.claude/settings.json`, `~/.claude/CLAUDE.md`, and from the logins `~/.claude.json` ([merged](#copies), only its settings, account state and MCP servers) |
|
||||
| codex | `~/.codex/{prompts,skills}` | `~/.codex/{config.toml,AGENTS.md}`, and from the logins `~/.codex/auth.json` |
|
||||
| opencode | the subfolders of `~/.config/opencode` (not `node_modules`) | the files in `~/.config/opencode` (not lock files), and from the logins `~/.local/share/opencode/auth.json` |
|
||||
| opencode | the subfolders of `~/.config/opencode` (not `node_modules`) | the files in `~/.config/opencode` (not lock files, `.gitignore`, `.DS_Store` or [its service's settings](#opencodes-service)), and from the logins `~/.local/share/opencode/auth.json` |
|
||||
| pi | `~/.pi/agent/{extensions,skills,prompts,themes}` | `~/.pi/agent/{settings.json,keybindings.json,models.json,mcp.json,AGENTS.md,SYSTEM.md,APPEND_SYSTEM.md}`, and from the logins `~/.pi/agent/auth.json` |
|
||||
|
||||
### Importing from this machine
|
||||
@@ -116,13 +116,13 @@ devvm agent import --follow-links # copy what links out of the agents' folders
|
||||
devvm says which agents it imported and where, and an agent you named that your home folder has nothing of gets a warning. What the import copies and asks:
|
||||
|
||||
- The import copies only the paths in the table above, so it never copies your history or `~/.claude/.credentials.json` ([what it copies](../internals/agents.md#importing)). From `~/.claude.json` it keeps only the settings, account state and MCP servers, so your API key and your per-project entries stay out of the store. From `~/.claude/plugins` it copies only the marketplaces, their records and the plugins' cache, never what is this machine's own, such as each plugin's data.
|
||||
- devvm reads each agent's settings inside the agent's own folder, such as `~/.claude`. A link to a file inside the folder becomes a copy of that file when that file is one of the settings that the import copies, such as `~/.claude/CLAUDE.md`. A link to anything else inside the folder, such as your history, `~/.claude/.credentials.json` or a plugin's data, is left out with a warning that names where it leads, and so is a link to a folder inside it, or one that leads nowhere. A login file that's a link is always left out with a warning too. A link that leads out of the folder, by a relative or an absolute path, is copied only when you allow it ([links out of an agent's folder](#links-out-of-an-agents-folder)).
|
||||
- devvm reads each agent's settings inside the agent's own folder, such as `~/.claude`. A link to a file inside the folder becomes a copy of that file when that file is one of the settings that the import copies, such as `~/.claude/CLAUDE.md`. devvm leaves out a link to anything else inside the folder, such as your history, `~/.claude/.credentials.json` or a plugin's data, with a warning that names where it leads. It does the same with a link to a folder inside it and a link that leads nowhere, and it always leaves out a login file that's a link, with a warning. A link that leads out of the folder, by a relative or an absolute path, is copied only when you allow it ([links out of an agent's folder](#links-out-of-an-agents-folder)).
|
||||
- One import copies at most 20,000 files, folders and links, 128 MiB, and 16 MiB in one file, of each agent's own folder, at most 128 folders deep. When the folder holds more, devvm imports nothing and names the folder, so take out what it doesn't need, such as a plugin's build files, and import again.
|
||||
- An import that fails leaves the store as it was, its settings and logins alike, whether it fails while it reads, such as at a file that changed meanwhile, or while it puts them in place, such as at a login it can't save, so run it again ([how](../internals/agents.md#importing)). In the rare case that putting the store back fails too, devvm names the stores it couldn't put back and the folders that hold what it moved aside, so copy what you need from those before you import again, which deletes them.
|
||||
- An import that fails leaves the store's settings and logins as they were, so run it again ([how](../internals/agents.md#importing)). That holds whether it fails while it reads, such as at a file that changed meanwhile, or while it puts them in place, such as at a login it can't save. In the rare case that putting the store back also fails, devvm names the stores it couldn't put back and the folders that hold what it moved aside, so copy what you need from those before you import again, which deletes them.
|
||||
- On a Mac, whose volume ignores case by default, a file whose name differs from the store's only in case, such as `foo.md` where the store has `Foo.md`, replaces the store's file, which keeps its name. Two names that differ only in case, which your home folder can have only on a volume that tells case apart, would be one file in the store, so devvm imports nothing and names both.
|
||||
- Runs that write the store take turns: while another `devvm agent import` or `devvm agent save` writes it, or a start cleans it, devvm says it's waiting and goes on once that one is done.
|
||||
- When a VM's project folder is inside an agent's folder, such as a skill you work on in `~/.claude/skills`, or holds one, such as `~/.pi`, devvm warns that the VM can change the settings it imports for every VM, so keep such a project somewhere else unless you trust that VM. Each launch of such a VM warns too ([project folders devvm refuses](settings.md#project-folders-devvm-refuses)). An agent's folder that a link in a VM's project folder leads elsewhere is left out with a warning.
|
||||
- A VM whose state devvm can't read gets a warning that names the file, because devvm can't tell where its project folder is, and `devvm doctor` says what's wrong with it. Until it's fixed, devvm leaves out every link out of an agent's folder, and an agent's folder or login whose path leads through a link, such as an agent's folder that's a link to your dotfiles, naming the state, because that VM's project folder could hold the link.
|
||||
- Runs that write the store take turns. While another `devvm agent import` or `devvm agent save` writes it, or a start cleans it, devvm says it's waiting and goes on once that one is done.
|
||||
- When a VM's project folder is inside an agent's folder, such as a skill you work on in `~/.claude/skills`, or holds one, such as `~/.pi`, devvm warns that the VM can change the settings it imports for every VM, and each launch of such a VM also warns ([project folders devvm refuses](settings.md#project-folders-devvm-refuses)). Keep such a project somewhere else unless you trust that VM. When the path to an agent's folder passes through a link in a VM's project folder that leads elsewhere, devvm leaves that agent's folder out with a warning.
|
||||
- A VM whose state devvm can't read gets a warning that names the file, because devvm can't tell where its project folder is, and `devvm doctor` says what's wrong with it. That VM's project folder could hold a link, so until the state is fixed, devvm leaves out, with a warning that names the state, every link out of an agent's folder, and every agent's folder or login whose path leads through a link, such as an agent's folder that's a link to your dotfiles.
|
||||
- When the store already has settings or a login of an agent you import, devvm asks in a terminal whether to replace them, with no as the default. Without a terminal, or with `--no-input`, devvm refuses and names `--force`, which replaces them without asking. An agent whose settings aren't in your home folder keeps the store's settings, and one without a login there keeps the store's login.
|
||||
- On macOS, Claude Code keeps its own login in the Keychain, and devvm neither reads it nor copies it. You log Claude Code in from a VM instead, with `devvm agent login claude`, and every VM with Claude Code gets that login ([Claude Code login](#claude-code-login)).
|
||||
- When this machine's opencode is version 2 or later, devvm saves the API key of each provider, and your OpenAI login when you made it with one of opencode's Codex logins, the browser or the headless one. Any other login is left out with a warning that names it, such as opencode's Sign in with ChatGPT, whose tokens a VM can't use, or another provider's OAuth login, and you log in from a VM instead, with `devvm agent login opencode` ([logging in with devvm agent login](#logging-in-with-devvm-agent-login)). When `opencode auth export` fails, the import fails too, and the store keeps the login it had.
|
||||
@@ -146,7 +146,7 @@ What devvm copies through a link, and what it refuses:
|
||||
- **Only inside the folder you allowed.** devvm reads what a link leads to through a `follow-links` folder, or with `--follow-links` through the linked folder itself, or the linked file's own folder. A link inside a linked folder becomes a copy of the file it leads to only when that file is inside the same folder, and any other is left out with a warning.
|
||||
- **Never your secrets or devvm's own files.** devvm never follows a link to your home folder or a folder that holds it, to devvm's own folders, to `~/.ssh`, `~/.gnupg`, `~/.aws`, `~/Library/Keychains`, `~/.config/devvm`, `~/.netrc`, `~/.config/gh`, `~/.docker` or `~/.kube`, or to an agent's logins or history, such as `~/.codex`, nor into one of these or to a folder that holds one. It leaves such a link out with a warning, even with `--follow-links`.
|
||||
- **A `follow-links` folder must be safe as a whole.** A folder that is, holds or is inside one of those places fails the import, naming it, so name a folder inside it instead, such as `~/dotfiles/skills` when `~/.claude` is a link to `~/dotfiles/claude`. Write each folder as an absolute path or one that starts with `~/`, and devvm refuses anything else (`config.toml` names the line).
|
||||
- **A VM's project folder gets a warning.** When a link leads into the folder of one of your VMs, `--clone` VMs included, devvm names that VM and warns that it can change what every VM's agent reads from the next import on. Follow such links only when you trust that VM. A link that passes through a link in a VM's project folder to a place outside that folder is left out with a warning naming the VM, whatever allows it, because that VM chose where it leads. While a VM's state can't be read, every link is left out so, with a warning naming the state, because devvm can't tell where that VM's project folder is.
|
||||
- **A VM's project folder gets a warning.** When a link leads into the folder of one of your VMs, `--clone` VMs included, devvm names that VM and warns that it can change what every VM's agent reads from the next import on. Follow such links only when you trust that VM. A link that passes through a link in a VM's project folder to a place outside that folder is left out with a warning naming the VM, whatever allows it, because that VM chose where it leads. While a VM's state can't be read, devvm can't tell where that VM's project folder is, so it leaves out every link, with a warning that names the state.
|
||||
- **At most 20,000 files and folders, 128 MiB, and 16 MiB in one file,** for all the links of one import together. A link whose files would pass that is left out whole, with a warning.
|
||||
- **Settings files and folders keep their kind.** A link that is one of an agent's settings files, such as `~/.claude/CLAUDE.md`, must lead to a file, and one that is a settings folder, such as `~/.claude/skills`, must lead to a folder. Any other is left out with a warning.
|
||||
|
||||
@@ -161,7 +161,7 @@ devvm agent save # show what changed in the VM's agents' settings, then
|
||||
devvm agent save codex # save only Codex's
|
||||
```
|
||||
|
||||
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. When the VM sends more, or sends a path outside the agents' settings, devvm saves nothing. A save that fails partway leaves the store as it was.
|
||||
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 VM sends only what the store keeps, as the table above lists, so opencode's lock files, such as the `bun.lock` that its plugins' installs write, stay in the VM. When the VM sends more, or sends a path outside the agents' settings, devvm saves nothing. A save that fails partway leaves the store as it was.
|
||||
|
||||
For example, to give every VM a plugin that you install in one:
|
||||
|
||||
@@ -176,9 +176,13 @@ Before it saves anything, devvm shows what would change:
|
||||
- The diff shows the settings files and `~/.claude.json` as a VM gets them, written out again with `devvm-redacted` in place of the values that look like secrets, so it never prints your secrets, and it says so when only those values or the file's layout changed.
|
||||
- Every character that a terminal wouldn't show, such as a control character, a zero-width character or a character that reverses the text, appears in the diff as its code, such as `\u{200b}`, so a VM can't hide a line from you.
|
||||
- The diff names a binary file without showing it, and it shows a file of more than 1 MiB or 10,000 lines, and every line past the first 20,000 of the whole diff, only as a count.
|
||||
- On a Mac, whose volume ignores case by default, a file whose name differs from the store's only in case, such as `foo.md` where the store has `Foo.md`, is the store's file, so the diff shows it as changed and the store keeps its name. Two names in the VM that differ only in case, such as `A.md` and `a.md`, would be one file in the store, so once you say yes, devvm saves nothing and names both, and you rename one of them in the VM.
|
||||
- On a Mac, whose volume ignores case by default, a file whose name differs from the store's only in case, such as `foo.md` where the store has `Foo.md`, is the store's file, so the diff shows it as changed and the store keeps its name.
|
||||
- Two names in the VM that differ only in case, such as `A.md` and `a.md`, would be one file in the store on a Mac, so once you say yes, devvm saves nothing and names both, and you rename one of them in the VM.
|
||||
|
||||
Then devvm says that every VM with these agents runs the hooks, the MCP servers' commands and the plugins you save, and it asks whether to save them, with no as the default. Read the diff before you answer, because a hook or a plugin that a [rogue agent](../safety/attack-vectors.md#rogue-agents) added in one VM runs in every VM once you save it. devvm agent save always asks, and no flag answers for you, so without a terminal, or with `--no-input`, it shows what would change and then refuses. When a VM changed what's around a placeholder, devvm leaves that file out and warns you, so make that change in the store's file yourself. When the store changed after devvm showed what differs, as when you ran `devvm agent import` meanwhile, devvm saves nothing, so run `devvm agent save` again to see what differs now.
|
||||
Then devvm says that every VM with these agents runs the hooks, the MCP servers' commands and the plugins you save, and it asks whether to save them, with no as the default. Read the diff before you answer, because a hook or a plugin that a [rogue agent](../safety/attack-vectors.md#rogue-agents) added in one VM runs in every VM once you save it. devvm agent save always asks, and no flag answers for you, so without a terminal, or with `--no-input`, it shows what would change and then refuses. What devvm doesn't save:
|
||||
|
||||
- **A file where the VM changed what's around a placeholder,** which devvm leaves out with a warning, so make that change in the store's file yourself.
|
||||
- **Anything, when the store changed after devvm showed what differs,** as when you ran `devvm agent import` meanwhile, so run `devvm agent save` again to see what differs now.
|
||||
|
||||
## Mounts
|
||||
|
||||
@@ -201,7 +205,8 @@ Claude Code writes into its plugins folder as it runs, for each plugin's data, f
|
||||
- A plugin in the store loads when `enabledPlugins` in `~/.claude/settings.json` turns it on, as it does on this machine, and Claude Code keeps its data in the VM's own `~/.claude/plugins/data`.
|
||||
- A plugin you install in the VM goes into the VM's own folder, and only that VM has it until you [save it](#saving-a-vms-settings). The save copies the plugins you installed and their marketplaces into the store, and it never takes a plugin out of the store, so remove one in the store's folder yourself, or import your machine's plugins again.
|
||||
- Claude Code doesn't update the store's marketplaces in a VM, and `claude plugin marketplace update` refuses them, so update a marketplace on this machine and run `devvm agent import claude` again.
|
||||
- Neither `devvm agent import` nor `devvm agent save` copies what is each machine's own, such as each plugin's data, and an export of the VM's history leaves out the VM's plugins folder. When the store holds such entries, as an import by devvm 0.1.0 left there, a VM's start takes them out of the store and warns once, naming them, and leaves your own folder as it is. When devvm can't take them out, or the store's `~/.claude/plugins` is a link or below one, a VM with Claude Code doesn't start until that folder is one of its own that holds only `known_marketplaces.json`, `marketplaces` and `cache` ([how](../internals/agents.md#claude-codes-plugins)).
|
||||
- Neither `devvm agent import` nor `devvm agent save` copies what is each machine's own, such as each plugin's data, and an export of the VM's history leaves out the VM's plugins folder.
|
||||
- When the store holds such entries, as an import by devvm 0.1.0 left there, a VM's start takes them out of the store and warns once, naming them, and leaves your own folder as it is. When devvm can't take them out, or the store's `~/.claude/plugins` is a link or below one, a VM with Claude Code doesn't start until that folder is one of its own that holds only `known_marketplaces.json`, `marketplaces` and `cache` ([how](../internals/agents.md#claude-codes-plugins)).
|
||||
|
||||
```sh
|
||||
claude plugin list # in the VM: the store's plugins and the VM's own
|
||||
@@ -209,7 +214,7 @@ claude plugin list # in the VM: the store's plugins and the VM's own
|
||||
|
||||
## Copies
|
||||
|
||||
devvm copies the store's files into the VM's home on every launch, over the VM's own. On every [network tier](../safety/network.md#network-tiers), the copies of the logins and settings files have your secrets taken out, and the VM's proxy puts them into requests instead ([agents' logins and settings](../internals/network.md#agents-logins-and-settings)). devvm merges the store's `.claude.json` into the VM's own, so servers added in the VM stay, and Claude Code's login into the VM's `~/.claude/.credentials.json`, so [MCP servers' logins](#mcp-servers-logins) made in the VM stay, writes `devvm-redacted` in place of each secret in the settings files, names what it replaced in each file, and names each file it didn't copy ([what it takes out](../internals/agents.md#copies)).
|
||||
devvm copies the store's files into the VM's home on every launch, over the VM's own. On every [network tier](../safety/network.md#network-tiers), the copies of the logins and settings files have your secrets taken out, and the VM's proxy puts them into requests instead ([agents' logins and settings](../internals/network.md#agents-logins-and-settings)). devvm merges the store's `.claude.json` into the VM's own, so servers added in the VM stay, and it merges Claude Code's login into the VM's `~/.claude/.credentials.json`, so [MCP servers' logins](#mcp-servers-logins) made in the VM also stay. It writes `devvm-redacted` in place of each secret in the settings files, names what it replaced in each file, and names each file it didn't copy ([what it takes out](../internals/agents.md#copies)).
|
||||
|
||||
### Claude Code login
|
||||
|
||||
@@ -220,14 +225,14 @@ devvm agent login claude # log Claude Code in to your Claude subs
|
||||
devvm agent login claude --setup-token # get a long-lived Claude Code token with claude setup-token instead
|
||||
```
|
||||
|
||||
devvm starts the folder's VM first if it's stopped, as `devvm host` does, and then runs Claude Code's own login in the VM, on your terminal: `claude auth login --claudeai`, or `claude setup-token` with `--setup-token`. Claude Code shows an address, which you open in a browser on any machine. When you approve the login there, the browser shows a code, which you paste back at Claude Code's prompt, so devvm forwards no port. The VM uses the login at once, and every other VM with Claude Code gets it from its next launch ([how](../internals/agents.md#claude-codes-login)). When the login ends without a new login in the store, devvm says so and fails, as it does when Ctrl-C ends Claude Code's login in the VM. Run `--setup-token` in a terminal, because `claude setup-token` draws on one and shows nothing without it, which devvm warns about ([how the login gets a terminal](../internals/network.md#logins-made-in-a-vm)).
|
||||
devvm starts the folder's VM first if it's stopped, as `devvm host` does, and then runs Claude Code's own login in the VM, on your terminal: `claude auth login --claudeai`, or `claude setup-token` with `--setup-token`. Claude Code shows an address, which you open in a browser on any machine. When you approve the login there, the browser shows a code, which you paste back at Claude Code's prompt, so devvm forwards no port. The VM uses the login at once, and every other VM with Claude Code gets it from its next launch ([how](../internals/agents.md#claude-codes-login)). When the login ends without a new login in the store, such as when Ctrl-C ends Claude Code's login in the VM, devvm says so and fails. Run `--setup-token` in a terminal, because `claude setup-token` draws on one and shows nothing without it, and devvm warns when there's none ([how the login gets a terminal](../internals/network.md#logins-made-in-a-vm)).
|
||||
|
||||
devvm keeps one Claude Code login, either your subscription's login or a Claude Code token, and the newest replaces the other, so every VM uses the account you logged in to last:
|
||||
|
||||
- **Your subscription's login**, from `devvm agent login claude` or a `claude /login` that you run in a VM yourself, goes in devvm's agent store, in `~/.local/share/devvm/logins/claude/.claude/.credentials.json`, only yours to read. The VM's `~/.claude/.credentials.json` holds placeholders, with no refresh token and an expiry in 2099, so Claude Code in the VM never refreshes the login itself. The VM's proxy puts the login into the VM's requests to `api.anthropic.com` and to `mcp-proxy.anthropic.com`, the host of your claude.ai connectors, and refreshes it on this machine when it's due, through the company proxy when `config.toml` names one. devvm keeps only a login that can use Claude's models and can't make API keys, so a login to an Anthropic Console account, which Claude Code uses to make an API key, fails in a VM, and no API key reaches it. Only a VM that has Claude Code can log it in.
|
||||
- **A Claude Code token**, from `devvm agent login claude --setup-token` or a `claude setup-token` that you run in a VM yourself, goes with the other [secrets](../safety/network.md#saving-and-binding-secrets). You can also save one with `devvm secret set claude` and paste the token that `claude setup-token` printed on another machine (`sk-ant-oat01-…`), not the code the browser shows. devvm neither saves nor sends a Claude Code token that isn't a setup token. Every VM with Claude Code gets the token in its environment as `CLAUDE_CODE_OAUTH_TOKEN`, holding a placeholder of its own, and its proxy puts the token into its requests. When you set up a token in a VM, `claude setup-token` prints that VM's placeholder, not the token, because devvm already saved it.
|
||||
|
||||
A `CLAUDE_CODE_OAUTH_TOKEN` in devvm's own environment on this machine wins over both, as it does in Claude Code, so VMs get that token, and `devvm agent login claude` warns you when it's set. Only your subscription's login reaches your claude.ai connectors, so a VM can use them, which [your claude.ai connectors](../safety/attack-vectors.md#the-network) says how to stop. Anthropic doesn't document the requests that Claude Code's login sends, so devvm follows the ones Claude Code sends today, and a new Claude Code release can change them. When a login in a VM stops working, run `devvm agent login claude` again, or save a Claude Code token instead.
|
||||
A `CLAUDE_CODE_OAUTH_TOKEN` in devvm's own environment on this machine wins over both, as it does in Claude Code, so VMs get that token, and `devvm agent login claude` warns you when it's set. With your subscription's login, and only with it, a VM can use your claude.ai connectors, and [your claude.ai connectors](../safety/attack-vectors.md#the-network) says how to stop that. Anthropic doesn't document the requests that Claude Code's login sends, so devvm follows the ones Claude Code sends today, and a new Claude Code release can change them. When a login in a VM stops working, run `devvm agent login claude` again, or save a Claude Code token instead.
|
||||
|
||||
#### MCP servers' logins
|
||||
|
||||
@@ -291,6 +296,23 @@ opencode's Anthropic login is an API key, because opencode itself has no other w
|
||||
|
||||
A login that Codex or opencode makes in a VM, whether `devvm agent login` runs it or you run it yourself, is saved in devvm's store, and every VM with that agent gets it from its next launch. A login that shows a code to type into a browser works in a VM as it is, but opencode's Sign in with ChatGPT doesn't, so choose one of opencode's Codex logins instead, as `devvm agent login opencode` does ([how a VM's logins are saved](../internals/agents.md#logins-made-in-a-vm)). On the open tier, a program that goes around the VM's proxy gets the login's tokens itself, and devvm saves nothing ([logins made in a VM](../internals/network.md#logins-made-in-a-vm)).
|
||||
|
||||
### opencode's service
|
||||
|
||||
opencode's background service, which opencode starts when it needs one, asks for a password when you sign in to it, and each VM's opencode makes its own the first time its service starts. To sign in to a VM's service, such as from opencode's app, read that VM's password in the VM:
|
||||
|
||||
```sh
|
||||
opencode service get password # in the VM: its service's password, made now if it has none
|
||||
opencode service set password PASSWORD # in the VM: choose another, which stops its service
|
||||
```
|
||||
|
||||
- devvm never copies this machine's opencode service settings into its agent store or a VM. They're `service.json` in `~/.config/opencode`, or `service-<channel>.json` for another channel's opencode, and they hold this machine's service password and, with remote access on, the secret route that the service is served on. So `devvm agent import` and `devvm agent save` leave them out, and each VM's service settings stay in that VM.
|
||||
- When devvm's agent store holds them, a VM's start takes them out and warns once, and each VM's setup takes out any copy of them that devvm made, so the VM's opencode makes its own password ([how](../internals/agents.md#opencodes-service)).
|
||||
- A service that's running keeps the password it started with, so after that warning, restart each running VM that has opencode:
|
||||
|
||||
```sh
|
||||
devvm restart # in the VM's folder: its opencode service starts again with a password of its own
|
||||
```
|
||||
|
||||
### pi logins
|
||||
|
||||
pi in a VM uses API keys that devvm keeps on this machine, for the providers whose keys the VM's proxy puts in, which [API keys the proxy puts in](#api-keys-the-proxy-puts-in) lists. You save one with `devvm agent login pi --api-key --provider PROVIDER`, because pi's login always takes both flags, or you import the API keys in your own `~/.pi/agent/auth.json` with `devvm agent import pi`:
|
||||
@@ -332,7 +354,8 @@ devvm starts the folder's VM first if it's stopped, as `devvm host` does, and th
|
||||
- Cursor's CLI never refreshes a login, so devvm doesn't either. When the login expires, the proxy puts nothing in, and its own log says to log in again with `devvm agent login cursor`. devvm doesn't keep a Cursor API key, so `devvm agent login cursor` takes neither `--api-key` nor `--device-code`.
|
||||
- `devvm agent import cursor` copies the CLI's settings from `~/.cursor` on this machine, which are `cli-config.json`, `mcp.json` and the `rules` and `commands` folders. On Linux it copies the CLI's login from `~/.config/cursor/auth.json` too. On macOS the CLI keeps its login in the Keychain, which devvm doesn't read, so log in from a VM instead.
|
||||
- The CLI would update itself in the VM, but every VM sets its channel to `static` in `~/.cursor/cli-config.json` at each launch, which the CLI never updates on, so it stays the release that devvm pins. Cursor's CLI has no setting that turns off its reports to Cursor, so its allowlist leaves out the host it sends its metrics to, `api3.cursor.sh`, which Cursor documents for its editor's Tab requests, and the reports it sends to Cursor's API go with the rest. That host is [quiet](../safety/network.md#quiet-hosts), so its blocks never show in the VM. If Cursor Tab doesn't work in a [`devvm cursor`](ssh.md#cursors-agent) window on the allowlist tier, `devvm network allow api3.cursor.sh` lets it through.
|
||||
- In a VM, Cursor's CLI can't install, update or remove plugins and marketplaces, change automations or cloud agents' environments, start, fork, pin or merge the work of a cloud agent, or change your team, because each of those changes your Cursor account in a way that outlasts the VM and acts outside it. Do them from Cursor on your machine. Cursor's agent store isn't available in a VM either, so use it from Cursor on your machine. The CLI in a VM keeps its own chats without the store. Checking Amazon Bedrock keys doesn't work in a VM either, as devvm doesn't keep them. Neither does `cursor-agent worker`, which makes the machine a worker that runs your cloud agents' work, because the proxy never puts the login into its requests, and its host, `api2direct.cursor.sh`, isn't among the Cursor hosts the allowlist tier lets through ([how](../internals/network.md#logins-made-in-a-vm)).
|
||||
- In a VM, Cursor's CLI can't install, update or remove plugins and marketplaces, change automations or cloud agents' environments, start, fork, pin or merge the work of a cloud agent, or change your team, because each of those changes your Cursor account in a way that outlasts the VM and acts outside it. Do them from Cursor on your machine. Cursor's agent store isn't available in a VM either, so use it from Cursor on your machine. The CLI in a VM keeps its own chats without the store. Checking Amazon Bedrock keys doesn't work in a VM either, as devvm doesn't keep them.
|
||||
- `cursor-agent worker`, which makes the machine a worker that runs your cloud agents' work, doesn't work in a VM, because the proxy never puts the login into its requests, and its host, `api2direct.cursor.sh`, isn't among the Cursor hosts the allowlist tier lets through ([how](../internals/network.md#logins-made-in-a-vm)).
|
||||
- The VM's proxy puts the real login only into the requests that the CLI's own methods make, and cuts a reply off where a token starts, but a token in a shape devvm doesn't know could still reach the VM, so if you suspect that one did, log in again with `devvm agent login cursor` ([how](../internals/agents.md#cursors-cli)).
|
||||
|
||||
### API keys the proxy puts in
|
||||
@@ -385,7 +408,7 @@ devvm reads only an image, a PDF or a copied file's reference from the clipboard
|
||||
- **One copied file**, after devvm asks you about it.
|
||||
- **Nothing over 64 MiB**, whether it's an image, a PDF or a file.
|
||||
|
||||
devvm checks that an image's or a PDF's bytes are the type the clipboard claims ([how](../internals/design.md#pasting-images)). Text is never sent, so paste text, such as an error message, into the agent's terminal yourself. The app you copied from hands over what you copied when devvm asks for it, and devvm waits for it at most 30 seconds, then stops waiting, sends nothing and says so, so copy it again, or wait until the app responds, then run devvm paste again. On macOS, devvm reads the clipboard of the session you're logged in to, so run devvm paste in a terminal on that Mac, not over ssh.
|
||||
devvm checks that an image's or a PDF's bytes are the type the clipboard claims ([how](../contributing/design.md#pasting-images)). Text is never sent, so paste text, such as an error message, into the agent's terminal yourself. The app you copied from hands over what you copied when devvm asks for it, and devvm waits for it at most 30 seconds, then stops waiting, sends nothing and says so, so copy it again, or wait until the app responds, then run devvm paste again. On macOS, devvm reads the clipboard of the session you're logged in to, so run devvm paste in a terminal on that Mac, not over ssh.
|
||||
|
||||
What devvm gets depends on the app you copied from:
|
||||
|
||||
@@ -396,7 +419,7 @@ What devvm gets depends on the app you copied from:
|
||||
|
||||
### Copied files
|
||||
|
||||
Before devvm sends a copied file, it shows the file's path on this machine and asks, [y/N], because the clipboard can name any file of yours, such as a key in `~/.ssh` that you didn't mean to copy. Answer no and nothing is sent. An image or a PDF is sent without a question, because it's only what you copied. devvm sends a copied file under a name of its own that keeps only the file's extension, when it's letters and digits alone and at most 16 of them, so `my shot (1).png` becomes `paste-20261109-153012-7f3a9c01.png`, and `Makefile` becomes `paste-20261109-153012-7f3a9c01` ([why](../internals/design.md#pasting-images)).
|
||||
Before devvm sends a copied file, it shows the file's path on this machine and asks, [y/N], because the clipboard can name any file of yours, such as a key in `~/.ssh` that you didn't mean to copy. Answer no and nothing is sent. An image or a PDF is sent without a question, because it's only what you copied. devvm sends a copied file under a name of its own that keeps only the file's extension, when it's letters and digits alone and at most 16 of them, so `my shot (1).png` becomes `paste-20261109-153012-7f3a9c01.png`, and `Makefile` becomes `paste-20261109-153012-7f3a9c01` ([why](../contributing/design.md#pasting-images)).
|
||||
|
||||
It sends one file at a time, and it refuses:
|
||||
|
||||
@@ -461,11 +484,11 @@ devvm reads and writes the clipboard with `wl-paste` and `wl-copy` in a Wayland
|
||||
sudo apt install wl-clipboard # or xclip for X11; dnf, pacman and zypper have both
|
||||
```
|
||||
|
||||
devvm looks for them only in the system's folders, never elsewhere on your `PATH` ([which folders, and why](../internals/design.md#pasting-images)). Run devvm paste from a terminal in your desktop session, because without either variable there's no clipboard to read. If `WAYLAND_DISPLAY` or `DISPLAY` names a session that's over, as in a tmux window left from an earlier login, devvm tells you that `wl-paste` or `xclip` failed and what it said, rather than that the clipboard is empty. Copying the path leaves `wl-copy` or `xclip` running until you copy something else, because a Linux clipboard's contents live in the program that copied them.
|
||||
devvm looks for them only in the system's folders, never elsewhere on your `PATH` ([which folders, and why](../contributing/design.md#pasting-images)). Run devvm paste from a terminal in your desktop session, because without either variable there's no clipboard to read. If `WAYLAND_DISPLAY` or `DISPLAY` names a session that's over, as in a tmux window left from an earlier login, devvm tells you that `wl-paste` or `xclip` failed and what it said, rather than that the clipboard is empty. Copying the path leaves `wl-copy` or `xclip` running until you copy something else, because a Linux clipboard's contents live in the program that copied them.
|
||||
|
||||
## History
|
||||
|
||||
Each VM's transcripts and sessions stay in that VM. `devvm history export [FILE]` saves them, and `devvm rm` saves them before it deletes a VM that has an agent. The export is a `.tar.gz` of the agents' history in the VM, <!-- the agents' history, generated from internal/agents by mise run cli-docs -->`~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`<!-- end of the agents' history -->, written to FILE or to `~/.local/share/devvm/exports/<vm>-<date>-<time>.tar.gz`. An export in that folder gets a `<vm>-<date>-<time>.folder` file beside it, which names the VM's project folder and the VM's [network tier](../safety/network.md#network-tiers) when devvm wrote the export. The agents' logins are never in an export, and an export holds at most 2 GiB ([what an export holds](../internals/agents.md#history-exports)). The commands:
|
||||
Each VM's transcripts and sessions stay in that VM. `devvm history export [FILE]` saves them, and `devvm rm` saves them before it deletes a VM that has an agent. The export is a `.tar.gz` of the agents' history in the VM, <!-- the agents' history, generated from internal/agents by mise run cli-docs -->`~/.claude`, `~/.claude.json`, `~/.codex`, `~/.local/share/opencode`, `~/.local/state/opencode`, `~/.pi/agent/sessions` and `~/.cursor/chats`<!-- end of the agents' history -->, written to FILE or to `~/.local/share/devvm/exports/<vm>-<date>-<time>.tar.gz`. An export in that folder gets a `<vm>-<date>-<time>.folder` file beside it, which names the VM's project folder and the VM's [network tier](../safety/network.md#network-tiers) when devvm wrote the export. The agents' logins are never in an export, and neither is the key that every machine paired with the VM's opencode trusts. An export holds at most 2 GiB ([what an export holds](../internals/agents.md#history-exports)). The commands:
|
||||
|
||||
```sh
|
||||
devvm history # list the exports devvm saved
|
||||
@@ -515,8 +538,36 @@ devvm history import ~/backup.tar.gz # or an export of your own
|
||||
- When devvm makes a new VM that has an agent, and it saved an export for the same folder before, it offers that export. In a terminal it asks whether to import it into the new VM, with no as the default. Without a terminal, or with `--no-input`, it doesn't ask, and it says which export it found and that `devvm history import` in the folder puts it into the VM. devvm imports the export once the VM has started and before its setup, and if the import fails, devvm warns and makes the VM anyway, so you can run `devvm history import` later.
|
||||
- An export holds what a VM wrote, so devvm treats it as untrusted, and when it comes from a VM on a less strict tier than the VM you import it into, devvm warns you before it imports. It treats an export with no tier recorded, or a FILE elsewhere, as if it came from an open VM. When an export holds a path outside the agents' history folders, devvm imports nothing.
|
||||
- The import leaves out what devvm puts in the VM itself. That's the agents' logins, `~/.claude/.credentials.json`, with the old VM's own MCP servers' logins in it, `~/.codex/auth.json`, and opencode's `auth.json`, `account.json`, `mcp-auth.json` and `bin`. It's also `~/.claude.json`, whose copy in the old VM held that VM's own placeholders, and every agent's [mounted folders and copied files](#devvms-agent-store), which the new VM's setup links and copies from devvm's agent store.
|
||||
- The import also leaves out the old VM's opencode identity, as an export does: opencode's `~/.local/state/opencode/machine`, with the key that every machine paired with the old VM's opencode trusts, and its `service.json`, or `service-<channel>.json` for another channel's opencode, and `pty`, which hold the password of the old VM's opencode service and the access tokens of its terminals' daemons. The new VM's opencode makes its own. The import also leaves out the project plugins you approved in opencode's native client, `plugin-approvals.json` and `plugin-staged`, so opencode asks again before it runs one.
|
||||
- opencode's sessions come without what opencode would act on without asking. Neither an export nor an import keeps:
|
||||
- automations, whose shell commands run on their schedule without asking again
|
||||
- the requests you said always to allow
|
||||
- subagents' jobs and queued messages
|
||||
- a project's commands
|
||||
- opencode's git repositories and worktrees
|
||||
|
||||
No session resumes its turn on its own, and each session keeps only its deny and ask rules ([what an export holds](../internals/agents.md#history-exports)). In the new VM, make again any automation you want, and opencode asks again before the requests you had always allowed. `devvm rm` deletes opencode's worktrees with the VM, so it asks before their uncommitted changes go ([opencode's worktrees](#opencodes-worktrees)).
|
||||
- A file or folder the VM already has stays as it is, so importing into a VM that has history of its own adds the export's files without replacing any of its own.
|
||||
|
||||
### opencode's worktrees
|
||||
|
||||
```sh
|
||||
devvm rm # show opencode's worktrees' uncommitted changes, then ask
|
||||
devvm rm --no-worktree-check # delete the VM without checking them, losing those changes
|
||||
devvm update --clean-home # a remake that starts from the image's home folder checks them too
|
||||
```
|
||||
|
||||
opencode makes its worktrees in `~/.local/share/opencode/worktree` in the VM, and an export leaves that folder out, so their uncommitted changes go with the VM. Before `devvm rm` deletes the VM, and before a command that makes it again with `--clean-home` gives it the image's home folder, devvm checks each of those worktrees, starting a stopped VM for the check as a launch does. It asks before what it finds is lost, only in a terminal, so `--force` never answers. Without a terminal, or with `--no-input`, devvm refuses and keeps the VM, and when only the worktrees have work, the refusal names `--no-worktree-check`, which warns and goes ahead without the check.
|
||||
|
||||
devvm asks about:
|
||||
|
||||
- **Uncommitted changes:** it lists the first 20 in all, under each worktree's path.
|
||||
- **A detached HEAD's commits** that no branch, tag or remote-tracking branch in the VM has. To keep them, run `git switch -c NAME` in that worktree first.
|
||||
- **A worktree that git can't read,** such as one whose entry your project's repository pruned, because it may hold changes devvm can't see.
|
||||
- **More than 100 worktrees,** of which devvm checks the first 100.
|
||||
|
||||
To keep the work, commit it in the worktree, which puts it in your project's repository for a VM that mounts the folder, or in the clone, whose branches `devvm rm` offers to fetch, for a `--clone` VM ([deleting the VM](clone.md#deleting-the-vm)). For a `--clone` VM, the clone's check and the worktrees' share one question, and when the clone has work too, the refusal tells you to run the command in a terminal, as the clone's own does. When reading the worktrees fails, or the VM doesn't start for the check, devvm keeps the VM and names `--no-worktree-check`. A command that keeps the VM's home folder, such as `devvm update` without `--clean-home`, keeps the worktrees too, so it doesn't check them ([how devvm checks](../internals/agents.md#opencodes-worktrees)).
|
||||
|
||||
## The VM's setup
|
||||
|
||||
Besides the agents' config, every launch sets the VM up from this machine's settings:
|
||||
|
||||
@@ -21,7 +21,7 @@ A [layer](images.md#layers) is a script, `~/.config/devvm/layers/<name>.sh`, tha
|
||||
- **Names** are made of lowercase letters, digits and dashes, and start with a letter or digit. A name can't be `base`, a [built-in layer's](images.md#built-in-layers) name (`desktop`, `docker` or `nix`) or a shared tool's name (`node`, `claude` and so on). A command's name, such as `log`, is fine, because devvm takes layers only through `--layers`, the list and image names.
|
||||
- Built-in layers go in the same image names as yours, bottom first, as in `devvm --layers docker,mailpit`, which makes the image `docker+mailpit`.
|
||||
- Put interactive shell setup in `~/.bashrc.d/<name>.sh`, which every VM's `~/.bashrc` reads, and PATH changes in `~/.profile`.
|
||||
- Download files with `devvm-fetch URL SHA256 OUT`, which `base` installs. It fails when the file's checksum doesn't match.
|
||||
- Download files with `devvm-fetch URL SHA256 OUT`, which `base` installs. It tries a download that was cut or stalled again from where it stopped, and it fails when the file's checksum doesn't match ([building](../internals/images.md#building)).
|
||||
- devvm runs a line of its own in place of your script's `#!` line, which gives it `$devvm_arch`, the VM's architecture as `arm64` or `amd64`, `$devvm_libc`, which is `musl` on Alpine and `gnu` elsewhere, and `devvm_sha TOOL`, which prints the checksum you pinned for this VM, as the [example](#example-mailpit) shows. Names that start with `devvm_` are devvm's, and one your script sets is your script's from then on. Bash's errors give your file's own line numbers, or one more without a `#!` line ([the prelude](../internals/images.md#the-scripts-prelude)).
|
||||
- `NAME.policy` lists the hosts that VMs with the layer can reach on the [allowlist tier](../safety/network.md#allowlists), one rule per line.
|
||||
- Editing the script rebuilds its image, and the ones built on it, the next time they're used ([rebuilding](images.md#rebuilding)).
|
||||
|
||||
@@ -231,7 +231,7 @@ devvm reads the home folder as the VM's user before it stops the VM, and copies
|
||||
|
||||
- What other shells in the VM write after devvm reads the folder is lost, so close them first.
|
||||
- A file that the new image puts in your home itself, such as `~/.bashrc`, stays the image's, so put shell settings of your own in a file of yours in `~/.bashrc.d`.
|
||||
- devvm leaves out what the new VM gets from devvm itself: `~/.config/devvm`, `~/.ssh/authorized_keys`, the agents' logins, and the agents' folders and files that devvm links or copies from this machine. It leaves out `~/.cache` too.
|
||||
- devvm leaves out what the new VM gets from devvm itself: `~/.config/devvm`, `~/.ssh/authorized_keys`, the agents' logins, and the agents' folders and files that devvm links or copies from this machine. It leaves out `~/.cache` too. It keeps opencode's `~/.local/state/opencode/machine`, which an export of the VM's history leaves out, so the machines that opencode paired still trust the VM.
|
||||
- Claude Code's logins to MCP servers, which it keeps in its login file, don't come along, so you log in to those servers again in the new VM ([MCP servers' logins](coding-agents.md#mcp-servers-logins)).
|
||||
- devvm keeps only files, folders and symlinks, without setuid bits, and nothing from a filesystem mounted inside your home.
|
||||
|
||||
@@ -243,7 +243,7 @@ Everything else on the VM's disk is lost:
|
||||
- the Nix store
|
||||
- the processes that ran in it
|
||||
|
||||
When saving the home folder fails, devvm keeps the VM as it was, and `--clean-home` goes ahead without it.
|
||||
When saving the home folder fails, devvm keeps the VM as it was, and `--clean-home` goes ahead without it. With `--clean-home`, opencode's worktrees go with the home folder, so devvm checks them for uncommitted changes first and asks before they go, as `devvm rm` does. `--no-worktree-check`, which works only with `--clean-home`, skips that check ([opencode's worktrees](coding-agents.md#opencodes-worktrees)).
|
||||
|
||||
### A remake that stops halfway
|
||||
|
||||
@@ -439,7 +439,7 @@ devvm's mise and the shared Nix cache are both in `cache/` in [devvm's data fold
|
||||
- `devvm gc --caches` then frees devvm's share of Lima's own caches, such as its downloads of Ubuntu's cloud image, after asking, or without asking with `--force`, which it needs without a terminal ([Lima's caches](space.md#limas-caches)).
|
||||
- `devvm gc --retention` then applies the [retention settings](settings.md#retention) at once, which devvm otherwise applies at most once a day. They're all off until you set them.
|
||||
- When Lima can't list its images while one of your VMs uses it, for example because Lima isn't installed, gc warns and leaves Lima's images, shared tools, VM leftovers and caches alone. It also leaves the shared tools whose record doesn't name the backend that built them, because they may be Lima's. gc still succeeds, so run `devvm doctor` to see what's wrong with Lima, then run gc again once it answers. `devvm images` fails instead, because it lists all the images or none.
|
||||
- gc never deletes VMs, and it keeps current images, which `devvm images rm` deletes ([deleting images](#deleting-images)). Without `--tool-images` it keeps the current shared tools. It always keeps every shared tool that any VM has, including a stopped VM's and that of a VM deleted outside devvm whose state is left, until `--orphans` deletes that state.
|
||||
- gc never deletes your VMs, and it keeps current images, which `devvm images rm` deletes ([deleting images](#deleting-images)). It does delete, without asking, the build VMs that a killed or failed tools build left, which hold nothing of yours, and it names each one ([VMs devvm has no state for](space.md#vms-devvm-has-no-state-for)). Without `--tool-images` it keeps the current shared tools. It always keeps every shared tool that any VM has, including a stopped VM's and that of a VM deleted outside devvm whose state is left, until `--orphans` deletes that state.
|
||||
- On Linux hosts, a stale image whose disk VMs are overlays of stays, and devvm says which VMs use it.
|
||||
- After an Alpine VM is gone, the shared tools built for Alpine are unused, unless you give gc that `--from`.
|
||||
|
||||
|
||||
@@ -135,12 +135,16 @@ Before devvm builds an image or makes a VM, it checks the free space on the disk
|
||||
| --- | --- | --- |
|
||||
| building `base` | 8 GiB | 8 GiB |
|
||||
| building any other image | 2 GiB | 8 GiB |
|
||||
| building shared tool images | 3 GiB, and 0.5 GiB for each tool | 9 GiB, and 0.5 GiB for each tool |
|
||||
| building shared tool images | 3 GiB for each build VM, and 0.5 GiB for each tool | 9 GiB for each build VM, and 0.5 GiB for each tool |
|
||||
| making a VM | 2 GiB | 2 GiB |
|
||||
|
||||
devvm rounds each number up to whole GiB, so building one shared tool with Lima on macOS needs 4 GiB, and building all ten needs 8 GiB. Each build checks again before it starts, so the first VM on a Mac, which builds base, needs 8 GiB free. A tools build also checks the disk of devvm's data folder, where the shared tool images come out, and [free space](../internals/images.md#free-space) explains which disks devvm checks, what each one needs and how the numbers were measured.
|
||||
devvm rounds each number up to whole GiB, so building one shared tool with Lima on macOS needs 4 GiB, and building all ten in one build VM needs 8 GiB. Each build checks again before it starts, which means:
|
||||
|
||||
`devvm doctor` also warns when that disk has less free space than building base needs, but the warning doesn't make doctor fail. When devvm refuses, see [Not enough free space](troubleshooting.md#not-enough-free-space) for how to make room.
|
||||
- **The first VM on a Mac** builds base, so it needs 8 GiB free.
|
||||
- **Tool images** that build side by side need room for each build VM, up to four, and devvm runs fewer when this machine's memory, its CPUs or this disk has room for fewer.
|
||||
- **A tools build** also checks the disk of devvm's data folder, where the shared tool images come out.
|
||||
|
||||
[Free space](../internals/images.md#free-space) explains which disks devvm checks, what each one needs and how the numbers were measured. `devvm doctor` also warns when the disk that holds images has less free space than building base needs, but the warning doesn't make doctor fail. When devvm refuses, see [Not enough free space](troubleshooting.md#not-enough-free-space) for how to make room.
|
||||
|
||||
## As JSON
|
||||
|
||||
|
||||
@@ -286,9 +286,10 @@ These trust the CAs:
|
||||
- **Every project VM,** in its system's store, from its next launch.
|
||||
- **Every build VM,** for an image or for shared tools. devvm takes them out of a build VM before the image is finished, so images never keep them, and adding or removing a CA rebuilds nothing. A layer script of yours that copies the system's CA bundle somewhere else does keep that copy ([a company's CA in builds](../internals/images.md#a-companys-ca-in-builds)).
|
||||
- **The VM's proxy,** on every [network tier](../safety/network.md), for the connections it makes itself, the refresh of a coding agent's login included, which the proxy makes on this machine when the login is due, so a company proxy that inspects TLS doesn't make the refresh fail.
|
||||
- **Ubuntu's cloud image,** which devvm looks up and downloads on this machine to build base. The lookup and the download trust these CAs as well as this machine's own store, and when this machine doesn't trust the server's certificate, devvm says so and names this folder.
|
||||
- **devvm's own mise,** which devvm downloads once to resolve the shared tools' versions on this machine. That download trusts these CAs as well as this machine's own store, and on Linux so does that mise. On macOS, mise trusts them for most of its connections, but the part of it that checks where each tool's release was built trusts only the CAs that macOS trusts, which Keychain Access shows. So on macOS, a company's CA that mise needs has to be there too, where a Mac that your company manages usually has it already. When mise doesn't trust a server's certificate, devvm says so and names this folder.
|
||||
|
||||
devvm's other connections from this machine, such as checking an image's registry or Ubuntu's image, trust this machine's own store, as your other programs here do. When you take a certificate out of the folder, VMs stop trusting it at their next launch, and stores that copy the system's CAs, such as Java's `cacerts`, drop it too.
|
||||
devvm's other connections from this machine, such as checking an image's registry, trust this machine's own store, as your other programs here do. When you take a certificate out of the folder, VMs stop trusting it at their next launch, and stores that copy the system's CAs, such as Java's `cacerts`, drop it too.
|
||||
|
||||
Most tools read the system's store, among them apt, apk, curl, git and Python's `ssl` module. For those that don't, every VM's environment points them at it:
|
||||
|
||||
@@ -306,18 +307,24 @@ A CA in the folder can read every TLS connection a VM makes, as it can this mach
|
||||
`~/.local/share/devvm` (`$XDG_DATA_HOME/devvm`) holds what devvm makes and keeps for you, and devvm writes everything in it, so don't edit it by hand. It holds the defaults that `devvm setup`, `devvm size -g`, `devvm ports -g`, `devvm network -g` and `devvm retention` save in `settings.json`, below [`config.toml`](#configtoml)'s, and a folder for each VM in `vms/`, with the VM's state, its own allowlist and its network logs. It also holds the images and the shared tools, the [run logs](troubleshooting.md#a-command-fails), the agents' history that `devvm history export` and `devvm rm` save, the [ssh config](ssh.md#ssh-access-by-name) for your VMs, and devvm's own Lima home (`lima/`), where the Lima backend's VMs and images live. [devvm's data folder](space.md#devvms-data-folder) lists each file and folder in it, with how each one is cleaned up.
|
||||
|
||||
- On Linux hosts this folder also holds your [secrets](../safety/network.md#saving-and-binding-secrets), in files under `secrets/` that only you can read, so keep that in mind when you back it up. On macOS they're in the Keychain.
|
||||
- devvm's Lima home is its own, whatever `LIMA_HOME` says, so Lima settings meant for other VMs never reach devvm's. Set `DEVVM_LIMA_HOME` to move it, for example to a sandbox or to a shorter path.
|
||||
- devvm's Lima home is its own, whatever `LIMA_HOME` says, so Lima settings meant for other VMs never reach devvm's. Set `DEVVM_LIMA_HOME` to move it, for example to a sandbox or to a shorter path. When devvms with data folders of their own share one Lima home, don't build shared tools or run `devvm gc` in two of them at once, because each can delete a build VM that another is still using ([building tools](../internals/images.md#building-tools)).
|
||||
- Only you can read devvm's files, in either folder, because each time devvm runs, it makes both folders yours alone ([devvm's data folder](space.md#devvms-data-folder)). When devvm can't read one of its files, it names the file and the line ([a file devvm can't read](troubleshooting.md#a-file-devvm-cant-read)).
|
||||
|
||||
## Project folders devvm refuses
|
||||
|
||||
A VM mounts its project folder read-write, so devvm refuses to make a VM for a folder that would give the VM more than the project. It refuses a folder that is or holds your home folder, `~/.config/devvm`, `~/.local/share/devvm` or devvm's Lima home. It also refuses a folder inside one of devvm's own folders, because a VM there could rewrite the scripts that every image build runs, or the files that devvm runs on this machine. devvm compares the folders themselves, not only their names, so on a Mac, where a name's case doesn't count, `~/.Config/devvm` is refused as `~/.config/devvm` is.
|
||||
A VM mounts its project folder read-write, so devvm refuses to make a VM for a folder that would give the VM more than the project:
|
||||
|
||||
When devvm refuses a folder, make the VM in a project folder inside it, or keep the project somewhere else. A [`--clone`](clone.md) VM mounts nothing from the folder, so devvm doesn't refuse its folder. A folder inside a coding agent's folder on this machine, such as a skill you work on in `~/.claude/skills`, or one that holds an agent's folder, such as `~/.pi`, isn't refused, but devvm warns at each launch, because code in the VM can change that agent's settings on this machine. Keep such a project somewhere else unless you trust what runs in its VM.
|
||||
- **Your home folder and devvm's folders,** and any folder that holds one: your home folder, `~/.config/devvm`, `~/.local/share/devvm` or devvm's Lima home.
|
||||
- **A folder inside one of devvm's own folders,** because a VM there could rewrite the scripts that every image build runs, or the files that devvm runs on this machine.
|
||||
- **Another name for one of these folders.** devvm compares the folders themselves, not only their names, so on a Mac, where a name's case doesn't count, `~/.Config/devvm` is refused as `~/.config/devvm` is.
|
||||
|
||||
When devvm refuses a folder, make the VM in a project folder inside it, or keep the project somewhere else. A [`--clone`](clone.md) VM mounts nothing from the folder, so devvm doesn't refuse its folder.
|
||||
|
||||
> [!WARNING]
|
||||
> If you mean to give the VM the whole folder, pass `--unsafe-folder` when you make the VM, and devvm warns you that the VM gets read-write access to it ([only the project folder](../internals/security.md#only-the-project-folder)).
|
||||
|
||||
A folder inside a coding agent's folder on this machine, such as a skill you work on in `~/.claude/skills`, or one that holds an agent's folder, such as `~/.pi`, isn't refused, but devvm warns at each launch, because code in the VM can change that agent's settings on this machine. Keep such a project somewhere else unless you trust what runs in its VM.
|
||||
|
||||
## Colors
|
||||
|
||||
In a terminal, devvm colors the labels and links around its messages, while the messages' own text stays in your terminal's usual color. The tables that devvm ls, devvm images, devvm space and devvm doctor print are colored too, and their columns line up the same with colors or without:
|
||||
|
||||
@@ -12,25 +12,25 @@ devvm, the tools it runs and Lima keep files on this machine outside your projec
|
||||
|
||||
| Column | |
|
||||
| --- | --- |
|
||||
| `WHAT` | `VMs`, `images`, `tools gnu` or `tools musl` for the shared tools' builds for each C library, `history` for the exports of agents' history, `network logs` for the VMs' logs and the daily tools check's log, `run logs`, `mise`, `packages` for the copies of [base's packages](images.md#base), `Nix cache` for the [shared Nix cache](toolchains.md#nix-projects), `leftover state` for the whole folder of each VM that `devvm gc --orphans` would forget, and `state` for the rest of devvm's data folder, which includes the rest of the VMs' folders |
|
||||
| `WHAT` | `VMs`, `images`, `tools gnu` or `tools musl` for the shared tools' builds for each C library, `history` for the exports of agents' history, `network logs` for the VMs' logs and the daily tools check's log, `run logs`, `mise`, `packages` for the copies of [base's packages](images.md#base), `cloud images` for devvm's copies of [Ubuntu's cloud images](#ubuntus-cloud-images), `Nix cache` for the [shared Nix cache](toolchains.md#nix-projects), `leftover state` for the whole folder of each VM that `devvm gc --orphans` would forget, and `state` for the rest of devvm's data folder, which includes the rest of the VMs' folders |
|
||||
| `COUNT`, `SIZE` | how many there are and the disk they take, in powers of 1024 (`2.1G`) |
|
||||
| `KEPT` | `remade` when devvm makes it again when it's needed, `only copy` for VMs and exports, which nothing else has, `log` for logs, `state` for what devvm knows of its VMs and images, and `leftover` |
|
||||
| `KEPT` | `remade` when devvm makes it again when it's needed, `only copy` for VMs and exports, which nothing else has, `log` for logs, `state` for what devvm knows of its VMs and images and for the cloud images, as a release that Ubuntu removed can't be downloaded again, and `leftover` |
|
||||
| `GC` | what `devvm gc` frees of it now, which for the Nix cache is what it takes beyond its cap |
|
||||
| `FREED BY` | what frees the rest, such as `devvm rm`, `images rm`, which deletes images that are current, or `gc --nix-cache` |
|
||||
| `FREED BY` | what frees the rest, such as `devvm rm`, `images rm`, which deletes images that are current, `gc --caches` or `gc --nix-cache` |
|
||||
| `RETAIN` | the [retention setting](settings.md#retention) that applies to the row when it's on, such as `30d`, with what it would delete now in brackets, and `-` when none is on |
|
||||
|
||||
Sizes count each file's blocks once, as `du` does. On macOS a Lima VM's disk shares its image's blocks until the VM writes them, so those blocks count for both the VM and its image, and the total can be more than the disk they take. When Lima doesn't answer while one of your VMs uses it, devvm says so, and its VMs and images aren't counted.
|
||||
|
||||
### Lima's caches
|
||||
|
||||
The second table lists the caches that belong to Lima, with what each cache holds, how many entries it has, its size and where it is. That's Lima's download cache. devvm's builds fill it, but it can also hold your own downloads, so it isn't in the total. The [Lima](#lima) section below says what it holds.
|
||||
The second table lists the caches that belong to Lima, with what each cache holds, how many entries it has, its size and where it is. That's Lima's download cache, which can hold your own downloads and the cloud images that earlier releases of devvm had Lima download, so it isn't in the total. The [Lima](#lima) section below says what it holds.
|
||||
|
||||
```sh
|
||||
devvm gc --caches # gc as usual, then free devvm's share of Lima's caches, after asking
|
||||
devvm gc --caches # gc as usual, then free the cloud images nothing needs, after asking
|
||||
devvm gc --caches --force # the same without asking, as a script must
|
||||
```
|
||||
|
||||
devvm never prunes these caches on its own. `devvm gc --caches` cleans up as `devvm gc` does, then frees devvm's share of them, which is what devvm's builds put there and nothing of devvm's needs. It lists the entries it would delete with their sizes and asks. Without a terminal it refuses unless you give `--force`, which frees them without asking.
|
||||
devvm never prunes these on its own. `devvm gc --caches` cleans up as `devvm gc` does, then frees devvm's copies of [Ubuntu's cloud images](#ubuntus-cloud-images) and devvm's share of Lima's caches that nothing of devvm's needs. It lists the entries it would delete with their sizes and asks. Without a terminal it refuses unless you give `--force`, which frees them without asking.
|
||||
|
||||
### devvm space --json
|
||||
|
||||
@@ -156,7 +156,11 @@ Once a VM's state is gone, `devvm gc` treats its shared tools like any others. `
|
||||
|
||||
### VMs devvm has no state for
|
||||
|
||||
A VM can also be the other way around: the backend has it, with devvm's label, but devvm has no state for it. Usually it belongs to another devvm, such as one run with another `XDG_DATA_HOME` for a test or a sandbox. `devvm space` names each one, with the data folder its label names, and devvm never deletes it, because the other devvm may still use it. To delete one yourself, run `devvm limactl delete NAME`.
|
||||
A VM can also be the other way around: the backend has it, with devvm's label, but devvm has no state for it. Usually it belongs to another devvm, such as one run with another `XDG_DATA_HOME` for a test or a sandbox. `devvm space` names each one, with the data folder its label names. devvm never deletes one, because the other devvm may still use it, but the next tools build and `devvm gc` delete the build VMs that a killed or failed tools build left, `devvm-tools-build` to `devvm-tools-build-4`. To delete any other yourself:
|
||||
|
||||
```sh
|
||||
devvm limactl delete NAME # delete the VM named NAME from devvm's Lima home
|
||||
```
|
||||
|
||||
### VMs whose folder is gone
|
||||
|
||||
@@ -182,13 +186,30 @@ These warnings never make doctor fail, and `devvm doctor --json` lists them in `
|
||||
|
||||
The Lima backend's VMs and images are in devvm's Lima home, `~/.local/share/devvm/lima`. Each image is a stopped VM named `devvm-img-<key>`, and each project VM is a clone of one. On macOS a clone's disk shares its image's blocks until the VM writes them, so `du` counts those blocks twice. On Linux hosts a VM's disk is an overlay of its image's. `devvm rm` deletes a VM, `devvm gc` deletes stale and unfinished images, and `devvm images rm` deletes any image you name.
|
||||
|
||||
Lima keeps a download cache of its own, `~/Library/Caches/lima` on macOS and `~/.cache/lima` on Linux, or `$XDG_CACHE_HOME/lima` when `XDG_CACHE_HOME` is set. When devvm builds base, Lima downloads Ubuntu's cloud image into that cache, which is 600 to 900 MB for each release, and on macOS it also keeps a copy converted to a raw disk, which takes about 2.4 GB more. The cache is Lima's and it isn't in devvm's Lima home, so your own Lima VMs' downloads share it.
|
||||
Lima keeps a download cache of its own, `~/Library/Caches/lima` on macOS and `~/.cache/lima` on Linux, or `$XDG_CACHE_HOME/lima` when `XDG_CACHE_HOME` is set. devvm gives Lima its own copy of Ubuntu's cloud image, so its builds add nothing to that cache. The cache can still hold the cloud images that earlier releases of devvm had Lima download, about 900 MB for each release, and on macOS a copy of each converted to a raw disk, which takes about 2.4 GB more. The cache is Lima's and it isn't in devvm's Lima home, so your own Lima VMs' downloads share it.
|
||||
|
||||
```sh
|
||||
devvm gc --caches # free devvm's share of Lima's cache, after asking
|
||||
```
|
||||
|
||||
devvm deletes something in it only when you run `devvm gc --caches`. Lima keeps each download in a folder named by the SHA-256 of its address, and gc frees only the folders of Ubuntu's cloud images at the address devvm downloads base from, for its Ubuntu release, that no image record of devvm's names and that haven't changed in the last hour. A cloud image that one of your own Lima VMs downloaded from that same address can be among them, and Lima downloads it again the next time it needs it. No VM needs its entry once it's made, because Lima copies the disk out of the cache. `limactl prune` deletes the whole cache, your own downloads included, so devvm never runs it.
|
||||
devvm deletes something in it only when you run `devvm gc --caches`, and only a folder of Ubuntu's cloud image that all of these hold for:
|
||||
|
||||
- **It's devvm's.** Lima keeps each download in a folder named by the SHA-256 of its address, and the folder's address is the one devvm downloads base from, for its Ubuntu release.
|
||||
- **devvm's own state names it.** An image record of devvm's names that address, as a build of base by an earlier release left it, and devvm now has its own copy of that image, which builds use instead. An image that no record names stays, as your own Lima VMs may have downloaded it.
|
||||
- **Lima's own templates don't use it.** devvm reads the templates of the `limactl` on your `PATH`, and when it can't read them, it frees nothing of Lima's cache, and the run log says why.
|
||||
- **It hasn't changed in the last hour.**
|
||||
|
||||
No VM needs its entry once it's made, because Lima copies the disk out of the cache. `limactl prune` deletes the whole cache, your own downloads included, so devvm never runs it, and you can run it yourself to free the rest.
|
||||
|
||||
### Ubuntu's cloud images
|
||||
|
||||
devvm keeps the Ubuntu cloud image that base starts from in `~/.local/share/devvm/images/ubuntu`, as `<sha256>.img`, about 900 MB for each release, and a download that stopped as `<sha256>.img.part`, which the next build goes on from. `devvm space` shows them as `cloud images`.
|
||||
|
||||
```sh
|
||||
devvm gc --caches # free the cloud images no image needs, after asking
|
||||
```
|
||||
|
||||
devvm keeps the image pinned now, which the next build of base needs, and each image that an image's record names, as Ubuntu removes its dated releases after a few months and building that image again needs the copy. `devvm gc --caches` frees the others, and a stopped download of any image once that image is there whole, unless one changed in the last hour. When devvm can't read which image is pinned, `devvm gc --caches` fails rather than free an image the pin may name ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)).
|
||||
|
||||
## Outside devvm's folders
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Once it finds Cursor's `cursor` command, `devvm cursor` reads that file, without
|
||||
|
||||
## Agent forwarding
|
||||
|
||||
SSH agent forwarding is off by default. While it's on and you're connected, anything in the VM, coding agents included, can *use* the agent's keys, for example to push, to log in to servers or to sign any data, as `ssh-keygen -Y sign` does. It can't copy them, or remove them, lock the agent or add keys to it ([the SSH agents](../internals/processes.md#the-ssh-agents)), except in a VM that has run since before you upgraded devvm to this release, until its next start. devvm warns of such a VM each time it opens it or changes its links, and `devvm restart` in its folder gives it the relay at once. Turn forwarding on for one VM when you need git over SSH there.
|
||||
SSH agent forwarding is off by default. While it's on and you're connected, anything in the VM, coding agents included, can *use* the agent's keys, for example to push, to log in to servers or to sign any data, as `ssh-keygen -Y sign` does. It can't copy or remove them, lock the agent or add keys to it ([the SSH agents](../internals/processes.md#the-ssh-agents)). Turn forwarding on for one VM when you need git over SSH there.
|
||||
|
||||
```sh
|
||||
devvm --ssh-agent # a new VM that forwards your SSH agent
|
||||
@@ -111,6 +111,7 @@ flowchart TD
|
||||
- `devvm --ssh-agent` creates the VM forwarding your agent. `devvm ssh-agent on`, `devvm` or `off` changes it for an existing VM from its next start, and `devvm ssh-agent` shows it. For a running VM, devvm asks in a terminal whether to restart it now, as `devvm restart` does, and otherwise, or without a terminal or with `--no-input`, the change waits for `devvm restart` or the VM's next start. Until then, each time devvm opens the running VM it asks in a terminal whether to restart it with the change, with no as the default unless an agent's new folders wait too ([restarting](vms.md#restarting-and-stopping)).
|
||||
- The choice applies to devvm's shells and to the ssh entries alike, both as the VM's current start was made with, so a change reaches neither until the VM next starts, whichever folder devvm runs from. When forwarding is on, an entry names the VM's own agent socket, `~/.local/share/devvm/run/agent-<hash>.sock`, as the agent, so an editor forwards the agent the VM started with however the editor was started. When forwarding is off, an entry says `ForwardAgent no`, whatever your own `Host *` settings say, and none of devvm's own connections to the VM carry your agent.
|
||||
- A VM started outside devvm, such as with `devvm limactl start`, gets no agent in its ssh entry, because nothing says which agent that start forwards. devvm's shells get its proxy's relay of the agent that devvm last started it with, if any, until devvm starts it again.
|
||||
- A VM that has run since before you upgraded devvm to this release can still remove the agent's keys, lock the agent and add keys to it until its next start. devvm warns of such a VM each time it opens it or changes its links, and `devvm restart` in its folder gives it the relay at once.
|
||||
- With forwarding off, git over SSH in the VM fails. devvm says so when it creates a VM for a repo whose `origin` is an SSH URL. Use an HTTPS remote with a GitHub token instead, or turn forwarding on.
|
||||
- **No keys loaded.** When a VM forwards your agent, the agent has no keys and `~/.ssh` has one, devvm offers to load it (`ssh-add --apple-use-keychain` on macOS). To keep it loaded across reboots, add `AddKeysToAgent yes`, and `UseKeychain yes` on macOS, under `Host *` in `~/.ssh/config`.
|
||||
- You can also use an agent that asks you to approve each use, such as 1Password's or Secretive.
|
||||
|
||||
@@ -15,8 +15,11 @@ devvm -v # open this folder's VM, showing each command's output
|
||||
devvm -v build base # the same for any command
|
||||
```
|
||||
|
||||
With `-v`, devvm shows each line on standard error as the log gets it, in place of the status line, and it still writes the log. When a step fails with `-v`, devvm names the log instead of printing its end again. Without `-v`, a status line in a terminal shows what devvm is waiting for, such as a command it runs, a check of the VM, a look through a folder or another devvm that's changing the same thing, with how long it has run and the log's latest line, and a step that takes more than a few seconds leaves a line with its time. With `-v`, or without a terminal, a wait for another devvm shows nothing. A warning prints above the status line, and a question takes the status line away until you answer it.
|
||||
With `-v`, devvm shows each line on standard error as the log gets it, in place of the status line, and it still writes the log. When a step fails with `-v`, devvm names the log instead of printing its end again.
|
||||
|
||||
- **The status line,** which devvm shows in a terminal without `-v`, says what devvm is waiting for, such as a command it runs, a check of the VM, a look through a folder or another devvm that's changing the same thing. It also shows how long the wait has run and the log's latest line, and a step that takes more than a few seconds leaves a line with its time.
|
||||
- **A wait for another devvm** shows nothing with `-v` or without a terminal.
|
||||
- **A warning** prints above the status line, and a question takes the status line away until you answer it.
|
||||
- **The log** is `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, one for each run that runs a command, which only you can read, and devvm keeps the newest 20, fewer when they take more than 256 MiB together.
|
||||
- **Each command** appears in it as a `+` line with its arguments, followed by its output, and a numbered step adds a `# [2/5] <step>` line first.
|
||||
- **Passwords and a VM's proxy key** stay out of it, written as `user:<password>@` and `devvm:<key>@`, including a company proxy's password from your shell's `HTTPS_PROXY` ([the run log](../internals/overview.md#the-run-log)).
|
||||
@@ -81,9 +84,15 @@ devvm deletes an interrupted new VM, with its state, until its first shell opens
|
||||
|
||||
## base can't build on Lima
|
||||
|
||||
On Lima, base starts from a dated release of Ubuntu's cloud image. The first time devvm builds base, it finds the newest release on cloud-images.ubuntu.com and pins it on this machine, so that build needs to reach Ubuntu's list of releases and the release's checksums. When it can't, devvm says so and pins nothing, so check that you're online and run the command again. When the newest release doesn't boot, devvm says so and builds base from the release before it ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)).
|
||||
On Lima, base starts from a dated release of Ubuntu's cloud image. The first time devvm builds base, it finds the newest release on cloud-images.ubuntu.com and pins it on this machine, then downloads that image, which takes a while on a slow link ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)). What devvm says tells you which of these went wrong:
|
||||
|
||||
Once an image is pinned, building base again needs Lima's cached copy of it or the release itself, which Ubuntu removes after a few months. Building the same base again also needs the copies of its packages that devvm kept from its first build, and when one of them is gone or changed, devvm names it and builds nothing ([base's packages](../internals/images.md#bases-packages)). Either way, start base again from the newest release and packages:
|
||||
- **It can't pin a release.** The first build needs to reach Ubuntu's list of releases and the release's checksums, and when it can't, devvm says so and pins nothing. Check that you're online and run the command again. When the newest release doesn't boot, devvm says so and builds base from the release before it.
|
||||
- **It couldn't download the image.** devvm keeps what came, so check that you're online, or that a company proxy lets the download through, and run the command again, which goes on from where the last try stopped.
|
||||
- **The server's certificate isn't valid.** When a CA this machine trusts signed a certificate that's out of date or for another host, devvm says so, for the list of releases and the image alike. Check that this machine's date and time are right, and that nothing on this network, such as a hotel's sign-in page, answers for that host. When the certificate fails for another reason, such as a weak signature from a network that inspects TLS, devvm names that reason, and trying again won't help. A certificate this machine doesn't trust at all needs your company's CA ([a company's CA](settings.md#a-companys-ca)).
|
||||
- **The release is gone.** Once an image is pinned, building base again needs devvm's copy of it, Lima's cached copy or the release itself, which Ubuntu removes after a few months, and devvm says when Ubuntu no longer has it.
|
||||
- **A package is gone or changed.** Building the same base again also needs the copies of its packages that devvm kept from its first build, and when one of them is gone or changed, devvm names it and builds nothing ([base's packages](../internals/images.md#bases-packages)).
|
||||
|
||||
When the release or a package is gone, start base again from the newest release and packages:
|
||||
|
||||
```sh
|
||||
devvm rebuild base # pin the newest cloud image again, and install the newest packages
|
||||
@@ -108,12 +117,14 @@ A VM's own state file, `vm.json` in its folder in `vms/`, is the one to fix rath
|
||||
- devvm doesn't know which shared tools such a VM uses or which folders it mounts, so `devvm space`, `devvm images` and `devvm gc` fail and name the file.
|
||||
- devvm refuses to add a key to its own SSH agent, or to load one into it as a VM starts, because it can't tell whether that VM mounts the key's folder.
|
||||
|
||||
To find every VM whose state devvm can't read, run doctor. It reads each VM's `vm.json` and each of its sections as every command on a VM reads them, and names each VM it can't read and why, the file included, once, even when it can't read the VM's folder, without changing anything. Such a VM doesn't hide doctor's other warnings, such as a line of another VM's policy file that isn't a rule. Every command on such a VM fails until you fix its file:
|
||||
Every command on such a VM fails until you fix its file. To find every VM whose state devvm can't read, run doctor:
|
||||
|
||||
```sh
|
||||
devvm doctor # warns of each VM whose vm.json, or a section of it, devvm can't read
|
||||
```
|
||||
|
||||
doctor reads each VM's `vm.json` and each of its sections as every command on a VM reads them, without changing anything. It names each VM it can't read once, with the file and why, even when it can't read the VM's folder, and such a VM doesn't hide doctor's other warnings, such as a line of another VM's policy file that isn't a rule.
|
||||
|
||||
## devvm says a newer release is out
|
||||
|
||||
When you run devvm in a terminal and a newer release is out, devvm says so in one line before it opens the VM, and it opens the VM as usual. Run `devvm upgrade` to install the release, or carry on with the devvm you have, because devvm never upgrades on its own. The line comes from devvm's daily check, and `devvm doctor` shows the newest release that check found and the day it found it. When you'd rather not see the line, set `release-check = false` in `config.toml`, or `DEVVM_NO_RELEASE_CHECK=1` in the environment ([the release check](settings.md#the-release-check)).
|
||||
@@ -156,7 +167,7 @@ If you press Ctrl+C while devvm starts a confined VM, devvm stops the VM and its
|
||||
|
||||
## The proxy doesn't start
|
||||
|
||||
A confined VM runs only with its proxy, so when the proxy doesn't start, devvm stops the VM, and the next `devvm` starts both again. When devvm refuses before it stops the proxy, such as when your company proxy's password isn't saved, the VM and its proxy run on while that proxy still enforces the VM's tier, and otherwise devvm stops the VM.
|
||||
A confined VM runs only with its proxy, so when the proxy doesn't start, devvm stops the VM, and the next `devvm` starts both again. When devvm refuses before it has stopped the running proxy, such as when your company proxy's password isn't saved, the VM and that proxy run on as long as the proxy still enforces the VM's tier. Otherwise devvm stops the VM.
|
||||
|
||||
- **The proxy didn't start:** read the log devvm names for why. A VM's is `proxy.log` in its logs folder, where the proxy's two processes, its broker and its child, each write their own lines, and a build's is `proxy.log` in the build proxy's `logs/` folder.
|
||||
- **Another program took the proxy's port:** devvm picks another port the next time it starts the VM, so run `devvm restart`.
|
||||
@@ -165,7 +176,7 @@ A confined VM runs only with its proxy, so when the proxy doesn't start, devvm s
|
||||
|
||||
## The proxy runs without a sandbox
|
||||
|
||||
The part of a VM's proxy that reads the VM's network runs in a sandbox, which keeps it from your files, your unix sockets, this machine's services on `localhost` and the rest of this machine if a VM ever took it over: macOS's on macOS, and Landlock and a seccomp filter on Linux. When the sandbox can't start, or the kernel has only part of it, the proxy runs with what there is, so the VM keeps its network, and devvm doctor warns for each running VM:
|
||||
The part of a VM's proxy that reads the VM's network runs in a sandbox, which is macOS's on macOS, and Landlock and a seccomp filter on Linux. If a VM ever took that part over, the sandbox keeps it from your files, your unix sockets, this machine's services on `localhost` and the rest of this machine. When the sandbox can't start, or the kernel has only part of it, the proxy runs with what there is, so the VM keeps its network, and devvm doctor warns for each running VM:
|
||||
|
||||
```sh
|
||||
devvm doctor # names each VM whose proxy runs without a sandbox
|
||||
@@ -173,12 +184,12 @@ tail ~/.local/share/devvm/vms/<hash>/logs/proxy.log # the proxy's own warnin
|
||||
devvm restart # in the VM's folder: start the proxy again, sandboxed if it can be
|
||||
```
|
||||
|
||||
- **sandbox-exec is missing:** macOS's `/usr/bin/sandbox-exec` runs the sandbox, and Lima's hostagent needs it too, so check that it's there, and run `devvm restart` once it is.
|
||||
- **sandbox-exec is missing:** macOS's `/usr/bin/sandbox-exec` runs the sandbox, and Lima's hostagent also needs it, so check that it's there, and run `devvm restart` once it is.
|
||||
- **sandbox-exec couldn't start it:** `proxy.log` has `sandbox-exec`'s own error, which says why, such as a profile that this macOS refused. Run `devvm restart` once you've fixed what it names, and if it names devvm's profile, report it as a bug ([reporting a bug](#reporting-a-bug)), with your macOS version.
|
||||
- **Its sandbox let it open a file it mustn't:** the sandbox started but didn't hold, so the proxy runs as if it had none. Report it as a bug ([reporting a bug](#reporting-a-bug)), with your macOS version.
|
||||
- **This kernel has no Landlock, or an older one, or no seccomp filters:** on Linux, the proxy gets what the kernel has. Check that Landlock is turned on with `cat /sys/kernel/security/lsm`, whose list should name `landlock`, and turn it on as your distribution's docs describe, or update the kernel: with Landlock's ABI 8 or later, or ABI 6 or 7 with its fix for signals between threads, and the seccomp filter, the proxy is fully confined. Then run `devvm restart`.
|
||||
- **This kernel has no Landlock, or an older one, or no seccomp filters:** on Linux, the proxy gets what the kernel has. Check that Landlock is turned on with `cat /sys/kernel/security/lsm`, whose list should name `landlock`, and turn it on as your distribution's docs describe, or update the kernel. The proxy is fully confined with the seccomp filter and Landlock's ABI 8 or later, or ABI 6 or 7 with its fix for signals between threads. Then run `devvm restart`.
|
||||
- **An older devvm started it:** a VM that ran as you upgraded devvm keeps the proxy that the older devvm started, one process without a sandbox, until devvm next opens the VM. Run `devvm` in the VM's folder, which starts its proxy again with the sandbox, while the VM runs on.
|
||||
- **devvm can't tell:** devvm doctor reads how the proxy is confined only from the proxy that runs now, which it knows by when the system says it started, so when it can't read that, it says it can't tell whether the proxy runs in its sandbox, and why. Run `devvm restart` in the VM's folder, and if the warning stays, report it as a bug ([reporting a bug](#reporting-a-bug)).
|
||||
- **devvm can't tell:** devvm doctor reads how the proxy is confined only from the proxy that runs now, which it knows by when the system says it started. When it can't read that, it says it can't tell whether the proxy runs in its sandbox, and why. Run `devvm restart` in the VM's folder, and if the warning stays, report it as a bug ([reporting a bug](#reporting-a-bug)).
|
||||
- **devvm can't confine it on this system yet:** this devvm, or this machine's architecture, has no sandbox for it, though devvm's releases for macOS and for Linux on Intel and Arm have one, so install a release ([installing devvm](../getting-started/install.md)).
|
||||
|
||||
[The child's sandbox](../internals/network.md#the-childs-sandbox) has what the sandbox allows and how the proxy decides to run without it.
|
||||
@@ -193,7 +204,11 @@ On the allowlist tier, a VM reaches only the hosts on its allowlist, and on the
|
||||
curl https://jenkins.corp.example.com/ # in the VM: the host's full name, not jenkins
|
||||
```
|
||||
|
||||
A block whose reason says that this machine's DNS has no address for the name means that a rule allows the name, but the proxy couldn't resolve it on this machine. So the block suggests no `devvm network allow` command, and `devvm network log --blocked` shows `-` for it. The proxy looks each name up as it's written, without this machine's DNS search domain, so a name without a dot, such as `jenkins`, which your other tools may reach as `jenkins.corp.example.com`, gets a reason that says to use the full name. Name the host in full in the tool's URL or settings. A block that says the DNS didn't answer in time, or can't resolve the name, names `proxy.log` on this machine, which holds the resolver's error ([inside the VM](../safety/network.md#inside-the-vm)).
|
||||
The proxy looks each name up on this machine as it's written, without this machine's DNS search domain, so name the host in full in the tool's URL or settings. What the block's reason says ([inside the VM](../safety/network.md#inside-the-vm)):
|
||||
|
||||
- **This machine's DNS has no address for the name:** a rule allows the name, but the proxy couldn't resolve it on this machine. So the block suggests no `devvm network allow` command, and `devvm network log --blocked` shows `-` for it.
|
||||
- **A name without a dot,** such as `jenkins`, which your other tools may reach as `jenkins.corp.example.com`, gets a reason that says to use the full name.
|
||||
- **The DNS didn't answer in time, or can't resolve the name:** the block names `proxy.log` on this machine, which holds the resolver's error.
|
||||
|
||||
## A tool that skips the proxy fails
|
||||
|
||||
@@ -280,7 +295,13 @@ devvm stop # in a running VM's folder
|
||||
devvm ls # which VMs run
|
||||
```
|
||||
|
||||
A stopped VM can give up its port to a VM that starts, and it gets another at its own next start. When the message says the ports are taken on this machine without naming your VMs, VMs that are starting or building have them, a running VM lists them to forward, which you change with `devvm ports` in its folder, or another program has them, such as another user's on this machine, whom you'd ask to end it. A VM that an older devvm started keeps its old ssh port until you stop it and start it again, and devvm warns of it at each launch until then ([the ssh port](../internals/lima.md#what-devvm-sets-on-a-vm)).
|
||||
A stopped VM can give up its port to a VM that starts, and it gets another at its own next start. When the message says the ports are taken on this machine without naming your VMs, one of these has them:
|
||||
|
||||
- **VMs that are starting or building.**
|
||||
- **A running VM that lists them to forward,** which you change with `devvm ports` in its folder.
|
||||
- **Another program,** such as another user's on this machine, whom you'd ask to end it.
|
||||
|
||||
A VM that an older devvm started keeps its old ssh port until you stop it and start it again, and devvm warns of it at each launch until then ([the ssh port](../internals/lima.md#what-devvm-sets-on-a-vm)).
|
||||
|
||||
## A VM won't boot
|
||||
|
||||
@@ -290,7 +311,7 @@ A Lima VM that doesn't answer over ssh within a minute of starting is stopped. R
|
||||
tail -n 100 ~/.local/share/devvm/lima/<vm>/serialv.log
|
||||
```
|
||||
|
||||
The log is `serialv.log`, or another `serial*.log`, in the VM's folder in devvm's Lima home, which is `~/.local/share/devvm/lima/<vm>/` unless you set `DEVVM_LIMA_HOME` ([Lima's limits](../backends/lima.md#limits)). A log that passed 10 MiB while the VM ran has its earlier lines in the same name with `.1` added, and its own start is then a long run of empty bytes, which is why `tail` reads it better than an editor.
|
||||
The log is `serialv.log`, or another `serial*.log`, in the VM's folder in devvm's Lima home, which is `~/.local/share/devvm/lima/<vm>/` unless you set `DEVVM_LIMA_HOME` ([Lima's limits](../backends/lima.md#limits)). A log that passed 10 MiB while the VM ran has its earlier lines in the same name with `.1` added, and the log then starts with a long run of empty bytes, so `tail` reads it better than an editor does.
|
||||
|
||||
## A VM whose creation didn't finish
|
||||
|
||||
@@ -320,7 +341,7 @@ devvm warns on each launch when an image the VM was made from has changed, and w
|
||||
|
||||
## A download doesn't check out
|
||||
|
||||
devvm checks Ubuntu's cloud image and its own mise against checksums before it uses them, and it refuses a download that doesn't match. Ubuntu's checksums must also carry a valid signature from Ubuntu's cloud image key, which devvm checks itself, with nothing to install. When devvm refuses one, try again later, and if it keeps failing, the server or the network between may be serving something else. In the same way, when `devvm rebuild base` finds Ubuntu's list of releases ending before the release that base starts from, it says so and keeps that release ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)).
|
||||
devvm checks Ubuntu's cloud image and its own mise against checksums before it uses them, and it refuses a download that doesn't match. A cloud image that doesn't match is downloaded again from nothing once before devvm refuses it, as a download that went on from an earlier try may have joined two versions of the server's file. Ubuntu's checksums must also carry a valid signature from Ubuntu's cloud image key, which devvm checks itself, with nothing to install. When devvm refuses one, try again later, and if it keeps failing, the server or the network between may be serving something else. In the same way, when `devvm rebuild base` finds Ubuntu's list of releases ending before the release that base starts from, it says so and keeps that release ([Ubuntu's cloud image](../internals/images.md#ubuntus-cloud-image)).
|
||||
|
||||
## A new tool release isn't there yet
|
||||
|
||||
|
||||
@@ -57,13 +57,13 @@ devvm upgrade tells how devvm was installed from where the devvm you ran is, and
|
||||
- **With Homebrew**, devvm is in Homebrew's Cellar, and devvm upgrade runs `brew upgrade devvm` after asking, or `brew upgrade devvm-rc` when you installed the formula for prereleases. Homebrew may upgrade Lima at the same time, because the formula needs it. Homebrew installs the release its formula names, which can come out a little after the release itself, so until then `brew upgrade devvm` finds nothing to upgrade.
|
||||
- **Any other way**, such as `go install`, a build from devvm's source, or a copy of devvm somewhere else, devvm upgrade can't upgrade. It says how that devvm was installed and how to upgrade it, such as with `go install github.com/devvmhq/devvm/cmd/devvm@latest`, and fails.
|
||||
|
||||
A devvm built without devvm's release key can't check a release's signature, so devvm upgrade refuses to install a release with it and says to run the install script again.
|
||||
A devvm built without a release key it can read can't check a release's signatures, so devvm upgrade refuses to install a release with it and says to run the install script again.
|
||||
|
||||
### What devvm upgrade checks
|
||||
|
||||
devvm upgrade downloads over HTTPS only, and checks each file before it uses the next:
|
||||
|
||||
1. It downloads the release's `SHA256SUMS` and its signature, `SHA256SUMS.minisig`, and checks that devvm's release key signed it for that release's version. The key is built into the devvm you have, so a replaced release can't bring its own.
|
||||
1. It downloads the release's `SHA256SUMS` and its signatures, and checks that the release key that has signed every release so far signed it for that release's version, or, once devvm has its three new release keys built in, that two of them did. The keys are built into the devvm you have, so a replaced release can't bring its own ([the release keys and the signatures](../internals/install.md#the-release-keys-and-the-signatures)).
|
||||
2. It downloads the archive for this machine and checks it against its checksum in `SHA256SUMS`.
|
||||
3. It unpacks the archive, which must hold only devvm's files in one folder.
|
||||
4. It runs the new devvm with `--version`, which must say the release's version.
|
||||
|
||||
@@ -64,7 +64,7 @@ devvm rm devvm-web-71a99b1076d92c # a VM whose folder is gone, by its name
|
||||
|
||||
`devvm rm` deletes this folder's VM together with what devvm keeps for it. That's the VM's state, its own allowlist, its network log, its `.git` locks or, for a `--clone` VM, the repo's `devvm` remote, and its ssh config entry ([deleting a VM](../internals/overview.md#deleting-a-vm)). It asks first in a terminal, and `--force` deletes without asking, which `devvm rm` needs when there's no terminal.
|
||||
|
||||
When the VM has an agent, devvm first exports the agents' history, unless you give `--no-export`, and when the export fails, devvm keeps the VM ([history](coding-agents.md#history)). For a `--clone` VM, devvm offers to fetch the branches this repo hasn't fetched, and it deletes the VM's uncommitted changes only after you confirm. `--no-clone-check` skips that check and warns you that the clone's unfetched commits and uncommitted changes go with the VM ([deleting the VM](clone.md#deleting-the-vm)).
|
||||
When the VM has an agent, devvm first exports the agents' history, unless you give `--no-export`, and when the export fails, devvm keeps the VM ([history](coding-agents.md#history)). For a `--clone` VM, devvm offers to fetch the branches this repo hasn't fetched, and it deletes the VM's uncommitted changes only after you confirm. `--no-clone-check` skips that check and warns you that the clone's unfetched commits and uncommitted changes go with the VM ([deleting the VM](clone.md#deleting-the-vm)). When the VM has opencode, devvm also checks the worktrees opencode made in it, which an export leaves out, and asks before their uncommitted changes go. It starts a stopped VM for that check, even with `--no-export`, and `--no-worktree-check` skips the check, so with `--no-export` as well, devvm deletes a stopped VM without starting it ([opencode's worktrees](coding-agents.md#opencodes-worktrees)).
|
||||
|
||||
Some VMs devvm deletes only after you confirm, and it asks these questions only in a terminal, where `--force` never answers them:
|
||||
|
||||
@@ -175,12 +175,16 @@ Each time `devvm` makes or opens the nested project's VM, it warns once and name
|
||||
|
||||
## A folder made again
|
||||
|
||||
A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself ([one VM per folder](../internals/security.md#one-vm-per-folder)). When that folder was deleted and a new one made at the same path, every command that opens, stops or changes the VM refuses it, such as `devvm`, `devvm stop`, `devvm restart` and `devvm tools`. A restart of your Mac can give the folder's disk another device number, but that doesn't make it a new folder, so the VM opens as before, unless the VM has recorded its folder's volume and the folder is on another volume now, such as a copy of the disk with a volume ID of its own, mounted at the same path. Two commands deal with a folder made again, and each acts only after you confirm in a terminal:
|
||||
A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself ([one VM per folder](../internals/security.md#one-vm-per-folder)). When that folder was deleted and a new one made at the same path, every command that opens, stops or changes the VM refuses it, such as `devvm`, `devvm stop`, `devvm restart` and `devvm tools`. Two commands deal with a folder made again, and each acts only after you confirm in a terminal:
|
||||
|
||||
- `devvm rm` deletes the VM and never exports its history, because its folder is gone. The VM may hold that project's work, so `--force` never answers this question.
|
||||
- `devvm adopt` gives the VM to this folder, with its files, secrets and allowlist. Its `.git` protection starts again, as if `.git` had just appeared. `devvm adopt --force` gives it without asking, which `devvm adopt` needs when there's no terminal.
|
||||
|
||||
When devvm can't read the folder at all, as when code in a VM that mounts it took away your read permission, it can't tell whether the folder is the VM's, so every command on the folder's VM refuses it, naming the folder and why it can't be read. Make the folder readable to you again, with `chmod u+rx` on it, and the VM opens as before. On Linux, once the VM has recorded its folder's volume, a Btrfs snapshot that you roll back to at the folder's path is another subvolume, so its folder is another folder too, as is the folder after you give its volume a new UUID, and you give it the VM with `devvm adopt`.
|
||||
What devvm does in the cases between:
|
||||
|
||||
- **A restart of your Mac** can give the folder's disk another device number, but that doesn't make it a new folder, so the VM opens as before. The exception is a VM that has recorded its folder's volume, when the folder is on another volume now, such as a copy of the disk with a volume ID of its own, mounted at the same path.
|
||||
- **A folder devvm can't read at all,** as when code in a VM that mounts it took away your read permission, leaves devvm unable to tell whether the folder is the VM's, so every command on the folder's VM refuses it, naming the folder and why it can't be read. Make the folder readable to you again, with `chmod u+rx` on it, and the VM opens as before.
|
||||
- **A Btrfs snapshot on Linux** that you roll back to at the folder's path is another subvolume, once the VM has recorded its folder's volume, so its folder is another folder, as is the folder after you give its volume a new UUID. You give it the VM with `devvm adopt`.
|
||||
|
||||
## A moved or renamed folder
|
||||
|
||||
@@ -215,12 +219,12 @@ codex resume ID # resume a session by its ID, wherever it started
|
||||
|
||||
opencode keeps the sessions of a git repo by the repo's first commit, so they follow the folder without any change. In a folder that isn't a git repo, opencode keeps sessions by the folder's path, so they stay under the old path.
|
||||
|
||||
devvm offers the move only when the folder at the new path is the folder the VM was made for, which devvm knows by its device, inode and birth time, or by its volume, inode and birth time after a restart gave its disk another device number ([one VM per folder](../internals/security.md#one-vm-per-folder)), and when nothing is at the old path any more, or only a symlink to the new path. There's no offer in these cases:
|
||||
devvm offers the move only when the folder at the new path is the folder the VM was made for, and when nothing is at the old path any more, or only a symlink to the new path. devvm knows the folder by its device, inode and birth time, or by its volume, inode and birth time after a restart gave its disk another device number ([one VM per folder](../internals/security.md#one-vm-per-folder)). There's no offer in these cases:
|
||||
|
||||
- **A copy:** a copy of the folder is another folder.
|
||||
- **Some file systems:** a folder on a file system that may give a new folder the inode number of a deleted one, such as a network share, a FUSE file system or a USB drive formatted with FAT or exFAT, never gets the offer. [One VM per folder](../internals/security.md#one-vm-per-folder) lists the file systems that do.
|
||||
- **Another user's folder:** devvm offers no VM for a folder that another user owns. On a Mac, a volume that ignores ownership, as disk images and external disks often do, shows every folder as yours, so there devvm can't tell another user's folder from yours, and you should check that a folder on it is yours before you say yes.
|
||||
- **Moved after a restart, before its volume was recorded:** a VM records its folder's volume when it's made, adopted or moved, and a VM made before records it at its first launch that finds its folder. Until then, a folder moved after a restart gets no offer, nor does one whose volume is still to check after a restart when devvm can't read the volume at the move either, because the restart may have given its disk another device number, and neither does a folder on a file system whose volume devvm can't tell, such as XFS or tmpfs on Linux. `devvm adopt VM` moves the VM to it.
|
||||
- **Another user's folder:** devvm offers no VM for a folder that another user owns. On a Mac, a volume that ignores ownership, as disk images and external disks often do, shows every folder as yours, so devvm can't tell another user's folder there from yours. Check that a folder on such a volume is yours before you say yes.
|
||||
- **Moved after a restart, before its volume was recorded:** a VM records its folder's volume when it's made, adopted or moved, and a VM made before records it at its first launch that finds its folder. Until then, a folder moved after a restart gets no offer, because the restart may have given its disk another device number. The same goes for a folder whose volume is still to check after a restart when devvm also can't read the volume at the move, and for a folder on a file system whose volume devvm can't tell, such as XFS or tmpfs on Linux. `devvm adopt VM` moves the VM to it.
|
||||
- **A `--clone` VM,** which keeps its own clone of the repo at the old path inside the VM.
|
||||
- **Several VMs:** when more than one VM was made for the folder at paths it had before, devvm moves none of them and names them, so you can choose one with `devvm adopt VM`.
|
||||
|
||||
@@ -236,11 +240,12 @@ When you delete or move a project folder, its VM stays, because the VM may hold
|
||||
devvm ls # the VMs, with (gone) after a folder that's gone
|
||||
devvm rm devvm-web-71a99b1076d92c # delete one by its name, after asking
|
||||
devvm rm devvm-web-71a99b1076d92c --no-export # a stopped one with an agent, without its history
|
||||
devvm rm devvm-web-71a99b1076d92c --no-export --no-worktree-check # a stopped one with opencode, without checking its worktrees
|
||||
```
|
||||
|
||||
`devvm rm VM` deletes a VM whose folder is gone, and you can run it in any folder. VM is the VM's name, as `devvm ls` lists it, or the alias that ssh reaches it by. In a terminal, devvm names the VM and its folder and asks before deleting it, with no as the default. `--force` deletes it without asking, which `devvm rm VM` needs when there's no terminal. Like `devvm rm`, it deletes what devvm keeps for the VM, and when the VM has an agent, devvm first exports the agents' history unless you give `--no-export` ([history](coding-agents.md#history)).
|
||||
|
||||
The export reads the history from the running VM. Starting a stopped VM would make its folder again, because Lima makes a missing folder that a VM mounts, so for a stopped VM with an agent devvm refuses and tells you to run `devvm rm VM --no-export`. If you moved the folder and want the history, run `devvm history export` or `devvm rm` in the folder at its new path, which moves the VM there first ([a moved or renamed folder](#a-moved-or-renamed-folder)). A `--clone` VM mounts no project folder, so devvm starts it to export the history. Its clone's work can't be fetched into a repo that's gone, though, so devvm refuses to delete it unless you give `--no-clone-check`, which deletes the VM and that work with it.
|
||||
The export reads the history from the running VM. Starting a stopped VM would make its folder again, because Lima makes a missing folder that a VM mounts, so for a stopped VM with an agent devvm refuses and tells you to run `devvm rm VM --no-export`. devvm reads opencode's worktrees from the running VM too, so for a stopped VM with opencode it tells you to run `devvm rm VM --no-export --no-worktree-check`. If you moved the folder and want the history, run `devvm history export` or `devvm rm` in the folder at its new path, which moves the VM there first ([a moved or renamed folder](#a-moved-or-renamed-folder)). A `--clone` VM mounts no project folder, so devvm starts it to export the history. Its clone's work can't be fetched into a repo that's gone, though, so devvm refuses to delete it unless you give `--no-clone-check`, which deletes the VM and that work with it.
|
||||
|
||||
Given this folder's own VM, `devvm rm VM` does what `devvm rm` does. It refuses these:
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
# a line here.
|
||||
getting-started: rocket
|
||||
using: wrench
|
||||
releases: information-circled
|
||||
safety: locked
|
||||
backends: cube
|
||||
compared: view-grid
|
||||
|
||||
+104
-20
@@ -11,10 +11,17 @@
|
||||
# Everything is in functions, so a download cut short runs nothing.
|
||||
set -euo pipefail
|
||||
|
||||
# Set by scripts/release.sh in the copy attached to a release: that release, and the public key its
|
||||
# SHA256SUMS is signed with (packaging/minisign.pub).
|
||||
# Set by scripts/release.sh in the copy attached to a release: that release, and the old release key's
|
||||
# public half (packaging/minisign.pub), which also signs each release while releases bridge from it.
|
||||
release_version=""
|
||||
minisign_key=""
|
||||
# The release keys' public halves, as packaging/keys has them (a test keeps them the same): two of
|
||||
# the three sign each release's SHA256SUMS, CI's, the co-signer's and the recovery key's, each in its
|
||||
# own SHA256SUMS.<role>.minisig. Empty while packaging/keys has none, and then only the old release
|
||||
# key's signature is checked.
|
||||
release_ci_key=
|
||||
release_cosign_key=
|
||||
release_recovery_key=
|
||||
repo_url=${DEVVM_REPO_URL:-https://github.com/devvmhq/devvm}
|
||||
|
||||
# Lima, when neither it nor Homebrew is there: its latest release, checked against its SHA256SUMS.
|
||||
@@ -143,24 +150,104 @@ resolve_version() {
|
||||
latest_release "$repo_url"
|
||||
}
|
||||
|
||||
# check_signature DIR: SHA256SUMS in DIR is signed by the release key (SHA256SUMS.minisig next to
|
||||
# it). A checksum from the same place as the archive only catches a damaged download; the signature,
|
||||
# made with a key the maintainer holds, also catches a release that someone else replaced. Needs
|
||||
# minisign: without it, says how to check by hand and carries on.
|
||||
# The release keys' roles, as their signatures' names have them.
|
||||
roles=(ci cosign recovery)
|
||||
|
||||
# role_key ROLE: that role's release key.
|
||||
role_key() {
|
||||
case $1 in
|
||||
ci) echo "$release_ci_key" ;;
|
||||
cosign) echo "$release_cosign_key" ;;
|
||||
recovery) echo "$release_recovery_key" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# download_signatures BASE: each of SHA256SUMS's signatures that the release at BASE has, into $tmp:
|
||||
# the release keys' and, while releases bridge from it, the old release key's (check_legacy), each
|
||||
# only when this script has its key. One that doesn't download is left out, so check_signature finds
|
||||
# it missing.
|
||||
download_signatures() {
|
||||
local r
|
||||
for r in "${roles[@]}"; do
|
||||
[[ -n $(role_key "$r") ]] || continue
|
||||
fetch -o "$tmp/SHA256SUMS.$r.minisig" "$1/SHA256SUMS.$r.minisig" 2>/dev/null || rm -f "$tmp/SHA256SUMS.$r.minisig"
|
||||
done
|
||||
[[ -z $minisign_key ]] || fetch -o "$tmp/SHA256SUMS.minisig" "$1/SHA256SUMS.minisig" 2>/dev/null ||
|
||||
rm -f "$tmp/SHA256SUMS.minisig"
|
||||
}
|
||||
|
||||
# check_signature DIR VERSION: SHA256SUMS in DIR is VERSION's, signed by two of the three release keys
|
||||
# (signed_by_two) or, while releases bridge from it, by the old release key (check_legacy). A checksum
|
||||
# from the same place as the archive only catches a damaged download; the signatures, made with keys
|
||||
# that the release's builders and the maintainer hold, also catch a release that someone else
|
||||
# replaced. Needs minisign: without it, says that only the checksum is checked, says how to check the
|
||||
# signatures by hand and carries on.
|
||||
check_signature() {
|
||||
local d=$1
|
||||
if [[ -z $minisign_key ]]; then
|
||||
warn "this install.sh has no release key (not from a release), so the signature isn't checked"
|
||||
return 0
|
||||
local d=$1 v=$2 r n=0 legacy=false names="" keys="release key"
|
||||
for r in "${roles[@]}"; do
|
||||
[[ -n $(role_key "$r") ]] || continue
|
||||
names+="SHA256SUMS.$r.minisig, " keys="release keys"
|
||||
[[ ! -f $d/SHA256SUMS.$r.minisig ]] || n=$((n + 1))
|
||||
done
|
||||
[[ -z $minisign_key || ! -f $d/SHA256SUMS.minisig ]] || legacy=true
|
||||
if ((n == 0)) && ! $legacy; then
|
||||
if [[ -z $minisign_key ]]; then
|
||||
warn "this install.sh isn't from a release and devvm $v has no signatures it can check, so only its checksum is checked"
|
||||
return 0
|
||||
fi
|
||||
die "couldn't download devvm $v's signatures (${names:+${names%, } or }SHA256SUMS.minisig)"
|
||||
fi
|
||||
if ! command -v minisign >/dev/null; then
|
||||
warn "minisign isn't installed, so devvm's signature isn't checked, only its checksum"
|
||||
echo " to check it yourself: minisign -Vm SHA256SUMS -P $minisign_key" >&2
|
||||
warn "minisign isn't installed, so only devvm's checksum is checked, which can't tell who made the release"
|
||||
if ((n >= 2)) || ! $legacy; then
|
||||
echo " to check it yourself, two of these must each print \"Trusted comment: devvm-release $v\":" >&2
|
||||
for r in "${roles[@]}"; do
|
||||
[[ ! -f $d/SHA256SUMS.$r.minisig ]] || echo " minisign -Vm SHA256SUMS -x SHA256SUMS.$r.minisig -P $(role_key "$r")" >&2
|
||||
done
|
||||
else
|
||||
echo " to check it yourself, this must print \"Trusted comment: devvm $v\":" >&2
|
||||
echo " minisign -Vm SHA256SUMS -P $minisign_key" >&2
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
minisign -Vqm "$d/SHA256SUMS" -x "$d/SHA256SUMS.minisig" -P "$minisign_key" >/dev/null 2>&1 ||
|
||||
die "devvm's SHA256SUMS isn't signed with the release key: not installed"
|
||||
say "signature checked"
|
||||
if ((n >= 2)) && signed_by_two "$d" "$v"; then
|
||||
say "signatures checked: two of devvm's three release keys"
|
||||
return 0
|
||||
fi
|
||||
if $legacy && check_legacy "$d" "$v"; then
|
||||
say "signature checked: devvm's old release key"
|
||||
return 0
|
||||
fi
|
||||
die "devvm's SHA256SUMS isn't signed with devvm's $keys: not installed"
|
||||
}
|
||||
|
||||
# signed_by_two DIR VERSION: two of the three release keys signed DIR's SHA256SUMS as VERSION's
|
||||
# release: each SHA256SUMS.<role>.minisig checks out with its own role's key, its trusted comment,
|
||||
# which minisign's global signature covers, is devvm-release VERSION, and two different keys made
|
||||
# them. -H takes only minisign's prehashed signatures, as devvm upgrade does.
|
||||
signed_by_two() {
|
||||
local d=$1 v=$2 r k comment seen=" " n=0
|
||||
for r in "${roles[@]}"; do
|
||||
k=$(role_key "$r")
|
||||
[[ -n $k && -f $d/SHA256SUMS.$r.minisig && $seen != *" $k "* ]] || continue
|
||||
comment=$(minisign -VHQm "$d/SHA256SUMS" -x "$d/SHA256SUMS.$r.minisig" -P "$k" 2>/dev/null) || continue
|
||||
[[ $comment == "devvm-release $v" ]] || continue
|
||||
seen="$seen$k "
|
||||
n=$((n + 1))
|
||||
done
|
||||
((n >= 2))
|
||||
}
|
||||
|
||||
# The bridge from the old release key, which devvm 0.1 and 0.2 check releases with: while it lasts,
|
||||
# each release is signed by it too, and its signature alone also passes, so --version installs a 0.1
|
||||
# or 0.2 release. It ends by deleting minisign_key, its download in download_signatures, its branch
|
||||
# in check_signature and check_legacy.
|
||||
# check_legacy DIR VERSION: the old release key signed DIR's SHA256SUMS as VERSION's release, with
|
||||
# the trusted comment devvm VERSION.
|
||||
check_legacy() {
|
||||
local comment
|
||||
comment=$(minisign -VHQm "$1/SHA256SUMS" -x "$1/SHA256SUMS.minisig" -P "$minisign_key" 2>/dev/null) || return 1
|
||||
[[ $comment == "devvm $2" ]]
|
||||
}
|
||||
|
||||
# in_use DIR: a running process names something in DIR, as a VM's proxy or QEMU does devvm's binary.
|
||||
@@ -180,11 +267,8 @@ install_devvm() {
|
||||
say "downloading devvm $v ($name)"
|
||||
fetch -o "$tmp/devvm.tar.gz" "$base/$name.tar.gz" || die "couldn't download $name.tar.gz"
|
||||
fetch -o "$tmp/SHA256SUMS" "$base/SHA256SUMS" || die "couldn't download devvm $v's checksums"
|
||||
if [[ -n $minisign_key ]]; then
|
||||
fetch -o "$tmp/SHA256SUMS.minisig" "$base/SHA256SUMS.minisig" ||
|
||||
die "couldn't download devvm $v's signature (SHA256SUMS.minisig)"
|
||||
fi
|
||||
check_signature "$tmp"
|
||||
download_signatures "$base"
|
||||
check_signature "$tmp" "$v"
|
||||
want=$(awk -v f="$name.tar.gz" '$2 == f { print $1 }' "$tmp/SHA256SUMS")
|
||||
got=$(sha256 "$tmp/devvm.tar.gz")
|
||||
[[ -n $want && $got == "$want" ]] || die "$name.tar.gz doesn't match its checksum: not installed"
|
||||
|
||||
@@ -507,60 +507,87 @@ func FuzzCapture(f *testing.F) {
|
||||
if err := json.Unmarshal(out, &vm); err != nil || vm == nil {
|
||||
t.Fatalf("the VM's reply isn't a JSON object: %q", out)
|
||||
}
|
||||
rest := withoutPlaceholders(t, vm)
|
||||
for _, tok := range tokens {
|
||||
if strings.Contains(rest, tok) && !keptElsewhere(r, tok) {
|
||||
t.Fatalf("the VM's reply holds the token %q: %s", tok, out)
|
||||
for _, s := range withoutPlaceholders(r, vm) {
|
||||
for _, tok := range tokens {
|
||||
if strings.Contains(s, tok) && !keptElsewhere(r, tok) {
|
||||
t.Fatalf("the VM's reply holds the token %q: %s", tok, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// withoutPlaceholders is the VM's reply as JSON without devvm's own placeholders, which a token
|
||||
// can match by chance (a short one is a prefix of fakeJWT's header): devvm-proxy-managed, and a
|
||||
// JWT-shaped placeholder whose header and claims are fakeJWT's, devvm's mark and an expiry.
|
||||
func withoutPlaceholders(t *testing.T, vm map[string]any) string {
|
||||
t.Helper()
|
||||
// withoutPlaceholders is every string in the VM's reply, its keys and values, nested ones
|
||||
// included, but what devvm itself wrote in its placeholders, which a token can match by chance (a
|
||||
// short one is a prefix of fakeJWT's header, whatever claims follow it): devvm-proxy-managed goes,
|
||||
// and a JWT-shaped placeholder, fakeJWT's header and mark, leaves only its claims, decoded, but
|
||||
// devvm's own (its mark and an expiry) and those that one of r's JWTs has as they are, the
|
||||
// account the VM's placeholders carry by design. Strings, not the reply's JSON, so that no token
|
||||
// matches across the JSON's quotes and braces, or misses one that JSON escapes.
|
||||
func withoutPlaceholders(r, vm map[string]any) []string {
|
||||
header := strings.SplitN(fakeJWT(nil), ".", 2)[0]
|
||||
rest := map[string]any{}
|
||||
var out []string
|
||||
for k, v := range vm {
|
||||
out = append(out, k)
|
||||
s, _ := v.(string)
|
||||
parts := strings.Split(s, ".")
|
||||
if s == managed || len(parts) == 3 && parts[0] == header && parts[2] == jwtMark && devvmClaims(parts[1]) {
|
||||
if s == managed {
|
||||
continue
|
||||
}
|
||||
rest[k] = v
|
||||
if parts := strings.Split(s, "."); len(parts) == 3 && parts[0] == header && parts[2] == jwtMark {
|
||||
if c, ok := placeholderClaims(r, parts[1]); ok {
|
||||
v = c
|
||||
}
|
||||
}
|
||||
out = appendStrings(out, v)
|
||||
}
|
||||
b, err := json.Marshal(rest)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(b)
|
||||
return out
|
||||
}
|
||||
|
||||
// devvmClaims reports whether seg, a JWT's encoded claims, holds only the claims devvm's
|
||||
// placeholders have: its mark and an expiry.
|
||||
func devvmClaims(seg string) bool {
|
||||
// placeholderClaims is seg, a JWT-shaped placeholder's encoded claims, decoded, without the claims
|
||||
// devvm adds to every placeholder (its mark and an expiry) and those that one of r's JWTs has
|
||||
// with the same value. It's false when seg isn't claims.
|
||||
func placeholderClaims(r map[string]any, seg string) (map[string]any, bool) {
|
||||
raw, err := base64.RawURLEncoding.DecodeString(seg)
|
||||
if err != nil {
|
||||
return false
|
||||
return nil, false
|
||||
}
|
||||
var c map[string]any
|
||||
if json.Unmarshal(raw, &c) != nil {
|
||||
return false
|
||||
if json.Unmarshal(raw, &c) != nil || c == nil {
|
||||
return nil, false
|
||||
}
|
||||
for k, v := range c {
|
||||
switch s, _ := v.(string); {
|
||||
case k == "devvm" && strings.HasPrefix(s, "placeholder-"):
|
||||
case k == "exp":
|
||||
if _, ok := v.(float64); !ok {
|
||||
return false
|
||||
if s, _ := c["devvm"].(string); strings.HasPrefix(s, "placeholder-") {
|
||||
delete(c, "devvm")
|
||||
}
|
||||
if _, ok := c["exp"].(float64); ok {
|
||||
delete(c, "exp")
|
||||
}
|
||||
for _, v := range r {
|
||||
s, _ := v.(string)
|
||||
for k, want := range jwtClaims(redact.NewSecret(s)) {
|
||||
if got, ok := c[k]; ok && reflect.DeepEqual(got, want) {
|
||||
delete(c, k)
|
||||
}
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
return c, true
|
||||
}
|
||||
|
||||
// appendStrings appends every string in v, decoded JSON, to out: a string, an object's keys and
|
||||
// values, and an array's items.
|
||||
func appendStrings(out []string, v any) []string {
|
||||
switch v := v.(type) {
|
||||
case string:
|
||||
out = append(out, v)
|
||||
case map[string]any:
|
||||
for k, e := range v {
|
||||
out = appendStrings(append(out, k), e)
|
||||
}
|
||||
case []any:
|
||||
for _, e := range v {
|
||||
out = appendStrings(out, e)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// keptElsewhere reports whether a field of r besides its tokens holds tok, which the VM's reply
|
||||
|
||||
@@ -741,13 +741,13 @@ var (
|
||||
// among other words replaced (shapeInText, schemeInText), the words around them kept.
|
||||
func scrubText(s string) string {
|
||||
s = urlInText.ReplaceAllStringFunc(s, scrubURL)
|
||||
s = shapeInText.ReplaceAllString(s, "${1}devvm-redacted")
|
||||
s = shapeInText.ReplaceAllString(s, "${1}"+RedactMark)
|
||||
return schemeInText.ReplaceAllStringFunc(s, func(m string) string {
|
||||
cred := schemeInText.FindStringSubmatch(m)[1]
|
||||
if !strings.ContainsAny(cred, "0123456789+/=") || strings.HasPrefix(cred, "/") || strings.HasPrefix(cred, "~/") {
|
||||
return m
|
||||
}
|
||||
return strings.TrimSuffix(m, cred) + "devvm-redacted"
|
||||
return strings.TrimSuffix(m, cred) + RedactMark
|
||||
})
|
||||
}
|
||||
|
||||
@@ -755,7 +755,7 @@ func scrubText(s string) string {
|
||||
// holds it: a known key's shape whole, else scrubText's.
|
||||
func scrubCommand(s string) string {
|
||||
if secretShape.MatchString(s) {
|
||||
return "devvm-redacted"
|
||||
return RedactMark
|
||||
}
|
||||
return scrubText(s)
|
||||
}
|
||||
@@ -787,7 +787,7 @@ func scrubURL(raw string) string {
|
||||
for k, vs := range q {
|
||||
for i, v := range vs {
|
||||
if v != "" && (secretName.MatchString(k) || secretLike(v)) {
|
||||
vs[i] = "devvm-redacted"
|
||||
vs[i] = RedactMark
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
@@ -798,7 +798,7 @@ func scrubURL(raw string) string {
|
||||
segs := strings.Split(u.Path, "/")
|
||||
for i, s := range segs {
|
||||
if secretLike(s) {
|
||||
segs[i] = "devvm-redacted"
|
||||
segs[i] = RedactMark
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
@@ -834,16 +834,16 @@ func scrubList(as []any) ([]any, bool) {
|
||||
}
|
||||
switch {
|
||||
case strings.HasPrefix(prev, "-") && !strings.Contains(prev, "=") && secretName.MatchString(prev) && !strings.HasPrefix(s, "-"):
|
||||
out[i], changed = "devvm-redacted", true
|
||||
out[i], changed = RedactMark, true
|
||||
case strings.HasPrefix(s, "-") && strings.Contains(s, "="):
|
||||
k, val, _ := strings.Cut(s, "=")
|
||||
if val != "" && (secretName.MatchString(k) || secretLike(val)) {
|
||||
out[i], changed = k+"=devvm-redacted", true
|
||||
out[i], changed = k+"="+RedactMark, true
|
||||
} else if u := scrubURL(val); strings.Contains(val, "://") && u != val {
|
||||
out[i], changed = k+"="+u, true
|
||||
}
|
||||
case secretLike(s):
|
||||
out[i], changed = "devvm-redacted", true
|
||||
out[i], changed = RedactMark, true
|
||||
case strings.Contains(s, "://") && scrubURL(s) != s:
|
||||
out[i], changed = scrubURL(s), true
|
||||
}
|
||||
@@ -923,14 +923,14 @@ func claudeVM(m map[string]any, salt string) map[string]any {
|
||||
s["args"], _ = scrubArgs(a)
|
||||
}
|
||||
for k := range obj(s, "env") {
|
||||
obj(s, "env")[k] = "devvm-redacted"
|
||||
obj(s, "env")[k] = RedactMark
|
||||
}
|
||||
https := claudeHost(s) != ""
|
||||
for _, h := range sortedKeys(obj(s, "headers")) {
|
||||
if https {
|
||||
obj(s, "headers")[h] = Placeholder("", claudeBindingName(n, h), salt)
|
||||
} else {
|
||||
obj(s, "headers")[h] = "devvm-redacted"
|
||||
obj(s, "headers")[h] = RedactMark
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ func agentSetting(path, k string) bool {
|
||||
return path == "env."+k && claudeEnv.MatchString(k) && !credName.MatchString(k)
|
||||
}
|
||||
|
||||
// redactMark is what the VM's copy holds in place of a secret.
|
||||
const redactMark = "devvm-redacted"
|
||||
// RedactMark is what the VM's copy holds in place of a secret.
|
||||
const RedactMark = "devvm-redacted"
|
||||
|
||||
// redactKeep: a value that names where a secret is rather than holding it.
|
||||
func redactKeep(v string) bool {
|
||||
switch {
|
||||
case v == "" || v == redactMark:
|
||||
case v == "" || v == RedactMark:
|
||||
return true
|
||||
case envName.MatchString(v): // an env var's name (Codex's env_key)
|
||||
return true
|
||||
@@ -180,7 +180,7 @@ func (r *redaction) str(s, path, k string, secret bool) string {
|
||||
keep := redactKeep(s) || plainValue.MatchString(s) || (url && !named) || agentSetting(path, k)
|
||||
if (secret && !keep) || secretShape.MatchString(s) { // a known key's shape, wherever it is
|
||||
r.paths = append(r.paths, path)
|
||||
return redactMark
|
||||
return RedactMark
|
||||
}
|
||||
out := s
|
||||
if url && !strings.ContainsFunc(s, unicode.IsSpace) { // else text holding URLs (scrubText)
|
||||
@@ -202,7 +202,7 @@ func (r *redaction) list(l []any, path string, keys []string, k string, secret b
|
||||
continue
|
||||
}
|
||||
if !redactKeep(s) {
|
||||
l[i], changed = redactMark, true
|
||||
l[i], changed = RedactMark, true
|
||||
} else if t := scrubText(s); t != s {
|
||||
l[i], changed = t, true
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ GITHUB_TOKEN = "DUMMY-GH" # a comment
|
||||
"model": "o4",
|
||||
"preferred_auth_method": "apikey",
|
||||
"model_providers.x.env_key": "OPENAI_API_KEY",
|
||||
"model_providers.x.http_headers.Authorization": redactMark,
|
||||
"model_providers.x.http_headers.Authorization": RedactMark,
|
||||
"mcp_servers.s.command": "npx",
|
||||
"mcp_servers.s.env.API_KEY": redactMark,
|
||||
"mcp_servers.t.env.GITHUB_TOKEN": redactMark,
|
||||
"mcp_servers.s.env.API_KEY": RedactMark,
|
||||
"mcp_servers.t.env.GITHUB_TOKEN": RedactMark,
|
||||
} {
|
||||
v := any(got)
|
||||
for _, k := range strings.Split(path, ".") {
|
||||
|
||||
@@ -29,7 +29,7 @@ const managedMark = "devvm-proxy-managed"
|
||||
// HasPlaceholder reports whether data holds a placeholder of a VM's copies: devvm-redacted, one
|
||||
// the proxy fills in, or a JWT-shaped one (a captured or copied login's tokens, fakeJWT).
|
||||
func HasPlaceholder(data []byte) bool {
|
||||
for _, m := range []string{redactMark, managedMark, jwtMark} {
|
||||
for _, m := range []string{RedactMark, managedMark, jwtMark} {
|
||||
if bytes.Contains(data, []byte(m)) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
go test fuzz v1
|
||||
byte('\x01')
|
||||
string(" ")
|
||||
[]byte("grant_type=authorization_code")
|
||||
[]byte("{\"access_token\":\"eyJhbGciOiJub25lIiwidHlwIj\",\"\":\"\",\"id_token\":\".eyJlbWFpbCI6ImFAYiIsImV4cCI6MTc5NDkyMDU2NiwiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS9hdXRoIjp7ImNoYXRncHRfYWNjb3VudF9pZCI6ImFjY3QtMSIsImNoYXRncHRfcGxhbl90eXBlIjoicHJvIn19.\",\"refresh_token\":\"r\"}")
|
||||
@@ -0,0 +1,5 @@
|
||||
go test fuzz v1
|
||||
byte('\x01')
|
||||
string(" ")
|
||||
[]byte("grant_type=authorization_code")
|
||||
[]byte("{\"access_token\":\"\\\"id_token\\\":{\\\"email\\\":\\\"a@b\\\"\",\"id_token\":\".eyJlbWFpbCI6ImFAYiIsImV4cCI6MTc5NDkyMDU2NiwiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS9hdXRoIjp7ImNoYXRncHRfYWNjb3VudF9pZCI6ImFjY3QtMSIsImNoYXRncHRfcGxhbl90eXBlIjoicHJvIn19.\",\"refresh_token\":\"r\"}")
|
||||
@@ -42,6 +42,9 @@ const (
|
||||
OpencodeConfig = ".config/opencode"
|
||||
// OpencodeData is opencode's data folder, which holds its login file and its database.
|
||||
OpencodeData = ".local/share/opencode"
|
||||
// OpencodeState is opencode's state folder: its prompt history (prompt-history.jsonl) and
|
||||
// the TUI's state, beside what is its machine's own, which an export leaves out.
|
||||
OpencodeState = ".local/state/opencode"
|
||||
// PiFolder is pi's agent folder: its settings, its logins (auth.json) and its sessions.
|
||||
PiFolder = ".pi/agent"
|
||||
// PiSettings is pi's settings.json, whose VM copy leaves out what undoes devvm's settings
|
||||
@@ -212,9 +215,9 @@ func SeedOf(rel string) (Seed, bool) {
|
||||
return Seed{}, false
|
||||
}
|
||||
|
||||
// MachineOwn reports whether rel, relative to the home folder, is in a seed's folder but in
|
||||
// none of its Entries: each machine's own, which neither devvm agent import nor devvm agent
|
||||
// save copies.
|
||||
// MachineOwn reports whether rel, relative to the home folder, is each machine's own, which
|
||||
// neither devvm agent import nor devvm agent save copies: in a seed's folder but in none of its
|
||||
// Entries, or an entry of a WholeFolder agent's Folder that its FolderOwn names, or below one.
|
||||
func MachineOwn(rel string) bool {
|
||||
for _, s := range Seeds() {
|
||||
if rest, ok := strings.CutPrefix(rel, s.Rel+"/"); ok {
|
||||
@@ -222,9 +225,31 @@ func MachineOwn(rel string) bool {
|
||||
return !slices.Contains(s.Entries, first)
|
||||
}
|
||||
}
|
||||
for _, d := range Defs {
|
||||
if rest, ok := strings.CutPrefix(rel, d.Folder+"/"); ok && d.WholeFolder {
|
||||
first, _, _ := strings.Cut(rest, "/")
|
||||
return slices.ContainsFunc(d.FolderOwn, func(p string) bool {
|
||||
m, _ := path.Match(p, first)
|
||||
return m
|
||||
})
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// MachineOwnFiles are every agent's FolderOwn, each relative to the home folder as a pattern of
|
||||
// the same form, in Defs' order: what a VM's setup takes out of the VM when it's a copy that an
|
||||
// earlier devvm gave it (guest/sync.sh's clean_machine_own).
|
||||
func MachineOwnFiles() []string {
|
||||
var out []string
|
||||
for _, d := range Defs {
|
||||
for _, p := range d.FolderOwn {
|
||||
out = append(out, d.Folder+"/"+p)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// LoginCmd is an agent's own login, as devvm agent login runs it in the VM, in a login shell:
|
||||
// each command line starts with the agent's command, or with env and its arguments.
|
||||
type LoginCmd struct {
|
||||
@@ -292,12 +317,28 @@ type Def struct {
|
||||
// TOML one as a settings file, Markdown as it is, and any other withheld, as devvm can't
|
||||
// take secrets out of it.
|
||||
WholeFolder bool
|
||||
// FolderOwn are the names of a WholeFolder agent's Folder's entries that are each machine's
|
||||
// own (MachineOwn), as path.Match patterns, such as opencode's service.json, which holds
|
||||
// its background service's password: never settings, so devvm agent import and devvm agent
|
||||
// save never copy them, no VM gets this machine's, and each VM's agent makes its own.
|
||||
FolderOwn []string
|
||||
// Logins are its login files, the one devvm agent import copies from the home folder
|
||||
// first.
|
||||
Logins []Login
|
||||
// History is what devvm rm exports of it from a VM, relative to the home folder, and
|
||||
// HistoryExcludes what of that an export leaves out: its logins.
|
||||
// HistoryExcludes what of that an export leaves out and an import never writes: its logins.
|
||||
History, HistoryExcludes []string
|
||||
// HistoryOwn is what of its History is the VM's own as a machine, such as a private key
|
||||
// that other machines trust, or what another VM must never take from it, such as a git
|
||||
// repository whose config can name a command that the agent's git runs: an export leaves
|
||||
// it out and an import never writes it, as HistoryExcludes, but a VM made again keeps
|
||||
// it, as that's the same machine.
|
||||
HistoryOwn []string
|
||||
// Worktrees are where in its HistoryOwn it makes git worktrees, relative to the home
|
||||
// folder, as patterns of each worktree's folder, as the shell reads them: an export leaves
|
||||
// them out, so their uncommitted changes go with the VM's disk, and the commands that delete
|
||||
// it check them first: devvm rm, and the commands that make a VM again, given --clean-home.
|
||||
Worktrees []string
|
||||
// Env is the guest environment its VMs' shells get: its self-updates and telemetry off.
|
||||
Env []Env
|
||||
// Secret is the secret (secrets.Known) every VM with the agent uses: Claude Code's token.
|
||||
@@ -413,12 +454,48 @@ var Defs = []Def{
|
||||
"agent", "agents", "command", "commands", "mode", "formatter", "lsp", "references",
|
||||
},
|
||||
NamedValues: []string{"permission", "permission.*", "agent.*.permission", "agent.*.permission.*"},
|
||||
Logins: []Login{{Opencode, OpencodeData + "/auth.json"}},
|
||||
History: []string{OpencodeData, ".local/state/opencode"},
|
||||
// From opencode v2.4.1's source (service-config.ts), its background service's settings:
|
||||
// service.json on its latest, dev, beta and next channels, service-<channel>.json on any
|
||||
// other (and an earlier build's service-<hash>.json), each written through
|
||||
// <file>.<pid>.tmp. They hold the service's password, which opencode makes when the file
|
||||
// has none, and with remote access on, the secret route it's served on.
|
||||
FolderOwn: []string{"service.json", "service-*.json", "service.json.*", "service-*.json.*"},
|
||||
Logins: []Login{{Opencode, OpencodeData + "/auth.json"}},
|
||||
History: []string{OpencodeData, OpencodeState},
|
||||
HistoryExcludes: []string{
|
||||
OpencodeData + "/auth.json", OpencodeData + "/account.json", OpencodeData + "/mcp-auth.json", OpencodeData + "/bin",
|
||||
},
|
||||
Env: []Env{{Name: "OPENCODE_DISABLE_AUTOUPDATE", Value: "1"}},
|
||||
// From opencode v2.4.1's source, what of its state folder is its machine's own:
|
||||
// machine/home-key, the private Ed25519 key of its home, which every machine it pairs
|
||||
// trusts and which it never replaces; its background service's registration, with the
|
||||
// service's password, service.json on its latest, dev, beta and next channels and
|
||||
// service-<channel>.json on the others (service-registration.ts, registration.rs),
|
||||
// written through <file>.<id>.tmp, beside <file>.pty-handoff, a terminal's handoff
|
||||
// ticket, written through <file>.pty-handoff.<uuid>.tmp (handoff.rs); and pty, its
|
||||
// terminals' daemons' sockets and the access tokens they take. Of its data folder, its git
|
||||
// repositories, whose config and attributes can name commands that git runs, such as a
|
||||
// clean filter or core.fsmonitor, which opencode's own git commands would then run in
|
||||
// another VM: snapshot, a repository for each project's snapshots, which opencode uses
|
||||
// again when it's there (snapshot.ts), repos, its cache of repositories, and worktree,
|
||||
// its git worktrees. Of its native client (cli-rs's plugin/src/loader/approval.rs, which
|
||||
// doesn't ship in 2.4.1), in its state folder: plugin-approvals.json, the project plugins you
|
||||
// approved, with its lock (.lock) and the temporary files it's written through
|
||||
// (.plugin-approvals.json.<pid>.<n>.tmp), and plugin-staged, the approved plugins' copies,
|
||||
// which it runs without hashing them again. A pattern holds *, as GNU tar's --exclude and the
|
||||
// shell read it.
|
||||
HistoryOwn: []string{
|
||||
OpencodeState + "/machine", OpencodeState + "/service.json", OpencodeState + "/service-*.json",
|
||||
OpencodeState + "/service.json.*", OpencodeState + "/service-*.json.*", OpencodeState + "/pty",
|
||||
OpencodeData + "/snapshot", OpencodeData + "/repos", OpencodeData + "/worktree",
|
||||
OpencodeState + "/plugin-approvals.json", OpencodeState + "/plugin-approvals.json.lock",
|
||||
OpencodeState + "/.plugin-approvals.json.*", OpencodeState + "/plugin-staged",
|
||||
},
|
||||
// From opencode v2.4.1's source (worktree/strategies.ts, worktree.ts): its worktree folder
|
||||
// is worktree/<the first 6 characters of the project's ID>/<the worktree's name> in its
|
||||
// data folder, made with git worktree add, unless its config's worktree.directory names
|
||||
// another.
|
||||
Worktrees: []string{OpencodeData + "/worktree/*/*"},
|
||||
Env: []Env{{Name: "OPENCODE_DISABLE_AUTOUPDATE", Value: "1"}},
|
||||
// Its Codex login to OpenAI (its methods chatgpt-browser and chatgpt-headless), whose
|
||||
// token endpoint the proxy captures: its Sign in with ChatGPT gets its tokens from
|
||||
// another endpoint, whose replies the proxy refuses.
|
||||
@@ -638,8 +715,21 @@ func LoginFiles() []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// HistoryExcludes are what an export of every agent's history leaves out, in Defs' order.
|
||||
// HistoryExcludes are what an export of every agent's history leaves out and an import never
|
||||
// writes, in Defs' order: each agent's HistoryExcludes, then its HistoryOwn.
|
||||
func HistoryExcludes() []string {
|
||||
var out []string
|
||||
for _, d := range Defs {
|
||||
out = append(out, d.HistoryExcludes...)
|
||||
out = append(out, d.HistoryOwn...)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// HistoryLogins are every agent's HistoryExcludes alone, in Defs' order, without its
|
||||
// HistoryOwn: what a VM made again leaves out of the old VM's history, as it's the same
|
||||
// machine.
|
||||
func HistoryLogins() []string {
|
||||
var out []string
|
||||
for _, d := range Defs {
|
||||
out = append(out, d.HistoryExcludes...)
|
||||
|
||||
@@ -148,16 +148,31 @@ func TestDefsWellFormed(t *testing.T) {
|
||||
t.Errorf("LoginOf(%s) = %v, %s, %v", l.Kind, got, a.Name, ok)
|
||||
}
|
||||
}
|
||||
for _, x := range d.HistoryExcludes {
|
||||
for _, x := range slices.Concat(d.HistoryExcludes, d.HistoryOwn) {
|
||||
if !slices.ContainsFunc(d.History, func(h string) bool { return x == h || strings.HasPrefix(x, h+"/") }) {
|
||||
t.Errorf("%s: history exclude %s is outside its history %v", d.Name, x, d.History)
|
||||
}
|
||||
}
|
||||
// A worktree's folder is one an export leaves out, which is why it's checked, and its
|
||||
// pattern goes to the VM's shell unquoted, so it's only of a path's plain characters and *.
|
||||
for _, p := range d.Worktrees {
|
||||
if !slices.ContainsFunc(d.HistoryOwn, func(o string) bool { return strings.HasPrefix(p, o+"/") }) ||
|
||||
strings.Trim(p, "abcdefghijklmnopqrstuvwxyz0123456789./-_*") != "" || path.Clean(p) != p {
|
||||
t.Errorf("%s: worktrees %q aren't a plain pattern below its HistoryOwn", d.Name, p)
|
||||
}
|
||||
}
|
||||
for _, p := range slices.Concat(d.Dirs, filesOf(d)) {
|
||||
if !strings.HasPrefix(p, d.Folder+"/") {
|
||||
t.Errorf("%s: setting %s is outside its folder %s", d.Name, p, d.Folder)
|
||||
}
|
||||
}
|
||||
// A pattern goes into the save's script as a case pattern and into the setup's
|
||||
// machine-own file as a glob, so it's only of a name's plain characters and *.
|
||||
for _, p := range d.FolderOwn {
|
||||
if _, err := path.Match(p, ""); err != nil || !d.WholeFolder || strings.Trim(p, "abcdefghijklmnopqrstuvwxyz0123456789.-_*") != "" {
|
||||
t.Errorf("%s: FolderOwn %q isn't a plain pattern of a WholeFolder agent's entry", d.Name, p)
|
||||
}
|
||||
}
|
||||
for _, s := range d.Seeds {
|
||||
if !slices.Contains(d.Dirs, s.Rel) || !strings.HasPrefix(s.Link, d.Folder+"/") || slices.Contains(d.Dirs, s.Link) || len(s.Entries) == 0 {
|
||||
t.Errorf("%s: seed %+v isn't one of its folders, or its link isn't a path of its own", d.Name, s)
|
||||
@@ -207,10 +222,12 @@ func TestSettingsFormat(t *testing.T) {
|
||||
// The lists of every agent's are each Def's, in Defs' order, and Of,
|
||||
// which code of one agent's own asks with its constant, finds it.
|
||||
func TestLists(t *testing.T) {
|
||||
var history, excludes, kinds []string
|
||||
var history, excludes, logins, kinds []string
|
||||
var env []Env
|
||||
for _, d := range Defs {
|
||||
history, excludes, env = append(history, d.History...), append(excludes, d.HistoryExcludes...), append(env, d.Env...)
|
||||
history, env = append(history, d.History...), append(env, d.Env...)
|
||||
excludes = append(append(excludes, d.HistoryExcludes...), d.HistoryOwn...)
|
||||
logins = append(logins, d.HistoryExcludes...)
|
||||
for _, l := range d.Logins {
|
||||
kinds = append(kinds, l.Kind)
|
||||
}
|
||||
@@ -218,9 +235,12 @@ func TestLists(t *testing.T) {
|
||||
if got := History(); !slices.Equal(got, history) || !slices.Contains(got, ClaudeJSON) {
|
||||
t.Errorf("History = %v", got)
|
||||
}
|
||||
if got := HistoryExcludes(); !slices.Equal(got, excludes) {
|
||||
if got := HistoryExcludes(); !slices.Equal(got, excludes) || !slices.Contains(got, OpencodeState+"/machine") {
|
||||
t.Errorf("HistoryExcludes = %v", got)
|
||||
}
|
||||
if got := HistoryLogins(); !slices.Equal(got, logins) || slices.Contains(got, OpencodeState+"/machine") {
|
||||
t.Errorf("HistoryLogins = %v", got)
|
||||
}
|
||||
if got := GuestEnv(); !slices.Equal(got, env) || !slices.Contains(got, Env{Name: "PI_TELEMETRY", Value: "0"}) {
|
||||
t.Errorf("GuestEnv = %v", got)
|
||||
}
|
||||
@@ -262,6 +282,21 @@ func TestSeeds(t *testing.T) {
|
||||
t.Errorf("MachineOwn(%s) = %v, want %v", rel, got, want)
|
||||
}
|
||||
}
|
||||
// opencode's service settings (opencode v2.4.1's service-config.ts): service.json on its
|
||||
// default channels, service-<channel>.json on the others, their temporary files, and
|
||||
// whatever is below an entry of that name; none of its other files, nor a file of that name
|
||||
// below a subfolder or another agent's folder.
|
||||
for rel, want := range map[string]bool{
|
||||
OpencodeConfig + "/service.json": true, OpencodeConfig + "/service-local.json": true,
|
||||
OpencodeConfig + "/service-0123abcd.json": true, OpencodeConfig + "/service.json.4242.tmp": true,
|
||||
OpencodeConfig + "/service-local.json.4242.tmp": true, OpencodeConfig + "/service.json/x": true,
|
||||
OpencodeConfig + "/opencode.json": false, OpencodeConfig + "/services.json": false, OpencodeConfig + "/service.jsonc": false,
|
||||
OpencodeConfig + "/agent/service.json": false, OpencodeConfig: false, ".claude/service.json": false,
|
||||
} {
|
||||
if got := MachineOwn(rel); got != want {
|
||||
t.Errorf("MachineOwn(%s) = %v, want %v", rel, got, want)
|
||||
}
|
||||
}
|
||||
env := GuestEnv()
|
||||
for _, v := range []Env{
|
||||
{Name: "CLAUDE_CODE_PLUGIN_CACHE_DIR", Value: ClaudePlugins, Home: true},
|
||||
|
||||
@@ -81,6 +81,15 @@ type Images interface {
|
||||
// cleanup), so the run log ends with what failed. The images it
|
||||
// leaves are in spec.Format, which is ToolFormat's.
|
||||
BuildTools(ctx context.Context, spec ToolsSpec) error
|
||||
// DeleteToolsLeft deletes the throwaway VMs BuildTools left: a killed
|
||||
// run's, or a failed build's whose cleanup found another devvm
|
||||
// holding the share's lock (ToolsSpec.Hold), and never another VM or
|
||||
// an image. It returns the VMs it deleted, those before a failure
|
||||
// included. The caller holds that lock, so no build of this data
|
||||
// folder's is using them (devvm gc), but a devvm with another data
|
||||
// folder and the same backend home holds a lock of its own. None for a
|
||||
// backend that leaves none.
|
||||
DeleteToolsLeft(ctx context.Context) ([]vmname.VM, error)
|
||||
// ToolFormat is the format of the tool images the backend's VMs
|
||||
// mount, which their keys hash: "" for the build script's own
|
||||
// (compressed EROFS), else a name of the backend's that changes
|
||||
@@ -175,11 +184,13 @@ type Housekeeping interface {
|
||||
// has no state for (devvm space), which devvm never deletes: they may
|
||||
// be another devvm's.
|
||||
Strays(ctx context.Context) ([]Stray, error)
|
||||
// DevvmCache lists devvm's share of the backend's own caches, which
|
||||
// devvm's builds fill (devvm gc --caches): entries only devvm's
|
||||
// builds make, that no image or VM of devvm's needs, never the
|
||||
// user's own. It changes nothing; none for a backend whose caches it
|
||||
// can't tell apart.
|
||||
// DevvmCache lists what the backend's builds downloaded that no
|
||||
// image or VM of devvm's needs (devvm gc --caches): devvm's share of
|
||||
// the backend's own caches, only entries devvm's own state shows its
|
||||
// builds made and that nothing of the backend's own uses, never one
|
||||
// that may be the user's, and the backend's downloads it keeps in
|
||||
// devvm's data folder, such as Lima's cloud images. It changes
|
||||
// nothing; none for a backend whose caches it can't tell apart.
|
||||
DevvmCache(ctx context.Context) ([]CacheEntry, error)
|
||||
// DeleteCache deletes entries DevvmCache listed, each checked again
|
||||
// first: one that isn't devvm's any more stays.
|
||||
@@ -240,13 +251,29 @@ func Check(ctx context.Context, b Backend) error {
|
||||
var ErrNotFound = errors.New("no such VM")
|
||||
|
||||
// LoggedError is a failure whose details are in the run log, from a
|
||||
// command run into it: the CLI shows it with the UI's ErrorLogged(e.Msg),
|
||||
// command run into it: the CLI shows it with the UI's ErrorLogged,
|
||||
// the log's end first, rather than the message alone.
|
||||
type LoggedError struct{ Msg msg.M }
|
||||
type LoggedError struct {
|
||||
Msg msg.M
|
||||
// Tag names the run log's lines of what failed, when it ran beside
|
||||
// others (msg.WithLogTag): the CLI shows those lines' end. "" for
|
||||
// every line's.
|
||||
Tag string
|
||||
}
|
||||
|
||||
// Logged returns m as a LoggedError.
|
||||
func Logged(m msg.M) error { return &LoggedError{Msg: m} }
|
||||
|
||||
// LoggedIn is err with its run log's lines tagged tag, when it's a
|
||||
// LoggedError of every line's: the failure of commands that ran beside
|
||||
// others under tag.
|
||||
func LoggedIn(err error, tag string) error {
|
||||
if e, ok := errors.AsType[*LoggedError](err); ok && e.Tag == "" {
|
||||
return &LoggedError{Msg: e.Msg, Tag: tag}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (e *LoggedError) Error() string { return e.Msg.Error() }
|
||||
|
||||
// Unwrap returns the message, so errors.As finds it.
|
||||
@@ -362,6 +389,22 @@ type ToolsSpec struct {
|
||||
// Trust is the user's CAs for the build VM: added before the script
|
||||
// runs (Remove isn't needed: the VM is deleted, only Out is kept).
|
||||
Trust Trust
|
||||
// Slot is which of the builds running at once this is, from 0: each
|
||||
// slot has a build VM of its own, which only one devvm uses at a
|
||||
// time, as builds hold the share's lock. Slots is how many this run
|
||||
// uses (0 is 1): the first slot's build deletes what a killed run
|
||||
// left in the others, which none of this run's builds uses.
|
||||
Slot, Slots int
|
||||
// Size is the build VM's CPUs and memory, for builds running side by
|
||||
// side; zero fields are base's.
|
||||
Size Size
|
||||
// Hold takes the share's lock again for the run's cleanup that
|
||||
// deletes a failed build's VM, which runs once the build has let go
|
||||
// of it: false when another devvm holds it (a build, gc or the daily
|
||||
// refresh), so the cleanup leaves the VM to the next tools build,
|
||||
// which deletes what it finds in the slots, or to the next gc
|
||||
// (DeleteToolsLeft). nil deletes it whatever holds the lock.
|
||||
Hold func() (release func(), ok bool)
|
||||
}
|
||||
|
||||
// Built is what a build reports, for the image's record and the build's
|
||||
|
||||
@@ -56,6 +56,19 @@ func TestLoggedError(t *testing.T) {
|
||||
if msg.IDOf(err) != m.ID() || err.Error() != m.Error() {
|
||||
t.Errorf("as its message: %v", err)
|
||||
}
|
||||
// Tagged for the lines of commands that ran beside others, once: a
|
||||
// tag it has stays, and an error that isn't one stays as it is.
|
||||
tagged := LoggedIn(err, "node")
|
||||
if le, ok := errors.AsType[*LoggedError](tagged); !ok || le.Tag != "node" || le.Msg.ID() != "start_failed" {
|
||||
t.Errorf("LoggedIn: %v", tagged)
|
||||
}
|
||||
if le, _ := errors.AsType[*LoggedError](LoggedIn(tagged, "bun")); le.Tag != "node" {
|
||||
t.Errorf("LoggedIn of a tagged error: %q, want node's tag kept", le.Tag)
|
||||
}
|
||||
if plain := errors.New("x"); LoggedIn(plain, "node") != plain { //nolint:errorlint // the very error given back, unwrapped
|
||||
|
||||
t.Error("LoggedIn changed an error that isn't a LoggedError")
|
||||
}
|
||||
}
|
||||
|
||||
// A start's RemountError is still its message, for errors.As and
|
||||
|
||||
@@ -45,6 +45,7 @@ type Subject struct {
|
||||
const (
|
||||
conformVM vmname.VM = "devvm-conformance-0123456789abcd"
|
||||
conformOther vmname.VM = "devvm-other-0123456789abce"
|
||||
conformTools vmname.VM = "devvm-tools-0123456789abcd" // a folder named tools: devvm-tools-, as build VMs' names start
|
||||
missingImage = "fedcba987654"
|
||||
)
|
||||
|
||||
@@ -119,6 +120,7 @@ func imageChecks() []check {
|
||||
{"delete-image", anySubject, checkDeleteImage},
|
||||
{"origin", anySubject, checkOrigin},
|
||||
{"build-image", booting, checkBuildImage},
|
||||
{"delete-tools-left", anySubject, checkDeleteToolsLeft},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,6 +281,34 @@ func checkDeleteImage(ctx context.Context, s Subject) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteToolsLeft deletes only what tool builds left, never another VM or
|
||||
// an image: with no build's VM there, it deletes nothing, and the checks'
|
||||
// VMs, a folder named tools' among them, and the image stay.
|
||||
func checkDeleteToolsLeft(ctx context.Context, s Subject) error {
|
||||
vms := []vmname.VM{conformVM, conformTools}
|
||||
for _, vm := range vms {
|
||||
if _, err := create(ctx, s, vm); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
deleted, err := s.Backend.DeleteToolsLeft(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("DeleteToolsLeft with none left: %w", err)
|
||||
}
|
||||
if len(deleted) > 0 {
|
||||
return fmt.Errorf("DeleteToolsLeft deleted %q, with none left", deleted)
|
||||
}
|
||||
for _, vm := range vms {
|
||||
if _, err := s.Backend.Inspect(ctx, vm); err != nil {
|
||||
return fmt.Errorf("Inspect %s after DeleteToolsLeft: %w, want the VM still there", vm, err)
|
||||
}
|
||||
}
|
||||
if ok, err := holds(ctx, s.Backend, s.Image); err != nil || !ok {
|
||||
return fmt.Errorf("DeleteToolsLeft deleted the image: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Base's origin steps, from Ubuntu or a container image, each have a name.
|
||||
func checkOrigin(_ context.Context, s Subject) error {
|
||||
for _, f := range []*backend.From{nil, {Ref: "debian:12", Digest: "debian@sha256:" + strings.Repeat("a", 64)}} {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/devvmhq/devvm/internal/backend"
|
||||
@@ -45,8 +46,46 @@ type (
|
||||
reachesStopped struct{ *Fake } // SSH reaches a stopped VM
|
||||
sizeless struct{ *Fake } // a VM without its size
|
||||
wrongProxy struct{ *Fake } // a proxy without the VM's password
|
||||
deletesAllVMs struct{ *Fake } // DeleteToolsLeft deletes every VM
|
||||
deletesImage struct{ *Fake } // DeleteToolsLeft deletes the image
|
||||
deletesByPrefix struct{ *Fake } // DeleteToolsLeft deletes every devvm-tools-* VM
|
||||
)
|
||||
|
||||
func (m deletesByPrefix) DeleteToolsLeft(ctx context.Context) ([]vmname.VM, error) {
|
||||
vms, err := names(ctx, m.Fake)
|
||||
var deleted []vmname.VM
|
||||
for _, vm := range vms {
|
||||
if !strings.HasPrefix(vm.String(), "devvm-tools-") {
|
||||
continue
|
||||
}
|
||||
if err := m.Delete(ctx, vm); err != nil {
|
||||
return deleted, err
|
||||
}
|
||||
deleted = append(deleted, vm)
|
||||
}
|
||||
return deleted, err
|
||||
}
|
||||
|
||||
func (m deletesAllVMs) DeleteToolsLeft(ctx context.Context) ([]vmname.VM, error) {
|
||||
vms, err := names(ctx, m.Fake)
|
||||
for _, vm := range vms {
|
||||
if err := m.Delete(ctx, vm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return vms, err
|
||||
}
|
||||
|
||||
func (m deletesImage) DeleteToolsLeft(ctx context.Context) ([]vmname.VM, error) {
|
||||
keys, err := m.Images(ctx)
|
||||
for _, k := range keys {
|
||||
if err := m.DeleteImage(ctx, k); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (m staleRun) Running(ctx context.Context, vm vmname.VM) (backend.Run, error) {
|
||||
r, err := m.Fake.Running(ctx, vm)
|
||||
r.ID = "start-1"
|
||||
@@ -123,6 +162,9 @@ func TestConformanceFinds(t *testing.T) {
|
||||
{"stopped", func(f *Fake) backend.Backend { return reachesStopped{f} }},
|
||||
{"create", func(f *Fake) backend.Backend { return sizeless{f} }},
|
||||
{"proxy-url", func(f *Fake) backend.Backend { return wrongProxy{f} }},
|
||||
{"delete-tools-left", func(f *Fake) backend.Backend { return deletesAllVMs{f} }},
|
||||
{"delete-tools-left", func(f *Fake) backend.Backend { return deletesImage{f} }},
|
||||
{"delete-tools-left", func(f *Fake) backend.Backend { return deletesByPrefix{f} }},
|
||||
} {
|
||||
s, f := fakeSubject(t)
|
||||
s.Backend = tc.wrap(f)
|
||||
|
||||
@@ -77,10 +77,13 @@ type Fake struct {
|
||||
Errs map[string]error // by method name: returned in place of its answer, changing nothing
|
||||
// ToolsBuild, when set, is what BuildTools does after recording the
|
||||
// call, in place of writing the images.
|
||||
ToolsBuild func(backend.ToolsSpec) error
|
||||
ToolsBuild func(context.Context, backend.ToolsSpec) error
|
||||
// ToolGlibc is the glibc version each tool's build says it needs, by
|
||||
// its name in the lock: none for a tool it doesn't name.
|
||||
ToolGlibc map[string]string
|
||||
// ToolsLeft is the build VMs DeleteToolsLeft says it deleted, as a
|
||||
// killed run would have left them: the fake's own builds leave none.
|
||||
ToolsLeft []vmname.VM
|
||||
// OnCall, when set, is given each call's method as it's recorded,
|
||||
// with the fake locked: a test checks what showed meanwhile, such as
|
||||
// a status line (msg.Fake.Showing).
|
||||
@@ -297,15 +300,17 @@ func ToolImage(file string) []byte {
|
||||
// BuildTools records the call, then runs ToolsBuild on the spec, or
|
||||
// writes each image its script would (every third argument, from the
|
||||
// third) into spec.Out as ToolImage, with FILE.glibc, the tool's
|
||||
// ToolGlibc.
|
||||
func (f *images) BuildTools(_ context.Context, spec backend.ToolsSpec) error {
|
||||
// ToolGlibc. Builds run side by side as a backend's would: only the
|
||||
// record is under the fake's lock.
|
||||
func (f *images) BuildTools(ctx context.Context, spec backend.ToolsSpec) error {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
if err := f.record("BuildTools", spec); err != nil {
|
||||
err := f.record("BuildTools", spec)
|
||||
f.mu.Unlock()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if f.ToolsBuild != nil {
|
||||
return f.ToolsBuild(spec)
|
||||
return f.ToolsBuild(ctx, spec)
|
||||
}
|
||||
for i := 2; i < len(spec.Args); i += 3 {
|
||||
file := spec.Args[i]
|
||||
@@ -323,6 +328,19 @@ func (f *images) BuildTools(_ context.Context, spec backend.ToolsSpec) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteToolsLeft records the call and returns ToolsLeft, then none: the
|
||||
// fake's builds leave no VM.
|
||||
func (f *images) DeleteToolsLeft(context.Context) ([]vmname.VM, error) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
if err := f.record("DeleteToolsLeft"); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
left := f.ToolsLeft
|
||||
f.ToolsLeft = nil
|
||||
return left, nil
|
||||
}
|
||||
|
||||
// ToolFormat returns Format.
|
||||
func (f *images) ToolFormat() string { return f.Format }
|
||||
|
||||
|
||||
@@ -156,3 +156,24 @@ func TestFakePresetErrors(t *testing.T) {
|
||||
t.Errorf("a failed CreateVM made a VM: %v, %v", ins, err)
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteToolsLeft is recorded, returns ToolsLeft once, and returns its
|
||||
// preset error: the fake's builds leave no VM to delete.
|
||||
func TestFakeDeleteToolsLeft(t *testing.T) {
|
||||
boom := errors.New("boom")
|
||||
f := New("fake", nil)
|
||||
f.ToolsLeft = []vmname.VM{"devvm-tools-build"}
|
||||
if got, err := f.DeleteToolsLeft(t.Context()); err != nil || !slices.Equal(got, []vmname.VM{"devvm-tools-build"}) {
|
||||
t.Fatalf("DeleteToolsLeft: %v, %v", got, err)
|
||||
}
|
||||
if got, err := f.DeleteToolsLeft(t.Context()); err != nil || got != nil {
|
||||
t.Fatalf("DeleteToolsLeft again: %v, %v, want none", got, err)
|
||||
}
|
||||
f.Errs = map[string]error{"DeleteToolsLeft": boom}
|
||||
if _, err := f.DeleteToolsLeft(t.Context()); !errors.Is(err, boom) {
|
||||
t.Errorf("DeleteToolsLeft: %v, want %v", err, boom)
|
||||
}
|
||||
if got := f.Methods(); len(got) != 3 || got[0] != "DeleteToolsLeft" {
|
||||
t.Errorf("calls %v", got)
|
||||
}
|
||||
}
|
||||
@@ -17,13 +17,18 @@ type Floors struct {
|
||||
Base uint64 // building base
|
||||
Image uint64 // building any other image
|
||||
VM uint64 // making a VM, with its first launch
|
||||
// Tools and PerTool are what a shared tools build wants: Tools, and
|
||||
// PerTool more for each tool it builds.
|
||||
// Tools and PerTool are what a shared tools build wants: Tools for
|
||||
// each build VM running at once, and PerTool more for each tool it
|
||||
// builds.
|
||||
Tools, PerTool uint64
|
||||
}
|
||||
|
||||
// ForTools is what building n shared tool images wants.
|
||||
func (f Floors) ForTools(n int) uint64 { return f.Tools + count(n)*f.PerTool }
|
||||
// ForTools is what building n shared tool images wants, in slots build
|
||||
// VMs at once (at least one): each a copy of base, which a disk without
|
||||
// copy on write holds whole.
|
||||
func (f Floors) ForTools(slots, n int) uint64 {
|
||||
return count(max(slots, 1))*f.Tools + count(n)*f.PerTool
|
||||
}
|
||||
|
||||
// count is n, a number of tools, as a uint64; none when negative.
|
||||
func count(n int) uint64 {
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestSpaceCheck(t *testing.T) {
|
||||
},
|
||||
{
|
||||
// 3 GiB and 0.5 more for each of three tools, 4.5, is rounded up.
|
||||
"rounded up to whole GiB", b, func(f backend.Floors) uint64 { return f.ForTools(3) },
|
||||
"rounded up to whole GiB", b, func(f backend.Floors) uint64 { return f.ForTools(1, 3) },
|
||||
freeOf(map[string]uint64{"/lima": 9 << 29}, nil),
|
||||
"disk_low dir=/lima free=4.5 name=node need=5",
|
||||
},
|
||||
@@ -93,8 +93,16 @@ func TestSpaceCheckDir(t *testing.T) {
|
||||
|
||||
func TestForTools(t *testing.T) {
|
||||
f := backend.Floors{Tools: 3 << 30, PerTool: 512 << 20}
|
||||
if got := f.ForTools(10); got != 8<<30 {
|
||||
t.Errorf("ForTools(10) = %d", got)
|
||||
if got := f.ForTools(1, 10); got != 8<<30 {
|
||||
t.Errorf("ForTools(1, 10) = %d", got)
|
||||
}
|
||||
// Four build VMs at once, each one a copy of base where the disk has
|
||||
// no copy on write.
|
||||
if got := f.ForTools(4, 10); got != 17<<30 {
|
||||
t.Errorf("ForTools(4, 10) = %d", got)
|
||||
}
|
||||
if got := f.ForTools(0, 10); got != 8<<30 {
|
||||
t.Errorf("ForTools(0, 10) = %d, want one build VM's", got)
|
||||
}
|
||||
if got := backend.ToolImages(10); got != 3<<30 {
|
||||
t.Errorf("ToolImages(10) = %d", got)
|
||||
|
||||
Loaded 100 of 345 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user