180 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 ffacfb75ef fix(bump): e2e-tools reads mise's 404 when mise prints in color
On CI mise prints its log in color, so unpublished's ^mise ERROR match
missed the 404 and the run failed with "mise lock failed" instead of
waiting for upstream. mise lock now runs with MISE_COLOR=0, and
unpublished strips SGR escapes before it reads the errors and the
Processing line.

bump.txtar: a stub log with CI's colored lines, and the stub records
the MISE_COLOR it was run with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 09:13:04 -07:00
w3cjandClaude Opus 5.5 bc185ec80e fix(release): every file release.sh writes is 0755 or 0644, whatever the umask
minisign writes its signatures with the process umask, so on a host
whose umask is 0002, as Ubuntu's is, dist/SHA256SUMS.minisig came out
0664, and --ci-sign's SHA256SUMS.ci.minisig, --sign-legacy's signature,
--formula-from's formulas and --ci's folder for the co-signer were
group-writable too. release.sh now sets umask 022 once at its top, for
the host and the container alike, in place of the two copies in build
and modules.

release_head.txtar's modes check builds under umask 0002, checks the
signature is 0644, and labels the catch-all lines so a stray mode can't
pass as an expected one; release_ci.txtar's --ci-sign runs under umask
0002 and checks its signature is 0644. Both failed before the fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 07:35:02 -07:00
w3cjandClaude Opus 5.5 2cc9d8c862 fix(bump): e2e-tools waits for a release that isn't published everywhere yet
When a shared tool's newest version, newer than tests/e2e-mise.lock's, has
no download for a platform yet (mise lock stopping on a 404, as for Node
24.23.0's linux-arm64-musl build, a lock entry without a checksummed
download, or a dotnet SDK without its archive), e2e-tools names the tool,
version and platform. --check reports it as waiting for upstream and goes
on, so the weekly Pins workflow passes; applying prints mise's output,
stops, to try again later, and writes no lock.

After a 404 wait, --check holds that tool back in its copy of mise.toml
(at the e2e lock's version, or left out when the lock has none) and runs
mise lock again, so the other tools are still reported and their
failures still stop the run. A tool is held back once at most: its 404
again fails the run, so the loop ends. The Pins workflow's issue lists
the waiting lines in their own Waiting for upstream section and stays
open while any is there, and maintaining.md says to look at a wait that
lasts two weeks, and to bump the other pins by name meanwhile, since a
plain run stops at e2e-tools.

Real failures still stop the run: a 404 or missing download for a version
the lock already has, a checksum mismatch, any other mise lock error, an
unfetchable releases.json, and a dotnet entry its downloads can't go into.
A 404 counts as unpublished only when it's mise's only ERROR line, apart
from its Version: and Run with --verbose trailer, and never a WARN, so a
checksum mismatch beside a 404 fails. dotnet's downloads go only after
the specifiers line of dotnet's own entry, which ends at the next [
header, and only dotnet_downloads' own wait (dotnet_waited) skips
dotnet's checksum check.

It waits rather than stepping back as devvm does for users: a step back
in bash would copy internal/tools' stepBack, and the next run retries.

New in scripts/bump.sh: newer, not_yet, unpublished, hold_back, the
waiting and dotnet_waited flags. bump.txtar covers the musl 404 with the
rest still reported (the tool left out, and held at the lock's version),
a held tool's 404 again, the lock-version 404, a checksum mismatch alone,
beside a 404 ERROR and beside a WARN-level .sig 404, a WARN-level 404
alone, a 404 whose URL holds two tools' versions, mise's output on the
apply path, dotnet waiting (reported once, for its own platform) and its
control, an unfetchable releases.json against the older lock, a tool
missing checksums reported once with the rest still reported, a dotnet
entry missing a checksum while another tool waits, and a dotnet entry
without specifiers before another tool's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 07:35:02 -07:00
w3cjandClaude Opus 5.5 b5c58d82b8 fix(tools): a platform's missing download (a 404) steps the tool back, not failing the resolve
mise 2026.11 (devvm's host mise since 0.2.0-rc.1) downloads some files as
it locks them and fails the whole `mise lock`, writing nothing, when one is
a 404. So while Node 24.23.0 had no musl builds on unofficial-builds,
Versions.Resolve returned tools_resolve_failed: a first run stopped, and
the daily check and devvm tools update kept their versions. The step back
only handled a lock that succeeded with an entry lacking a download.

- lockAll: after a full lock whose own log shows a 404, lock each tool on
  its own, and a tool that still fails one platform at a time, so its entry
  lacks only the missing platform and stepBack steps it back. Any other
  failure in the fallback is resolveFailed's.
- lockTool: one lock, its log started again, missing only on its own 404.
- olderWithDownload/lockVersions: when the step back's lock of its older
  versions 404s, lock them one at a time.
- logSays: shared by resolveFailed.
- Stub mise: MISE_STUB_FAIL=404 and MISE_STUB_OFFLINE_TOOL; per-tool,
  per-platform merging checked against real mise 2026.11.14.
- Tests: TestRefreshStepsBackPastA404, TestMise404.

Checked against real mise 2026.11.14: node steps back to 24.22.3, the
other 12 tools at their newest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 07:35:02 -07:00
w3cjandClaude Opus 5.5 c09875c55d fix(bump): e2e-tools downloads devvm's host mise as its pinned .tar.gz
devvm's host mise pin (internal/tools/mise.go's miseSHA256) has been the
SHA-256 of mise's .tar.gz since mise was downloaded as its archive, and
bump.sh mise writes it from SHASUMS256.txt's .tar.gz lines, but
bump_e2e-tools still downloaded the raw binary (mise-v$v-$os-$a) and
hashed it against that pin, so every e2e-tools run, the Pins workflow's
--check included, stopped with "devvm's host mise ... doesn't match its
pinned SHA-256". It now downloads mise-v$v-$os-$a.tar.gz, as miseURL
does, checks it against the pin, and runs the mise/bin/mise it takes out.

Its hashes, and e2e-from's and e2e-curl's digests, go through the
script's sha256 helper rather than shasum, which Fedora lacks.

bump.txtar's new case runs bump.sh mise and then e2e-tools on a release
whose .tar.gz and raw binary have their own SHA-256s, as a real one does:
the lock is resolved by the archive's mise, with dotnet's downloads and
the mise.toml's SHA-256, and an archive that isn't the pinned one is
refused before its mise runs. It failed on the old script with the
Pins workflow's error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-01 05:19:12 -07:00
w3cjandClaude Opus 5.5 0c6ee50ff5 fix(bump): GitHub's API calls send the workflow's token
The Pins workflow's run on 30 November failed right after nix with
"curl: (22) The requested URL returned error: 403". The next call was
direnv's gh_latest, an unauthenticated curl to api.github.com: GitHub
allows 60 of those an hour from one address, which a hosted runner
shares with other jobs, and answers 403 once they're spent. The workflow
already set GH_TOKEN and GITHUB_TOKEN for gh, but curl never sent them.

gh_api now makes every GitHub API call (gh_latest, gh_head and Lima's
release), with GH_TOKEN or else GITHUB_TOKEN when one is set, written
to a header file in the run's temp folder (mode 600) and passed as
-H @FILE, so it's on no command line and goes to api.github.com alone.
A failed fetch now names its URL, which the failed run's log didn't.

bump.txtar's curl stub records the header files it reads, and the test
checks that GitHub's API gets GITHUB_TOKEN, and GH_TOKEN when both are
set, that for each no other URL and no argument gets it, that no call
has a header without one, and that a failed fetch names its URL. It
fails on the old script. Contributing's Updating pinned versions and
the Pins workflow's comment say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 23:15:59 -07:00
w3cjandClaude Opus 5.5 22d0abe38e fix(agentlogin): FuzzCapture looks for tokens in what placeholders carry, not their fixed parts
The nightly fuzz run failed FuzzCapture for four days on one input: a
26-character access token, "eyJhbGciOiJub25lIiwidHlwIj", which is a prefix
of fakeJWT's fixed header, with an id_token carrying account claims (an
email and an OpenAI account). The VM's reply held only placeholders; the
check matched the token against devvm's own header in the id_token's
placeholder. The earlier fix skipped a placeholder only when its claims
were devvm's mark and an expiry alone, so a placeholder that carries an
account's claims, as Codex's and opencode's do, still had its header
checked.

The test's oracle was wrong, not devvm. It now looks for each token in
every string of the VM's reply, keys and nested values included, rather
than in its JSON, so no token matches across quotes and braces or misses
one that JSON escapes. A JWT-shaped placeholder (fakeJWT's header and mark)
stands for its decoded claims, without devvm's mark and expiry and without
any claim that one of the reply's own JWTs has with the same value, the
account the placeholders carry by design. Plain fields keep the strict
rule: only a non-token field of the reply excuses a token.

The oracle still catches a leak: accountClaims made to copy the token into
a claim fails FuzzCapture on six seeds. Eight minutes of fuzzing found
nothing more. The corpus gets the crash input, ed0b7ccd0f55eed0, and
placeholder-claims-json, a token shaped like the claims' JSON
('"id_token":{"email":"a@b"'), which fails a check on the reply's JSON.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 23:15:59 -07:00
w3cjandClaude Opus 5.5 a56552dd4f docs(release): the release process through CI and the co-signer, and the bridge's end
- maintaining.md's Releasing: the maintainer's part is git tag -s and
  scripts/publish.sh, then approving the Release workflow's run and,
  while the bridge lasts, publish.sh --sign-legacy, with what the
  default mode and --sign-legacy check and ask; Publishing from this
  machine, --local, which stays until GitHub is set up and the first
  release through CI is out, and goes when the bridge ends at the
  latest; The release script, its own heading, with --check-tag; the
  prerelease and tap rules as the co-signer and --local follow them;
  the scripts' tests.
- The bridge from the old release key, a heading of its own: each
  release through CI carries the old key's signature, which the
  co-signer waits for; it ends with a release after at least two
  releases through CI and a few weeks of 0.1 and 0.2's daily check,
  which takes out legacy.go's fallback, check_legacy and minisign_key,
  still carries SHA256SUMS.minisig itself, and has a What to do step
  for 0.1 and 0.2 users (devvm upgrade --to it, or the install
  script); then legacy_key, --sign-legacy, --local and release.sh's
  old-key signing go.
- cosigner.md: releases go through it once GitHub is set up, and the
  bridge's signature comes from publish.sh --sign-legacy; only a run a
  tag's push started counts, init's latest older than a release it
  published is an alert, and a release older than one it published
  isn't made GitHub's latest.
- Approve only a run for the tag you just pushed, as approving gives
  CI's key to that tag's code (maintaining.md's Releasing).
- structure.md's scripts row.
- The 0.2.0 release page: Releases through CI and the co-signer, and
  the co-signer's section's build failures and latest check; the
  changelog's internal line. Users act on nothing until the bridge
  ends, so no What to do line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 7874354a15 docs(release): the GitHub setup that releases through CI and the co-signer need
contributing/github-setup.md, the maintainer's checklist, in order, each
step with its clicks and, where GitHub's API does the same, the gh api
command to read, check against GitHub's docs and run, never run for
them:

1. the three release keys, each where its holder keeps it, and the CI
   key deleted once it's the environment's secret;
2. the GitHub App: Contents read and write, Actions read, no webhook,
   installed on devvm and homebrew-tap alone, its key on the co-signer,
   and the commands that list what it can reach;
3. the co-signer's machine, by cosigner.md, init once the rest is done;
4. the release environment: you as the required reviewer, admins'
   bypass off, v* tags alone, RELEASE_CI_KEY and RELEASE_TAG_SIGNERS;
5. the v* tag ruleset: creations, updates and deletions restricted, the
   repository admin role the one bypass, as rulesets take no single
   user, with the command that lists who's an admin;
6. immutable releases;
7. the tap's ruleset, with the app the one bypass;
8. the notify command, an ntfy script over HTTPS, and what GitHub emails;
9. the first release through CI, a release candidate, after which
   --local isn't needed.

maintaining.md's CI section and cosigner.md's GitHub App link it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 19ae9a7071 feat(release): the switch: the maintainer signs and pushes the tag, and CI and the co-signer do the rest
scripts/publish.sh's default is now the maintainer's whole part of a
release that CI builds and the co-signer publishes: the tag's checks,
then main and the tag pushed to origin, which starts the Release
workflow, and what comes next. It needs git alone. It refuses a tag
whose commit has no release keys, which CI's workflow would refuse, and
a version with no changelog entry, which the co-signer takes the notes
from.

- scripts/publish.sh --sign-legacy, the one command for the bridge:
  VERSION's draft release, which the co-signer made, has SHA256SUMS,
  SHA256SUMS.ci.minisig and SHA256SUMS.cosign.minisig downloaded, and
  scripts/release.sh --sign-legacy checks both signatures with this
  checkout's packaging/keys and devvm-release <version>, then signs
  SHA256SUMS with the old key, devvm <version>, and checks that with
  packaging/minisign.pub; after asking once, SHA256SUMS.minisig goes on
  the draft, which the co-signer waits for, then publishes. A draft
  that has it already, or a published release, or a draft without the
  co-signer's signature yet, is said so, and nothing is uploaded. A
  checkout without the release keys is refused before anything is
  signed, pointing at github-setup.md's step 1, as is the default
  mode's tag without them.
- scripts/publish.sh --local, the old path, as it was: built, signed
  with the old key alone and published from this machine. It stays
  until the GitHub setup for CI and the co-signer is done, and goes
  when the bridge ends, as a release that only the old key signed is
  then one no devvm accepts. A flag, not the default, because the
  default is what's documented and what's safe to run at any time: it
  publishes nothing itself, so run before the setup it only pushes a
  tag whose workflow run fails; and a --local release after the
  co-signer starts is one it alerts on, as it didn't publish it.
- scripts/release.sh --check-tag: --check's tag and keys checks alone,
  with no container runtime or signing key, which the default mode runs.
- The shared parts are one function each: check_tag (the tag, main
  and origin), notes (the changelog entry), ask (the question), needs_gh.
- release.sh's closing line names publish.sh --local, and --tag's build,
  CI's and the co-signer's, has none.

Tests: testdata/script/publish_tag.txtar (the modes in --help, two
modes refused, no tag, another signer, a dirty tree, no release keys,
no changelog entry, a tag off main's HEAD, --dry-run, n, y and the
pushes in order, again with nothing to push, origin's other tag;
--sign-legacy: gh logged out, no draft, no co-signer signature yet, a
co-signer signature by another key, CI's for another version, --dry-run,
y and the upload, which verifies as devvm 1.2.3, again with nothing to
do, a published release, a checkout without the release keys), failing
before the code; publish.txtar runs the old path as --local, in a repo
without release keys, as devvm is until they're made: SHA256SUMS signed
with the old key alone, no role signatures, install.sh's key lines
empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 5b2786c758 ci(release): CI's release workflow, which builds, signs and hands each tag over
.github/workflows/release.yml, CI's half of each release, for a pushed
v* tag, in the release environment, which waits for the maintainer's
approval and holds what the workflow trusts: RELEASE_TAG_SIGNERS, the
SSH keys that sign release tags, and RELEASE_CI_KEY, CI's release key.
The job's token has contents: read, and id-token and attestations write
for the attestation alone, so it can't make or publish a release; the
co-signer does.

- scripts/release.sh --ci TAG DIR: the tag checked against
  DEVVM_RELEASE_SIGNERS, an allowed signers file, never the tagged
  commit's packaging/release-signer, as CI runs the tag's workflow and
  release.sh: annotated, a release's version, its tag object naming
  itself, signed by one of those keys, its commit on main
  (DEVVM_RELEASE_MAIN, refs/remotes/origin/main by default) and holding
  the three release keys. Then --tag's build, with the same signers as
  git's, and DIR with SHA256SUMS and exactly the files it lists, each
  checked against its SHA-256, and not the formulas, which the
  co-signer renders.
- scripts/release.sh --ci-sign TAG DIR: SHA256SUMS signed with CI's key,
  read on standard input into the script's memory and handed to
  minisign through a pipe, never a file or an argument, with the trusted
  comment devvm-release <version>, checked with the tag's
  packaging/keys/release-ci.pub, which can't be marked PLACEHOLDER: a
  key on standard input that isn't CI's is refused, and its signature
  removed. The placeholders' check is placeholder(), one owner for
  --tag's check and this one. --ci and --ci-sign refuse a tag without
  the release keys, pointing at github-setup.md's step 1.
- The workflow: a first step that stops a tag without the release keys
  before anything is installed, with the same pointer, then the tag
  fetched as GitHub has it, minisign alone through
  mise with no cache, the build under the runner's podman, the
  signature, an artifact attestation of every file SHA256SUMS lists
  (subject-checksums), and the artifact release, kept 90 days. Every
  action pinned by its commit; actionlint and zizmor (and zizmor's
  auditor persona) find nothing.
- The base's workflow, base.yml, comes with the published base; the
  workflow's header says where it goes.
- maintaining.md: CI's release workflow, its steps and its trust.

Tests: testdata/script/release_ci.txtar (signers only from
DEVVM_RELEASE_SIGNERS, an empty one, a tag signed by a key git trusts
but the list doesn't hold, not a release's tag, a lightweight tag, a
tag object of another tag, a commit off main, a folder that's there or
relative, the folder's exact files and their checksums, no key on stdin,
another role's key, the right key's signature and its trusted comment,
a second signature, a release-ci.pub marked PLACEHOLDER, a commit with
no release keys for --ci and --ci-sign), failing before the code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 e85e85d075 build(cosign): the units, install.sh and the co-signer's docs
- [email protected], a template: devvm-cosign@run for the timer, and
  @check and @init for setting up. The keys are root's, mode 0600, and
  reach the service only as systemd's credentials (LoadCredential=), in
  a folder of its own while it runs; the base's key comes from a drop-in,
  devvm-cosign-base.conf, which install.sh installs once there is one, as
  a credential that isn't there fails the service. Its processes are in
  a PID namespace of their own (PrivatePIDs=), and any failure starts
  devvm-cosign-failed.service (OnFailure=).
- devvm-cosign-podman.service, where a process that escapes a build's
  container lands: a PID namespace of its own, so no other process's
  /proc/<pid>/root; the config, the keys, every service's credentials and
  the whole state folder inaccessible; its HOME, with podman's config and
  storage, and its only writable folder, the build folder,
  /var/lib/devvm-cosign-build; StopWhenUnneeded=, so it runs only while
  a run needs it; each start deletes the whole build folder, podman's
  config first, then its images and containers (podman system reset),
  then the rest, so nothing a build left, a link or a config pointing
  podman at another runtime, reaches the next; and OnFailure=, as a run
  whose podman fails to start doesn't fail itself.
- devvm-cosign-failed.service runs devvm-cosign failed, which tells the
  maintainer through the config's notify command, reading no key.
- devvm-cosign.timer starts devvm-cosign@run hourly.
- install.sh: 65536 subordinate IDs from the first multiple of 65536
  above every range another user has in /etc/subuid or /etc/subgid, so
  no two users' containers share an ID; the state folder and the build
  folder, with the folders the units need; the config readable by the
  co-signer's group, for retry and ack; the old devvm-cosign.service
  removed.
- Docs: contributing/cosigner.md for the new flow: what CI hands over,
  what a run does (the old step 8 split into the draft, the publish and
  the check after), refusals and alerts, retry, ack and notify through
  OnFailure (HTTPS, not a local sendmail, under NoNewPrivileges), the
  base's snapshot bound and why, its files, the config's new keys and
  the credentials' names and modes, the setup with the Go the tag's
  mise.lock pins (mise exec), the units, what a build's container can
  reach and what's still shared (the user and the machine: an escape can
  slow or change the build it's in, which then doesn't match, and use
  the network while that run lasts; a kernel escape gets past it all),
  the GitHub App's Actions: read and the tap ruleset's bypass, that the
  units name the folders, and moving machines by copying
  /var/lib/devvm-cosign but stage/, src/ and cache/. maintaining.md's
  Release keys say who publishes, as it is; structure.md's package row;
  the 0.2.0 page and the changelog line.

Validated on Fedora 43 (SELinux enforcing, podman 5.6, systemd 258), in
a throwaway Lima VM: install.sh, then check, init and a run under these
units with rootless podman, against the fake GitHub over TLS with a
throwaway v9.9.9 and throwaway keys. CI's build was release.sh --tag
under rootless podman, handed over as an artifact; the co-signer cloned
its root-owned checkout, rebuilt, matched, signed, made the release,
published it and wrote both formulas, the same bytes as CI's build's.
Both signatures verified with minisign, every file with SHA256SUMS, the
podman unit stopped after the run, and a second run did nothing. During
the build, from the podman service's namespaces as the co-signer's
user: only the build's own processes were there, so release.sh's and
the run's /proc/<pid>/root weren't; the state folder, the clone
release.sh ran from and CI's staged files were refused; and only the
build folder was writable; only SHA256SUMS and CI's signature were
staged; and the build's finished files and the download cache were in
the state folder. A second start of the podman service reset the last
build's images and containers and left an empty build folder. A run
failed with GitHub gone started devvm-cosign-failed, whose notify got
the recorded failure, and a podman start that failed started it too. The first
runs found three things the fake can't, fixed in the earlier commits:
podman needs ~/.config, which install.sh now makes; system credentials
are mode 0440 with an ACL; and the clone needs the checkout's .git named
safe.

The podman service's first ExecStartPre deletes the co-signer's user's
/dev/shm/libpod* files, podman's locks, which outlive the service and no
folder it empties holds (TestPodmanUnitStartsClean). cosigner.md also
covers a build that keeps failing and GitHub's latest release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 00e5ea59f4 feat(cosign): the run, which makes and publishes each release CI hands over
devvm-cosign's run (Cosigner.Run), its command (cmd/devvm-cosign, Main)
and the maintainer's commands, devvm-cosign retry, ack and failed.

CI's token can only read the repo, so CI hands each build over as a
workflow artifact, and only the co-signer, and the maintainer by hand,
can make or publish a release. For each release CI handed over that it
hasn't published, oldest first, from the newest successful run of the
pinned release workflow for each tag, of this repo's own:

- its version is newer than the newest it signed, or one it signed, with
  the same SHA256SUMS; an older one is an alert, as a replay, until the
  maintainer acks it, unless it was published before the state began;
- CI's artifact is staged (stage/, which no build can reach) and
  checked: SHA256SUMS, CI's signature with CI's key and devvm-release
  <version>, and exactly the files it lists, each with its SHA-256; its
  files are deleted before the build and downloaded again after a match,
  so none of CI's bytes is on disk while a container could be live;
- a run builds once, so the podman service, which lives for the run,
  lives for one build, and anything that escaped a container is gone
  before the next build's host git and release.sh run; the next release
  or base waits for the next run;
- the build's finished files go in a folder of the state's src/, which
  release.sh copies to and the co-signer reads, where no container can
  swap a file or the folder;
- the tag's commit has to be the commit CI's run built, and the
  co-signer's own build has to match every file and SHA256SUMS; it
  renders the tap's formulas itself from the tag's template and the
  signed SHA256SUMS (formula.go, as release.sh's formula function does),
  and the build's own formulas have to be the same bytes, so neither
  builder's container decides what Homebrew installs. The formulas and
  the notes, the tag's CHANGELOG.md entry, are kept in kept/<v>/ with
  their SHA-256s in the state, and checked again before the tap;
- it signs, makes the draft itself, titled devvm <version> with the
  tag's notes, and uploads SHA256SUMS, both signatures and CI's files,
  each hashed as it's sent, keeping an asset only when its size and
  GitHub's digest are right and deleting any other;
- while the bridge lasts it waits for the old key's signature on the
  draft, failing each run so the maintainer hears of it, and downloading
  nothing again while it waits;
- it publishes only when the draft is exactly what it made, its tag,
  title and notes (but for line endings and the space at either end),
  and its assets by ID, size and digest, and the tag still names the tag
  object its rebuild checked; then checks the published release again,
  and finishes the tap.

Alerts and refusals:

- init records the highest release ID GitHub showed and the drafts there
  were then; IDs only go up, so any release published since that isn't a
  draft the co-signer made is an alert, whatever its tag or version, by
  <tag>#<ID>, so another release of an acked tag is alerted on again;
  each run also reads GitHub's latest release, wherever the list puts it.
- A published release that differs from what it checked, its own draft
  published without it seeing the answer that then doesn't check out,
  and a tap formula newer than any release it signed, by
  tap:<formula>@<version>, are alerts; the tap is updated only for a
  release it published and checked after.
- A rebuild that doesn't match is a refusal, which isn't downloaded or
  rebuilt again, even for CI's run again; devvm-cosign retry <tag> lets
  the next run rebuild it once more. Nothing retries on its own.
- Every run fails (exit 1) while an alert or refusal waits, until
  devvm-cosign ack or retry. A run records in last-failure.txt that it
  started, then what failed, or removes it when it succeeds; devvm-cosign failed, which the units' OnFailure=
  runs for any failure, a killed or timed-out run's or a config that
  won't load included, runs notify, the maintainer's command, with it on
  its stdin, a fixed environment and a minute of its own, whatever ended
  the run's context.

Bases go the same way, from the newest successful run of the base
workflow on main, made at the index's commit and never GitHub's latest.

Main makes the process non-dumpable (prctl PR_SET_DUMPABLE 0) before
anything else, so no process of its user can read its memory, where the
keys and token are, and reads the keys from systemd's credentials when
CREDENTIALS_DIRECTORY is set. A run empties the build folder's work/
and the state's stage/ and src/ in place, never making them again.

Tests, each fix reverted once to see it fail: TestPublishedBySomeoneElse
(a release published by someone else, whatever its tag or version, the
same tag again after an ack, a draft from before init published since,
and GitHub's latest past where the list stops; one from before the state
left alone), TestOneBuildPerRun (the build's files in the state, none of
CI's on disk during the build, and the next release left for the next
run), TestFormulas (a build's formula of
its own; a kept formula changed on disk), TestRenderFormula,
TestPrereleasePublished (a tap formula newer than any release signed),
TestDraftChangedBeforePublish (a swapped file, a retag, other notes),
TestTagMovedBeforePublish, TestAlertAfterPublish and
TestLostPublishChecked, TestMismatchSignsNothing (a failure every run,
and retry), TestReplayedOlderVersion (an alert, then acked),
TestNotify, TestLegacyBridge (a failure every run, with no download),
TestRunPagesReleases, TestInitPaged (init past ten pages of bases, which
fails with a page check that stops at its first unfinished entry),
TestRunsChecked, TestArtifactChecked, TestUploadChangedOnDisk,
TestBaseIndexChecked (a re-signed base on a 61-day snapshot),
TestBasePublishChecked, TestBasePublishedElsewhere (an expired base still
counts in checkBehind), TestWorkEmptiedInPlace, TestCommandLine (retry
and ack read no key file), and on Linux TestUndumpable.

A build that fails, rather than differs, is built again at the next
run, but the third failure in a row refuses it, with a report holding
the last failure (buildFailed), so a build that keeps failing no longer
takes every run's one build and holds up each newer release and base;
retry builds it again, and a build stopped with its run isn't counted.
Refusing rather than rotating past it keeps releases oldest first, as
versions only go up, and keeps the failure in front of the maintainer
through held and notify. buildRelease and buildBase are the build and
its comparison, apart from what's recorded. And GitHub's latest release
has to be the one init saw or one the co-signer published, not one of
its own older than another it published: anything else is an alert,
latest:<tag>#<ID> (staleLatest), as the install script's default
downloads it; so is the one init saw, once it's older than one the
co-signer published. The co-signer makes a release GitHub's latest only
when it's newer than every release it published, so publishing an older
release after a newer one, as when the old key signs the newer draft
first, never moves the latest back itself. And a release's run counts
only when a tag's push started it (PushEvent, which the structure
test's nameFree lets name "push"). Tests, each failing before its code:
TestFailingBuildRefused, TestBaseRefused's base that keeps failing,
TestLatestChecked, TestOlderReleaseNotLatest, TestRunsChecked's run by
hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 1bd598c791 feat(cosign): ReleaseBuild, the co-signer's own build of a tag
ReleaseBuild rebuilds a release with the co-signer's own devvm: a new
clone of its checkout at its pinned commit (checked clean), the tag and
main fetched into it, the tag's SSH signature checked against the pinned
signers (VerifyTag), the tag naming itself and its commit on main, then
the clone's release.sh --tag with those signers as git's
allowedSignersFile, so release.sh checks the tag again. Nothing of the
tag's runs on the host.

- The clone, its git config and allowed signers and release.sh's log go
  in Src, the state folder's src/, which no build's container can reach,
  as release.sh and git run from it on the host; only release.sh's
  TMPDIR, where its containers work, goes in Work, the build folder. A
  container that could write the clone could otherwise edit release.sh
  as bash reads it, or set gpg.ssh.program or a filter in its .git/config
  for git to run on the host. release.sh's download cache, which only it
  reads, on the host, goes in the state folder too, so nothing that
  escaped a container can plant a link for its next download.
- Build returns Built: the checked tag, its tag object's ID, and the tag
  commit's Homebrew
  formula template (packaging/homebrew/devvm.rb) and CHANGELOG.md, read
  with git before release.sh runs, so no build's container can change
  them. The co-signer renders the tap's formulas and the release's notes
  from them and the signed SHA256SUMS.
- The checkout is root's, so git reads it as the co-signer's user only
  with it named safe on its own command line: its worktree for git
  status, and its .git for a clone, whose upload-pack checks that path.
  A full run on Fedora under the units found the clone refused with the
  worktree alone; TestCheckoutNamedSafe holds both.
- git runs with no system or global config, no hooks or fsmonitor, no
  replace objects, files and HTTPS alone, an environment of its own and
  its output capped.
- The structure test's commandsFree is now keyed by the command, then the
  file, so build.go may run git and no other guarded command; its
  execSites and statusFree entries, and the owners table, say why.

Tests: TestReleaseBuild (the template and changelog read, then a stub
release.sh that deletes the clone's .git, as a build could, and says
where it ran: its script in Src and its TMPDIR in Work, which fails with
the clone in Work, reverted once to see it; the tag object), the
existing refusals (an unpinned signer, off main, a dirty or moved
checkout, a lightweight tag, a tag naming another, release.sh failing),
TestCheckoutNamedSafe, and TestRulesFail's "another command in a file
commandsFree lists for git", which fails with commandsFree keyed by file
alone (reverted once to see it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 da68e5d67e feat(cosign): GitHub, CI's artifacts, the app's token, the config, the state and the lock
What devvm-cosign reads and writes, below its run:

- github.go, actions.go: every GitHub call goes through Client: releases
  listed, read one, by its tag, a draft made, an upload streamed from a
  file with the SHA-256 of the bytes it sent, a delete, a publish, the
  tap's contents; and the Actions API's runs of a workflow file, a run's
  artifacts by name and an artifact's zip, which redirects to storage
  that never gets the token. CI's token can only read the repo, so CI
  hands its build over this way, and only the co-signer makes and
  publishes releases.
- Lists are read a page at a time until a page holds only entries the
  caller is done with, newest first as GitHub lists them, so years of
  releases and bases never stop a run; ten pages it isn't done with are
  an error, never a list cut short. Every entry of a page is asked about
  (every), never stopping at the first that isn't done, so a caller that
  counts what it's asked, as init does, sees the whole page.
- TagRef: what a tag names now, so a release is published only while
  its tag names the tag object the rebuild checked; Latest: GitHub's
  latest release, which /releases/latest/download/ serves.
- artifact.go: an artifact downloaded into the co-signer's stage folder,
  capped, checked against GitHub's digest, and unzipped with nothing but
  a flat list of regular files, each named as a manifest names a file,
  stored or deflated, written new (O_EXCL), each no larger than its
  header says, within the artifact's bounds, and hashed as written.
- app.go: the GitHub App's installation token (RS256 JWT), now asking
  for actions: read beside contents: write, on the two repos alone.
- config.go: release_workflow and [base]'s workflow and
  max_snapshot_days; notify, the maintainer's command for a failed run;
  build_dir, the folder the builds' containers write, apart from
  state_dir, which they can't reach, neither in the other; ReadConfig,
  without the keys, for retry and ack; and the key
  files read from systemd's credentials folder ($CREDENTIALS_DIRECTORY)
  by their own names, where systemd's system manager makes them root's,
  mode 0440, with an ACL for the service's user, so there only others'
  bits are refused. A kind with no keys at all, as before the release
  keys are made, is refused by name, pointing at github-setup.md's
  step 1, so the co-signer doesn't start without them.
- state.go: a ledger for each kind: what it signed, the drafts it made,
  what it published, each refusal with how often it was retried, each
  alert with how often it was acked, and the CI runs it signed; releases
  also record the SHA-256 of each file kept for the tap and each tag
  object checked. The state's watermark, the highest release ID GitHub
  showed at init, and the drafts there were then, and the alerts on what
  isn't one of its own: a release someone else published since, by
  <tag>#<ID>, and a tap formula it didn't write. A save is refused when
  it drops or changes an entry or counts one back, and
  writeWhole now syncs the folder after the rename, so a crash can't
  lose the record of a version made before its signature is uploaded.
- lock_unix.go: one run at a time, unchanged.
- forbidigo's exclusions now name their files: the web for github.go and
  app.go, Flock for lock_unix.go, so a second client or lock elsewhere in
  the package still fails the lint.

Tests: the fake GitHub serves workflow runs and artifacts and makes
drafts; TestUnzip (a folder, a path, a parent, a dot file, a link, a file
twice, too many, a size that lies, not a zip, a file already there),
TestFetchArtifact, TestClientReleasesAndRuns, TestReleasesPaged (1,100
settled releases read in two pages), TestLedger, TestStateNeverBackwards
(drafts, publishes, kept files, alerts and refusals counted back),
TestConfigCredentials, TestConfigRefused (the build folder in the state
folder or the reverse). Reverted once each to see the test fail: the
paging's stop (TestReleasesPaged), the credentials folder
(TestConfigCredentials), the lint's scope (an http.Client in another
file fails forbidigo). The folder's fsync was checked with strace on
Fedora: openat of the folder and fsync right after the rename.

The state also counts each manifest's failed builds in a row
(Refusal.Failed, Ledger.failed): the third, maxBuildFailures, refuses it
as a mismatch does, with its cause (Why), and the count alone may go
back, as a lower one only builds more. And it records GitHub's latest
release at init (InitLatest), which a save may never change.
TestStateNeverBackwards covers both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 5ad326e13c feat(cosign): the co-signer's parsers of outside input, and their fuzz targets
The first of devvm-cosign's code, the parts that read what CI and GitHub
send, so they can be reviewed apart:

- sshsig.go: git's SSH tag signatures (OpenSSH's SSHSIG over the tag
  object's payload, namespace git, Ed25519 alone), checked against the
  tag signers the co-signer's own config pins (VerifyTag, ParseSigner,
  AllowedSigners); the payload split at the last armor header, as git's
  parse_signed_buffer does, and a tag naming itself and a commit.
- manifest.go: SHA256SUMS (ParseSums), base-index.json (ParseIndex),
  each with its files and the trusted comment's subject, and release
  versions as release.sh orders them.
  - A base's index is refused when its Ubuntu snapshot is more than
    maxAge old (the config's max_snapshot_days, 60 by default) or ahead
    of now, whether or not it's rebuilt: the co-signer re-signs an
    unchanged base with a new serial and expiry, so the expiry alone
    can't keep users off an old base, and a stolen CI base key could
    otherwise keep them on one snapshot for as long as it signs.
  - The expiry is the last day the index is taken, in UTC, as the
    field's comment says: refused from the start of the next day.
  - Neither manifest may list a manifest's or a signature's name
    (SHA256SUMS, base-index.json, *.minisig), so a listed file can never
    stand in for the co-signer's signature.
  - indexSubject reads an index's subject whatever its times, so a base
    the co-signer signed counts in checkBehind however long ago it
    expired.
- Fuzz targets: FuzzVerifyTag, FuzzParseSums, FuzzParseIndex.
- Guards: depguard's cosign rule (the standard library, BurntSushi/toml
  and internal/minisign alone); the layers "only cmd/devvm-cosign runs
  the co-signer" and "the co-signer imports only internal/minisign";
  signatureFree's internal/cosign/sshsig.go, another project's format,
  and the owners table regenerated.

Tests: TestParseIndex (a 60-day snapshot taken, 61 days, ahead, bad or
none refused; expiring today taken, yesterday refused), TestIndexSubject,
and the existing parsers' tables. Each fix was reverted once to see its
test fail: the snapshot bound (TestParseIndex, TestBaseIndexChecked) and
the expiry's day (TestParseIndex).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 77e0f94f84 feat(minisign): sign as minisign does, for the co-signer
The co-signer signs SHA256SUMS and base-index.json with a minisign key
of its own, made with no password, so it can sign unattended. This adds
that signing to internal/minisign, the one owner of devvm's signatures,
reviewable against minisign's format alone:

- SecretKey and ParseSecretKey: an unencrypted minisign -G -W key, 158
  bytes: Ed, KDF \0\0, B2, salt and limits, key ID, the 64-byte key and
  a BLAKE2b-256 checksum over the algorithm, key ID and secret key. An
  encrypted key is refused, the checksum is checked when it isn't zero,
  and the public half is derived again from the seed and compared.
- Sign: the prehashed ED signature, the global signature over the
  signature and the trusted comment, and minisign's own untrusted
  comment, the same bytes minisign -S -t writes (TestSignAsMinisign
  pins them to a signature minisign 0.12 made). Ed25519 is
  deterministic, so signing again gives the same bytes.
- Keys.CheckRole checks one role's signature, as the co-signer checks
  CI's before it rebuilds anything; LegacyComment is the old release
  key's trusted comment, devvm <version>, which upgrade/legacy.go now
  takes from here.

The zero checksum of a -W key was checked against minisign's source:
generate() zeroes the key and computes the checksum only inside
encrypt_key, which -W skips, in 0.12 and on master, and a key minisign
0.12 made with -W has 32 zero bytes there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 51e4c795e4 refactor(structure): the layers in devvmLayers, a pure move
devvm()'s layer list moves, unchanged, into a function of its own,
devvmLayers, so devvm() stays within revive's function length when the
co-signer's two layers join it in a later commit. Nothing else changes:
git diff -w shows only the move.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 f3052e5a8e feat(upgrade): releases checked by two of three release keys, bridged from the old key
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.

The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.

- internal/minisign: the one owner of signature checks (moved from
  internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
  compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
  Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
  distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
  blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
  FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
  code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
  but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
  in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
  packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
  none, or three distinct minisign keys, none the old key),
  TestCheckReleaseKeys (fixture keys from minisigntest),
  TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
  empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
  marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
  none or all three of packaging/keys' release keys. With none,
  install.sh's release_<role>_key lines are empty or missing; with all
  three, each is a minisign key, distinct, not the old release key, not
  marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
  and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
  signature only when the script has its key), check_signature,
  signed_by_two, check_legacy; plainer warning without minisign, with
  the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
  upgrade.txtar (-legacy, -keys, and the keys built in, none),
  install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
  (real minisign), release.txtar (none, nolines, nokeyline, old, marked
  and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
  Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
  releases/0.2.0.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 d001f7be0f build(release): every release builds to the same bytes on any machine
The signing design's first phase. The same tag, built by two builders,
now gives byte-identical archives, source tarball, install.sh,
SHA256SUMS and formulas.

- scripts/release.sh builds every file but the signature in one
  container, release_image (Debian's buildpack-deps:trixie-scm, pinned
  by its index's digest), under podman or Docker
  (DEVVM_RELEASE_RUNTIME), on this machine's processor. The image and
  the code that runs in the build's container (_build) are the built
  commit's copies, so a tag builds the same from any checkout; a commit
  whose release.sh pins no release_image is refused. Everything outside
  the build's container is the checkout's: the tag's checks, the
  downloads, the modules' container, the checks on what the build
  wrote, and the signature.
- The build has no network (--network none). The Go modules come first,
  in a container of their own, the only one with the network, which
  runs only the checkout's code: its release_image, its release.sh
  _modules and the Go its mise.lock pins, given only the commit's go.mod
  and go.sum, read-only, and downloading from proxy.golang.org alone
  (GOVCS=*:off, GOWORK=off). The checkout's Go rather than the commit's,
  so a commit can't pick an old Go with a known flaw for the step with
  the network, and rather than refusing a commit whose Go is older than
  the checkout's, which would refuse every old tag once mise.lock moves
  on, though rebuilding old tags is what --tag is for; go.sum pins the
  module files, so the bytes don't depend on which Go downloaded them. A
  commit whose go.mod needs a newer Go than the checkout's is refused
  before anything runs. Every module path the commit's go.mod names is
  looked up on Google's proxy and checksum database, which the docs say.
  The build reads the modules read-only as a GOPROXY's files
  (file:///mod).
- Every container runs with --cap-drop ALL, --security-opt
  no-new-privileges, --pids-limit 8192, --memory 8g and --entrypoint
  bash, so a setuid file in the commit's image gives no privileges under
  a rootful runtime, root in it can't chown, a fork bomb or a runaway
  allocation stops at the container's limits, and the image's
  entrypoint never runs; Go and GoReleaser are unpacked with tar
  --no-same-owner. Both runtimes take both limits; rootless podman
  applies them on cgroups v2 with the pids and memory controllers
  delegated, as systemd does, and CI's runner needs the same. A full
  build peaked at 330 processes and 1.8 GiB under Docker Desktop on 10
  CPUs. Neither runtime can bound a bind mount's disk use, so the docs
  say that a running build can fill the temp folder's disk until the
  time limit.
- Each container is named for its run (devvm-release-<the temp folder's
  suffix>-<n>), so no other run's container, even one left over, has
  the name, and it's removed (rm -f, then its client ended, then rm -f
  again): after two hours (DEVVM_RELEASE_TIMEOUT seconds) by a
  watchdog, and as soon as release.sh stops early. The client runs in
  the background, so Ctrl+C (INT), a closed terminal (HUP) and kill
  (TERM) run release.sh's traps at once, which exit through the EXIT
  trap that removes the container; in the foreground, bash would wait
  for the client, and the client for the container's PID 1, bash, which
  ignores them. After kill -9, the watchdog, which outlives release.sh
  and ignores INT and HUP, removes the container and the temp folder.
- Go and GoReleaser are the built commit's mise.lock downloads for
  linux-arm64 or linux-x64, kept in ~/.cache/devvm-release by SHA-256
  and checked before each use, as is the modules' Go from the
  checkout's mise.lock. A URL has to start with
  https://dl.google.com/go/ or GoReleaser's releases/download/, can't
  hold .. or %, which curl decodes (so %2e%2e can't be ..), and goes to
  curl as --url's value (a lock URL of -K<file> was curl options, run
  on the host); file:// only from the folder that
  DEVVM_RELEASE_TEST_FILE_URLS names, which only the tests set, and
  only when it exists and isn't /. curl: HTTPS redirects only, 30 s to
  connect, 15 minutes, 1 GiB. A lock with two entries for a tool, or
  two downloads for the platform, is refused.
- The build's repository is new (git init --template=), holding only
  the commit and, for a tag, the tag, fetched into a pack: no other
  branches, tags or objects of the maintainer's, no hardlinked files
  the container could write, and origin set to devvm's GitHub URL,
  which GoReleaser needs and nothing fetches. Go stamps the binary
  from the tags it finds, so it finds only the release's.
- The container runs as root under a rootless runtime and as you under
  a rootful one, from the runtime's info (podman's
  Host.Security.Rootless, Docker's security options), never its name;
  a runtime that doesn't answer stops the build. Inside: umask 022,
  TZ=UTC, LC_ALL=C.UTF-8, GOTOOLCHAIN=local, -mod=readonly, no git
  config but safe.directory, and Go's caches in a container-local
  folder (Docker Desktop's share lost files that parallel module
  downloads renamed).
- The build writes its files to /out, a mount of its own that it can't
  swap for a link. Before anything is copied, signed or kept, the
  folder has to be the one release.sh made, not a link, and everything
  in it a file or a folder, never a link, yours, and neither setuid,
  setgid, sticky nor world-writable, and 2 GiB at most, counted as
  read (sparse files whole) and read no further. The files are then
  copied to dist/, never moved, as yours with mode 0755 or 0644.
  minisign signs outside, after the containers are gone.
- release.sh --commit COMMIT builds any commit as --head does, with its
  VERSION; release.sh --tag TAG builds a tag as its release, with its
  checks, unsigned, to compare with a published SHA256SUMS. An unsigned
  build never replaces a dist/ that holds SHA256SUMS.minisig, and a
  build signed with a test key never replaces one whose SHA256SUMS
  verifies with the checkout's packaging/minisign.pub, the release key.
- .goreleaser.yaml: builds_info and every file's info set owner and
  group root, mode 0755/0644 and the commit's time.
- scripts/repro-check.sh [COMMIT | TAG] builds twice with the
  checkout's release.sh, so no commit's code runs on the host directly.
  Build 2 fetches from a repository with a stray tag, v0.0.0-stray, at
  the commit, and runs under Docker where build 1 runs under podman when
  both are installed (root against your user); every platform
  archive's files have to be root's with mode 0755 or 0644 (tar -tv).
  A build that leaves no release fails, whatever its exit status. CI's
  repro job runs it under the runner's podman and Docker, with a
  45-minute limit. The docs say that building a commit runs its code,
  in a container only as isolated as the runtime keeps it, so an
  outside commit is built only with the maintainer's go-ahead, and that
  rebuilding an old tag needs proxy.golang.org to still serve its
  modules.
- scripts/bump.sh release-image moves the container's digest, the
  SHA-256 of the index it fetched, after checking the index lists
  linux/amd64 and linux/arm64; TestBumpCoversPins finds the pin.
- Tests: release_head.txtar, publish.txtar and the new
  repro_check.txtar run the scripts through podman and docker stubs
  and a mise.lock of file:// tarballs. New cases: -K, http://, another
  host, .. and a percent-encoded .. in a lock URL refused before curl
  runs, file:// refused without the switch, with it set to 1, to a
  folder that doesn't exist, to / and from another folder, curl's
  bounds, two go entries, the build's repository's tags, refs, objects,
  hardlinks and origin, a stray tag kept out, the image and build code
  taken from the commit, a commit with no release_image, each runtime's
  user (rootless and rootful podman and Docker, podman behind docker,
  no answer), both containers' run lines (security options, limits,
  entrypoint, --network none, mounts), each container's name its run's
  (the stub checks it against the run's temp folder), the modules'
  container getting only go.mod, go.sum, Go and the checkout's
  release.sh, in the checkout's image, with the checkout's Go, a go.mod
  newer than the checkout's Go refused before any container, and the
  build reading its modules; refused output: a link in it, the output
  folder swapped for a link, a mode 4755, 2755 or 0666 file, a mode
  1755 or 0777 folder, a sparse file a byte over 2 GiB (a file of
  another user's needs root to test, which the test says); a mode 0600
  file copied as 0644; a build past DEVVM_RELEASE_TIMEOUT removed by
  name; release.sh sent INT, HUP and TERM mid-build, ending within 10
  s through its trap, and kill -9, each leaving no container, process
  or temp folder; an unsigned --head and --tag refused over a signed
  dist/, and a test-key build over a release-key one; --commit never
  running the commit's host code, --tag's unsigned build matching the
  signed SHA256SUMS, and repro-check catching a build that records its
  user, archives that aren't root's, and a release.sh that builds
  nothing; bump.txtar covers the platform check. Each fails with its
  fix taken out, which was checked for every fix of the third review:
  the name, the limits, the test-key refusal, %, the folder's
  existence and /, the size cap, setgid, sticky, the signal traps, the
  EXIT trap's removal, the watchdog's removal after kill -9, the client
  in the background (in the foreground, INT took 60 s), the checkout's
  Go and the Go version check.

Proof, with a throwaway commit whose _build probes its container and
leaves a mode 4755 copy of bash and a mode 0666 file in /out, built by
this release.sh under Docker Desktop on an arm64 Mac, and under rootful
Docker and rootless podman on x86_64 Fedora: every build ran with
CapEff and CapBnd 0, NoNewPrivs 1 and no network, couldn't write /mod
or rename /out, and was refused before anything was kept; rootful
Docker refused its chown to root. The same image under the old run
line, on Fedora's rootful Docker: CapBnd a80425fb, NoNewPrivs 0, and
proxy.golang.org reachable.

Real builds of this commit, stopped 20 s into the build's container:
under Docker Desktop, INT, TERM and HUP ended release.sh within 3 s
(exit 130, 143, 129) with no container left at once, and kill -9 left
the container running for the watchdog, which had removed it and the
temp folder 5 s later. The same on Fedora under rootless podman (INT,
kill -9, TERM, HUP) and rootful Docker (INT, kill -9). Afterwards no
devvm-release container or temp folder was left on either machine.

repro-check on this commit, a prerelease (no devvm.rb), agreed on all
eight files on the Mac (Docker Desktop, both builds) and on Fedora
(rootless podman as root, then rootful Docker as cj), and the two
machines' printouts were the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 23:41:10 -07:00
w3cjandClaude Opus 5.5 592076cfda fix(lima): taking base's packages out says why it failed, in the run log
The tar that streams the packages base downloaded out of its build VM
had its standard error dropped, and neither its failure nor the host's
reading of the stream reached the run log, so packages_take_failed left
nothing to go on. Its error output now goes to the run log, with a line
naming either side's failure.

The CHANGELOG's Fixed and the release page's Base's packages that don't
come out say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 f0c7449d3b fix(assets): tldr's pages download gives up after a minute
cli-tools.sh's tldr --update has no timeout of its own: through a proxy
that stalled its connection, it held base's build for 120 s (measured
on the mini) before it failed, which the script already tolerates. It
now runs under timeout 60.

Base's key changes (features/cli-tools.sh).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 1946707e19 fix(tools): mise's downloads try six times, on the host and in tool builds
Through a proxy that cut and stalled connections (measured on the mini,
a two-minute stall), mise's three retries of bun's download each timed
out after 30 s, as mise tried again on the connection that had stalled,
and the tool build failed. shared-tools/build.sh and the host's mise
(miseCmd) now set MISE_HTTP_RETRIES=6, which outlasts such a stall; each
try still ends after 30 s without bytes (mise's http_timeout).

Every tool image's key changes (shared-tools/build.sh).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 9f2dda910d feat(assets): base's build fetches only the package lists apt installs from
apt.sh begin's update fetched 35.8 MB of lists on arm64, of which the
translations (Translation-en, 7.9 MB), AppStream's components (4.8 MB)
and command-not-found's metadata are nothing apt installs from, and the
image keeps no lists. The build's apt settings now leave them out
(Acquire::Languages "none", and DefaultEnabled "false" for the DEP-11
and CNF index targets): 22.8 MB, and apt.sh begin 3.7 s against 6.4 s on
the mini (measured). The record still gives back every InRelease and
Packages list it used. A layer's apt.sh lists runs after apt.sh end has
removed these settings, so its apt is Ubuntu's as it is.

Base's and every layer's key change (apt.sh).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 20f97b10eb feat(vm): a new VM's tools resolve while its image builds
A first run resolved the tools' versions, downloading devvm's own mise
first, only after base had built: 10 s on the mini, 5 s on fedora, in
series. Neither needs the other, so create now starts Versions.Lock in
the background as an image starts to build (resolveWhile's start, which
build.Env.Building calls once an image is found unbuilt and its features
are chosen) and waits for it after, cancelling it when the build fails.
When every image is built already, nothing starts in the background, and
Files resolves in the foreground with its status lines as before.

While the build runs, the resolve says nothing, as the build has the
terminal: a held Reporter keeps its messages, shows no status line and
refuses every question as without a terminal, and its commands' lines
in the run log are tagged resolve. Once the build ends, done releases
it: what it held is said, what it does from then on shows, and devvm
waits under resolving_tools when it's still running. done returns its
error, so a failure is said once and the launch doesn't resolve again.
A VM whose lock is already there reads it at once.

TestHeld, TestResolveShowsAfterBuild and TestBuildingCalled fail when
held shows a status line, when the wait shows none, and when Building
isn't called. Docs: images.md's Versions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 dd46dd7a0f feat(tools): tool images build side by side
A first run built its tool images one after another, each paying a
build VM's boot (5.7 s on vz, 9.3 s on QEMU) before a download of a few
seconds to a minute. Share.Build now hands the images out to up to four
slots (buildAll), each slot's builds one after another in a build VM of
its own:

- slots: as many as the host's memory, less what the backend's running
  VMs have, and its CPUs give a build VM of 2 GiB and 2 CPUs each after
  keeping 6 GiB and 2 CPUs, at most backend.MaxToolSlots (4) and the
  number of images; one alone keeps base's size. A backend that can't
  list its VMs builds one at a time. A running VM's memory counts whole
  (7.5 GiB, not 7): TestBuildSlotsFit's running VMs fail when it isn't
  counted or is truncated.
- plan lowers the slots until the backend's disks have room:
  Floors.ForTools counts Tools once for each build VM at once, as on a
  disk without copy on write each is a whole copy of base.
- backend.ToolsSpec gets Slot, Slots, Size and Hold; Lima's slot VMs are
  the constants ToolsVM to ToolsVM4, sized with --cpus/--memory, and the
  first slot's build deletes what a killed run left in the slots this
  run doesn't use. Builds hold the share's lock, so one devvm uses the
  slots.
- A failed build's VM goes in the run's cleanup, which runs after the
  build let go of the share's lock: it deletes the VM only once it has
  the lock again (ToolsSpec.Hold, Env.holdShare's TryLockFile), and
  leaves it while another devvm holds it (a build, gc or the daily
  refresh) (TestBuildToolsCleanupHolds, TestBuildHoldsShareForCleanup).
  The next tools build deletes what it finds in the slots, and so does
  devvm gc, which holds the share's lock: backend.Images'
  DeleteToolsLeft, Lima's deleting the slots' build VMs that are there
  and no other VM, which gc asks of every backend first, without
  asking, a backend that can't being a run log line. It returns what
  it deleted, which gc names in one line (tools_build_vms_deleted), and
  gc then never says nothing_to_clean or nothing_deleted
  (gc_tools_build.txtar, TestDeleteToolsLeft in lima and vm, the fake's
  ToolsLeft). The cli skill's judgment.md names this exception to "gc
  --force deletes exactly what gc lists". The conformance suite's
  delete-tools-left checks that it deletes no other VM, not even the
  project VM of a folder named tools (devvm-tools-<hash>), and no image
  (TestConformanceFinds: deletesAllVMs, deletesImage, deletesByPrefix).
  The share's lock
  is the data folder's, so devvms with their own data folders and one
  Lima home don't exclude each other's builds: the docs say not to build
  tools or run gc in two at once (a lock per build VM in the Lima home
  would close it, but it would replace Hold and needs e2e).
- Side by side, one status line covers the builds
  (building_tools_together), and their commands' lines in the run log
  are tagged with their tool (msg.WithLogTag): the UI's LoggedCmd
  prefixes them and shows no status line of its own. Every write starts
  with the tag, as does every line in it, one ended by "\r" included,
  so no build can pass a line off as another's (TestTaggedWrites), and
  a tool's lines are found after another's "\r" (taggedLines splits
  there, a progress bar's updates staying one line: TestTaggedLines). The
  first failure cancels the others and is what Build returns, tagged
  (backend.LoggedIn), so ErrorLogged shows that tool's lines' end.
- A test build's DEVVM_TOOL_SLOTS caps the slots; the CLI tests set 1,
  so the stub's calls keep their order, and tools_side_by_side.txtar
  sets 3, with an interrupt that leaves no build VM. The stub keeps each
  build VM's folder by its name, and the fake backend's BuildTools runs
  its builds outside its lock, as a real backend's would, passing
  ToolsBuild its context.

Docs: images.md's Building tools and Free space, ports-size.md,
space.md, images.md (using) and gc's help (the build VMs gc deletes),
settings.md (one Lima home for two data folders), extending.md,
testing.md and tests.md; the cli skill's judgment.md; the CHANGELOG's
first highlight and the release page's A faster first run.

New messages: building_tools_together, tools_build_vms_deleted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:57:15 -07:00
w3cjandClaude Opus 5.5 32a3469ed2 fix(assets): image builds' downloads retry, resume and time out on a stall
What a build VM downloads failed on a network's first hiccup: curl's
--retry 3 skips a connection cut mid-transfer (exit 18) and waits for
ever on a stall, apt's retries were off, and oh-my-bash's clone had
none.

- devvm-fetch: each try has --connect-timeout 20 and a stall limit
  (--speed-limit 1024 --speed-time 30), and any failure is tried again,
  five tries in all, from where it stopped (-C -): curl's own --retry,
  --retry-all-errors included, starts again from nothing (measured on
  curl 8.7). A server that can't resume (33, 36) starts it again; a file
  that came whole and checks out ends the loop; a file that doesn't
  check out is fetched again from nothing once, as a resume may have
  joined two versions. A redirect goes only to https
  (--proto-redir =https), so no try or resume moves to plain http.
  TestDevvmFetchTries runs it against a server that cuts, ignores
  ranges, changes the file, fails and redirects to http.
- apt.sh: package lists still fail fast (exit 75 when no source
  answers), and once they're in, the build's installs get
  Acquire::Retries "3", with apt's own backoff.
- crane (oci/build.sh, the --from conversion, which has no devvm-fetch):
  --retry 5 --retry-all-errors --retry-delay 2 and the same timeouts.
- oh-my-bash: the clone is tried five times in all, with git's
  low-speed limit.

Docs: images.md's Building and Base's packages, customizing.md's
devvm-fetch; the CHANGELOG's second highlight, which says which
downloads resume, and What to do 1, which names the layers and --from
bases that rebuild and pull again; the release page's A first run on a
bad network.

Image keys change: base's (base.sh, apt.sh, omb.sh), every layer's
(apt.sh is in each), and a --from conversion's (oci/build.sh). Tool
images' keys don't (shared-tools/build.sh is unchanged).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 3c7fbad7a3 feat(tools): mise downloaded as its .tar.gz, on the host and in base
mise's raw binary is 147 to 192 MB, its .tar.gz 51 to 63 MB. Both of a
first run's mise downloads now take the archive:

- the host's mise (internal/tools): the .tar.gz checked against its
  pinned SHA-256 by fetch.Download as before, into a folder of its own,
  then hashed again through the descriptor that mise/bin/mise is taken
  out of with archive/tar and compress/gzip, capped at miseCap. One
  devvm downloads it at a time (Dirs.MiseDownloadLock,
  cache/mise/download.lock, mise_waiting), and another takes what it
  kept. Under the lock, a .download-* folder a killed run left is taken
  away first (TestHostMise). A failure says its cause
  (mise_download_failed's Because) in the run log too.
- base's mise (layers/base.sh): devvm-fetch's .tar.gz, unpacked with tar
  in a folder of mktemp's, which every base has (gzip is Essential on
  Debian and Ubuntu, BusyBox has it): .tar.xz would need xz, which
  --from images may lack.

The pins are the archives' SHA-256s from the release's SHASUMS256.txt,
and scripts/bump.sh reads the .tar.gz lines. TestMisePins still checks
that base.sh's Linux pins are the host's.

Docs: images.md's Versions and overview.md's locks; the release page's
A faster first run; the CHANGELOG's Highlights, a first run that
downloads less with the cloud image's two lines, now highlights too.

Base's key changes (base.sh). Tool images' keys don't: they hash base's
mise version, not its checksum.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 a8f0517579 feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut
in its 900 MB fails base's build, and a stall hangs it. devvm now
downloads the pinned image itself through fetch.Resumable
(ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage),
resuming across cuts, stalls and runs, and gives Lima that file. Lima
2.3 checks a local file against the digest before it copies it.

- Before downloading, it takes the image from Lima's own download cache
  when that holds it with the pin's SHA-256: copied into a new file of
  devvm's own, mode 600, hashed as it's written, capped, stopped by the
  context, and kept only once it checks out. Lima's cache is never
  changed, and a base whose dated release Ubuntu may have removed still
  builds again.
- One devvm downloads at a time (images/locks/ubuntu-image), another
  waiting under ubuntu_image_waiting and looking again under the lock
  (TestUbuntuImageAfterWait, which fails without that second look).
- The download goes through the company proxy and trusts the user's CAs
  (Lima.Roots, from trust.Pool, which internal/cli passes through the
  registry), as do the Finder's lookups (TestNewTrustsRoots, and the
  registry's TestOverrides). An untrusted certificate is
  ubuntu_untrusted, naming the CAs' folder, one from a trusted CA
  that's for another host, out of date or not valid yet
  ubuntu_bad_certificate (check the clock and what answers for the
  host), and any other that fails to verify (a SHA-1 signature, a CA's
  name constraints, a key for clients alone) ubuntu_certificate_invalid,
  naming Go's reason, for the lookups (the listing, the checksums, their
  signature: TestLookupCertificates) and the download alike
  (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410)
  ubuntu_release_gone, which names devvm rebuild base; none is retried.
  ubuntu_download_failed no longer starts with devvm.
- fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a
  CertificateInvalidError that's Expired) and fetch.Unverified (any
  failure to verify, with its reason, so every error the other two
  name), beside fetch.Gone, are the one
  place that tells a certificate's failures apart: Transient asks
  Unverified, the lookups and the download ask all three, host mise
  asks Untrusted, and a forbidigo rule keeps x509's and tls's
  verification errors in internal/fetch (TestCertificateClasses,
  TestTransient, testdata/lint, the owners doc's row).
- An https address, or a test build's file:// DEVVM_UBUNTU_URL, read
  from disk the same way; anything else is refused. The CLI tests'
  sandbox has a stand-in of this host's image in the store.
- Base's record keeps the image's address, and the key is as it was: it
  hashes the pin (release, file, digest), not the location.
- devvm gc --caches frees devvm's copies that no record names and that
  aren't pinned now, unchanged for an hour, a stopped .part and a killed
  import's .import included, and those of a kept image once its .img is
  there. A pin it can't read fails it.
- Of Lima's cache, it frees only an entry that devvm's own state shows a
  build of devvm's left: a base record names its address, devvm has its
  own copy of the image, and the installed Lima's own templates
  (share/lima/templates beside limactl, Lima.Templates) don't name it.
  An entry no record names may be the user's own Lima's, so it stays,
  and none is freed when the templates can't be read, with a line in
  the run log naming the folder and why. A test build's
  DEVVM_LIMA_TEMPLATES stands in for the templates folder.
- ubuntu.ParseImage reads a record's image as Image.String writes it,
  and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in
  place of Lima's own regex.
- devvm space shows the copies as a cloud images row, freed by gc
  --caches, kept as state, as a release Ubuntu removed can't be
  downloaded again.

0.1.0's frozen state runs the new commands (fixture_v010_cloud_image):
devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's
base record keeps and never changes the entry, base builds from devvm's
own copy, and gc --caches keeps that copy, frees Lima's entry the
record names and devvm's own stale copies, and keeps an older entry no
record names.

Docs: images.md (the download, its failures, the import, gc's rules),
space.md, backends/lima.md, settings.md (the lookups and the download
trust your CAs), troubleshooting.md, overview.md, testing.md,
tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed
lines, which later commits make highlights, What to do 5 and 6, and the
release page's Ubuntu's cloud image in devvm's folder.

New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting,
ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate,
ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted.
Lima.LocalImage is the seam, Lima.ImageClient the client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 326660d748 feat(fetch): resumable downloads that survive cuts and stalls
fetch.Resumable downloads a large file into <path>.part and keeps it
across failures and runs: each retry asks only for the rest (Range, with
If-Range once the server named a strong ETag or Last-Modified, and
Accept-Encoding: identity, so no gzip changes what a range counts), a
try that reads nothing for Stall ends and is tried again, and Tries
tries in a row that bring nothing fail it, as do 100 tries in all, with
the wait doubling up to a minute. The file is kept at its path only once
its SHA-256 checks out; a part that doesn't is fetched again from
nothing, once. A server that ignores the range (200), has nothing past
it (416) or answers it from another byte starts the part again.

- A part that's already the whole file, as a run killed before its
  rename or a try that failed after its last byte leaves it, is kept
  without another request, where a range past its end would get a 416
  and start it again.
- A failure that trying again in this run won't mend (a 403, a proxy
  that refuses) keeps the part for the next run; only 404 and 410
  (fetch.Gone) and a file over Limit take it with them.
- A part that can't be written, or a whole file that can't be renamed
  into place, is ErrWrite, never tried again, and the part's hash and
  length count only what the file took, so a short write can't put them
  out of step.
- Content-Range is read strictly (parseContentRange, fuzzed), and a
  length over Limit fails as ErrTooLarge.
- The structure test's status-lines rule counts a
  fetch.Resumable{…}.Download as a request; structure.md says so, and
  its internal/fetch row names Resumable.

Tested in a synctest bubble on memnet against a server that cuts,
stalls, hangs, answers 403, 404 or 410, ignores the range or answers it
from byte 0, cuts after the last byte, behind a proxy that refuses, with
a part that can't be written, a whole part left by a killed run and a
file that can't be renamed into place (TestResumableWholePart,
TestResumableRenameFails).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 19:09:22 -07:00
w3cjandClaude Opus 5.5 de502f7840 fix(vm): rm's read of a --clone VM's clone gives up past 8 MiB or 2 minutes
readClone stopped keeping the VM's answer past cloneStateMax (8 MiB), but took the rest and waited for the command to end, with no time limit, so a VM that wrote without end, or never answered, kept devvm rm and devvm clone off waiting until Ctrl+C. The read of the agents' worktrees already had the bounds; workCheck.answer is now the one read for both, taken from agentTrees: at most cloneStateMax bytes, past which the bounded writer cancels the command, within answerWait (2 minutes, treesWait before), an interrupt returned as ctx's error. A failed, over-long or late answer is the check's failure, clone_check_failed or trees_check_failed, which keeps the VM and names the flag that skips the check, and a hostile one is parseCloneState's, as before. readClone fails before parsing on a bad answer, so its result is never a nil list (the nilaway baseline loses that line) and gosec sees its loop bounded by both lists.

On Lima the time limit didn't hold for either read: a cancelled limactl shell leaves its ssh child holding the command's output pipes, so os/exec's Wait waited for the VM's command to end. Exec now goes through the lima package's bounded (WaitDelay, a second), as the remount's commands do, so it ends a second after its context does; output a child held past limactl's own success is exec.ErrWaitDelay, an error, so an answer cut short is never taken as a whole one. That bounds every Exec, devvm paste's time limit and the history export included.

treeGlobs returns a list that's never nil: nilaway took its nil for one parseAgentTrees slices into, a false positive (agentTrees returns before it without patterns, and parseAgentTrees indexes pats only below nextRecord's len(pats)), which the CI job reported on main.

Tests that fail without the fix: TestWorkCheckBounded (TestAgentTreesBounded, now a table over both reads: an endless answer cancelled, a silent VM given up on after 2 minutes in a synctest bubble, an interrupt kept as the interrupt), whose clone case isn't cancelled and then deadlocks its bubble; TestExecHeldOutput, a real limactl stand-in that leaves a child holding its output, killed and after a success, which waits 30 s each, the success read as one, without bounded. TestParseAgentTrees checks treeGlobs with no patterns.

Docs: clone's --no-clone-check names a VM that doesn't answer within 2 minutes, How it works' deleting a VM gives the clone read's bounds, the Lima page's A command's output, the clone design note's cost and threat drop the wait that's gone, and internal/vm's map names answer. The changelog gets an If you use --clone block with the line, the release page its section under Fixes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:45:33 -07:00
w3cjandClaude Opus 5.5 e4b44b5994 fix(lima): limactl shell never starts a stopped VM past devvm's checks
In a terminal, limactl shell of a stopped VM asks whether to start it, yes by default (Lima 2.3.0, reproduced under a pty), and that start is Lima's own: no proxy or sandbox-exec profile (no QEMU wrapper on Linux), no pins, and no folderChanged, so the project folder's mount, by path on Linux's 9p, follows a link put at the path or makes a folder that's gone again. devvm opens a shell (Shell) and runs an agent's login (Exec) on the terminal after bringUp, so a guest that powered itself off between the two got that question. This is the start path the self-check's restart was suspected of: that restart goes through startOnce, but limactl shell didn't.

The limactl builder, which every limactl command of devvm's goes through, now gives limactl shell --start=false, which Lima has had since 2.0.0-rc.0 (devvm's oldest is 2.2): a stopped VM's shell or command fails at once ("instance is stopped"), without asking, and devvm's next launch starts it with every check. devvm limactl, which passes its arguments on as given, is unchanged.

TestShellNeverStarts checks Exec's, Shell's and the builder's limactl shell, and fails without the change; the lima package's and the CLI scripts' expected limactl shell calls name the flag, their negative patterns too, so none turns vacuous. Docs: How it works' Lima page's A stopped VM's shell; the changelog's Security hardening gets the line, its summary widened to cover both of its lines, and the release page its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:53 -07:00
w3cjandClaude Opus 5.5 80923fc580 test(vm): a gone folder's VM restarted by its self-check is refused before its start
devvm rm VM, for a VM whose project folder is gone, goes on with the VM as it runs for its export, or with --no-export for the check of the agents' worktrees, and the network self-check of a confined VM started outside devvm offers to restart it confined. A yes stops the VM, and the restart goes through startOnce, which checks folderChanged before the backend's Start: the start is refused (project_folder_changed), the VM is kept, stopped, and its folder, which Lima would make again for its mount, isn't made. startOnce holds the only backend Start in internal/vm, so every start devvm makes (a launch, devvm restart, an export, rm's checks, a remake, the self-check's restart) is checked the same way.

rm_gone_unenforced.txtar drives both rm paths with a yes to the restart: no limactl start, no export or worktree read, the VM kept, and once stopped refused as ever (rm_gone_stopped, rm_gone_stopped_trees) until the flags that skip what needs it running. The stub's limactl start makes no folder, so no limactl start is what shows the folder isn't made again. With startOnce's check before the backend's Start removed, it fails: the backend starts the VM, and only the check after the start stops it (project_folder_changed_stopped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 07:43:46 -07:00
w3cjandClaude Opus 5.5 376f1c2ad7 fix(agents): opencode's save, plugin approvals and the history scripts' framing
devvm agent save refused a VM whose ~/.config/opencode held a bun.lock (which opencode's plugins' installs write), a package-lock.json, a .gitignore or a .DS_Store: the save's script sent every entry of that folder but node_modules and FolderOwn, while the host's listedPath refuses those files (fileSetting), so it saved nothing. notSettings is now their one list, as patterns path.Match and the shell's case read alike: fileSetting leaves them out and the script sends a file of those names no more, only a folder that isn't a link, which is a setting. TestAgentSaveScriptRuns plants them and a folder named old.lock, and failed with agent_save_unsafe before the fix.

opencode's HistoryOwn names its native client's plugin approvals, in its state folder (cli-rs's plugin/src/loader/approval.rs and tui/src/plugins/host.rs, opencode v2.4.1): plugin-approvals.json, its .lock and the .plugin-approvals.json.<pid>.<n>.tmp it's written through, and plugin-staged, the approved trees' copies, which it reuses by their hash's name without hashing them again, so a hostile VM's export could approve a project plugin for the VM that imports it. That client doesn't ship in 2.4.1. TestHistoryExportRuns and TestHistoryImportRuns plant them, with plugin-notes.json as the control, and failed on fedora without the entries.

The history scripts' framing (onInputCmd) now says why on its stderr, which goes to the VM's log, when its input was cut short: TestOnInputCutShort checks it for every cut, an empty input included, and none for a whole one, and failed before. TestHistoryScriptsOnInput holds each script under 128 KiB, Linux's limit on one argument, which bash -c "$s" passes it as. The CLI scripts match the framing's new start.

Docs: the save's and the store's table say which files stay in the VM; the import's and How it works' lists name the plugin approvals; the release page gets opencode's lock files in a save and the approvals; the changelog's opencode block gets the save's fix, and the hardening line names approved plugins. The review's optional wording: the design note's `*` matches every resource, and the plain-password steps set this machine's password first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:03:05 -07:00
w3cjandClaude Opus 5.5 b625469ac6 fix(vm): devvm rm asks before opencode's worktrees' uncommitted changes go
An export leaves out opencode's worktree folder, as a git repository's config can name a command that git runs, so the uncommitted changes in the worktrees opencode makes there (~/.local/share/opencode/worktree/<project>/<name>, opencode v2.4.1's worktree/strategies.ts) went with the VM's disk on devvm rm, and on a remake with --clean-home, with nothing to say so.

The registry gets Worktrees (opencode's worktree/*/*, below its HistoryOwn, TestDefsComplete holding each to a plain pattern there). rm's unsaved-work check, cloneCheck, becomes workCheck: the clone (cloneLost, as before) and the agents' worktrees (agentTrees), one question for both. agentTreesState reads them in the running VM in one command, in its home folder, each * of a pattern sent as *, .[!.]* and ..?* (treeGlobs), so a name that starts with a dot is found: each folder with a .git, its git status and a detached HEAD's commit nothing else has; past 100 it says more. devvm reads at most 8 MiB of the answer, cancelling the command past it, and waits at most treesWait (2 minutes). parseAgentTrees takes the answer as untrusted: whole records of a glob asked for, each path clean, matched by its pattern and once, at most 100, each with one status. Dirty, detached, unreadable (wfail) and more are shown and asked about (delete_anyway or remake_anyway), which --force never answers; refused without a terminal (no_terminal_delete_trees, naming --no-worktree-check, or the clone's no_terminal_delete when it has work too). --no-worktree-check skips the check and warns (trees_check_skipped). A failed, late or hostile answer keeps the VM (trees_check_failed), and so does a VM that doesn't start for it (trees_check_not_started).

Rm and rmGone run it, and rmGone refuses a stopped VM with opencode, which starting would make its folder again (rm_gone_stopped_trees, naming --no-export --no-worktree-check); stillGone takes the refusal to give. remaking.checkWork runs it before a remake with --clean-home (remakeTo, Update, SetClone, whose clone check it joins), its messages naming the command as typed (remakeInVM.typed), with --clean-home, which --no-worktree-check needs (needs), so devvm clone off --clean-home's clone check messages name it too. A remake's flag has its own help. The stub guest runs the read in vmhome-<vm>.

Tests that fail without the check: TestRmAgentTrees, TestRmVMAgentTrees, TestRemakeAgentTrees, TestUpdateAgentTrees, TestSetCloneAgentTrees and the rm_agent_trees script; TestAgentTreesBounded (an endless answer cancelled, a silent VM given up on, in a synctest bubble); TestAgentTreesState runs the script under sh on real worktrees, a dot-named one included; TestParseAgentTrees holds the answer's checks, TestCloneGit the stub's. TestSetCloneOff names the command with --clean-home. e2e's network section makes a worktree in opencode's folder in the real VM, and devvm rm refuses, then --no-worktree-check deletes it.

Docs: coding agents' opencode's worktrees, How it works' opencode's worktrees, deleting a VM, a VM whose folder is gone, images, clone, the overview's remake, Commands, extending and rm's help; the changelog's What to do step 4 names --no-worktree-check for scripts and devvm rm VM of a stopped VM, and opencode's block gets the check; the release page has its section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 00:03:05 -07:00
w3cjandClaude Opus 5.5 962c183117 fix(agents): imported opencode history brings no automations, approvals or resumed turns
An export of opencode's history held what opencode 2.4 acts on without asking, so a hostile VM's export could run commands in the VM that imports it (opencode v2.4.1's source): its automations (automation), each a trigger and a shell command that it approved once and never asks about again (core/src/automation/shell.ts); the requests you said always to allow (permission, which Permission.evaluate turns into allow rules); each session's own rules (session_v2.permission, a Permission.Ruleset); the subagents' jobs (job), the queued messages (session_inbox) and the suspended sessions (session_v2.time_suspended), which its service starts or resumes when it starts (core/src/session/execution/restart.ts), with the session's agent's own rules, explore's allowing shell; a project's commands (project.commands), whose start command it runs with bash -lc for each worktree (core/src/worktree.ts); and its git repositories in its data folder (snapshot, repos, worktree), whose config can name a clean filter or core.fsmonitor that its own git update-index runs (core/src/snapshot.ts, git.ts).

opencodeClean now empties the tables opencodeUnattended picks (automation, permission, job, session_inbox, and any whose name starts so), sets the columns opencodeNulled picks to NULL (time_suspended, commands, in any case), keeps only the deny and ask rules with a text action of every permission column, each written again from what sqlite3 read, so a key written twice can't keep an allow effect for JSON.parse (opencodeAllowRules), drops every view, and fails its check on a generated column (opencodeHidden). Its check counts each and must print 0, so a sqlite3 without JSON leaves the database out. A view, an upper-case column, a generated column and a duplicate key bypassed the first version, as the security review showed.

opencode's HistoryOwn now names its background service's registration on every channel and the files written beside it (service-*.json, service.json.*, service-*.json.*) and its git repositories (snapshot, repos, worktree): an export leaves them out and an import never writes them, while a VM made again keeps them. The import's clean-up loop expands each as a pattern; TestHistoryImportScript holds every skip to a path's plain characters.

Tests that failed first (fedora's gate): TestOpencodeCleanSchema (automation and permission emptied, a session's allow rule gone), TestHistoryImportRuns and TestHistoryExportRuns (service-local.json, the handoff's and the registration's temporary files); TestOpencodeCleanSessionRules fails closed without the statements. The review's additions: TestOpencodeCleanSchema (job, session_inbox, a suspended session, a project's commands), TestOpencodeCleanSessionRules (a key written twice, a non-text action, an upper-case column), TestOpencodeCleanHidden (a view, a generated column), and the git folders in the export and import tests.

The review's docs fixes across the stack land here too: the changelog's What to do steps, the release page, the coding agents page, How it works and the design note.

A kept rule whose resource is missing or isn't text gets "*", as opencode's Permission.Rule needs one, and the check also counts a rule that isn't in the rebuilt form, so a copy whose rules weren't rebuilt fails closed. A stack-wide review's last docs fixes land here: devvm rm deletes opencode's worktrees with the VM, so the changelog has a What to do step to commit their work first.

The export's and the import's scripts, which the stack doubled, now go on the VM's input (onInput): a line with the script's length, the script, then the import's export. In the command's arguments, quoted for ssh's shared connection, macOS's ssh failed to start the session (mm_send_fd: sendmsg: Message too long), which the mini's e2e hit, the export first and then the import. The VM reads exactly that many bytes (dd bs=1) and runs the script only when it read them all, so an input cut short runs nothing (TestOnInputCutShort), and the script gets the rest as its input. TestHistoryScriptsOnInput holds every argument under 4 KiB; TestHistoryExportRuns and the import's runs use onInput too. The stub guest takes such a script off its input (inputScript), matches its switches and files() against it and keeps an export's and an import's in history-export.sh and history-import.sh, which history, history_import, rm_vm, existing_agents and layer_add read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 17:17:55 -07:00
w3cjandClaude Opus 5.5 b3e614743d fix(agents): opencode's service settings never reach the store or VMs
opencode 2 keeps its background service's settings in ~/.config/opencode/service.json, or service-<channel>.json on another channel (opencode v2.4.1's service-config.ts): the service's password, which the service makes when the file has none, and with remote access on, the secret route its address is served on and remoteAccepted. devvm agent import, and devvm agent save, copied every file of opencode's folder into the store, so every VM with opencode got a copy at each launch, with devvm-redacted in place of the password and the route as it was: each such VM's service took the known password devvm-redacted.

The agents' registry gets FolderOwn, the names of a WholeFolder agent's entries that are each machine's own; MachineOwn covers them, so agentFiles, agentDirs, agentLinks and listedPath leave them out: the import never copies them, no VM gets them from a store that holds them, and the save's script never sends the VM's own (which would have made the save fail). cleanStore (cleanSeeds, which now also runs cleanFolderOwn through the shared cleanOwn) takes them out of the store at a start, warning once (agent_store_own_cleaned, agent_store_own_clean_failed). The setup gets machine-own (agents.MachineOwnFiles) and DEVVM_REDACTED (agentlogin.RedactMark, exported, and now the one source of the placeholder in agentlogin's copies), and sync.sh's clean_machine_own takes out each regular file of those names that holds the placeholder, failing the setup with the cause when it can't, so the VM's opencode makes its own password; opencode service get password shows it.

Tests that failed first: TestSeeds' MachineOwn cases, TestOpencodeServiceNotImported, TestOpencodeServiceNotStaged, TestOpencodeServiceNotSaved, TestCleanStoreOpencodeService and TestSyncCleansMachineOwn. e2e's network section plants the store's service.json and checks the start takes it out, no VM gets its password or route, two VMs' passwords differ, and a launch takes out devvm's old copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 16:16:12 -07:00
w3cjandClaude Opus 5.5 394869407b test(e2e): Claude Code's login check asks for its full sign-in link
Since 2.1.330, Claude Code's sign-in link is a short one without the
state, which the check pastes back as code#state. Its documented
CLAUDE_CODE_FULL_SIGN_IN_LINK=1 prints the full link again, for scripts
that read the link, so the check sets it in the VM's login shells before
devvm agent login claude; earlier releases ignore it.

e2e's lock moves Claude Code from 2.1.327 to 2.1.331; nothing else moves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 15:22:38 -07:00
w3cjandClaude Opus 5.5 9acdd0c47c fix(agents): history exports leave out opencode's machine key
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 ~/.local/state/opencode/machine/home-key. That folder is in opencode's History, so devvm history export, and the exports devvm rm and a remake write, copied the key onto this machine, and devvm history import wrote it into other VMs, with the background service's registration (service.json and its .pty-handoff, the service's password and a handoff ticket) and the terminals' daemons (pty, their sockets and access tokens).

The agents' registry gets HistoryOwn: what of an agent's history is the VM's own as a machine. HistoryExcludes() returns it after each agent's HistoryExcludes, so the export leaves it out and the import never writes it, by its paths after it unpacks too. HistoryLogins() is each agent's HistoryExcludes alone, which a remake's home copy (homeSkips) leaves out, so a remade VM, the same machine, keeps its key. The copy of opencode's database empties its machine table (opencodeLogins), the paired machines' public keys, which are the VM's own pairings.

opencode's schema fixture moves to 2.4.1 (testdata/opencode-2.4.1.sql, from its release's schema.gen.ts, which matched 2.2.5's VM-printed file line for line): automation replaces schedule and is kept; machine is emptied.

Tests: TestHistoryExportRuns, TestHistoryImportRuns and TestHistoryImportV010 plant the key, service.json, its handoff and pty, and fail without the fix; TestHomeSkipsEveryLogin checks each HistoryExcludes is skipped and each HistoryOwn kept in a remake; TestLists covers HistoryLogins; e2e's network section plants the key in a VM and finds it in no export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 15:22:38 -07:00
w3cjandClaude Opus 5.5 82f075c5bd build(deps): bump pins
scripts/bump.sh's safe bumps, patches and minors:

- images: mise 2026.11.10 -> 2026.11.14 (base and the host's, with
  internal/tools/mise.go's checksums), nix 2.35.6 -> 2.36.0, Docker's
  buildx 0.39.0 -> 0.39.1 and model 1.2.9 -> 1.2.10
- e2e: the lock's pnpm 12.21.0 -> 12.23.0, bun 1.4.4 -> 1.4.5, codex
  0.169.1 -> 0.171.0, opencode 2.3.2 -> 2.4.1, pi 1.5.2 -> 1.6.0;
  --from's node:24 by its new digest
- dev-tools: nilaway to its newest commit's pseudo-version
  (0.0.0-20261124161746-91ad9bf5d8e6), goreleaser 2.20.3, vale 3.28.1,
  markdownlint-cli2 0.24.2, whose lock folder moves to
  .mise/locks/markdownlint-cli2/0.24.2/, zizmor 1.33.1, with mise.lock
- ci: the workflows' mise 2026.11.14, jdx/mise-action v5.3.0,
  amannn/action-semantic-pull-request v6.1.4

The e2e lock keeps Claude Code at 2.1.327: 2.1.328 made its sign-in link
much shorter, without the state parameter that the network section's
login check reads to answer it, so with 2.1.330 that check and the
refresh after it fail. devvm itself never reads the link.

mise's and Nix's new checksums match upstream's SHASUMS256.txt and
.sha256 files; buildx and model are apt packages from Docker's signed
repository. Cursor's CLI stays on 2026.11.17-f532c45: 2026.11.22-e9042b2
is out, and it moves only when named. pflag stays held below 1.1.0 and
Node on 24.

The new nilaway no longer reports three of agentsave.go's bounds
findings, so their lines leave testdata/nilaway-baseline.txt, which
nilaway and nilaway:linux fail on while they're stale.

The CHANGELOG's Unreleased has the pins line, and the 0.2.0 page a
section for them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 14:35:10 -07:00
w3cjandClaude Opus 5.5 8e04b1c86d fix(scripts): bump.sh moves a Go tool's pseudo-version from the module proxy
mise latest prints nothing for go:go.uber.org/nilaway/cmd/nilaway, which
has no releases and is pinned to a pseudo-version, and exits 0, so
bump.sh --check reported "nilaway: X -> (change)" and the run listed it in
its summary without moving it.

dev-tools now reads a go: tool pinned to a pseudo-version from the Go
module proxy's @latest, for the longest prefix of its package's path that
the proxy has as a module (go.uber.org/nilaway). Only the proxy's 404 or
410 moves on to a shorter prefix; any other failure is an error, so a
failed request never takes another module's version. An empty newest
version, from the proxy or from mise latest, stops the run with an error,
never a change, before anything is edited. A pseudo-version has no
"newest within" for a hold to fall back on. proxy_url is the proxy's
escaped path, which mod_versions now shares.

bump.txtar's mise stub prints nothing for nilaway, as mise does, and its
curl stub answers the proxy's @latest with -w's status; it checks the
bump, the errors for an empty @latest, for no module at any prefix, for a
503 at a longer prefix and for an empty mise latest, each with mise.toml
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 12:57:34 -07:00
w3cjandClaude Opus 5.5 99a0ab45bb test(devcontainer): FuzzParse's check reads variables as devvm does
The nightly fuzz run found an input that failed FuzzParse's own check, not
devvm: {"remoteEnv":{"A":"${${localEnv:}"}}. devvm reads each ${ to the
first } after it, so ${${localEnv:} is one variable whose name starts with
${, which it leaves as single-quoted text for the VM's shell, as the design
note intends. The check's pattern matched ${localEnv:} inside it.

The check now takes the variables as devvm reads them, non-overlapping
${...} to the first }, and flags only one whose name starts with localEnv:
or env:, in the environment and in what's kept. TestParse has a nested
${${localEnv:HOME}} in a variable and in a command, kept as text, and the
input is in the corpus. FuzzParse's row in Contributing's testing page
says how it reads them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-24 12:57:23 -07:00
w3cjandClaude Opus 5.5 06f72211ef docs(changelog): 0.2.0-rc.1's lines where their reader looks
The import's bounds, an import while a VM's state can't be read and the
save's string-file crash move to the agent store block, the NO_PROXY line
(#59) to the company proxy block, the open-files line to links and
forwarded ports, and Lima's console passwords, every host in one form and
devvm's other logs to Security hardening, as the docs-voice review
suggested. Internal keeps what no reader needs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 10:24:59 -07:00
w3cjandClaude Opus 5.5 336e45defb docs(changelog): the docs-voice review's fixes to 0.2.0-rc.1's lines
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 06:27:58 -07:00
w3cjandClaude Opus 5.5 2615a1322b docs: changelog entries by audience, with a test that keeps their shape
Releasing, in Contributing's maintaining.md, now gives the entry's groups
in their order (Highlights, What to do, Fixed, If you use… blocks,
Security hardening, Internal changes), what goes in each and the question
behind them, who notices; each line as one outcome sentence of at most 35
words, then its links; the release page as the full story; the sort table
and a fresh docs-voice review before the release commit; and how lines go
into Unreleased as changes land.

AGENTS.md gets a Changelog line, and the codebase-standards skill a
checklist item and its guard in rules.md. The rules that named the old
Breaking and After you upgrade sections (AGENTS.md, structure.md's
Released state, standards.md, rules.md) now name What to do.

TestChangelogShape (internal/cli/docgen/changelog_test.go) reads
CHANGELOG.md and checks each entry from 0.2.0-rc.1 on, and Unreleased
once it has a line: the groups and their order, three to five
Highlights, balanced <details> with a <summary> and the blank lines
GitHub needs, 35 words of prose a line outside What to do (links and a
credit not counted), a details link to releases/ on every line, and full
links for issues and pull requests. TestChangelogProblems breaks each
rule once on a small entry. lint:docs runs both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 06:26:05 -07:00
w3cjandClaude Opus 5.5 7b56231dda docs(changelog): 0.2.0-rc.1's entry by audience
The entry's 76 bullets become 55 lines sorted by who notices each change:
Highlights (3), What to do (8 steps), Fixed (9), seven collapsed If you
use… blocks (13), a collapsed Security hardening (7) and a collapsed
Internal changes (15). Each line is one outcome sentence and keeps every
link its bullets had; the release page holds each change's full story.

markdownlint's MD033 allows <details> and <summary> alone, everywhere, as
markdownlint-cli2 can't set a rule for one file. The release page's intro
names What to do in place of After you upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-21 06:23:57 -07:00
w3cjandClaude Opus 5.5 b66e5d63f8 docs(changelog): full links for issues and pull requests
Every #N in CHANGELOG.md, in every entry, a credit's included, is now
a full link, /issues/N for an issue and /pull/N for a pull request, as
gh api's .pull_request tells them apart: a bare #N links only in
GitHub's view of a release's notes. 31 references, 30 numbers: issues
3 (twice), 4, 17, 35, 36, 37, 40, 52, 54, 55, 56, 57, 59, 60, 61 and
62; pull requests 19, 20, 23, 25, 26, 27, 28, 30, 31, 32, 38, 42, 44
and 58. Maintaining's Releasing says to write them so, and the release
page already does, with the same kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 22:52:16 -07:00
w3cjandClaude Opus 5.5 b7178b0dc8 docs: the design notes move to Contributing
The design notes are for contributors: they hold each emulation's
design note, its threat check and its tests, with hundreds of Go
identifiers, so the page moves from How it works to Contributing
(weight 8, after Writing docs), keeping its title and anchors. An
alias keeps /docs/internals/design/ working, as a redirect to the new
page.

Every reference follows: the internals, using, safety and contributing
pages' links, the page's own links to the How it works pages, the
section index pages, AGENTS.md's Backends rule, contributing/docs.md's
What goes where, internal/proxy/README.md and two e2e comments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 22:49:50 -07:00
w3cjandClaude Opus 5.5 654ade131f docs: release notes as actionable changelog entries, with the full story on the docs site's release page
The changelog's 0.2.0-rc.1 entry keeps Breaking and After you upgrade
complete, gives each Changed and Fixed item a sentence or two, and adds a
Hardening section of one-liners. Every bullet links its section on the new
Releases page, its issue as a bare #N, as earlier entries write it, and the
commit that made the change.

docs/content/docs/releases/ is a new section, after Using, with 0.2.0.md:
a section for each change, with what was wrong, how it showed, how devvm
works now and what to do, holding every fact the entry had.

Writing docs, the docs-voice skill and AGENTS.md say releases/ is the one
place docs describe history, and Releasing describes the entry's sections,
its links and the release page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 21:02:25 -07:00
w3cjandClaude Opus 5.5 6dd965b475 docs: How it works names no Go identifiers; Contributing has them
The How it works pages (but the design notes) say each mechanism in
plain words, and the identifiers, repo paths and test names they named
move to Contributing: The packages' rows in structure.md, extending.md's
How a backend plugs in, maintaining.md's pins table, and a new tests.md
section, The tests behind How it works, which names the tests that the
pages now describe in words.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:55:25 -07:00
w3cjandClaude Opus 5.5 4499c1a926 docs(contributing): the changes since 0.1.1-rc.3 in the docs voice
A docs-voice pass over the passages of the Contributing pages and
internal/proxy/README.md that changed since v0.1.1-rc.3: clauses
chained with colons and semicolons split into sentences, "but" for
"except" spelled out, long table cells (folder-ids, status-lines,
internal/vmname, internal/redact, internal/vmlog, internal/proxy) and
list items (the proxy's connection limits, the e2e-* pins) broken into
sentences, passives given their actors, and two passages put in the
present (a proxy config's bytes, the proxy tests' start wait).

Every fact is kept: facts.sh finds no change on any page, and
facts.sh --all only five more copies of names already there. The
generated table in structure.md is untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 6e36a19058 docs(internals): the changes since 0.1.1-rc.3 in the docs voice
Rewrites the passages of the How it works pages that changed since
v0.1.1-rc.3 into joined, plain sentences: clauses chained with colons
and semicolons split or joined, trailing "too" turned into "also",
"X alone" into "only X", inverted and passive sentences turned round,
and design.md's broker note's "as the proxy does now" made present
tense. Every fact is kept (facts.sh --all: only punctuation next to
numbers and one more mention of NormHost, devvm _qemu pinned and the
17 ports).

Pages: agents, backends, design, desktop, git-protection, install,
lima, network, overview, ports, processes, security. _index and
images needed no change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 462699a491 docs: the user pages' changes since 0.1.1-rc.3 in the docs voice
Reworks the passages that changed since v0.1.1-rc.3 on troubleshooting,
coding-agents, settings, ssh, vms, attack-vectors and network: chained
clauses split, colons between clauses turned into sentences, back-to-back
paragraphs turned into lists, and doctor's command for unreadable state
moved ahead of its explanation. facts.sh reports no change on any page,
nor across the docs tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 78716806d4 docs(changelog): 0.2.0-rc.1's entry in the docs voice
Each bullet now leads with what changed for the user, then what to do,
then what it used to do, and the link. After you upgrade leads with
devvm update, and splits the plugins note so signing in to a plugin
again stands on its own. Long bullets are split (the proxy's sandbox
fallback, agent import's bounds, failure and warnings, the save's lock,
the status line's waits, the proxy's limits, the other logs' caps, a
folder on another volume), the status line's steps and the proxy's new
limits are lists, and #60 sits beside the moved-folder fixes.

Mechanism that the linked pages already say moved out: the child's
requests to its broker, the volume IDs and diskutil's retry, Unicode
tables' names for #55, the SSH agent relay's editor and limactl
entries, nc -N's detail, the forwarder's security-module case, the
log caps' rotation and holes, and a name block's allow suggestion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 7bb1a114f3 docs(readme): how to try 0.2.0-rc.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 6b859825f3 test(proxy): TestBrokerClientDial asks once more for a connection that reads as ended
On macOS, a socket in transit over SCM_RIGHTS can lose its data when
another test's goroutine closes a unix socket that still holds
descriptors (design.md, Things learned). TestBrokerClientDial read an
ended connection that way on macOS CI. It now dials again once when the
connection reads as ended, as TestBrokerClient does for a link.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 20:34:12 -07:00
w3cjandClaude Opus 5.5 7c4659ce87 chore(release): trust the second release machine's tag-signing key
packaging/release-signer names a fingerprint for each machine that tags
releases, so a tag signed on either one builds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 19:24:00 -07:00
w3cjandClaude Opus 5.5 bcd126a2c4 chore(release): 0.2.0-rc.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 17:51:16 -07:00
w3cjandClaude Opus 5.5 47593e21ab fix(proxy): NormHost keeps an address's trailing dot, its IPv6 zone's, and Public calls no zoned address the internet's
NormHost dropped one trailing dot from any host, so an IPv6 address whose
zone is "." (::1%.) became ::1%, an empty zone, which netip reads as no
address. The proxy refused both forms (HostOK), but a partial clone's
promisor warning (privateHost) no longer saw ::1%. as private, as
FuzzPromisorHostSite found. NormHost now leaves an address as it is, its
dot included, so every judge reads such a host as the zoned address it
is. Public now calls no address with a zone the internet's: netip's
prefixes never contain a zoned address, so the ranges alone missed, for
example, a zoned documentation address, which --from's registry check
took as public.

No VM could reach anything through such a host: every way in (CONNECT,
absolute-form requests, a transparent connection's Host and its TLS
server name) refused it with 400 before any lookup or connection, on
every tier, the broker refuses a lookup of it and a connection to a
zoned address, and no rule or NO_PROXY entry names one.

Tests: TestZonedHostsRefused sends each zoned and empty-zone host
through CONNECT, plain HTTP and the transparent path on the open,
internet, allowlist, none and loopback-allowing tiers, checking each
refusal is the proxy's own where net/http lets the request through,
with a control on each path that [::1] itself reaches the dialer where
allowed; it passed before the fix too, and fails when HostOK takes a
zone. TestNormHost, TestBrokerLookup, TestBrokerDial, TestInternal and
TestPublicAddr gain zoned cases; FuzzHostSites' splitSite and
policySite list the new divergence (zoneDot), and FuzzPromisorHostSite
lists a zoned address now counting as private; its crash input and the
zoned-unspecified one ([::%[]:) are added. design.md's list of the
host readers' differences names both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 17:36:57 -07:00
w3cjandClaude Opus 5.5 947decb301 fix(vm): VMs get the host terminal's COLORTERM (fixes #54)
limactl shell asks ssh to send COLORTERM (SendEnv), but its session
rides Lima's shared ssh connection (ControlMaster), opened without it,
and the master filters a session's environment by its own SendEnv, so
the variable never reached the VM (lima-vm/lima#2208, #1481). Closing
that connection would end every session and the VM's SSH agent relay,
so devvm now sets COLORTERM in the command it runs in the VM instead:

- backend.ShellOpts and ExecOpts get ColorTerm. Lima's Exec runs
  `cd D && export COLORTERM=<quoted> && exec argv`, and its Shell, with
  a ColorTerm, runs `sh -c 'export COLORTERM=<quoted> && exec "$SHELL"
  --login'`, as limactl shell does without a command; without one, the
  argv is as it was. colorTerm (lima) quotes the value with shell.Quote
  and links Lima #2208, so it can go once Lima sends it.
- vm's colorTerm is the one allow-list: only truecolor and 24bit pass,
  anything else or none is "". target.shell (devvm's shell) and
  AgentLogin.loginOpts (an agent's login on a terminal) fill it from
  Env.Getenv; no other command in the VM gets it.
- devvm's ssh config entries add `SendEnv COLORTERM`, so plain ssh by
  name (ControlMaster no) sends it: the e2e showed the base's sshd has
  AcceptEnv COLORTERM. It adds to a Host *'s SendEnv.

Tests, each failing without the fix: TestExecAndShellColorTerm (lima),
TestColorTerm (vm: the shell's and the login's value for allowed,
near-miss and injection-shaped values), testdata/script/colorterm.txtar
(the stub limactl's argv for the shell and an agent's login), ssh.txtar
and sshconfig's pinned lines, and e2e: a fresh VM's first shell, a
login shell on a terminal in the folder (24bit, and none for another
value) and ssh devvm-web. The structure test's dynamicScripts lists
both new built scripts.

Docs: Managing VMs, ssh access by name, How it works' Lima (A shell's
colors) and security (the ssh entries), and CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 11:27:28 -07:00
w3cjandClaude Opus 5.5 c4b4c02424 test: FuzzCapture skips devvm's own placeholders; FuzzParseLFSPointer counts a size as it parses
The nightly fuzz run found two inputs that failed the tests' own checks,
not devvm:

- FuzzCapture: a 26-character access token that is a prefix of fakeJWT's
  fixed header. The VM's reply held only placeholders, and the check
  matched the placeholder's header. It now looks for the tokens in the
  reply without devvm-proxy-managed and JWT-shaped placeholders whose
  header and claims are fakeJWT's own (its mark and an expiry).
- FuzzParseLFSPointer: "size -0", which strconv.ParseInt and git-lfs read
  as 0. The check counted only a canonical size or one with a leading +
  or zeros; it now counts a size line that parses to the size taken.

Both inputs are in the corpus.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 02:13:41 -07:00
w3cjandClaude Opus 5.5 a1c09016a1 test(vm): TestAgentImportFailsWhole keeps the listed file's inode
The test swapped the last listed file by removing it and writing a new
one at its path. On ext4 the new file can get the removed one's inode at
once, so it is the same file by device and inode, the import copies it,
and the test failed on Linux CI. The listed file is now renamed aside,
so its inode stays in use and the new file is another.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-20 02:01:54 -07:00
w3cjandClaude Opus 5.5 755f9bfd93 fix(vm): devvm link, link add and rm, group join and leave, network learn and lock, and a VM's stop show a status line for every slow step
TestCommandStatusLines runs more of the commands on a running and a
stopped VM, answering their questions in a terminal through the
msg.Fake (Confirm, Ask, Answer and the picker) and failing on one asked
under a status line: devvm network lock's picker (learned hosts in the
proxy's log), which it checks is asked, mount-cache and mount-cache
none, whose restart it checks is asked and answers yes, and with a
second VM, api, which runs, publishes 5432 and is in group web: link
add, link, link rm, group join, then link publish and unpublish (api's
links change in the group), group and group leave, then with api
stopped link add and link, then rm of api, which web links to. devvm
restart runs last but for devvm stop, on the VM restarted and again on
it stopped, and rm, as it starts a stopped VM. A proxy or a link
session started with no status line showing fails it.

It found, each now under a status line:
- linkRuns.apply, which gives a VM its changed links (its running
  checked, its setup sent again, its link session started, the wait for
  what came of each link), for link add and rm, link publish and
  unpublish, a group's changes and a target gone: links_applying.
- Links.warnUnenforced's look at the target (Inspect, and whether its
  tier is in force): checking_vm.
- Links.List's targets' status: reading_vms.
- Net.applyTier's PrepareRunning between two confined tiers, which
  starts the proxy again for the new tier, for network learn and lock:
  proxy_applying_tier.
- Net.Lock's read of the VM after the picker: finding_vm, only around
  the read, as applyTier shows its own.
- target.stop, every stop of a folder's VM (a restart, devvm stop, a
  move, a remake): stopping, which Lima's own step shows too.

Tests: testProxy runs a link session as a sleep that says each of its
links is carried, at once and as they change (linkSession), its signal
and the test's cleanup waiting until it says nothing more; sleeper is
the one sleep standing in for a background process, for testProxy,
testForwarders and linkRunsEnv; secondVM, beside existingVM, makes
TestGroupJoinsAtOnce's second VM too.

Docs: Contributing's status lines; CHANGELOG; the descriptions of
checking_vm, reading_vms, stopping and links_applying.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 23:15:50 -07:00
w3cjandClaude Opus 5.5 888078c9cd fix(vm): devvm agent save and import read names as the store's volume does, so a name that differs only in case never deletes a file
On a volume that ignores case, as a Mac's does by default, a store with
Foo.md and a VM sending foo.md (or a home folder with foo.md, for
devvm agent import) made the command rename the new file over Foo.md,
which keeps its name, then move Foo.md aside as a file the folder no
longer has, and delete it with the staging folder, reporting success.

- pruneIn keeps what keep names as the volume reads it: every kept
  name's folder, or file with one name, by what it is (platform.DevIno),
  so the store's Foo.md that a foo.md just replaced in place stays, in
  save's pruneFolder and import's apply alike. A hard link is kept only
  by the name keep has.
- storeFiles takes the VM's names and lists a store's file that the
  volume reads one of them as, under another name, under the VM's name,
  so compare shows the VM's foo.md as a change to Foo.md, never an add
  and a remove, and a kept name keeps its file. A hard link is never
  listed so, and the diff shows its names removed, more than the save
  takes out, never less.
- storeStage.claim checks each path before the stage writes it in its
  staging folder, which is on the store's volume and holds only what it
  wrote: a part already there under no name it wrote is a name the volume
  reads as another of its own (nameClash), named with that one. The save
  stages its folders too, and checks the names it leaves out
  (agent_save_names_collide); the import checks its folders and files
  (agent_import_names_collide). Either fails before the store changes.
- The save holds a VM's paths to the import's bounds, 128 folders deep
  and 4,096 bytes, measured from the agent's folder as the import's walk
  measures them (agent_save_too_much, which now lists every bound): each
  folder's claim, make and apply opens its path one name at a time, so a
  chain thousands deep cost the square of it under the store's lock.
  safefile's walkMaxDepth and walkMaxPath are MaxDepth and MaxPath, the
  one owner of both.

Tests that fail without the fix: TestAgentSaveCaseOnly,
TestAgentImportCaseOnly (the file was gone; a left-out PH.md shown
removed), TestAgentSaveCaseOnlyHardLink (the diff showed a change and
the save took out the other name), TestAgentSaveNamesCollide (two
files, two folders, two empty folders, a file and a name left out),
TestAgentImportNamesCollide (through the import's stage); they skip on
a volume that tells case apart. TestStoreNamesByWhatTheyAre (a hard
link stands in for the volume's other name, on any host) and
TestReadSent's depth and path cases, each at its bound and past it.

Docs: using/coding-agents.md (importing, saving), internals/agents.md;
CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 23:05:59 -07:00
w3cjandClaude Opus 5.5 2de3e31a6c fix(vm): devvm ports shows a status line as it restarts a running VM's forwarder, and every lock's wait is tested for its label
Lock waits:
- Tests record the label of each lock's wait that had none, the lock held
  as by another devvm and the wait ended by a cancel, a deadline failing
  one that shows nothing rather than hanging: git_lock_waiting
  (TestGitLockWaits; .git protection's Serial is gitSerial, so a test can
  reach it), packages_waiting and rebuilds_waiting (TestImageLocksWait),
  ubuntu_pin_waiting (TestPinOriginWaits), custom_secrets_waiting
  (TestYoursLockWaits) and forwarder_waiting (TestForwardsLockWaits).
- A test build's locks panic on a nil platform.Waiting
  (platform.CheckWaiting, which the root's run calls in every test build
  beside state.CheckLockOrder), so the CLI tests and e2e catch a nil wait
  the structure test can't see, such as a zero agentlogin.File's; a
  msg.Waiting given a nil status shows nothing and stays review only.
  msg.Waiting with no status gives a wait that shows nothing, never nil;
  platform.NoWait is the Waiting of a lock that never waits (the build
  port's record, which passed nil), and the status-lines rule holds it to
  statusSites as it does nil (TestCheckWaiting, TestWaiting, the rule's
  NoWait case).
- forbidigo refuses syscall.Flock and unix.Flock outside internal/platform,
  internal/proxy/rotate.go, the stubs and tests (testdata/lint, both).
- TestLockFileWaiting runs in a synctest bubble and checks the wait shows
  while held, not before (its counters under a mutex, which the race
  detector needs, as only the file's lock orders them).

Status lines:
- TestCommandStatusLines runs the setters too: devvm ports LIST and ports
  add, size --cpus, network open, allowlist, transparent off and on, learn
  and allow, git-protect off and on, ssh-agent off. It found devvm ports on
  a running VM starting its forwarder again (ssh and a command in the VM)
  with no status line; that step now shows ports_restarting.

The folder named twice:
- vm_folder_unreadable's why was the open's error, the folder's path in
  it; folderUnreadable gives the system's reason alone when the error is
  about the folder itself (TestUnreadableFolder checks the whole message).
- platform.OpenNoLinks and StatFolder return a link on the path as an
  fs.PathError about the folder too (ErrLinkOnPath still matches), so that
  case names it once as well (TestStatFolderUnique).

Docs: Contributing's CLI page (status lines) and structure page, the
codebase-standards guards; CHANGELOG (devvm ports' status line).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 17:04:29 -07:00
w3cjandClaude Opus 5.5 f80fd2df60 fix(vm): devvm agent save applies all or nothing under the login lock; a lock's wait and a walk end with their context; a link to the home folder counts unless only root can change it
All or nothing:
- devvm agent save goes through devvm agent import's undo journal: each
  plan's files are written into a staging folder of the agent's store
  (saver.stage, newStage, the import's .devvm-import- name, swept by the
  next import or save), then put in place (applyPlan: each file renamed in,
  the one it replaces kept aside as a hard link, folders made, what a folder
  no longer has moved aside, seeds and kept entries left), and the
  .claude.json subset saved last with secrets.SaveLogins, which holds the
  login's lock. A failure after the first change puts every agent's store
  and the login back; an undo that fails too says so
  (agent_save_undo_failed) and keeps the staging folder.
- applyStages (and stageSet) is what both commands apply through;
  importStage is now storeStage, pruneIn takes an fs.FS, and pruneFolder
  moves a folder's leftovers aside. pruneStore and applySettings go.
- A file in the VM where the store has a folder, or the other way round,
  fails the save before anything changes (agent_save_store_folder,
  agent_save_store_file; sameKind), where the stage would have replaced it without the diff
  showing; storeFiles reads such a path as empty.

Contexts:
- platform.LockDir flocks a folder, polling until ctx ends as LockFile
  does (waitLock is their shared loop); agentlogin's lockLogin is it, so
  the lock is the one an older devvm's proxy takes. LockLogin, LockFolder,
  File.CaptureRequest, Capture, SetKey, Remove and
  secrets.Store.CaptureRequest take a ctx. A capture whose reply the
  endpoint has given is saved with agentlogin.AfterReply's context, the
  exchange's without its end and bounded by two minutes of its own, so the
  exchange's deadline never loses a rotated login while a refresh or a save
  holds the lock, and a stalled holder never holds it for ever
  (File.Capture, secrets.Store.Capture, its loginsDir included).
- safefile.Walk takes a ctx and stops before each folder and batch once it
  ends; readSettings, followLinks and follower.copy pass theirs.
- LockFolder's comment said its lock was another than a login file's in
  the same folder; it's the same (.claude.json's), and says so.

Links while a state can't be read:
- homeHops exempted every link on the way to the home folder, on the
  claim that no project folder can hold one, which --unsafe-folder breaks.
  rootOnly exempts a link only when every folder above it, up to /, is
  root's, has no group or other write bit and the system says you can't
  write it (platform.Writable, access(2), which counts ACLs and FUSE), and
  devvm doesn't run as root.

The structure test lets internal/agentlogin import internal/platform and
counts platform.LockDir in its status-lines rule.

Tests that fail without their fix: TestAgentSaveApplyFailsWhole (a rename
and the login failing), TestAgentSaveUndoFails, TestAgentSaveLoginLock
(waits under agent_login_waiting; Ctrl-C leaves the stores as they were),
TestAgentSaveKindChanged, TestAgentImportHomeBelowALink,
TestCaptureOutlivesItsDeadline, TestClaudeCaptureOutlivesItsDeadline,
TestWalkCancelled, TestLockLogin (synctest:
a deadline and a cancel). New: TestLockDir (synctest, and a plain flock's
lock), TestRootOnly, TestWritable, the status-lines rule's LockDir case.
TestStoreOpsRefuseLinks checks openStoreDir in pruneStore's place.

Docs: internals/agents.md (saving, the staging folder, links to the home
folder), using/coding-agents.md, Contributing's CLI and structure pages;
CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 16:49:51 -07:00
w3cjandClaude Opus 5.5 cb7177b32c feat(ui): waits for another devvm's lock show a status line; a project folder devvm can't read says so
Lock waits:
- platform.LockFile and LockFileShared take a platform.Waiting, called
  once they find the lock held, never when it's free, whose end they call
  once the wait ends; LockFileWaiting, LockFileSharedWaiting and their
  delays (ShareNote, OCINote, WaitNote, groupsNote, makingNote) go.
- msg.Waiting makes one from a Reporter's Status and a label;
  msg.WithStatus and msg.StatusOf carry the run's Status in its context
  for the two packages that take no Reporter, internal/state and
  internal/trust, which cli's execute sets; forbidigo keeps StatusOf to
  them, and AGENTS.md says so.
- Every lock that waits shows its own label: vm_state_waiting (a VM's
  state, its deletion), claims_waiting, layout_waiting, git_lock_waiting,
  ca_waiting, packages_waiting, rebuilds_waiting, ubuntu_pin_waiting,
  custom_secrets_waiting, forwarder_waiting, agent_store_waiting, and the
  waits that printed a line after a delay, which now show theirs as a
  status line: share_waiting, oci_waiting, image_build_waiting,
  group_waiting, making_waiting.
- An agent's login file's lock (agentlogin's lockLogin, a folder's flock
  that a VM's proxy holds while it refreshes the login) tries first
  without waiting and shows agentlogin.File's Waiting
  (agent_login_waiting) while it waits; secrets fills it from its
  Reporter, for SaveLogins, Claude Code's logins folder and every File.
- The structure test's status-lines rule counts a LockFile or
  LockFileShared whose waiting is nil as slow work; the build port's
  record, a file just made that never waits, is listed in statusSites.
- Without a terminal, or with -v, a status line draws nothing, so the
  waits that printed an info line after a delay no longer print it there;
  the CHANGELOG and the troubleshooting page say so. from.txtar's check
  that a free conversion lock printed no wait goes, as TestLockOCI checks
  it.

The layout's migration runs under a status line (layout_migrating),
only when there are migrations to run.

Backend calls outside a launch: TestCommandStatusLines runs devvm ls,
ports, size, network, tools, git-protect, history export, stop and rm on
a running and a stopped VM and fails on a backend call with no status
line showing, with a control that each makes one.

A project folder devvm can't open and read (vm_folder_unreadable) was
taken for another folder's VM (vm_other_folder, which offers rm and
adopt, and adopt went on); the finder now keeps why (target.unread), and
every command on the folder's VM, from the folder or a subfolder of it,
names the folder and why; devvm rm VM run elsewhere goes by the VM's
name as before.

platform.UniqueFolderID had no caller but its test: FolderStat.Unique,
from the open folder, replaced it; it goes, and its test checks
StatFolder's Unique instead.

Tests: TestLockFileWaiting (rewritten: called only when held, its end
once got or given up, shared too), TestVMLockWaits, TestCheckLayoutWaits,
TestCheckLayout (migrations under layout_migrating, nothing shown
otherwise), TestLockGroups, TestLockShare, TestMaking, TestLockOCI and
the build lock's test (status lines, not info lines), TestLockLogin,
TestInitCACancelled (ca_waiting), the status-lines rule's lock cases,
TestCommandStatusLines, TestUnreadableFolder (a subfolder of it too),
TestStatFolderUnique.

Docs: Contributing's CLI page (Status lines) and structure page, the cli
and codebase-standards skills (the guards), AGENTS.md's Go conventions,
internals/images.md and design.md (the waits), using/troubleshooting.md,
using/vms.md (a folder devvm can't read); CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 15:10:22 -07:00
w3cjandClaude Opus 5.5 b04a1a9f12 fix(vm): agent import walks within its bounds, takes turns at the store, applies all or nothing, and refuses links while a state can't be read
The bounded walk:
- fs.WalkDir read each folder whole before the import's entry bound
  applied, so a VM whose project folder is in an agent's folder could make
  the walk hold millions of entries. safefile.Walk walks as fs.WalkDir
  does (order, SkipDir, SkipAll, errors) but reads each folder 256
  entries at a time, counting every entry it reads against a
  safefile.Bound, and stops with ErrTooMany before fn sees the folder;
  it also stops at a folder more than 128 deep or a path past 4,096
  bytes, so a deep chain can't make the walk quadratic.
- readSettings walks the agent's folder through the folder opened one
  folder at a time (h.safe), whose FS now opens folders to list them
  (rootFS.openDir: no follow, no blocking, the folder Lstat saw or
  ErrSwapped), so a link or a FIFO swapped in for a folder fails the
  walk. follower.copy walks each link's target the same way; the walks
  of all links read at most linkMaxWalked (80,000) entries in all, those
  left out for the bounds included.
- The structure test's status-lines rule counts safefile.Walk as a walk.

The store's lock:
- paths.Dirs.AgentStoreLock (agents.lock in the data folder), held by
  lockStore, under a status line (agent_store_waiting) while it waits:
  devvm agent import from its staging to its logins, devvm agent save's
  writes, and a start's clean of a seed's folder (cleanSeeds, now with
  ctx), which takes it only once it finds something to take out and
  looks again under it.
- devvm agent save plans again under the lock and saves nothing when the
  store changed since it showed the diff (agent_save_store_changed),
  rather than write over an import.

All or nothing:
- After staging, apply moves aside what it replaces or prunes into the
  staging folder's replaced folder (a file kept as a hard link, so it's
  still replaced in one rename), notes the folders it makes, and keeps
  each change's undo. The logins are saved all or none
  (secrets.SaveLogins, which reads each file it replaces first, puts them
  back on a failure, and holds each login's lock, agentlogin.LockLogin,
  as the proxy does while it refreshes one).
- A failure after the first change undoes every agent's changes, going on
  past an undo that fails; each store it couldn't put back keeps its
  staging folder, named with it (agent_import_undo_failed).
- An interrupted run's cleanup waits on the stage's mutex for an apply
  that started, and an apply after the cleanup took the staging folder
  out puts nothing in place.

Links through states devvm can't read:
- While any VM's state can't be read, the import leaves out every link
  out of an agent's folder and an agent's folder or login whose path
  leads through a link, but the links on the way to the home folder
  itself, naming the state (agent_import_link_unread_state), where before
  it followed them with only a warning (projectFolders.chosen, with
  throughVM's check).

Tests that fail without their fix: TestWalkBound (fs.WalkDir as the
control), TestWalkDepth, TestWalkAsWalkDir, TestWalkErrors,
TestRootFSOpenSwapped (a FIFO), TestAgentStoreLock (import, save, a
seed's clean), TestAgentSaveStoreChanged, TestAgentImportApplyFailsWhole
(a rename and a login failing, files and folders swapping kinds),
TestAgentImportUndoFails (two agents, the second's undo failing),
TestAgentImportInterruptedApply, TestSaveLogins, TestAgentImportLinksUnreadState
(a link out, a linked folder and its login, a login behind a link),
TestAgentImportLinkWalked. TestRootFS and TestCleanSeeds* follow the new
FS and ctx.

paths.Dirs is allowed 63 methods (largeTypes), for agents.lock.

Docs: using/coding-agents.md, internals/agents.md, using/space.md,
internals/overview.md, Contributing's structure page and the owners doc,
the codebase-standards guard for bounds; CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 14:56:20 -07:00
w3cjandClaude Opus 5.5 2b176c92b3 feat(ui): every slow step shows a status line, and messages and questions never land on it
Any work that can take noticeable time now runs under the UI's status
line: a Reporter's Status with a label message, or a LoggedCmd step.

The UI:
- status lines are a stack: a Status or LoggedCmd inside another shows
  its own line, then the outer one is drawn again, where before it
  ended the outer one for good
- a message (Info, Warn, Note, Say, data on Stdout/Stderr) clears the
  line, prints and draws it again below; an unended line holds it
- a question (Ask, Confirm, Answer, Secret), the picker and
  ui.Terminal hold it until they're done
- no status line starts once the run is interrupted, as nothing would
  clear it
- the run log's path is read without the log's lock, as the status line
  reads it under outMu

Covered, by site and label:
- finder.target: finding_vm; Lima's limactl --version: checking_backend
- bringUp's checks (seeds, instance, recordFolder, hostChecks, ssh,
  requirements) and a running VM's go-on (proxy, pins, mount check):
  checking_vm; startOnce after the agent: starting; the self-check's
  probes: checking_network; pinHostKeys: reading_host_keys
- setUpVM (sync, ssh config, links, clone seed): setting_up_vm; each
  devcontainer command: running_script; makeMachine: creating;
  buildOnce: checking_image; paste's count and rm: reading_pasted
- volumeOf's lookup (diskutil), for launch, adopt, move, ls and rm:
  looking_up_volume
- vm.ListAll (devvm ls): reading_vms; devvm doctor's checks:
  doctor_checking
- devvm agent import: agent_import_reading (walk, links, opencode),
  agent_store_saving (copy, marketplace git checks, tmutil); devvm agent
  save: agent_save_reading, agent_save_comparing, agent_store_saving
- devvm stop (from its pins check on): checking_vm; a delete, an
  orphan's teardown and Lima's DeleteImage: deleting; devvm git-protect
  and clone on/off's .git work (leftBehind, mountFolder, unmountFolder):
  git_protecting; git-protect's re-read: finding_vm
- devvm clone add: clone_reading, clone_adding; clone fetch:
  clone_fetching; planClone: clone_planning; the clone check before rm
  or a remake: clone_checking; history export and import:
  history_exporting, history_importing; a remake's home: saving_home,
  restoring_home
- devvm upgrade's install: upgrade_installing; the shared tools' step
  back and .NET's downloads: resolving_tools; gc's caches: reading_space;
  the retention settings (daily and in gc): retaining

Work that takes the terminal stays off: the shell, ssh-add's
passphrase (checkAgent, Agent.Ensure, reloadAgent) and an agent's login.

Tests and guard:
- msg.Fake: OnStatus and Showing; its LoggedCmd shows its step
- backendtest.Fake: OnCall
- TestLaunchStatusLines: every backend call of a new, running and
  stopped VM's launch runs under a status line but the shell's and
  Running's (pid files)
- TestSSHAddOffStatusLine: ssh-add, on the user's agent or devvm's, never
  runs under one; chflagsCalls fails a .git lock or unlock with none
- the structure test's status-lines rule (statusSites, statusFree)
- TestStatusLinesNest, TestMessagesClearTheStatusLine,
  TestQuestionsHoldTheStatusLine, TestSecretAndPickerHoldTheStatusLine,
  TestTerminalHoldsTheStatusLine, TestNoStatusLineOnceInterrupted,
  TestFakeStatus, TestAgentImportStatus, TestAgentSaveStatus,
  TestDoctorReport, TestProblems, TestList, TestListLooksUpVolumesOnce,
  TestVolumeOfCache, TestWithSDKDownloads, TestRetainStatus,
  TestSetCloneOn, TestTeardownLeavesNothing

The rule is written in the cli skill (rule 14, checklist, review), the
codebase-standards skill (Show what devvm waits for, its checklist line
and rules.md's row), Contributing's CLI page (Status lines), its tests
and structure pages, and the troubleshooting page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 11:13:13 -07:00
w3cjandClaude Opus 5.5 3101c85260 fix(vm): a failed agent import leaves the store as it was; the import's bounds count every entry and cap a file; a login's terminal is put back
devvm agent import wrote each settings file into the store as it read
it, so a file that failed to read partway (changed since it was listed,
or past the bounds) left the store half replaced. The import now reads
and writes every agent's settings into a staging folder of the agent's
store first (.devvm-import-<random>, beside the agent's folder, so no
VM mounts it), and only once all of them are staged, and the run isn't
interrupted, moves each file into place, prunes what the home folder no
longer has and then saves the logins. A failure or an interrupt while
staging leaves the store as it was: the staging folder goes, through
discard, or through a cleanup for an interrupted run, which reaches it
by a root of its own. A failure after that (a rename, a login) can
still leave the store partly replaced, which internals/agents.md says.
A killed import's leftover staging folder counts as nothing of the
agent's (inStore), so it never makes the import ask, and the next
import of that agent takes it out first (sweepStages).

The import's bounds on an agent's own folder now match devvm agent
save's: the walk counts every entry it meets, links, sockets and FIFOs
included, not only the folders and files it keeps, and a file of more
than 16 MiB, as listed or as read, fails the import as the 128 MiB
does. Claude Code's plugin records are copied with the store's longer
paths, and what the copy grows counts against the same bounds
(hostAgent.grew), naming the folder, or the link a file came through,
so the store never gets more than the import checked. The two handles
on an agent's folder, the os.Root it lists through and the folder
opened one folder at a time that it reads through, are checked to be
one folder (sameFolder), failing the import otherwise. A VM state the
import can't read is a warning (agent_import_states_unread), naming the
file, rather than silently dropping that VM from the project-inside
warnings and the link checks; the follower takes the VMs the import
read at its start instead of reading them again.

state.WriteFileIn and writeFileMode share one tail (finishTemp).
clearKind takes the root the import opened once, rather than opening
the store for every path, and pruneStore's walk is pruneIn, which the
import calls on the same root.

Cursor's changing verbs (proxy's cursorChanges), checked again against
the 1,463 methods of DashboardService, AutomationsService and
BackgroundComposerService in 2026.11.17-f532c45, read and not run.
generate goes: it matched only GenerateGrokCollectionDescription, which
only returns a draft, and GenerateTeamGrokBotScimIdpSigningKey, which
cursorCredential refuses anyway; no other method changes between
refused and passed. test stays, justified in its comment: it matches
TestAutomationFilter, a dry run that only reads, but also
TestTeamCustomerTelemetryDestinationConnection, which has Cursor's
servers send a request with any headers to any address. park, hand,
decline, replace and resend match only methods that cursorCredential
refuses too (as rotate, link and invite do), and stay, justified in
the comment, for the methods Cursor adds. Every cursorRoutes path the
CLI's login goes to is checked against the proxy by agentlogin's
TestCursorCapture (proxy can't import agentlogin, which imports it);
TestCursorChangingVerbs now says so.

devvm agent login on a terminal saves the terminal's state before the
login (ui.Terminal, through vm.Env.Terminal, which now returns a
restore) and puts it back once the login and endLogin are done, or in
a UI cleanup if the run ends first, so an ssh that a signal killed in
raw mode doesn't leave the host terminal raw.

Tests that fail without their fix: TestAgentImportFailsWhole (a failed
import leaves the store's own files and no staging folder),
TestAgentImportTooMuch (rewritten: its dead want field gone; exactly
20,000 entries and 128 MiB list whole, one more entry or byte fails, a
link and a FIFO count, a file of 16 MiB and a byte fails),
TestAgentImportPluginsGrow, TestSameFolder (the helper, and the import
with its folder swapped between the two opens),
TestAgentImportStageLeftover, TestAgentImportInterrupted (the ctx check
before apply, and the interrupt cleanup on its own),
TestAgentImportProjectInside (beside a
broken state), TestCursorChangingVerbs (GenerateGrokCollectionDescription
passes), TestAgentLoginTerminal (put back once, after the login ended,
interrupted included), TestTerminalRestores. Tests that pin what
already held: TestNarrowNotesBesideBroken (devvm network's -g
allowlists beside a VM state that can't be read), TestWriteFileIn (a
failed rename leaves no temporary file), and TestCursorChangingVerbs'
TestTeamCustomerTelemetryDestinationConnection.

The finder now checks fst with found, so nilaway no longer reports
fst's flow, and all of fst's lines in its baseline go.

Docs: using/coding-agents.md, internals/agents.md,
internals/network.md; CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 10:02:01 -07:00
w3cjandClaude Opus 5.5 da872a6550 fix(vm): a renumbered folder's volume is checked until it's read; folder identity is read once
When a boot numbered a project folder's disk anew and its volume couldn't
be read at that launch (diskutil failing or slow), recordFolder recorded
the new device with the old volume, and from then on the identity
matched byte for byte, so no launch compared the volume again: a copy of
the disk with a volume ID of its own, mounted at the folder's path
later, would have kept the VM. It now records the folder unchecked
(state.VM.SetFolderUnchecked, vm.json's folder_unchecked), so each
launch looks the volume up again; Env.keepsVolume compares it while the
record is unchecked, as for a renumbered one, refusing another volume
(vm_other_folder), and the first lookup that finds the recorded volume
clears the mark (folderRecord). A move matches an unchecked record only
on its volume (here.same), and a move whose lookup fails keeps the
recorded volume, bound to the inode and birth time a move keeps,
unchecked (recordMove). On Linux, where the volume is read in the
process (volumeFree), every launch compares it, so a Btrfs snapshot or
a ZFS clone mounted at the folder's path is another folder even on the
original's device; after a volume's UUID changes, devvm adopt gives the
folder its VM again.

The finder's sameFolder and madeFor share one body (madeForOpen), and
the folder is opened once: platform.SameOpenFolder is SameFolder for a
folder StatFolder already read, platform.RecordedAs is its exact match,
and keepsVolume, recordFolder and here.same take that read rather than
open the folder again (here's id and unique are its stat's). madeFor,
which the checks that ask which VM mounts a folder use, falls back to
the folder's stat when it can't be opened, as when code in a VM that
mounts it took away its read permission, so no VM hides from
clone_repo_mounted or project_in_vm_folder that way. recordFolder
compares again under the state's lock with the same folderRecord.

The structure test's folder-ids rule now finds a map literal keyed by a
folder's identity whose type is a named map type of the module's, a
generic one included, or elided in a map's or a slice's literal whose
elements are maps.

Docs: a Btrfs rollback at the folder's path, or a volume's new UUID,
needs devvm adopt; a Mac volume that ignores ownership makes every
folder yours to the offer's check; the unchecked mark and Linux's check
at every launch (internals, overview's vm.json fields).

Tests: TestUncheckedOnAnotherVolume, TestKeepsVolume, TestRecordFolder
(unchecked, then checked), TestRecordFolderUnderLock,
TestRecordMoveVolume, TestMovedFrom (unchecked), TestMountedByUnreadableParent,
TestSameFolder (SameOpenFolder, RecordedAs), folder-ids' named, generic
and elided map cases, and fixture_v010_renumbered's unchecked steps on
0.1.0's state.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 09:37:13 -07:00
w3cjandClaude Opus 5.5 c41ca82f6e fix(project): devvm's own folders are compared by identity; a launch warns of a project in an agent's folder
project.Unsafe's Holds and Inside compared a project folder with the home
folder and devvm's config, data and Lima folders by name alone
(paths.Within, paths.Below), so on a volume that ignores case, as a
Mac's does by default, a project at ~/.Config/devvm/layers passed both
and its VM got devvm's settings and layer scripts read-write. They now
compare by identity too: paths.In, the vm package's isIn moved to its
owner, finds the path or a folder above it to be the same folder as the
other, by device and inode, and paths.Under is In for the path's
folder. An empty folder holds nothing, so an unset one can't match the
working folder. sshagent's mountedBy, which refuses a key in a folder a
VM mounts, compared by name in the same way and uses paths.In now.

Each launch (Launch.Up, beside warnMounted) warns once, in one line,
when the project folder it mounts is inside an agent's folder in the
home folder or holds one (project_agent_folder), naming every such
folder from the agents' registry, with agent_import_project_inside's
detection (overlapsAgent). A --clone VM mounts nothing and gets no
warning.

Tests: TestUnsafeIgnoresCase, TestInAndUnder, TestMountedKeyIgnoresCase,
TestWarnAgentFolders; the case checks skip on a volume that tells
names apart by case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 09:05:20 -07:00
w3cjandClaude Opus 5.5 bb0df957a0 fix(doctor): a broken VM state hides no other VM's warnings; Cursor's account services refuse more changing verbs
doctor's policy warnings (netpolicy.NotRules) listed the VMs with
state.VMNames, which fails whole for one state it can't read, so one
broken vm.json made doctor skip every VM's policy warnings. So did
devvm network's warnings about every VM (allowlists for -g, and
OtherBinaries). They now use state.ReadableVMs, the VMs whose state
reads, which leaves the broken one out and the rest in; VMNames stays
strict for what must count every VM, such as ports. A VM folder doctor
can't read got two warnings, vms_unreadable from state.VMFolderProblems
and vm_state_broken from vm.StateProblems; VMFolderProblems now leaves
it to the latter, which names the VM and why.

cursorChanges, the verbs refused in Cursor's DashboardService,
AutomationsService and BackgroundComposerService, gains merge, fork,
write, pin, unpin, rerun, confirm, request, release, acquire, activate,
deactivate, notify, make, open, ensure, park, copy, bulk, advance,
abort, wake, snapshot, seed, reply, opt, hand, fail, use, skip, decide,
unshare, undelete, unpublish, unprepare, unresolve, enroll, unenroll,
upgrade, suspend, switch, duplicate, dismiss, deregister, deliver,
decline, convert, close, append, execute, provision, mutate, inject,
finish, finalize, reassign, reinstall, reject, renew, reorder, reparent,
replace, resend, rmdir, report and record. Each was checked against all
1,463 methods of those services in 2026.11.17-f532c45, read and not
run: every one of the 102 methods they match changes something, none
only reads, and the CLI calls none (Submit, Resolve, Check, Batch and
the like stay off, as their methods read or the CLI calls them).

fixture_v010_logs' capped.sh loop and network.txtar's sleeps around the
squatting proxy now wait with wait_until.

Tests: TestNotRules and TestOtherBinaries (beside a state that can't be
read), TestVMFolderProblems, doctor.txtar (an unreadable VM folder, one
warning), TestCursorChangingVerbs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:45:34 -07:00
w3cjandClaude Opus 5.5 c901b920ef fix(agents): the agent store is written only through roots, an import is bounded, and projects overlapping agents' folders get a warning
devvm agent import and save checked each path they wrote in the store by
path (storeGuard), then wrote by path (os.MkdirAll, state.WriteFileMode),
so a link swapped into the store between the check and the write could
lead the write elsewhere. They still check every path first, so a link
fails the command, naming it, before the store changes; they now write
only through the agent's folder in the store opened from devvm's config
folder as a root (makeStoreDir, which makes it and the folders on its
way through the config folder as a root, then openStoreDir), with
state.WriteFileIn, a whole-file write through an os.Root.

An import copied whatever an agent's folder held, one file at most
128 MiB, so a VM whose project folder is inside an agent's folder could
fill the store that every VM with the agent mounts. Each agent's folder
now gets agent save's bounds in all, 20,000 files and folders and
128 MiB: the walk stops at 20,000 (errFolderTooMany), the sizes as
listed are counted (hostAgent.tooMuch), and a folder over either fails
the import before anything is written, naming the folder and what to do
(agent_import_too_much); the files' reads share the 128 MiB (h.read),
so files that grew since the listing fail too.

Before it reads anything, the import warns of each VM whose project
folder is inside an agent's folder or holds it
(agent_import_project_inside). A project folder that holds an agent's
folder, such as ~/.pi for pi's ~/.pi/agent, let its VM put a link in the
agent folder's place, which the import followed, copying whatever it
led to, such as the home folder's files, into the store: the import now
resolves the folder's path one link at a time (linkHops), leaves it out
with agent_import_link_via_vm when a link in a VM's project folder leads
it out of that folder (throughVM, shared with the link follower), its
login with it (pi's auth.json), and reads the folder where the path led.
Every agent's login file but Claude Code's ~/.claude.json, which was
already a capped, regular-file read, was os.ReadFile by path, so a VM
whose project folder held it could swap in a link to another file, a
FIFO or an endless file between the check and the read: its path is now
resolved once (linkHops), left out when a link in a VM's project folder
leads it out of that folder (throughVM), and read where it led, through
its folder opened with no link and never resolved again (openPhysical),
opened without following one, a regular file of at most 128 MiB
(claudeHostLogin), so a folder swapped for a link since fails the read.

Tests: TestWriteFileIn, TestAgentImportTooMuch, TestAgentImportReadBudget,
TestAgentImportProjectInside, TestAgentImportProjectHolds (a folder and a
login led elsewhere), TestAgentImportLoginNoFollow,
TestStoreOpsRefuseLinks (makeStoreDir).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:36:19 -07:00
w3cjandClaude Opus 5.5 4ccdbf8125 fix(vm): folder identity's last checks: a renumbered folder keeps its volume
From the volume UUID commit's security review. A folder at its own
recorded path on a disk numbered anew (platform.SameFolder's renumbered
case) must now also be on the volume its state records, when both are
known (platform.KeepsVolume): the finder checks it (finder.sameFolder,
Env.keepsVolume, so a launch refuses with vm_other_folder) and so does
recordFolder under the state's lock, so a copy of the disk with a volume
ID of its own mounted at the folder's path is another folder. A volume
that can't be told leaves the device's rule, as for a state that
records none. mountedBy and mountsRepo keep the check without volumes
(madeFor), which errs towards warning.

hereOf reads the folder's identity, uniqueness, owner and volume from
one open folder (platform.StatFolder, now with Owner), so the folder
checked as the user's is the one matched and recorded. StatFolder is
one function for macOS and Linux (folderstat_unix.go) over each
system's openFolder, which SameFolder's renumbered case uses too, in
place of openFolderID and darwin's copy.

devvm ls and devvm space look volumes up through the run's Env
(Env.FolderOf, Inventory.List(ctx, e)), each mount once a run, in
place of diskutil for each VM; FolderOf, parentVolume and movedAway go.
FolderDevice is unexported (folderDevice), so only platform reads a
device; OnRecordedDisk takes a record without a device as on any disk.

The folder-ids rule tracks names assigned from such names, however
many steps on, and maps keyed by an identity, indexed or in a map's
literal, without counting a struct literal's field; its loop is
sitesWhereIn, shared with sitesWhere. The hdiutil e2e check makes sure
macOS gave the disk a new number, attaching up to three images first,
and is skipped when it never does. The design notes say who can forge
a volume ID and what it gets them.

Tests: TestKeepsVolume, OnRecordedDisk without a device,
TestRenumberedOnAnotherVolume (a launch and recordFolder),
TestListLooksUpVolumesOnce, StatFolder's Owner on both systems, the
folder-ids rule's new cases, and fixture_v010_renumbered.txtar (another
volume at its own path refused with nothing recorded; ls calls the
moved folder gone by its recorded volume, where it said not_connected).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:15:53 -07:00
w3cjandClaude Opus 5.5 ba510eec1f feat(vm): a folder moved across a restart keeps its VM, by its volume
A project folder's identity was its device, inode and birth time, and
since #60 a folder at its recorded path matched on another device. A
folder that moved while a restart gave its disk another device number
matched nothing, so plain devvm made it a second VM, and folderOf took a
renumbered disk for an unmounted one ("not connected"), so movedAway was
false too.

Each VM's state now records the folder's volume, which no renumbering
changes, as folder_volume, "<kind>:<value>:<ino>:<btime>", bound to the
folder it was read with (platform.VolumeOf, RecordedVolume): macOS's
volume UUID from diskutil (platform.VolumeUUID, only for the mount point
and device read from the folder opened with no link, its answer checked
against both), Linux's f_fsid on ext4, Btrfs and ZFS (StatFolder, read
from the open folder); none on a read-only volume or a snapshot, or
elsewhere. state.VM's folder is unexported: Folder(), FolderVolume() and
SetFolder(id, vol), the one writer, which creation, adopt, a move and
recordFolder (renumbered's successor, at each launch) use; a launch
records the volume of a VM made before, once it can (1 s at a launch,
5 s at an adopt or a move, one failure a run stops the rest, through
Env.Volumes and its run's cache).

moveHere matches a moved folder by its volume, inode and birth time
(platform.MayHaveMoved, MovedFolder), looking the volume up only once
the rest matches, with the identity it matched and records both read
from the folder opened with no link (hereOf), and folderOf compares the parent's volume where the
state records one (platform.OnRecordedDisk), through Env.folderState for
a move or an rm. The folder-ids rule now also reads Folder() and
FolderVolume() calls, FolderDevice, locals assigned from any of them,
switches and strings/slices comparisons.

An older devvm keeps folder_volume as it is (checked with 0.1.0's own
reader in a temp copy of its tree). A rename keeps the inode, so the
binding stays right; when an older devvm adopts another folder for the
VM, or a move across volumes copies it, the binding names another inode,
so the record names no volume and is recorded again. DEVVM_VOLUME stands
in for diskutil, and for Linux's f_fsid, in test builds (VolumesOnly).

Tests: TestFolderOf (not connected after a renumbering), TestMovedFrom
(moved and renumbered, and a split between the read that matched and
the one recorded), TestRecordFolder (made, a VM made before at its next
launch, a failed lookup, a renumbering keeping the bound volume),
TestVolumeOfCache, TestVolumeOf, TestMovedFolderAndRecordedDisk,
TestStatFolder(AndVolumeUUID), TestPlistStrings, the folder-ids rule's
new cases, fixture_v010_renumbered.txtar (0.1.0's VM records its volume,
then moved and renumbered it's offered, never a second VM), and e2e's
projectRenumbered (hdiutil, macOS) and the project section's volume
check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 01:59:06 -07:00
w3cjandClaude Opus 5.5 ecd266c7d3 test(cli): one wait for the scripts; the docs release job installs only what it builds with
The scripts waited with copies of the same loop: desktop.txtar's and
nix_cache.txtar's waitfor files, and sh -c loops in link_life,
fixture_v010_links, fixture_v010_small, ports and ports_stopped, each
with its own interval and limit. They now use one testscript command,
wait_until SCRIPT, which runs sh -c SCRIPT every 100 ms until it
succeeds, for up to 90 s, and fails at once when every background
command has ended, as wait_file does, or when SCRIPT exits 100
(waitGiveUp, a status no tool the scripts run gives), as the links
check does when its session has ended. Contributing's tests page names
it beside wait_file, whose limit it now says is 60 s.

The docs workflow's release job installed every tool in the tag's
mise.toml. It now installs only Go, Hugo by the name the tag gives it
(hugo-extended before Hugo 0.170) and Node when the tag draws its
diagrams, with --locked as mise-action did, picking them with mise's
own reading of the tag's mise.toml (mise ls --current --json, the tag's
file alone), and fails when the tag names no Hugo. MISE_AUTO_INSTALL is
off for the job, so mise run docs:diagrams and the shims install
nothing more, and a tool the pick missed fails the build. This job runs
only at a release, so it hasn't run yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 5924a373f0 feat(doctor): devvm doctor checks every VM's state
doctor read no VM's state, so a vm.json that devvm can't read, or one
with a section its package can't read, showed only when a command on
that VM failed. doctor now reads every VM's state (ReadStates) and runs
the check every command makes of the VM it finds for a folder on it
(checkState, every section's reader), and warns of each VM it can't
read, naming it, or its folder when the file can't be read, and why,
which names the file (vm_state_broken). It only reads, and --json lists
the warnings with the rest.

The task also named "the files vm.json names that devvm reads at
launch". None in a VM's folder stops a launch from older state: its
own policy file is read by the proxy, which keeps its last rules, and
doctor already checks its lines; home.tar.gz is read only while a
remake hasn't finished; run/ is written again at each start. So only
vm.json and its sections are checked. A value that reads but that a
launch refuses, such as a size that isn't a number, isn't checked, and
the docs say so.

Tests: doctor.txtar (a vm.json that isn't JSON, a section that doesn't
read, and one that's fine), fixture_v010.txtar (every 0.1.0 VM reads,
and no file changes), fixture_v010_housekeeping.txtar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 c9d0fdb270 feat(agents): warn about credentials in copied marketplaces
A Claude Code marketplace is a git clone that devvm agent import and save
copy whole into the store's plugins folder, which every VM with Claude
Code mounts, so a private marketplace's credential in its git config
reached every VM without a word. Both commands now check what they copy
and warn, naming the marketplace, the store's file and the keys, never
the credential (a URL subsection with one shows as <url>)
(marketplace_secret):

- each git config below a clone's .git (a submodule's included), read by
  git itself (listConfigFile, beside the clone seed's listConfig), and
  the files it includes from inside the clone: an http.extraHeader, and
  a URL with a credential in a remote's or submodule's URL, a push URL,
  a proxy or an insteadOf's base, judged as the clone seed judges a
  remote (cleanURL: changed or refused while it has an @);
- known_marketplaces.json's source URLs.

A config git can't read is named as unchecked (marketplace_unchecked),
as the VM reads the file whatever git makes of it. The copy is made as
before, as CJ chose.

Test: TestMarketplaceSecrets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 872c2e23c0 fix(proxy): Cursor's account services refuse more changing verbs and the cloud agents' endpoints; bridge mode stays off
cursorChanges, which refuses a method of DashboardService,
AutomationsService or BackgroundComposerService whose name starts with a
verb that changes something, now has clone, commit, generate, mute,
unmute, reindex and retry. Each was checked against all of those
services' methods in the 2026.11.17-f532c45 package (1110, 57 and 296),
read and not run. Twelve match: RetryAutomationRun,
CommitBackgroundComposer, MuteBackgroundComposers,
UnmuteBackgroundComposers, CloneGrokCollection,
CommitOrganizationNetworkBlocklistUpload,
GenerateGrokCollectionDescription, GenerateTeamGrokBotScimIdpSigningKey,
ReindexAndApplyTeamMarketplaceChanges, ReindexGrokCollectionDocument,
RetrySandMessagesPermission and RetryTeamXaiMembershipHold, and the CLI
calls none of them. cursorMints also refuses every path below
/cloud-agent/, on every Cursor host. The docs say the verbs are defence in
depth, as the bindings put the login only into the CLI's own methods, and
name changing methods they miss.

Bridge mode (api2direct.cursor.sh) isn't added to the allowlist: it is
cursor-agent worker, a self-hosted Cloud Agent worker that mints identity
tokens at /cloud-agent/identity-token/worker, runs cloud agents' work
started elsewhere, mounts the agent store, and sends Host: api2.cursor.sh
through a tunnel to api2direct, which has no bindings, so the login never
goes in. The coding-agents page says it doesn't work in a VM; the
decision is CJ's.

Test: TestCursorMints.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 aed6424c09 fix(proxy): a stale proxy.confined no longer hides proxy_old
run/proxy.confined said how the child was confined, but not which broker
said it. After a downgrade, an older devvm starts the VM's proxy as one
process and never writes the file, so the newer devvm's file stayed and
devvm doctor took the older devvm's unconfined proxy for a confined one.

The broker now writes a second line naming itself, its pid and its start
as the system tells it (proxy.BrokerID, through IO.Started), and
ReadConfined takes the file only when it names the running broker, which
doctor finds by the pid file and platform.ProcessStart (kern.proc.pid's
p_starttime on macOS, /proc's starttime on Linux). A file that names
another broker, or none, is one that hasn't said, so another binary's
proxy gets proxy_old, and when doctor can't read the running broker's
start it says it can't tell (proxy_confinement_unknown). The e2e broker
check reads the file's first line and checks the second names
run/proxy.pid's broker.

Tests: TestUnconfinedStaleMarker, TestReadConfined, TestProcessStart.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 d939d1d870 fix(agents): agent import and save never write through a linked store, nor copy a link to what they leave out
devvm agent import copied a link inside an agent's folder as the file it
led to wherever that was in the folder, so a link in ~/.claude/skills or
~/.claude/plugins/cache could put the history, .credentials.json or a
plugin's data into the store. Such a link is now copied only when its
target is one of the agent's settings (listedPath, MachineOwn included),
and any other is left out, naming where it leads
(agent_import_link_not_setting). Each file the import listed is read
through the agent's folder opened one folder at a time without
following a link (readListed), and must be the file it listed, so a VM
whose project folder is in the agent's folder can't swap a link or a
folder between the listing and the read; a file it can't read so is a
message (agent_import_read_failed), as is one whose details can't be read
while listing, which was dropped without a word. One file is read up to
128 MiB.

pruneStore and clearKind opened the store by path, so a store that was a
link (to ~, say) let import and save delete the files of the folder it led
to. They now open it from devvm's config folder, refusing a link on the
path (openStoreDir, sharing one walk, walkStore, with cleanSeed and the
guard), and import and save check every path they'll write, for every
agent they handle, before the first write (storeGuard, checkStore,
checkPlan, saver.applyAll): a link fails the command, naming it, before
the store changes (agent_store_link).

Tests: TestAgentImportLinksInsideToSettingsOnly,
TestAgentImportSwappedAfterListing, TestAgentImportLinkedStore,
TestAgentImportLinkedStoreOfAnother, TestAgentSaveLinkedStore,
TestAgentSaveLinkedStoreOfAnother, TestStoreOpsRefuseLinks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 23:07:04 -07:00
w3cjandClaude Opus 5.5 01e837a164 build(deps): bump Cursor's CLI to 2026.11.17-f532c45, rechecked
scripts/bump.sh cursor: 2026.11.11-b912975 -> 2026.11.17-f532c45, the
one shared tool pinned for users, applied only when named because
devvm's login and proxy code was read against its pinned release. Then
scripts/bump.sh e2e-tools, which writes tests/e2e-mise.lock for the new
mise.toml and moves e2e's claude (2.1.326 -> 2.1.327) and opencode
(2.3.0 -> 2.3.2) patches with it.

The recheck read both releases' Linux packages (checksums checked, read,
never run) and Cursor's changelog (nothing after Nov 6):
- Package layout and entry point: the same launcher and files.
- Login: the same loginDeepControl page, GET api2's /auth/poll with
  uuid and verifier, 404 while pending, accessToken and refreshToken
  (or xAI's), selectedTeamId, NO_OPEN_BROWSER and
  /auth/exchange_user_api_key. waitForResult gained an optional wake
  argument that cursor-agent login doesn't pass.
- No refresh-token call, as before; the JWT reader still takes exp
  (300 s early) and sub, so the 2099 placeholder still serves.
- Connect: about 65 RPC definitions added, mostly DashboardService's,
  2 removed (DashboardService's pull-request draft preference), and the
  methods the bundle calls are the same, so every route agentlogin's cursorRoutes and the proxy's
  cursorMinting and cursorPersists name is still there, and no new
  method carries the login.
- Hosts, config and auth files (CURSOR_CONFIG_DIR, XDG_CONFIG_HOME,
  ~/.cursor, auth.json, cli-config.json), the updater and channel: the
  same. New environment variables don't touch updates or telemetry.
So nothing in devvm's code, tests or allowlist changes; the comments,
the policy's note and internals/network.md name the new release.

- CHANGELOG: Changed, the pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 20:06:44 -07:00
w3cjandClaude Opus 5.5 b5f3899f1a test(vm): smaller 0.1.0 cases
fixture_v010_small.txtar runs what changed since 0.1.0 on its frozen
state, in smaller cases:

- devvm ports on 0.1.0's records of app's port forwarder (its pid and
  status, no list of what it forwarded) says nothing is held, taken,
  past the limit or refused.
- A proxy port 0.1.0 chose on one of the ports only VMs' ssh may have
  (its proxy port moved onto the sandbox's first ssh port) moves at
  app's next start, off the list, and the proxy's config listens there.
- On Linux, that start gives the guest's connections to the proxy the
  capped devvm _qemu connect, to that port, with app's own
  run/proxy.slots, where a 0.1.0 start had the two-argument form. The
  limactl stub now records the start's DEVVM_GUESTFWD
  ($STUB_DIR/start-guestfwd-<name>, empty when unset), as it records
  the start's agent, with its unit test, and the structure test's
  envSettings lists the stub as a reader of DEVVM_GUESTFWD.
- app, stopped, holds none of its listed ports: scratch lists 3000 too
  and forwards it, and app, started again, says scratch has it
  (ports_held, held_by in devvm ports --json) and that a program here
  has another port it lists (ports_taken), never the limit or a
  refusal. While it runs, devvm ports names each reason its
  forwarder's record gives (ports_taken, ports_limit, ports_refused,
  each its own port), and none for an older devvm's three-line record
  (reasons.sh judges only a run on the record as it wrote it, trying
  again when app's forwarder, waiting on scratch's port, replaced it).
- #52's leftover, a state as 0.1.0 wrote it for a folder named x--y
  before Lima refused the name (built from app's 0.1.0 state: its name
  and alias with the run of separators, the folder's path, no created
  time or start), is read as no VM and replaced by the folder's VM.
- After a boot that numbered the disks anew and a move of app's folder,
  devvm adopt VM moves app to the new path, and its launch starts it
  there.

Found, not changed: a moved folder on a renumbered device isn't taken
as the VM's folder (platform.SameFolder matches another device only at
the recorded path, as a copy keeping the inode and birth time sits
elsewhere), so devvm there, without adopt, makes a second VM for the
moved folder, saying nothing of the first, whose folder is gone; devvm
adopt VM is the way back, as the docs say.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 20:06:44 -07:00
w3cjandClaude Opus 5.5 7800be5ed5 test(vm): host keys and log caps on 0.1.0 state
fixture_v010_logs.txtar gives 0.1.0's app VM's Lima folder a serial
console's log (serialv.log) and a hostagent's error log (ha.stderr.log)
of 11 MiB each, holding the proxy's password from 0.1.0's proxy config
(which today's devvm keeps, as vm.json's proxy key) near their start
and at their end, as a boot logs it, checked there before the launch.
After a launch, each is at most 10 MiB with a .1 beside it holding the
log, and neither holds the password: the log keeper looks first in the
proxy's broker, before limactl start, so it copies 0.1.0's unredacted
log into the .1, whose redaction this checks. (Real Lima starts each
log afresh at every start, which the stub doesn't.) The launch pins
the new start's host keys in place of 0.1.0's: known_hosts' start line
is no longer 0.1.0's, a key line is pinned, and 0.1.0's key line is
gone. Nothing found to fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 58c7d87fe8 test(vm): links and the resolver on 0.1.0 state
fixture_v010_links.txtar starts 0.1.0's db VM, then its app VM, which
links to db's published 5432 as db.devvm.internal at 127.77.0.1: app's
launch says nothing of a stopped target, its link session starts and
carries 127.77.0.1:5432, and run/links.json is written again from
0.1.0's link with the same hosts, address, port and target and the
sandbox's own socket, which exists. The setup app gets
(sync.tar's vm) names the confined VM's resolver,
DEVVM_RESOLVER='127.0.0.1', and the paste folder, which 0.1.0's setup
didn't have, and its hosts file names db.devvm.internal. Nothing found
to fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 0fdb2ba5a2 test(vm): a 0.1.0 history export imports today
TestHistoryImportV010: devvm 0.1.0's own export script, the string its
historyExport returned, frozen in
internal/vm/testdata/v0.1.0-history-export.sh (made by running 0.1.0's
code from git archive v0.1.0), runs with real bash and GNU tar in a
home as a 0.1.0 VM had it: Claude Code's projects and todos, its
.credentials.json, settings.json and .claude.json, the store's plugins
and skills folders linked at their paths as 0.1.0 linked its mounts,
Codex's sessions, history and auth.json, opencode's storage, auth.json
and, where sqlite3 is, its database, and opencode's state. The export
holds the links and the copied settings (exportNames), the controls
for what the import leaves out, while 0.1.0's own excludes keep the
logins out of it. Today's historyImport takes it without
devvm-history-unsafe: the history arrives, opencode's database with its
session included, and the links, the copied settings and the plugins
stay out. The import's run moves to runImport, which
TestHistoryImportRuns shares, so that test stays within revive's
limit. Nothing found to fix. (It runs where GNU tar is, as the other
history tests do.)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 bc00ebc088 test(vm): housekeeping never deletes 0.1.0 state
fixture_v010_housekeeping.txtar runs today's housekeeping on 0.1.0's
frozen state: a launch whose daily retention is due (0.1.0's
retention.run made older than a day, and touched by the launch), then
devvm gc --force, devvm gc --orphans --tool-images --retention --force,
devvm space --json and devvm doctor. Every VM's vm.json and run folder
stays, every shared tool image a state's tools.made.files names stays
(the list read from the states before anything runs), no limactl
delete names a project VM, devvm ls, devvm space and Lima still list
all four, and nothing says unreadable or corrupt. A copy of a tool
image under a name no state has goes, the control that gc could delete
one. On Linux, 0.1.0's VMs' disks are modelled as it made them, qcow2
overlays of the image's disk (the fixture keeps no disks; the stub's
qemu-img info reads the backing file), and gc keeps 0.1.0's base image
with image_in_use; on macOS it deletes it, an older base than today's.
Nothing found to fix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 93322e9154 fix(vm): running 0.1.0 VMs are warned of and tested
A VM that devvm 0.1.0 started and that runs as you upgrade keeps what
0.1.0 gave it until its next start. Two of those went unsaid:

- A launch into a running VM whose start forwarded an SSH agent itself
  (an older devvm's recorded start, without made.relayed) keeps that
  agent, which can add, remove or lock keys, and now warns, naming
  devvm restart, which gives it the relay (agent_raw_old).
- devvm doctor said nothing of a running proxy without
  run/proxy.confined. One that another devvm binary started (its
  config's devvm_sha256) is an older devvm's single process without a
  sandbox, which it now names (proxy_old); one this binary started that
  hasn't written the file yet is still starting and gets none. doctor
  now passes devvm's own binary to the check.

Tests, on 0.1.0's frozen state made running in the sandbox copy
(hostagent pid file at 0.1.0's start's time from its known_hosts, run/
started, known_hosts and agent.made.started for that start, Lima
listing it running, its ssh port listened on, and 0.1.0's one-process
proxy): fixture_v010_running.txtar (doctor's proxy_old; a launch with
no stop, start or edit, ports_ssh_old, the proxy started again as
broker and child with proxy.confined, secrets.json and known_hosts
unchanged, no relayed; then stop and launch: one .ssh.localPort edit,
the new start's keys pinned) and fixture_v010_running_agent.txtar
(devvm's agent forwarded raw: kept and warned, then devvm restart gives
the relay and relayed, with only the ssh port's edit). The modelled
hostagent is a live process of the test's, not 0.1.0's pid 54798,
because a start counts as devvm's only while its hostagent runs.
TestUnconfined: a proxy that hasn't said, by this binary, another, or
an unreadable config.

- msg: agent_raw_old, proxy_old.
- Docs: ssh (agent forwarding), troubleshooting (the proxy runs without
  a sandbox), internals/install; CHANGELOG After you upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 7cc0dd76ed fix(agents): a 0.1.0 store's plugin data stays out of the seed
devvm 0.1.0's agent import copied the whole of ~/.claude/plugins into
the agent store, each plugin's data and installed_plugins.json
included, and every VM with Claude Code mounts the store's plugins
folder whole as its seed, so that data kept reaching every VM until
agent import ran again. Every start (starter.bringUp) now takes out of
each seed's folder in the store the entries a seed doesn't have
(agents.MachineOwn), before the VM runs, and warns once, naming them
(agent_seed_cleaned). The folder itself stays, so no VM's mounts or
Lima config change. A running VM stops seeing them through its mount
at once on macOS; on Linux, 9p's cache can keep what it read until its
next start.

The folder is reached from devvm's config folder as a root, each part
of the path below it a folder: a link there (only a hand-made store
has one, and the VM's mount would follow it, perhaps to the user's own
~/.claude/plugins) is refused (agent_seed_link), a link among the entries is removed,
never followed, and the opened folder is checked to be the one
checked. The temporary files a concurrent agent import or save writes
known_marketplaces.json through, regular files, stay. A folder that can't be cleaned
fails the start of a VM with that agent and warns for any other
(agent_seed_clean_failed, naming what the folder should hold).

- vm: Env.cleanSeeds, cleanSeed and seedTemp (agents.go), called
  first in bringUp with the VM's agents.
- msg: agent_seed_cleaned, agent_seed_clean_failed, agent_seed_link.
- Tests: TestCleanSeeds (0.1.0-style store, a link entry, a concurrent
  import's temporary file, no store, once only), TestCleanSeedsFails
  (a link at the store, .claude or plugins, for a VM with and without
  Claude Code; an entry that can't go); fixture_v010_plugins.txtar
  (0.1.0's app with the store's plugins as 0.1.0's import left them and
  their mount: the warning, no edit but the ssh port's, the seed's link
  to a folder without data/, nothing said again; then the store's
  plugins folder a link, and an entry that can't go, each refusing
  app's start with agent_seed_link or agent_seed_clean_failed).
- Docs: coding-agents, internals/agents, the design note's threat
  check; CHANGELOG Breaking, After you upgrade (running VMs, Linux's
  cache, plugin logins) and #56's Fixed entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 19:59:14 -07:00
w3cjandClaude Opus 5.5 c9005ae4be build(deps): bump pins: mise 2026.11.10, Docker 29.10.0, Hugo 0.170.1 and e2e's pins
scripts/bump.sh's safe bumps (patches and minors; no majors or held pins):

images (assets/):
- mise 2026.11.8 -> 2026.11.10 (base's, and the host's resolving mise)
- docker 29.9.3 -> 29.10.0, compose 5.7.1 -> 5.8.0
e2e:
- claude 2.1.322 -> 2.1.326, codex 0.167.2 -> 0.169.1, opencode 2.2.7 -> 2.3.0
- pnpm 12.18.0 -> 12.21.0, uv 0.13.7 -> 0.13.9, rust 1.99.1 -> 1.100.0
- ubuntu:26.04 digest 065aa8626841 -> d66b366dac61
- Ubuntu's cloud image release-20261016 -> release-20261108
go: deadcode v0.52.0 -> v0.53.0
dev-tools: govulncheck 1.9.0 -> 1.10.0, vale 3.26.0 -> 3.27.0,
  hugo-extended 0.169.0 -> hugo 0.170.1
ci: jdx/mise-action v5.2.8 -> v5.2.10, the workflows' mise 2026.11.8 -> 2026.11.10

Hugo 0.170 has no extended edition (one binary, without LibSass, which
the site doesn't use): mise.toml's hugo-extended becomes hugo, the docs
workflow installs hugo, its release job installs the tag's own tools
(an older tag names hugo-extended), and docs/hugo.yaml drops the
deprecated hugoVersion.extended.

The e2e runner deletes its sandbox's Ubuntu pin when it names a release
other than e2eUbuntuRelease (not in a --newest-base run), as devvm keeps
a pin it has: without it, moving e2eUbuntuRelease left a cached sandbox
on the old release. pinned and ubuntuPin are e2e's one reader of the pin,
and TestHarnessRepin covers repin.

Image keys change: base and every image above it, the docker layer's
included, and the shared tools' images build again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 17:26:09 -07:00
w3cjandClaude Opus 5.5 6965efcc0a fix(vm): devvm agent login claude --setup-token shows Claude Code's address (#57)
An agent's login in the VM ran with devvm's own writers as its output,
so os/exec gave limactl shell pipes, Lima added no ssh -t, and claude
setup-token, which draws full-screen, showed nothing and waited.

When devvm's stdin and stdout are terminals and both output streams are
files, the login now gets stdout and stderr as the files they are
(ui.Terminal, set by cli as vm.Env.Terminal), so Lima gives it a
terminal in the VM, as devvm's shell has. Without a terminal it keeps
pipes, and --setup-token warns first (setup_token_no_terminal). Its
output reaches devvm's output alone, never the run log, as before. On a
terminal, Ctrl-C goes to the login in the VM, which ends, and devvm
says the login ended or saved nothing.

- internal/ui: Terminal, over Files, never a half pair; TestTerminal.
- internal/vm: Env.Terminal; AgentLogin.loginOpts; the warning; why an
  interrupted login's cleanup stays as endLogin's backstop; endLogin's
  comment for a login on a terminal; TestAgentLoginTerminal
  (fails without the fix).
- internal/backend: ExecOpts says a terminal's files pass on as they
  are; Lima's TestExecStreamsAsGiven.
- internal/cli: vmEnv sets Terminal; agent_login.txtar checks the
  warning.
- locales/en.toml, internal/msg: setup_token_no_terminal.
- tests/e2e: OnTTY, out of TTYRun; network's check that
  devvm agent login claude --setup-token on a terminal shows the
  address, waiting for its devvm to end before the next login.
- Docs: internals/network.md, using/coding-agents.md,
  contributing/extending.md and tests.md; CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 15:32:47 -07:00
w3cjandClaude Opus 5.5 ea3037bc15 fix(vm): MCP servers' logins in a VM finish and survive launches (#62)
Each launch and each devvm agent login claude copied the store's VM copy
of Claude Code's OAuth login (claudeAiOauth only) over the VM's
~/.claude/.credentials.json, where Claude Code also keeps its logins to
MCP servers (mcpOAuth: their tokens and, mid-login, the PKCE verifier).
So an MCP login failed when the VM was set up again before it finished,
and a finished one was gone at the next launch.

The setup now gets the copy as claude-credentials.json (claudeSyncName),
and sync.sh's merge_claude_credentials merges it in the VM: the copy's
claudeAiOauth replaces the VM's (or takes it out when the copy has none),
every other key of the VM's file stays. It reads the VM's file with one
jq call (--slurpfile, so two JSON values or a non-object are caught) and
writes it whole, mode 600, through a mktemp file in ~/.cache, which no
history export or remake carries, then mv; a failed cat or mv removes
the temp file and fails the setup. A link, or a file that's empty, not
JSON or not one object, is replaced by the copy and said (a link removed
first, so mv never writes through it into a folder); a folder is left
and said.

With a Claude Code token (setup-token), devvm sends no copy, as before,
so the VM's file stays as it is: Claude Code prefers the token in its
environment, and a leftover login's placeholder gets the token at
api.anthropic.com and nothing at the connectors' host.

mcpOAuth stays in the VM: devvm agent save reads only settings and the
.claude.json allowlist, history export excludes .credentials.json
(HistoryExcludes) and import skips it, and a remake leaves login files
out (homeSkips), all unchanged.

Tests: TestStageClaudeOAuthMerged (the copy is staged to merge, never at
home/.claude/.credentials.json); TestClaudeSyncNamesMerged (sync.sh
merges each claudeSyncName name into its place); guest.txtar runs
merge_claude_credentials (mcpOAuth and other keys kept, claudeAiOauth
replaced or removed, a key with a \u escape, empty, not JSON, two values,
an array, a link to a file or folder, a folder, a failed move, the
warnings, mode 600, no temp left); agent_login.txtar reads the new name.

Docs: Coding agents' MCP servers' logins (real tokens the VM's code can
read, never leaving it) and its Copies, How it works' Claude Code's
login and the network page's sentences, what a VM made again keeps, the
sync.sh header, and the safety pages' claim that a VM never holds a
refresh token, narrowed to the logins devvm keeps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 13:57:45 -07:00
w3cjandClaude Opus 5.5 c1db911d1b fix(agentlogin): the Claude login reaches claude.ai's connectors (#61)
Claude Code lists a claude.ai account's connectors at
api.anthropic.com/v1/mcp_servers and reaches each at
mcp-proxy.anthropic.com/v1/mcp/<id>, with the login's access token. The
OAuth login's binding named api.anthropic.com alone, so the connectors'
requests carried the placeholder and were refused.

ClaudeOAuthBindings gives the OAuth login a second binding,
claude-connectors: the same placeholder, into Authorization for
mcp-proxy.anthropic.com below /v1/mcp/ alone. It has a name of its own
because the proxy looks a value up by its binding's name, and
secrets.Store.Get gives claude-oauth a Claude Code token in the login's
place but never gives one to claude-connectors, so a token, saved or in
devvm's environment (whose scope isn't checked), still goes only to
api.anthropic.com. The bindings file stays version 1.

Tests: TestClaudeCapture and the claude-oauth golden check both bindings;
TestClaudeBindings checks the connectors' binding gets the OAuth login and
never a saved or environment token (with the claude-oauth control);
network.txtar checks the VM's secrets.json and secrets.policy. e2e's
network section adds the connectors' host to its fake upstream: with the
claude secret, neither its placeholder nor the OAuth login's gets the
token there (the API, the control, does), and after the host's refresh
the connectors' host gets the refreshed access token.

Docs: the Claude Code login, the attack vectors' new entry for connectors
(deny mcp-proxy.anthropic.com to keep them from a VM), How it works'
bindings and threat lines, the agents' table, and Contributing's e2e
network section, whose refresh sentence was stale (the refresh succeeds).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 13:19:11 -07:00
w3cjandClaude Opus 5.5 8afdec7de4 fix(proxy): a NO_PROXY address with an IPv6 zone names nothing (#59)
parseNoProxy read an entry with netip.ParseAddr, which accepts a zone,
and PrefixFrom then dropped it, so fe80::1%eth0 sent fe80::1 direct.
Go's httpproxy, HostOK, dial and the policy all treat a zoned address
as naming nothing; the NO_PROXY reader now does too.

Tests: FuzzNoProxy's crash input (::%0 against [::]), and fe80::1%eth0
and [fe80::1%eth0]:443 in TestNoProxy's names-nothing cases.
FuzzHostSites' noProxySite lists the zoned address as a divergence
from the legacy reader.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 11:51:54 -07:00
w3cjandClaude Opus 5.5 e97db057fd fix(agents): Claude Code's plugins get a folder of each VM's own, the store's a read-only seed (#56)
A VM's ~/.claude/plugins was the agent store's plugins folder, mounted
read-only, so everything Claude Code writes there failed with EROFS: a
plugin's data (${CLAUDE_PLUGIN_DATA}), installs, marketplace refreshes,
mcpb/ and the rest. Making the store writable would let one VM change
what Claude Code runs in every other VM, so each VM's ~/.claude/plugins
is now its own folder on its disk (CLAUDE_CODE_PLUGIN_CACHE_DIR), and the
store's folder is linked at ~/.claude/plugins-seed and read as Claude
Code's own read-only seed (CLAUDE_CODE_PLUGIN_SEED_DIR). Checked on a
devvm VM first: a seed-cached plugin from a GitHub-style marketplace
loads with only enabledPlugins, its hook writes ${CLAUDE_PLUGIN_DATA} in
the VM's own folder, installs in the VM work, and seed marketplaces
refuse updates.

- agents: Def.Seeds (Rel, Link, Entries), Seeds, SeedOf, MachineOwn;
  Env gains Home; Claude's Env sets both variables below $HOME.
- vm: the setup links a seed at its Link and stages own-dirs, which
  sync.sh makes a folder in place of a link; agentEnv writes Home values
  through homeValue (shared with toolchainEnv); a remake keeps the VM's
  own folder and skips the seed's link.
- devvm agent import copies only a seed's entries (known_marketplaces.json,
  marketplaces, cache), directly and through followed links, so the
  host's plugins' data, mcpb, synced, .trash, store and
  installed_plugins.json never reach the store.
- devvm agent save: the VM's script excludes a seed folder's other
  entries by name, and readSent refuses any (listedPath); a seed folder
  adds and changes, never removes or prunes; claudeRecords renames the
  VM's plugins path to the store's and joins known_marketplaces.json by
  key, leaving records Claude Code registered from the seed as the
  store's, and the store's file as it is when nothing changed.
- History: an export leaves the VM's plugins folder out and an import
  skips it and the seed's link: it's settings and plugin data (which can
  hold a plugin's own logins), not history, and reaches other VMs only
  through devvm agent save's reviewed diff.
- Review fixes (security-audit): historyImport refuses a name with a
  ., .. or empty part (GNU tar's anchored excludes missed
  .claude/./plugins and .claude//plugins, which now reach a writable
  folder) and deletes importSkips by path after the link sweep; the save
  script never excludes a name with a wildcard's character (it's sent
  and refused); only a marketplace record whose exact installLocation is
  clean and in the store's marketplaces joins the store's.
- Tests: claude_test.go (TestClaudePluginsSeed, TestClaudePluginsHistory,
  TestAgentImportClaudePlugins, TestAgentSaveScriptClaudePlugins,
  TestReadSentClaudePlugins, TestAgentSaveClaudePlugins), TestSeeds,
  TestListedPath cases, the agent, agent_save and sync CLI tests, goldens,
  and e2e project checks of the seed, the VM's folder and a plugin's data.
- Docs: coding-agents (store table, Claude Code's plugins under Mounts,
  the save's plugin example), internals/agents, a design note with its
  threat check, extending.md, CHANGELOG Fixed and After you upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 11:37:40 -07:00
w3cjandClaude Opus 5.5 f3848294d8 fix(agentlogin): names you choose in agents' settings are no longer taken for secrets
Redact judged every key by redactName's substring rule, so a plugin, a
marketplace or an MCP server named tokeneconomizer, token-saver or
secret-scanner had all its settings replaced with devvm-redacted, and
Claude Code refused the VM's settings.json whole (#55).

Each agents.Def now lists the tables of its settings files whose keys are
names you choose (Names: a table under a name isn't judged by its name)
and the tables of settings keyed by names (NamedValues: neither a table
nor a setting's word, lower-case letters and dashes such as off, is),
read from each agent's docs; agents.NameTables is their one union, which
Redact applies to every agent's files. Fields under a name are judged as
before: the substring rule, wholeTable, secretShape and the URL and text
scrubbing. Any other value right under a names table is still judged by
its key, a name that's env or headers still makes a table of secrets, and
a * in a table's path never stands for a list's element.

The trade-off: a table with a secret-looking key right under a name, such
as {"mcp": {"tokens": {...}}}, is no longer replaced whole; no agent's
schema has one there, and the fields inside it are still judged.

Tests: TestRedactNames (Claude Code's, Codex's, opencode's and pi's
names, kebab and camel, secret fields under names, misplaced values in
names and settings tables, a list under a settings table's path, a
server named env), FuzzRedact's seeds under names and settings tables,
and TestRestoreOlderNamesCopy for a VM copy an older devvm blanked, which
devvm agent save leaves out with a warning (an After you upgrade line).
Thanks to dhruv1220 for the tests' idea in #58.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:48:29 -07:00
w3cjandClaude Opus 5.5 2c0a894a1c fix(vm): a project folder's VM works after a boot renumbers its disk
macOS numbers its disks' devices in the order they appear at boot, so
after a restart an unchanged project folder's identity (dev:ino:btime)
can have another device. The finder then refused its VM as made for an
earlier folder (vm_other_folder), a stopped VM's start refused it as
replaced (project_folder_changed), and the next .git check called it
replaced (git_replaced).

platform.SameFolder is now the one comparison of two folder identities:
the same ID, or at the same path the same inode and birth time on
another device. On another device the ID must also be the one read from
the folder opened at the path with no link followed (OpenNoLinks, then
fstat and fstatfs on it: openFolderID), on a file system whose IDs are
their folder's alone, so a link swapped in while the caller read the ID
can't pass a copy's (a snapshot's, a cloned disk's) off as the folder's.
A folder at another path (moved) matches only exactly.
platform.Renumbered says when the record needs the folder's ID as it is
now.

The finder's sameFolder, here.movedFrom, gitprotect's protectRepo and
the strict conversion's checks use it. A start records the project
folder's identity as it is now under the VM's state lock (renumbered, in
bringUp) before the backend mounts it by Want.ProjectID, so vz's
/.vol/<dev>/<ino> mount names the current boot's device, in the one
limactl edit; folderChanged's checks after it then compare exactly. A
.git check that accepts a renumbered .git records its current identity.
The move's check stays exact, as both its IDs are read in one run.

The structure test's folder-ids rule fails on == or != on a field named
Folder or GitID, or a call of FolderID or folderID, outside
internal/platform and tests, unless exactFolderIDs lists the function
with why: the agents' and exports' Folder paths, recordMove's
unchanged-state check and folderChanged.

Tests: TestSameFolder (platform), TestRenumberedFolder (vm),
TestReportsRenumbered (gitprotect), a renumbered vz case in
TestProjectMountByInode (lima), existing.txtar's renumbered folder, and
fixture_v010_renumbered.txtar on the frozen v0.1.0 state, through the
new renumber script command and stubtest.Renumbered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:12:14 -07:00
w3cjandClaude Opus 5.5 ba5613e1ed fix(project): a folder name's run of separators becomes one dash in its VM's name
A folder named x--y, "foo (copy)" or "C++ stuff" failed to get a VM
(#52): project.Slug turned each character other than a-z and 0-9 into
its own dash, and Lima's instance-name grammar refuses separators in a
row. Slug now writes one dash per run.

- vmname: the project-VM grammar refuses dashes in a row
  ([a-z0-9]+(-[a-z0-9]+)*); HasRuns recognises the names releases up to
  0.1.1-rc.3 made for such folders.
- state: a vm.json whose name HasRuns and that has no created time is
  read as no state. Only a create that Lima refused leaves one (vm.json
  is written before limactl clone), so the folder's next VM, in the same
  hash folder, replaces it, rather than every read failing as corrupt.
  One with created set is still corrupt.
- The limactl stub refuses names Lima refuses on create and clone;
  TestLimactlStubContract gains a refused clone, checked against real
  Lima.
- Tests: TestNamesLimaTakes (Lima's regex as the oracle), TestHasRuns,
  TestVMWithRuns, TestLimactlRefusesNames, name_runs.txtar (a new VM for
  x--y, and an older release's leftover state replaced).
- Docs: internals/backends.md's VM names; CHANGELOG Unreleased Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 12:39:29 -07:00
w3cjandClaude Opus 5.5 70ed1db7ef build(nilaway): nilaway:linux checks Linux's build and must pass before a push to main
CI's nilaway job only warns, so a new finding hides in a green run, and
a finding's key is its code path, so code that only moved can read as
new. mise run nilaway:linux runs scripts/nilaway.sh with GOOS=linux, so
nilaway checks the code as built for Linux, as CI's job does, from a Mac
too (a nil planted in a Linux-only file fails it there, where the plain
task passes); it exits 3 on a new finding and 1 on a stale line.

Contributing's Tools and tasks and Nil checks, AGENTS.md's tasks and
codebase-standards' rules.md say it must pass before a push to main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:34:26 -07:00
w3cjandClaude Opus 5.5 069f646e80 test(structure): an io.ReadAll outside tests reads through an io.LimitReader
The structure test's read-limits rule fails, outside tests, on an
io.ReadAll whose reader isn't an io.LimitReader made in the call, unless
unboundedReads lists its function with why; a listed function that has
none fails. Four are listed: the status line's tail of the run's own
log, which only that run writes, and the three test stubs' reads of the
standard input devvm under test writes and closes. readCases breaks it
on a renamed io import, a reader limited before the call and a read in
a function literal.

It shares dropped-errors' walk and table check (siteRule, sitesWhere).
Named as the guard in codebase-standards' Bound what you don't control
and rules.md, and in Contributing's structure test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:32:17 -07:00
w3cjandClaude Opus 5.5 f9c02c1c5c build(lint): a file a VM can write is changed through what opened it
forbidigo refuses os.Chmod, os.Chtimes, os.Chown, os.Lchown and
os.Truncate in internal/proxy, internal/vmlog and internal/vmssh, outside
tests: a change by path follows a link a VM swapped in after the open.
The two sites today, the proxy's SSH agent relay socket and the link
session's sockets, chmod a unix socket devvm has just made in its own
folder, which only its path can set; each says so in a nolint.

The safefile rule widens to internal/vmlog, which has no open of its
own, and to the proxy's rotate.go and nixcache.go, whose three opens to
write or lock say why in their nolints.

testdata/lint breaks the rule once for each function and keeps the
descriptor's own methods. Named as the guard in codebase-standards'
Treat what a VM can write as hostile and rules.md, and in the checks on
owners.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:29:53 -07:00
w3cjandClaude Opus 5.5 bd09e883d5 test(structure): a Wait's or a strconv parse's error assigned to _ fails
The structure test's dropped-errors rule fails, outside tests, on a
function that assigns a Wait's error, or a strconv parse's (Atoi, the
Parse functions, Unquote, UnquoteChar, QuotedPrefix), to _, unless
droppedErrors lists it with why; a listed function that drops none
fails. None is listed today. errorCases breaks it on each shape: an
assignment, both of a process's Wait results in a goroutine, a renamed
strconv import, a var and an if's init.

Named as the guard in codebase-standards' Never fail silently and
rules.md, and in Contributing's structure test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:27:28 -07:00
w3cjandClaude Opus 5.5 2208931253 test(proxy): the broker's too_long reply to a reply past a frame
The broker's answer refuses a reply too long for a frame with
too_long, so the child's request never waits on it, but no test
reached that path. TestServeChildTooLong, in a synctest bubble on
memnet, asks for a value past wireMax and checks that the child gets
too_long for it at once, and that its next request is answered.
Without the too_long send the bubble deadlocks on the child's wait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:22:47 -07:00
w3cjandClaude Opus 5.5 59126858c4 fix(proxy): the Nix cache's folders are made and chmodded through descriptors
makeNixFolders ran os.MkdirAll and os.Chmod on nar/ by its path, which
follows a link there. A confined proxy child makes regular files alone
in the shared Nix cache (Landlock has no MAKE_SYM for it, and Seatbelt
refuses anything but a regular file), so it can't plant one; a child
that runs without Landlock or Seatbelt could, and each proxy's next
start would chmod the folder the link led to. This is hardening for
that case, not a fix a user could see, so it has no CHANGELOG entry.

The cache's folder is now opened as a safefile.Root, and its mode set
through its descriptor (Root.Chmod: fchmodat on "."). Anything at nar/
that isn't a folder is deleted as itself (a link never followed), and
nar/ made and opened from the root as a folder, never a link
(Root.MakeDir, which tries mkdir only when nothing is there, as a
sandbox that refuses making folders may refuse it even where one is),
its mode set through its descriptor. makeNixFolders reports a
replacement, which the broker's log warns of, so the cache, which is
devvm's alone, never stops a proxy's start.

Test: TestMakeNixFoldersPlanted plants a link to a folder outside the
cache, a relative one to a folder in it, and a file; each fails without
the fix (the targets went to 700, or the start failed). Docs: How it
works' shared Nix cache and the design note on the folders the child
writes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:22:47 -07:00
w3cjandClaude Opus 5.5 0b85f5f557 fix(size): a size that isn't a number is refused, never read as 0
Size.Backend dropped strconv's errors, so a VM's size in vm.json that
isn't a number, such as "cpus": "four" after an edit by hand, read as
0, the image's, and the VM started with the image's size without a
word. Backend now reads each part with the check that took it
(settings.CPUCount, settings.GiB, which ParseCPUs and ParseGiB now
use), and returns an error naming the key and value. storedSize turns
a stored one into size_stored_invalid, naming the VM. Every start
(bringUp, before anything runs), a restart's stop (stopToStart, so a
running VM keeps running, as a refused proxy start leaves it), devvm
size and a remake's check refuse with it; devvm size --KEY sets it
again. ParseCPUs and ParseGiB also refuse a number too big for an int
or a float64, which for --disk reached Lima as +Inf.

Lima's originOf read base's disk with ParseFloat and dropped its
error: "NaN", "Inf" and "1e400" passed its check of a size above 0.
Only devvm's own Origin writes that step (gibString of BaseDiskGiB), so
no user, VM or limactl output reaches it; it now reads it with
settings.GiB and fails naming the value.

Every other discarded strconv error outside tests goes too:
- hostgit.Bool reads a boolean as git does (yes, on, whole numbers)
  and says when a value isn't one; GIT_CONFIG_NOSYSTEM, which
  strconv.ParseBool read as false for "yes", uses it, as does the clone's
  copy of a repo's config (gitBool, which had its own copy).
- image.GlibcOlder checks both versions itself and reports ok, so one
  that isn't a version is never read as 0.
- leaktest and state's lock order panic on a goroutine number
  runtime.Stack doesn't print today, rather than reading it as 0.
- cli's test-build overrides fail on a number that isn't one (a test
  build's panic), the stub limactl refuses a size it can't read, and
  opencodeMajor's fallback to 0 is explicit.

Tests: TestSizeBackend, TestStoredSizeInvalid (a stopped VM and a
running one's restart), TestSizeNumbers, new TestParseSizes and
TestOriginOfRefuses cases, TestParseUnknownFormat, TestBool,
TestUserFilesOf's git booleans, TestGlibc's invalid versions; each
fails with its fix reverted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:22:47 -07:00
w3cjandClaude Opus 5.5 c8505e326a fix(daemon,desktop): a process's Wait error is kept, not dropped
daemon.Spawn dropped its Wait's error and kept only the ProcessState.
When Wait can't reap the process (wait4 fails, as when something else
reaped it), there is no state: Exit then said "<nil>" and ExitSignal
dereferenced a nil state, which would have panicked the proxy's broker
in sandboxFailed. Handle.reaped now keeps Wait's error when there's no
state, Exit names it, and ExitCode and ExitSignal answer -1 and 0.

devvm desktop's sshChannel.Close dropped ssh's Wait error. An ssh that
ends on its own with a failure, such as 255 when the VM drops the
connection, now goes in the run log once and is Close's error; one that
Close killed after channelClose, or that the dial's context killed as
devvm desktop ends, isn't, as its end is the kill. startChannel, split
from dial, starts any command as a channel, for the test.

Tests: TestHandleReaped (fails without the nil-state handling: "<nil>"
and a nil-pointer panic), TestDesktopChannelClose (fails without Close
keeping Wait's error).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 08:07:30 -07:00
w3cjandClaude Opus 5.5 ddb06b1ea7 docs(skills): the codebase-standards skill, a short checklist from what reviews kept finding, and how new code matches the codebase
A new project skill, .agents/skills/codebase-standards/, curated from
what reviews of devvm's whole history kept finding. A standard stays
only when it recurred or was costly, and a contributor can apply it
while writing or reviewing; what the linters and the structure test
enforce is only in rules.md's guard tables.

- SKILL.md: the checklist of 13 standards in four groups (safety,
  failures and processes, changes, tests), a Match the codebase
  section (names and files, comments, errors, dependencies as fields,
  table tests, scripts in the VM, prose), how to review a change, and
  the bar for adding a standard.
- standards.md: one section per standard, with its rule, what the
  reviews found and its guard:
  - Fail closed, on every path (a weaker mode only when visible,
    documented and chosen, as the proxy's warn-and-run without a
    sandbox)
  - Bound what you don't control (listeners, locks, overflow, a capping
    writer that doesn't embed its buffer)
  - Treat what a VM can write as hostile (descriptors, signed sources
    and re-hashing, escaping, host tools by absolute path)
  - Keep secrets and host data on the host (no argv or shared
    environment, allowlists into the VM, logs redacted)
  - Parse once, with a real parser (IPv6 and its IPv4-carrying forms)
  - Never fail silently, and name the real cause
  - Give every process an owner that ends it (accept loops included)
  - Survive a kill and a second devvm (one good copy, OS file locks)
  - Extend the owner, and wait for a third copy (an existing owner is
    always extended; a copy of a judge gets one owner at once)
  - Mind what's already running and released
  - Claim only what the code does, where precision belongs (headline
    pages keep their short claims)
  - Prove each fix with a test that fails without it (outside oracles,
    controls for absence checks, sandboxes proven by attack)
  - Write tests that pass on any host, at any load
- rules.md: the rules whose home is AGENTS.md or Contributing, by area,
  each with its guard or review only.
- AGENTS.md: a rule line for the skill and its row in the layout, and
  the owner rule's wait-for-a-third clause, which Contributing's
  structure page explains.
- Contributing's first paragraph links the skill.
- The docs-voice skill's scope, .vale.ini, mise run lint:docs
  (markdownlint and Vale) and TestCommandLines cover the new skill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 07:50:54 -07:00
w3cjandClaude Opus 5.5 1a16b1bb73 build(nilaway): the baseline follows three triaged findings the harden stack reshaped
The agent relay's finder calls the VM state's Name directly, the links
report is read through safefile.Read rather than os.ReadFile, and the
rotation's Stat finding is gone with the broker's descriptor-based copy.
The two that remain are the same false positives in new shapes: fst is
set together with found, and from is reset when the data is shorter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 07:14:16 -07:00
w3cjandClaude Opus 5.5 df1d76bbd9 fix(desktop): devvm desktop's relay goes on after an accept error
devvm desktop's relay returned at any error from its listener's Accept,
so running out of open files in a burst (EMFILE) ended devvm desktop.
It now waits and tries again, as devvm's other accept loops do, with
their one owner, daemon.AcceptRetry: 5 ms, doubling up to a second,
logging only the first error of a run, and it still ends with its
context or its listener's close.

- internal/desktop/relay.go: Serve uses daemon.AcceptRetry.
- Tests: TestRelayAcceptRetries (a listener that fails three Accepts
  with EMFILE, then carries a viewer; the run logged once).
- Docs: processes' desktop relay, structure's internal/daemon row;
  CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 3da38436a7 feat(proxy): the broker opens the child's connections; its sandbox refuses it every one of its own
A sandbox fixed at the child's start can't tell this machine's
loopback, its own addresses and the LAN apart from the internet as a
rule changes, so the child's sandbox now refuses it every connection
of its own, and the broker looks up each name and opens each
connection for it, once its own read of the VM's policy and of the
host's addresses allows the address, as the floor does. A child that a
VM takes 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; a company proxy, which the child still speaks to with
its password, reaches whatever it reaches.

- wire.go: lookup (a host name, absolute, with its trailing dot), dial
  (an address and a port, or the https or http company proxy of the
  broker's config, never both), the connection as the reply's one
  descriptor, and cancel, for a lookup or a dial the child gave up on,
  which frees its slot.
- dial.go: the broker's own egress (newBrokerNet: the VM's built-in
  policies, its policy files, looked at on every dial, and the host's
  addresses), lookupable, broker.lookup, dial and dialProxy, within 20
  s and 15 s; the child's side (brokerClient.lookup, dial, dialProxy)
  wired into its egress by throughHost; the resolver's errors as codes
  the child makes into net.DNSError again.
- broker.go: the caps (256 lookups, 1024 connections at once); its
  line for each failed lookup and connection, which the VM drives, at
  most 20 a minute and then one that says it stops (logFailed,
  perMinute in limits.go, which egress.abandoned now shares).
- child.go and confine.go: every lookup and connection through the
  broker; the child lowers its open files, soft and hard, before it's
  confined (limitFiles).
- seatbelt: the child's profile allows no network out, TCP, UDP or a
  unix socket, nor mDNSResponder.
- landlock: the seccomp filter refuses every socket but a netlink
  route socket, connect, socketpair, listen and MSG_FASTOPEN on
  sendto, sendmsg and sendmmsg; Landlock no longer opens the resolver's
  files below /etc.
- Tests: the broker's dial and its rules (TestBrokerDial,
  TestBrokerDialFollowsRules, TestBrokerDialProxy), lookups and their
  errors, cancel, the client over a real socketpair,
  TestBrokerFailedLogCapped, TestPerMinute, the filter's programs, the
  child's own connections refused under Seatbelt and under Landlock and
  seccomp.
- Docs: the design note's broker (what crosses to the broker: the
  names and addresses, never a connection's bytes), its threat check,
  network's The child's sandbox and proxy.log, processes, attack
  vectors, troubleshooting, testing, tests, the proxy's README;
  CHANGELOG, with the company proxy's reach.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 7bc886133d fix(proxy): the broker frees a request's slot as its reply goes; start tests wait out a loaded host
The proxy's start and broker tests failed on loaded hosts, most on the
linux host under the race detector. The causes:

- Start timeouts (TestAgentRelay, TestMainRuns, TestMainRefuses,
  TestStartChildSandbox, TestV010ProxyConfigsStart, TestHandshakeChildGone):
  a broker's start, timed from its own, hashes its executable (selfSum),
  and the in-process child's spawn hashed it again. Under -race with the
  package's other tests, each hash took 2-3.5 s on the linux host, so
  starts passed startWait's 4 s (a start frame's write timing out, a
  relay or a proxy not listening within the test's 2 s of retries).
  IO gets a startWait field, a test seam; inProcess sets it to
  testStartWait (30 s) and hashes the test binary once per inProcess,
  and the tests wait as long for the proxy (retryFor). devvm's own
  proxy still waits 4 s.
- TestBrokerClientGivesUp's "busy": a real bug. The broker gave a
  request's slot back only after its reply was written, and the child
  gives its own back as the reply arrives, so a child that kept the
  caps and sent its next value at once could get busy. answer now
  frees the slot once the reply holds the socket's write lock, just
  before it's written (frameConn.sendThen), so a reply that waits for
  a child that doesn't read still holds its slot and the bound stays.
  TestServeChildFreesSlotsAsRepliesGo checks both, in a synctest
  bubble, and fails without the fix. The broker isn't released yet,
  so no CHANGELOG entry.
- TestSpliceKeepsAnEarlyAnswer (1 in 20 on linux under -race): splice
  could put the whole 4 MiB answer into loopback's buffers and close
  before the test's delayed upload arrived, which then reset the
  connection and dropped the unread answer. The test's server now
  answers once the upload's first bytes reach it, as a 413 does.

Coverage: internal/seatbelt has 53 statements, and the mini's unit and
CLI runs cover 51 (96.2%) every time; 97.4% isn't k/53 for any k, so the
baseline was measured on an earlier version of the package (37/38).
The two misses were ProxyChild's branch for a profile that can't be
made, now tested, and ChildProfile's template panic, which can't
happen. darwin's baseline rises to 98.1.

Docs: the design note says how the broker's caps never refuse a child
that keeps them; Contributing's tests page covers testStartWait.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 1793353dd9 feat(proxy): Linux confines the proxy's child with Landlock and seccomp
Before it reads a byte of the VM's, devvm _proxy-child confines every
thread of itself through proxy.confineSelf on Linux: no_new_privs
(syscall.AllThreadsSyscall), Landlock from ABI 2 (TSYNC from ABI 8) to
its logs folder, the Nix cache and the resolver's files (never /, the
home folder or one that holds it), binding no TCP port (ABI 4), scoping
signals and abstract sockets (ABI 6, or ABI 6/7 with erratum 2),
refusing named unix sockets (ABI 9) and UDP but to port 53 (ABI 10);
then a hand-written classic BPF seccomp filter, installed with TSYNC,
that refuses with EPERM AF_UNIX socket/socketpair, listen, io_uring,
ptrace, process_vm_readv/writev, pidfd_getfd, a file's mode, owner,
xattrs and times by its path (chmod, fchmodat, fchmodat2, chown, lchown,
fchownat, the six xattr calls, utime, utimes, futimesat, utimensat with
a path), truncate, the keyrings (add_key, request_key, keyctl),
prlimit64 on any pid but 0, setpriority, ioprio_set,
sched_setaffinity, sched_setscheduler, sched_setparam, sched_setattr,
inotify_init, inotify_init1, inotify_add_watch, fanotify_init,
fanotify_mark, execve, execveat, fork, vfork, unshare, setns, bpf,
userfaultfd,
perf_event_open, clone for anything but a thread or with a namespace's
flag, and clone3 with ENOSYS; it kills a foreign architecture's call or
an x32 number. fchmod, fchown, ftruncate and utimensat on a descriptor
stay. It checks the confinement holds, then proxy.checkConfined, and
that it still reads the host's addresses, within 2 seconds, or fails
the start. A kernel without Landlock or seccomp leaves that part out;
the child runs and says so. The broker sets itself undumpable
(PR_SET_DUMPABLE 0). The Nix cache marks a file used through its
descriptor. The broker's start, and its life with the child, take a
reset of the socket (ECONNRESET, Linux's end of a socket closed with
frames unread) as the child's end, as EOF is (socketEnded,
TestHandshakeChildGone).

Built on the Seatbelt item's shared owner, proxy.Confinement:
- internal/landlock (new, stdlib only, Linux build tags): Self, Result,
  Floor, ABIPorts/ABISignals/ABIUnix, ErrUnsupported; landlock_linux.go
  (resolverFolders, refusedFolder, homeFolder), filter_linux.go (filter,
  asm, encode, archOf), seccomp_linux.go, self_linux.go (Self, check,
  refused).
- internal/proxy: confineSelf on Linux calls landlock.Self;
  landlockConfinement words it (By landlock, seccomp; Why
  no-landlock-or-seccomp, no-landlock, no-seccomp, landlock-below-abi4,
  landlock-signals; full from ABI 6 with seccomp and scoped signals);
  confineChild takes the child's needs and returns an error, bounded by
  confineWait (within, confineWith); checkConfined only where Landlock
  or Seatbelt confines files; confineStarted; IO.confine required, set
  by ChildMain alone; hostAddrs.check; touch_linux.go and
  touch_other.go (touchFile, undumpable); IO.dumpable for tests.
- devvm doctor: netpolicy.Unconfined's Linux warnings
  (proxy_unconfined_no_kernel, _no_landlock, _no_seccomp, _old_ports,
  _old_signals).
- Tests: TestFilter and TestFilterBytes (an interpreter of the program's
  bytes, amd64 and arm64, and the assembler's refusals), TestSelf (a
  real confined child: outside file, ssh-like unix socket, listen, bind,
  signal, chmod, chown, setxattr, utimes, truncate, a keyring, unshare,
  exec, clone3, and new threads, fchmod, ftruncate and futimens kept),
  TestKernel, TestCheck, TestRights (refusedFolder), TestArchNumbers,
  TestLandlockConfinement, TestConfineWithin, TestCheckConfined,
  TestConfineStarted, TestRunChildOn, TestUnconfined; network.txtar; e2e
  network's Landlock, NoNewPrivs and Seccomp check.
- CI: a nocgo job (CGO_ENABLED=0) for internal/landlock and
  internal/proxy.
- Structure test, depguard, goroutineSites; docs: the child's sandbox,
  processes (and its why-Go note on unsafe), design (the network row's loopback follow-up on Linux,
  other processes and /proc without Landlock), doctor's checks,
  troubleshooting, attack vectors, Contributing, the proxy's README,
  AGENTS.md, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 941c63c696 feat(proxy): the proxy's child runs under Seatbelt on macOS
On macOS the broker starts devvm _proxy-child through
/usr/bin/sandbox-exec -p PROFILE, by devvm's real path, with a
deny-default profile, so the child is confined from its first
instruction: devvm's binary to run and read, its folder's metadata,
dyld-support.sb, /usr/lib and /System/Library, the time zone and
resolver files, its logs folder and the shared Nix cache (regular
files only, no hard links, no folder removed, no flags, ACL, owner,
set-id or xattr changes), stat alone on the watched files and every
link on the way, trustd and trustd.agent, mDNSResponder's socket, TCP
and UDP out (loopback left to the floor: a rule for a loopback port
applies at once, which a profile fixed at the start can't follow),
sysctl but kern.proc, signals to itself. No home folder, no devvm folder but its
own, no Keychain, no other unix socket, no bind, fork, exec, signal to
or look at another process (process-info, the process list).

- internal/seatbelt: the shared owner of Seatbelt (Exec, String,
  Path, Links, ChildProfile, Sandbox.ProxyChild); sbString, sbPath and
  sandboxExec move here from the Lima backend, which uses them.
  ChildProfile refuses a relative path and the root.
- internal/proxy/confine.go: the confinement report every platform
  shares (Confinement, ParseConfinement, ReadConfined: one line of
  fixed words in run/proxy.confined, refused unless it parses, and
  unless it fits what the broker started the child with), the child's
  self-check (checkConfined: its broker's config must be refused), and
  the in-process hook (confineSelf, confineself_linux.go and
  confineself_other.go) for the Landlock follow-up.
- internal/proxy/childstart.go: startChild, childSandbox, childNeeds;
  IO.Seatbelt, set by devvm _proxy on macOS.
  A missing sandbox-exec, or one that failed before devvm's code ran
  (exit 65 or 71, or SIGABRT or SIGKILL, before the child answered,
  decided before the broker's own stop), starts the child again
  unconfined within the broker's 4 seconds, with a warning in
  proxy.log; any other failure fails the start. The broker makes the
  Nix cache's folders first. start carries how the broker started the
  child (Spawned).
- watched.get: a stat refused for want of permission reads through the
  broker each time (a watched link pointed elsewhere after the start).
- daemon.Handle.ExitCode and ExitSignal.
- devvm doctor warns for each running VM whose proxy's child isn't
  fully confined (netpolicy.Unconfined; proxy_unconfined,
  proxy_unconfined_unsupported, _no_sandbox, _sandbox_failed,
  _check_failed).
- Tests: TestParseConfinement, TestCheckConfined, TestReadConfined,
  TestStartChildSandbox (an over-claiming ready, SIGTERM),
  TestSandboxFailed, TestChildNeeds,
  TestWatchedStatRefused, TestUnconfined, TestString, TestLinks,
  TestChildProfile, TestProxyChild, TestChildProfileConfines (the test
  binary run again under the profile on macOS: flags, rmdir, the
  process list), doctor's report, ExitCode and
  ExitSignal; e2e network checks run/proxy.confined is full seatbelt
  on macOS.
- Docs: How it works' The child's sandbox, Processes, the design
  note's confinement and threat check (loopback as open work, other processes'
  details and kern.procargs2, the shared folders' flags, mDNSResponder's
  records, trustd.agent's trust settings, the fallback's signals, a
  ready that claims more), Troubleshooting's The proxy runs without a
  sandbox, Staying safe's escaping the VM, doctor's
  checks, Contributing's packages, the proxy's README, AGENTS.md,
  CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 63bb1ff9a8 fix(network): a confined VM's programs ask 127.0.0.1 directly, so names fail at once
With transparent mode off or stopped, a confined VM's only name server,
127.0.0.1 (Lima's DNS setting), has nothing listening. glibc asked it
through systemd-resolved's stub, which could keep retrying it over UDP
and TCP without answering, so a lookup such as getent's waited out its
timeout instead of failing at once (seen on a Linux host: e2e network's
checks of DNS with transparent mode stopped and off).

Each launch's setup now replaces /etc/resolv.conf, the stub's link, with
devvm's own file on a confined VM: nameserver 127.0.0.1 alone, the stub's
search line, timeout:1 attempts:2. glibc gets a refusal at once with
nothing listening, and dnsmasq's answer through transparent mode's
nftables rule when it runs, as musl on Alpine does. An open VM gets the
stub's link back. Only systemd guests that have the stub's file and whose
/etc/resolv.conf is its link or devvm's own are touched.

Root cause, as far as it could be pinned down: with resolved's stub in
the path, a lookup depended on resolved's retry loop over a server that
refuses everything (24 attempts, flipping UDP and TCP feature levels),
and on the linux host that loop sometimes never answered the stub
within getent's 3 s. It didn't reproduce on demand (a base run on the
linux host passed both checks, and bursts of 200 parallel lookups and
stops mid-lookup all failed in under 2 s), so the fix takes resolved out
of glibc's path rather than tuning it.

Going back to open restarts systemd-resolved: it reads a /etc/resolv.conf
that isn't its own link as global servers and search domains, so it had
taken 127.0.0.1 and "~." from devvm's file, and kept them once the link
was back, which left an open VM unable to resolve names (caught by e2e
network's open checks on the linux host and ubuntu).

Review folded in: no change of a foreign or dangling link when the stub's
file is missing; two attempts; Docker's user-defined networks in the docs.
Second review: devvm's file alone is enough to go back on an open VM (a
warning when the stub's file is missing); a failed write says so in one
line and the launch goes on; troubleshooting's "An open VM resolves no
names after a downgrade"; tests for resolved's own resolv.conf link, an
open VM without the stub, a non-systemd guest with devvm's file and a
failed write.

workerd under wrangler dev, checked by hand on fedora with transparent
mode off: its fetch fails at once (Temporary failure in name resolution),
so the "about 40 seconds for each lookup" sentence is gone from lima.md,
safety/network.md and troubleshooting.md, and testing.md's manual check
covers it.

testdata/coverage/darwin.txt: internal/sshagent's baseline rose with
mise run coverage (unrelated to this change).

- backend.Confinement.Resolver: the one owner of a confined guest's name
  server; Lima's start sets .dns from it, sync.go sends it to the setup
  as DEVVM_RESOLVER; sync.go's setupInputs as mise run fmt writes it.
- assets/guest/sync.sh: resolver_conf; its unit test runs the function
  (internal/vm/resolver_test.go). sync.sh runs at each launch and goes in
  no image, so no image key changes.
- CLI tests: DEVVM_RESOLVER on confined (transparent on and off) and open
  VMs. e2e network: the stopped-transparent check also checks the file.
- Docs: network.md's The VM's resolver, lima.md, design.md, tests.md;
  CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 aeea3135b2 feat(proxy): the proxy's broker and its child
A VM's proxy runs as two processes, as design.md's "The proxy's broker"
says: devvm _proxy, the broker, which keeps what only the host should
do, and devvm _proxy-child, which reads the VM's network and can be
confined by the follow-ups.

- wire.go: the protocol over one socketpair (close-on-exec from the
  start: SOCK_CLOEXEC on Linux, ForkLock elsewhere), length-prefixed JSON
  frames of at most 2 MiB, unknown fields refused, bytes as base64, one
  descriptor on a frame's first bytes (SCM_RIGHTS, MSG_CTRUNC breaks the
  rules), wire types for every secret (redact.Secret at once).
- broker.go: newBroker, the start (handshake: version 1 and each side's
  executable's SHA-256, within 4 s), the answers (value through lookups,
  kept 30 s or 5 min, a failure 5 s, dropped when the bindings change;
  file by number; link connected by the broker and passed as a
  descriptor; token exchanged by the broker), each by something in its
  own config, with caps 1/8/4/256; live: the lifeline closes the socket
  and kills the child 6 s later, SIGTERM stops it within a second, a
  child that ends ends the broker, a rule broken stops the child.
- child.go: the start (startOf), the child's server (newChildServer),
  the broker as hostSide over the socket (brokerClient), runChildOn;
  ready only after it reads the host's addresses (kept: the last good
  read), roots and time zone loaded first.
- process.go: Main(ctx, ...) and ChildMain; the child spawned with
  /proc/self/exe on Linux, PR_SET_PDEATHSIG from a locked thread
  (daemon.Cmd.DieWithThread), descriptors 3 and 4, and TZ, SSL_CERT_*
  and GODEBUG with updatemaxprocs=0 alone; run/proxy-child.pid and
  run/proxy.confined ("none" until the follow-ups); KeepLogs in the
  broker. ChildMain refuses to start unless descriptors 3 and 4 are a
  unix socket and an IP one (checkInherited): run by hand, without
  them, those numbers can be the Go runtime's own, which closing
  crashed it (signal_recv: inconsistent state).
- capture.go: a captured token request goes to the broker
  (captureToken, exchanger), so a login's real tokens never enter the
  child; an error reply passes up to 1 MiB, longer gets 502.
- watched.go: the child stats each changing file and asks the broker
  for it once it changed, keeping the stamp of what the broker read.
- rotate.go: proxy.log rotated by both through its descriptor, under a
  lock of a description of its own; OpenLog opens a log never through a
  link, one link, yours, replacing what a child left in its place.
- nixcache.go: the trim and its count through a safefile.Root, nar/
  only as a folder, links deleted as themselves; reads never through a
  link; the lock tried for 5 s (ErrNixLocked, nix_cache_locked).
- daemon: Cmd.Err, Files, Env, DieWithThread; Handle.Kill, Exit;
  WritePID.
- netpolicy: Proxy.Stop also stops a child that outlived its broker
  (run/proxy-child.pid, _proxy-child -for); proxy.log opened with
  OpenLog; a refused launch keeps a running VM only while both run.
  devvm network log and lock read the event log through safefile.
- vm, vmssh, vmlog: links.log and ports.log opened with OpenLog, read
  through safefile, trimmed only as a regular file with one link.
- backend: the build proxy's logs in a logs/ folder of their own.
- cli: _proxy-child; _proxy waits for its child on a signal
  (StopsItsOwn); the child reads none of devvm's folders (no
  makePrivate); ui.Files.
- Tests: FuzzBrokerFrames, the frames' rules, the handshake and the
  pair's end in synctest bubbles, the caps, the broker naming its own
  alone, the client over a real socketpair with a passed descriptor,
  ChildMain, TestInheritedSocket and proxy.txtar's child run by hand,
  the frozen 0.1.0 configs starting a broker and child,
  two writers rotating once, planted links, FIFOs and hard links; the
  testscript runner stops _proxy-child too; e2e: broker and child, their
  arguments, descriptors and environment, stop, SIGKILL either, planted
  files in the logs folder and the Nix cache, build proxies gone.
- Review fixes: the lifeline closes the socket and starts the kill's
  timer before logging; every log lock (proxy.log's, the event log's
  rotation) is tried without blocking for 200 ms (flockWithin, which the
  Nix lock shares), then written without or the rotation skipped; a
  copied log's rotation streams at most twice its limit from a line's
  start (copyFrom, copyAtomic); a reply too long to send goes as
  too_long; kept token headers capped at 1 KiB; the child gives up on a
  request whose context ended, dropping its late reply and holding its
  slot until then; a write deadline on the start frame; errors reach the
  child as codes (not_found, refused, busy, too_long, failed), their
  text in the broker's log; FuzzFrameStreams, and FuzzBrokerFrames
  writes from a goroutine; nix_cache_locked links to How it works.
- Docs: processes, network, overview, design (with threat rows for the
  logs' locks and a log made huge), troubleshooting, the proxy's
  README, structure, testing; CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 9c74dac11e fix(logs): a VM's logs are held to their caps while it runs
internal/vmlog owns every log a VM can drive but the proxy's own:
Limit (moved from vmssh's logLimit, with Allow for the link session's
warnings), Capped and Trim for ports.log and links.log while they run,
and KeepVM, which the VM's proxy (proxy.IO.KeepLogs, Config.VMLogs from
backend.Run.Logs) and a Lima build run on the serial consoles' and the
hostagent's logs: redacted as they grow (redact.FileFrom), so a reboot
in place can't leave the proxy password there, and rotated past 10 MiB,
counting what a log holds past the hole its writer left
(platform.DataStart).

The proxy's http.Server logs through its own limited log, and its
copied log counts what reached it as stderr; the build proxy's log is
held as a VM's proxy's is. git-pins.jsonl has a cap. Run logs take at
most 256 MiB together, never the newest or a live run's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 4a4aabe9a8 fix(netpolicy): a refused launch leaves a running VM and its proxy as they were
With config.toml's proxy naming a user and no proxy secret saved, devvm in
a running VM's folder refused (proxy_password_missing) but stopped the VM
(net_proxy_down_stopped), and devvm restart stopped it before refusing.
Every check that can refuse a proxy start already ran before Prepare
stopped the old proxy; runningConfinement stopped the VM on any error.

- netpolicy.Proxy.PrepareRunning: Prepare for a running VM. A refusal
  before its proxy is touched keeps the VM and proxy (net_proxy_kept, a
  new message) only while that proxy enforces the state's tier now
  (enforcesNow: built-in, files, denies, open, devvm binary); otherwise,
  or once its proxy was stopped or started, or with none running, the VM
  is stopped (unproxied, was Unproxied, which now stops a proxy left
  running too).
- netpolicy.Proxy.Refusal (shared): the user's CAs and the company proxy,
  checked first in prepare, before a VM is made (up), before a running VM
  is stopped to start again (target.stopToStart: devvm restart,
  restartForNextStart), and before a running VM's tier changes between
  confined tiers (checkTier: devvm network, lock), so its state never
  names a tier its proxy doesn't enforce.
- devvm network's change to a running VM's rules goes through
  PrepareRunning, so a proxy that can't start again stops the VM rather
  than leaving it running without one.
- Proxy.Upstream removed (no callers); shared, prepare, unproxied and
  tierNow are functions of the proxy, keeping Proxy within 24 methods.

Tests: company_proxy.txtar (launch and restart refused, VM and proxy
untouched; devvm network allowlist refused, tier unchanged),
TestPrepareRunningRefused (eight rows), e2e corpConfig checks the VM's
status after the refused launch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:32 -07:00
w3cjandClaude Opus 5.5 90a64a44d1 fix(races): lock order checked, sandboxes' own ports, pins that meet a rename, daemons' groups stopped
- state: test builds and tests check the state locks' order (state.held, CheckLockOrder): a second VM's lock, a VM's lock under the claims lock, or a lock taken again panics before waiting.
- platform: PinBeneath opens the path again when a rename takes the file away before move_mount (ENOENT), so the keeper no longer reports a false lost pin (TestPinsInNamespace's 'f lost / f pinned-again'); TestPinWhileRenamed.
- daemon: Proc.Stop signals the process group (SignalGroup), so forwarders' and link sessions' ssh masters and relays end with them; ui.UI.StopsItsOwn makes _ports and _links wait for their ssh on an outside SIGTERM.
- vm: gc --orphans and devvm space count forwarders' leftover control sockets (vmssh.ControlGlob).
- CLI tests: each sandbox claims a block of ports below devvm's range and the ephemeral range (claimPortBlock, /tmp/devvm-test-ports); free_port, the fixtures' ports and DEVVM_SSH_PORTS come from it, and the sandbox's devvm chooses from its own range (DEVVM_PORT_RANGE override). Fixtures' forwarded ports and settings ports are rewritten too (FIXTURE_PORT_<port>).
- netpolicy and vm tests: the fake proxy's stop waits for its reap, and fake daemons run until the test ends, not 30 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 11ccecca15 docs(design): the proxy's broker, a design note for splitting devvm _proxy
The design note for splitting the VM's proxy into an unconfined broker
and a network-facing child that can be confined: what runs where and
why, the files and sockets each side needs, the protocol (a socketpair,
framed JSON with caps, versioned, failing closed, naming nothing but the
broker's own VM's), the token exchange in the broker, the Secret type on
the socket, the start, the end and how tests find each process, the
build proxy, upgrades and the frozen configs, what Landlock and Seatbelt
will confine in the child, performance, the options weighed and the
threat check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 a7cc12521e test(fuzz): fuzz targets with properties, fuzzed nightly
Twenty-three new fuzz targets, built-in Go fuzzing, each checking a
property rather than only that nothing panics: parsers of what a VM or
the network sends fail closed and keep to their caps, a secret goes only
where it's bound, and no planted secret survives a redaction.

- internal/proxy: FuzzCursorFrames (passes only what came; no message
  over frameMax or holding a JWT's start, decompressed and unescaped),
  FuzzInject (a binding's value only to a host it names, judged apart
  from the matcher in NormHost's form, for its path and methods, in its
  own header, which held the exact placeholder once; other headers
  untouched), FuzzParseBindings, FuzzLinkList, FuzzParseUpstream (errors
  hold no more of the URL than its scheme), FuzzNoProxy, FuzzParseNarinfo
  (only cache.nixos.org-1's signed narinfo is taken).
- internal/agentlogin: FuzzParseTokenRequest, FuzzRedact (secrets planted
  eight ways in JSON and TOML settings), FuzzCapture (the VM's reply holds
  none of the endpoint's tokens).
- internal/redact: FuzzSplit (a password written in parts through Split,
  as the run log writes it, never survives).
- internal/jsonc: FuzzStrip, differential against encoding/json.
- internal/upgrade: FuzzParsePublicKey, FuzzVerify, FuzzEntryName,
  FuzzUnpack.
- internal/vmssh: FuzzParseHostKeys, FuzzParsePorts.
- internal/vm: FuzzParseCloneState, FuzzParseInit, FuzzParseKept,
  FuzzParseLFSPointer.
- internal/desktop: FuzzHandshakeVM.

What they found, each fixed with a regression test:
- NO_PROXY: an entry with port 0 (git.test:0) was read as the host on
  every port, and git.test:080 or :+80 as port 80, which Go's clients
  match against nothing; an entry whose port no request has, or that
  isn't plain decimal, now matches nothing (TestNoProxy,
  testdata/fuzz/FuzzNoProxy). FuzzHostSites' NO_PROXY site allows this
  difference from its frozen copy, and the design note lists it.
- A JSON token request with more after its object was judged by its
  first object; it's refused now (TestCaptureRefuses).

The Fuzz workflow runs nightly rather than two minutes weekly: five
minutes a target, eight at a time, each target's corpus restored from
and saved to a cache of its own (a failing input added to it, so it
fails nightly until fixed), new inputs minimized in at most 1,000 runs,
and one issue, "Fuzzing found failing inputs", opened, commented on when
the failing targets change and closed on a clean night, by a separate
job with issues: write that runs no repo code, on main alone. Target
names must be unique across packages. bump.sh moves an action in a
folder of its repo (actions/cache/restore, /save) with its repo's
releases.

Docs: Contributing's Fuzzing (running a target, the nightly run, every
target's property), Maintaining's Fuzzing failures and its actions bump,
the proxy README, the NO_PROXY and token request facts in How it works'
network page and the design note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 19f9900b86 fix(sshagent): a VM reaches its SSH agent only through its proxy's relay
OpenSSH's ssh-agent answers every request a forwarded connection sends,
so a VM that forwarded your agent or devvm's own (shared by every VM
that uses it) could remove all its keys (ssh-add -D), lock it with a
password of its own (ssh-add -x) or add keys without bound, denying the
agent to you and to the other VMs. Checked with a throwaway sshd and
ssh-agent: all three succeed over ssh -A.

Each VM's proxy now relays the agent its start chose on a socket of the
VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and
the VM's backend, devvm's own connections and the ssh entries for
editors name that socket. The relay passes on only
SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the
[email protected] extension (so destination-constrained keys keep
their constraints), answers everything else with SSH_AGENT_FAILURE,
reads messages whole up to OpenSSH's 256 KiB, carries at most 16
connections and closes one idle for 2 minutes. A filtering relay rather
than an agent per VM: it covers your own agent too, needs no copy of a
key or a passphrase per VM, and fronts hardware and app-held keys.

- proxy: Config.Agent/AgentSocket (checked together, absolute), the
  relay in agent.go, listened before the proxy says it's ready; its
  accept loop backs off after an error that leaves the listener open
  (EMFILE), 5 ms doubling to 1 s, logging the first.
- daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only
  package the proxy already imports, so the relay, the port forwarder,
  the link session and a login's forward share one owner.
- netpolicy: Prepare takes a start's agent; a running VM's proxy keeps
  its start's agent from proxy.json (relayedAgent); Stop deletes the
  relay's socket.
- structure: paths.Dirs may have 62 methods (AgentRelay); the relay's
  goroutines in goroutineSites.
- sshagent: Made.Relayed, which RecordStart sets on every start of this
  devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK
  included, and ReachOf(st,
  start): a relayed start gets the relay (or none while it's down), a
  start devvm didn't record (one outside devvm) gets none, or its
  proxy's relay, and only an older devvm's recorded start keeps the raw
  agent until its next start (runningConfinement, finder.inspect,
  sshconfig).
- vm: LeftoverSockets also finds a killed proxy's relay socket for
  devvm gc --orphans and devvm space.
- Tests: relay filter, wiring through Main, bounds and idle close, real
  ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay,
  RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar,
  an outside start in ssh_agent.txtar, and e2e checks that the VM can't
  remove, lock or add to your agent, nor the VM or an editor's
  connection remove devvm's agent's keys.
- Docs: processes (the SSH agents, listeners), ssh, attack-vectors,
  security, design, lima, overview, space, structure, proxy README,
  AGENTS.md, CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 f37c70a5cd fix(bounds): bound what a VM can make the host hold
Five bounds, each with a test that failed first. Long downloads,
WebSockets, slow streams and SSE are never cut: every bound is on what a
connection holds, never on how long it lasts.

- _qemu connect (Linux): each guest connection to the proxy was a host
  process with no cap. Connect now takes one of connectMax (256) slots,
  lock files in the VM's run/proxy.slots (paths.VM.Proxy(".slots")),
  each process about 7.7 MB, so about 2 GB per hostile VM. A connection
  past them gets an HTTP 503 (connectsFullReply) and closes before it
  dials; QEMU's stderr says qemu_connects_full at most once a minute,
  decided under full.lock so refusals at once say it once. A VM started
  before keeps the two-argument form, unbounded until its next start.
  No idle timeout or byte bound: the proxy bounds what each carries.
  TestConnectSlots.
- The VM proxy (limits.go):
  - maxConns (2048, twice maxConnects so a CONNECT still gets its 503
    first) counts a connection from its first request with the VM's
    password (conns.admit, via httpServer's ConnContext); a request past
    it gets 503 and the connection closes. Connections without the
    password wait in a pool of maxWaiting (128) where a new one closes
    the oldest, so holding connections can't take a VM's room (a host-speed flood still slows it
    through the accept queue: listed in design.md).
  - maxRequests (2048) requests upstream at once, plain HTTP's and
    intercepted tunnels' (requests.take), 503 past it: per-tunnel
    HTTP/2 streams alone allowed ~100,000 upstream connections.
  - each limit logs once a minute at most (everyMinute).
  - httpServer adds IdleTimeout (10 min); a 407 closes its connection;
    handleHTTP's WithoutCancel is replaced by whileHeard, which ends a
    plain HTTP request once its client has stopped sending and goneWait
    (1 min) passes with nothing written, so half-closing clients still
    get answers that keep coming; quiet WebSockets aren't cut.
  - heardWriter.Unwrap: plain ws:// upgrades got 502 (pre-existing) and
    get 101.
  - No ResponseHeaderTimeout: non-streaming LLM requests wait minutes
    for headers, and a waiting client is counted.
  Tests: TestProxyLimitsSet, TestProxyConnectionBounds,
  TestProxyConnectionLimit, TestProxyWaitingConnections,
  TestUpstreamRequestLimit, TestUpstreamRequestLimitIntercepted,
  TestPlainWebSocket,
  TestPlainHTTPEndsWithClient.
- serveOne (intercepted tunnels, transparent HTTP, the 403 page) takes
  maxHeaderBytes (64 KiB) always, not 1 MiB, and HTTP/2
  MaxConcurrentStreams streamsMax (100, not 250). TestServeOneHeaderLimit,
  TestServeOneStreamsLimit.
- Accept loops (forwarder, link session, login forward) retried nothing
  or at a fixed 100 ms: vmssh.acceptRetry backs off from 5 ms to 1 s and
  logs the first error of a run, ending only when the listener closes or
  ctx ends. TestAcceptRetry, TestForwarderAcceptRetries,
  TestLinksAcceptRetries.
- The login callback (LoopbackForward) carries at most
  loopbackConnsMax (16) connections, an ssh each.
  TestForwardLoopbackLimit.

Docs: processes, network, ports, lima, design (threat rows),
attack-vectors, the proxy README, CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 c872cfe66c fix(proxy): look names up absolute, so the host's DNS search domain never applies
The proxy looked up the checked name without a trailing dot, so the host's
resolver added its search domain: with api.corp.example denied and ** allowing
the rest, CONNECT api:443 (or api.eu, once api.eu itself had no address)
reached api.corp.example. Validated on macOS (a CGO_ENABLED=0 darwin build
resolves through libSystem's getaddrinfo, which applies scutil's search domain)
and on Linux (Go's resolver applies resolv.conf's search, single- and
multi-label names, at ndots 1 and 5). egress.lookupName now asks for host+".",
for direct connections and the company proxy's floor alike.

A block because an allowed name didn't resolve is now Refused: a rule allows
the name already, so its 403, /blocked/new and devvm network log --blocked
suggest no devvm network allow command. A name without a dot that has no
address gets reasonShortName, which says to use the full name.

Tests: TestLookupIgnoresSearchDomain, with a resolver that has a search domain;
TestShortNameBlock; TestUnresolvedReason checks Refused and the short name.
Docs: safety/network (inside the VM, the refused field), internals/network
(the proxy, the reasons), internals/design (a company proxy and its own search
domain, links' short names), using/troubleshooting (a name that doesn't
resolve); CHANGELOG Fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:04:31 -07:00
w3cjandClaude Opus 5.5 3168eb04ad test(e2e): a company proxy in config.toml, its password the proxy secret
The network section's company proxy came only from the shell's
HTTPS_PROXY. Now config.toml's [proxy] names it with its user alone and
the shell sets none: the launch is refused (proxy_password_missing) until
devvm secret set proxy --stdin saves the password, in the run's own
secret store; then the VM's proxy config names the secret and holds no
password, and the company proxy, which refuses requests without it,
carries github.com. Its password is in no process's arguments, log,
proxy config or guest after.

netNoLeaks looks for every company proxy's password the section used,
netCorp's and netOpen's, as it is, as user:password, as Basic's base64
and as the whole Proxy-Authorization value, and for each VM's proxy
password as it is and in Basic's base64, in devvm's logs, the VMs'
proxies' logs and Lima's. corpThrough matches only the events after its
launch, so an earlier launch's tunnel can't pass it (eventsFrom), and
corpNoLeak is shared by both launches.

netSetup deletes the section's secrets at its start as well as its end,
so a proxy secret a killed run left can't let the refused launch go
ahead, and it links the section's HOME to the Keychains folder on macOS
from the start, as devvm secret set proxy is now its first Keychain
write (netClaudeLogins made the link before).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:41 -07:00
w3cjandClaude Opus 5.5 1b8fd8a639 test(lifecycles): synctest bubbles for the relays, the forwarder, the links, the proxy and the daemon's stop
Timeouts, graces and closes are tested in testing/synctest bubbles on the
bubble's fake clock, to the moment, instead of sleeping and polling on the
real one, with stand-ins in memory behind seams that are fields. Each kind
keeps one real-process test. No behaviour change: each seam's production
value is what the code did before.

Seams:
- vmssh: sshRelay{grace, start} carries a relay (pipeSSH's body, as
  pipeSSHFor was); start is execSSH in production.
- vmssh: Links.Listen (listenSocket unless set), for the links' sockets.
- proxy: egress.connect, the dialer for allowed far ends (a net.Dialer
  with its 15 s timeout, set in newServer).
- daemon: Proc.Alive (Alive unless set).
- proxy: httpServer, the proxy's http.Server as run serves it, which the
  tests' memServe shares.

New test-only package internal/memnet (standard library only): Pipe, whose
connections half-close, buffer 64 KiB and have deadlines, and Network,
listeners by address with Listen, Dial, DialContext and SetDeadline. The
structure test keeps it for tests and a leaf, depguard keeps it standard
library only, and its AfterFuncs are in goroutineSites.

Bubble tests:
- relay: TestRelayGrace (silent and talking, closed and half closed),
  TestRelayGraceSlowClient, TestRelayGraceWriteError,
  TestRelayCancelEndsBlockedWrite, TestGraceTimer (exact grace).
- forwarder: TestForwarder, TestForwarderAliveOnEnd, TestForwarderOnly,
  TestForwarderGap (reports exactly Gap apart), TestForwarderGivesUpSilently,
  TestForwarderClosesConnections (now also its stuck relay's ssh and slot).
- links: TestLinks, TestLinksSessionLost, TestLinksCap,
  TestLinksEndStuckRelays (memSSH; relays end at the next sync on removal,
  master replacement and target change), TestLinksList.
- proxy: TestTunnelHelloDeadline (EOF at exactly helloTimeout),
  TestTunnelHelloStall (and a hello whole a moment before the deadline),
  TestTunnelAddressSplitHello, TestConnectLimit, TestCloseConns,
  TestCloseConnsWaitsBounded (close gives up at exactly closeWait),
  TestSpliceEnds, TestSpliceEndsWhenItsClientCloses.
- secrets: TestSecretLookupFailuresNeverCached (hung lookups cut at
  lookupTimeout, cancelled, failed and empty ones never cached; a request's
  end doesn't cancel a lookup; the TTL to the moment).
- daemon: TestProcStopWaitsForTheEnd, TestProcStopKillsOnlyItsOwn,
  TestProcStopKillsAfterWait (fakeProc), TestFollowLifeline.
- TestCursorReplyScans uses httptest.NewTestServer.

Kept on real processes and the real clock: TestPipeSSHGrace,
TestPipeSSHGraceSlowClient, TestPipeSSHGraceWriteError,
TestForwarderEndsStuckRelay, TestLinksBurst, TestSpliceKeepsAnEarlyAnswer,
TestProcStop.

Docs: Contributing's Tests has Time and lifecycles; structure.md, _index.md
and AGENTS.md name memnet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:41 -07:00
w3cjandClaude Opus 5.5 4d409589bb refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.

Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.

Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.

Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.

Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:31 -07:00
w3cjandClaude Opus 5.5 e4ea123927 feat(ports): VMs' ssh on ports browsers refuse
Lima listens on a VM's 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 reached a server the VM controls with the cookies
of every app on localhost, even in a VM that forwards no ports.

- Every VM's ssh port, and every build VM's, is one of the 17 ports
  every browser engine refuses (ports.SSHPorts): the Fetch standard's
  bad ports from 1024 up that Chromium's kRestrictedPorts blocks too,
  which leaves out 4190 and 6679 (headless Chrome 157 loads both). The
  one allocator chooses it (Allocator.SSH and Build, through freeSSH). A
  stopped VM keeps its port while it's on the list, free, not listed to
  forward and not held by another start or build; else it gets one no
  state records, or else a stopped VM's, which that VM gives up at its
  own next start. Another VM's listed ports are avoided only while that
  VM runs or starts.
- The proxy and desktop ports never take one (free); one an older devvm
  chose moves at the VM's next start (Choose's keep path, proxyPort,
  the desktop's listener; Allocator.SSHOnly).
- A forwarder never takes one unless its VM lists it (ports.Reserved),
  so a guest forwarding every port can't fill them; devvm ports and each
  launch warn when a VM's list names one, whatever set it (--ports, a
  devcontainer.json, config.toml's ports) (ports_ssh_listed,
  ports.SSHListed).
- A start holds its port, kept or new, for a minute in the VM's own
  run/ports.ssh-hold (paths.VM.Forwarder; hold, held, projectHold),
  which other starts and builds avoid, so none takes it before Lima
  binds it; it goes with the VM's folder.
- A build takes its clone's own port (was) only when no other is free.
- Past 17: ports_ssh_limit names the VMs whose recorded ports are in
  use ("a or b" for a port two states record) with how many are taken
  otherwise, ports_ssh_limit_all when they have them all, and
  ports_ssh_limit_others when none of your VMs has one.
- Older devvm's ports move at the VM's next start, in startSets' one
  limactl edit, and the start pins the new host keys (pinHostKeys); a
  running VM keeps its port until then, and each launch warns of
  running VMs still on an off-list port (ports_ssh_old,
  Allocator.OffList, confirmed with the backend's Running).
- A test build's own list (DEVVM_SSH_PORTS, registry.Overrides.SSHPorts,
  the Allocator's and the Proxy's SSHList field), read only by
  readOverrides in a test build: each CLI test sandbox gets as many
  ports of its own from below the ephemeral range (sandboxPorts).

Frozen 0.1.0 fixture: each launch now makes exactly one limactl edit, of
.ssh.localPort alone, onto the sandbox's list, and vm.json changes only
in .ports.host.ssh (and the start it records); the fixture's data is
untouched.

Messages: ports_ssh_limit, ports_ssh_limit_all, ports_ssh_limit_others,
ports_ssh_listed, ports_ssh_old.
Tests: TestSSHPorts (Fetch's list less Chromium's gaps, SSHListed,
SSHOnly), TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild,
TestReserved, TestForwardsHeld's reserved counts, TestStartBuildSSHPort,
TestPrepareRestartsTheProxy, TestDesktopListener, TestOverrides
(DEVVM_SSH_PORTS), ssh_ports.txtar, fixture_v010.txtar, layout.txtar;
e2e project: the ssh port, first and after a move, is one browsers
refuse.
Docs: internals/lima (the ssh bullet, the hold's limit), processes
(listener table), design (threat check), ports, overview,
contributing/structure and testing (DEVVM_SSH_PORTS), using/ports-size,
troubleshooting (Too many VMs at once), safety/attack-vectors (allowed
ports, port squatting), CHANGELOG Breaking (17 VMs; forwarding every
port leaves the 17 out) and After you upgrade.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:31 -07:00
w3cjandClaude Opus 5.5 cc94465400 test(leaktest): goroutine leak checks, and the leaks they found
A new internal/leaktest, standard library only, so the proxy's and the
daemon's tests use it too (depguard's proxy rule allows it, and the
structure test holds it to tests and to importing nothing of devvm's):

- leaktest.Main(m), in TestMain: once the tests pass, every goroutine's
  stack (runtime.Stack), a settle of 5 s, then a failure naming those
  still running, but the standard library's own that outlive every test
  (allowed: signal.Notify's loop, an HTTP client's idle connections);
  then Go 1.27's goroutineleak profile, which fails on any goroutine
  blocked for good.
- leaktest.Check(t), first in a test: its own goroutines, followed by
  parent through those still running, and by which ran before it, never
  by ID (each thread takes a batch of IDs).

Main runs in proxy, vmssh, daemon, desktop, ui, vm, backend/lima,
platform, cli and gitprotect (main_test.go, or the TestMain they had).
Check runs in TestLinksEndStuckRelays (replacing its NumGoroutine
count), TestForwarder, the desktop relay's serve helper, TestRunChild,
TestPinWaits, and the proxy's new close tests.

The structure test's goroutines rule (internal/structure/goroutines_test.go):
goroutineSites lists every function outside tests that starts a
goroutine, with a go statement, a wait group's Go, or time's or
context's AfterFunc, function literals in package-level vars included,
as "file: Func", with its waiter, or "detached: " and why nothing waits.
A new one fails until listed, a listed one that starts none fails, and
a package that starts one fails until its tests call leaktest.Main.

Leaks it found, each fixed with a test:

- The proxy's close left its connections running: http.Server's Close
  neither closes a connection a handler took (a CONNECT's tunnel, a
  WebSocket upgrade ReverseProxy takes) nor waits for a handler. conns
  (conns.go) holds every connection the listener accepted (track) and
  counts every handler (handle); serve calls closeConns once Serve
  returns, which closes them, closes any accepted after, and waits up
  to 5 s for the handlers. splice also ends when its client's
  connection can't be read (closed, reset), rather than half-closing
  the far end and waiting on it; a failed write to the server (one that
  answered early and closed) still lets its answer through. Tests:
  TestCloseConns (a tunnel and an upgrade), TestConnectAfterClose,
  TestSpliceEndsWhenItsClientCloses, TestSpliceKeepsAnEarlyAnswer; the
  tests' listen closes as the proxy does, and the fake upstream closes
  its target once its client's end comes.
- platform's runChild left its signal-passing goroutine blocked on a
  channel signal.Stop never closes; it now closes it and waits
  (TestRunChild).
- platform's WaitExit and WatchFolders blocked in poll(2) and read(2),
  which closing their fd from the stop doesn't wake on every kernel
  (Debian's didn't), and a retried call could land on a reused fd. They
  now wait in Go's poller (pollable), which the stop wakes (TestPinWaits,
  with a wait stopped before its process ends).

Docs: Contributing's tests page (Goroutine leaks), the structure page
(the goroutines rule, goroutineSites, the layers, the packages), the Go
lint rules' depguard line, the proxy's shutdown in How it works'
processes page and the proxy's README, and AGENTS.md. Coverage
baselines: internal/leaktest's line on both systems, netpolicy's raise
on macOS.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 4e925492ca fix(proxy): every host is read in one form, proxy.NormHost, guarded by the structure test
Every check that judges or compares a host now reads it through
proxy.NormHost (internal/proxy/host.go), which also holds HostOK,
splitHostPort, hostASCII and asciiEqualFold: a host of printable ASCII is
lowercased in ASCII alone and loses its one trailing dot; any other host
stays as it is, so HostOK refuses it and no Unicode fold makes another
name match. A host with two trailing dots or more, or a dot after a
closing bracket, keeps them, so NormHost is idempotent and reading a host
twice can't turn evil.test.. into evil.test. A proxy.Host is what the
matchers take (rule.matchHost, noProxyRule.matches, local, sniMatches).

Brackets are strict (hostAddr): HostOK, Host.Addr and splitHostPort take
an address bare or an IPv6 address in one pair of brackets, never a stray
bracket ([[::1]], 1.2.3.4]) or brackets around a name or an IPv4 address
([evil.com]:443, [1.2.3.4]:443), which get 400.

Migrated: splitHostPort, sniMatches, sniHost, parseHostRule, the
policy's rulesFor, quiet, byName and coversOn, secrets.forHost,
parseNoProxy, route and local in internal/proxy; netpolicy.RiskOf,
Tickable and sameRule (devvm network rm and the duplicate check, so a
Kelvin sign never names the rule with a k); secrets.CheckHost;
from.publicHost (a name HostOK refuses isn't public);
agentlogin.claudeHost; vm.urlHostPort and privateHost. vm.urlHost
(cloneseed.go) keeps its own reading: it's a remote's ssh host, which ssh
lowercases and keeps the trailing dot of, to find a VM's alias.

Differential fuzz targets keep a frozen copy of each reader as it was and
allow only the decided differences: FuzzHostSites (proxy), FuzzRiskSites,
FuzzCheckHostSite, FuzzPublicHostSite, FuzzClaudeHostSite and
FuzzPromisorHostSite. A rule line is the same rule or no rule exactly as
before, so a broken deny stays a broken deny. TestFixtureHosts reads the
frozen v0.1.0 state's secrets.policy, secrets.json and links.json hosts
and finds them unchanged.

The structure test's new hosts check refuses, outside host.go and tests:
Trim, TrimLeft or TrimRight with a cutset holding ".", TrimSuffix or
CutSuffix with "."; ToLower, ToUpper, EqualFold and the TrimFunc family on
an argument named for a host; and a conversion to proxy.Host of anything
but a literal. Exceptions are by file and function, each with why
(request.go:trimDots, cloneseed.go:urlHost, cloneworktree.go:safeIndexPath,
cloneconfig.go:transportHelper, lima/start.go:machines.fillPassword). It
doesn't see slicing, strings.Map or variables not named for a host. The
owners doc, the proxy README, structure.md, design.md (One form of a
host), network.md and safety/network.md say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 89f26c5771 docs(site): draw the diagrams at build time with pele, no Mermaid JS
The docs site's 18 mermaid blocks are now drawn as SVGs before Hugo
builds the site, by docs/render-diagrams.mjs with pele 1.13.0, and
inlined by a render hook, so no page loads Mermaid's 5.5 MB script.

- docs/render-diagrams.mjs: finds each mermaid block in docs/content,
  draws it with pele in Departure Mono at 14px (a measurer from the
  font's metrics), and writes <key>.svg and <key>.json (its size) to
  the git-ignored docs/.build/diagrams. pele draws edge labels,
  messages and notes at round(14 * 0.875) = 12px with no option, so the
  measurer gives that text its 14px width and the script rewrites
  font-size="12" to 14 on each small-text group (pele-edge-labels,
  -notes, -boxes, -frames); a guard fails on any such group without
  font-size="12", or small text outside them, and a self-check, run
  whenever there's something to draw, renders an edge label, a message
  and a note and fails unless pele measured them at 12 and wrote their
  group with font-size="12". It also fails on a diagram without
  accTitle and accDescr, or on an indented block. A newline after each
  </text>, outside any text element, lets the search index see labels
  as separate words; screenshots of all 18 are byte-identical with and
  without it. (Newlines between a label's tspans would move centered
  lines, so a label's own lines stay joined in the index.)
- Caching: a block's key is sha256(salt + "\n" + text)[:16], the salt
  being sha256("pele <version>\n" + the script's text)[:16], written to
  diagrams/salt. The script keeps every drawing already there, draws
  only missing ones (written to .tmp and renamed), prunes files no key
  names, and touches the folder. docs:diagrams has sources (the pages,
  the script, package.json, the lock) and outputs (the folder), so mise
  skips an unchanged run, and runs npm ci only when the lock's SHA-256
  differs from docs/node_modules/.devvm-lock-sha256. An unchanged run:
  0.45-0.75 s before, 0.02 s now (0.09 s forced); one diagram changed:
  0.09 s. CI's check job caches ~/.npm keyed on the lock; the Docs
  workflow, which publishes, keeps no cache.
- docs/package.json and package-lock.json pin pele 1.13.0
  (sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==).
- docs/layouts/_markup/render-codeblock-mermaid.html: in place of
  Hextra's hook, reads the salt, computes the key from it and .Inner,
  inlines the SVG from assets/diagrams (hugo.yaml mounts .build/diagrams
  there), sets the wrapper's contain-intrinsic-block-size to the
  diagram's height and --devvm-diagram-width to its width, and errorf's
  when a drawing or the salt is missing. layouts/_partials/scripts/
  mermaid.html and params.mermaid go.
- custom.css: .devvm-diagram with content-visibility: auto, and pele's
  --pele-* variables from the palette (subgraphs, lifelines and notes in
  the border color). A diagram wider than the text reaches into the
  article's right padding (1.5rem, 3rem from 768px) as far as it needs,
  then into the left padding for the rest, so it never covers the table
  of contents; wider than both, it scrolls. From about 1010px no diagram
  scrolls, the four wide ones included (proxy checks 751px, agent store,
  VM states, SSH agent); at 900px five scroll. With the table of
  contents shown, the proxy checks take 48px on the right and 31px on
  the left.
- mise.toml: docs:diagrams, which docs and lint:docs depend on.
  docs.yml: the next and release jobs install node and draw the
  diagrams; the release job only when the tag has the script, so older
  tags still build.
- scripts/bump.sh: bump_pele, named only, replaces bump_mermaid: npm
  install --save-exact --ignore-scripts in docs, then mise run
  docs:diagrams, whose self-check catches a pele that changed how it
  draws small text. TestBumpCoversPins finds docs/package.json's
  dependencies (npm:NAME); bump.txtar tests --check and the install.
  The header and hextra's note say the mermaid render hook replaces
  Hextra's mermaid hook, so check it still has that name.
- Every diagram gets an accTitle and accDescr, which pele makes the
  SVG's title and desc (aria-labelledby, aria-describedby). Staying
  safe's columns are written in reading order, as pele lays subgraphs
  out from left to right. The proxy checks' description names every
  branch, and a hand-placed <br> keeps "CA)" off a line of its own.
- AGENTS.md: the one Node script; no other build script is JavaScript,
  and no other npm package is installed outside mise's tools.
  Contributing's docs, tools and
  maintaining pages describe the drawing, the caching, the margin, the
  task and the bump.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 b6954e1e11 refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a
project VM, an image's machine (devvm-img-<key>), a build VM and a
remake's aside. Fields, parameters, results and map keys that held a VM's
name as a string now hold a VM, from the backend interface down to the
CLI's --json structs, whose output is byte for byte the same.

Boundary parsers, the only places a string becomes a VM:
- vmname.Parse: a project VM's name (state's vm.json name, export file
  names, devvm _links's argument, the forwarder's -vm, project.Nth)
- vmname.ParseListed: one path element, for what a backend lists
- VM.UnmarshalText: JSON (Lima's list, proxy config and events, links'
  targets in state, link lists); empty stays no VM
- vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs
- msg.M.VM: the VM a message's function took, read back

vmname's functions on names became methods (Hash, Slug, Short, Aside,
AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname;
vmname.Join joins VM lists. Messages' vm and vm_name fields are typed
by the generator. Seven messages whose field took something else became
what= (backend_lacks, backend_unreviewed, backend_unreviewed_used,
starting, deleting, configuring, running_script) and rm_vm_failed's
name=: the text is unchanged, the names-mode scripts follow.
Review.RequireFor names an image or the tools being built.

Typed sites per package (added lines with vmname.VM, non-test): msg 347
(generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22,
backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8,
ports 6, paths 3, sshagent 2, sshconfig 2, tools 2.

The structure test's owners rule now fails on a field, parameter or
result named for a VM (vm, vms, otherVM, vmName) typed string, []string
or map[string]…, and on converting anything but a literal to vmname.VM
outside the files it lists; internal/stubtest is free. depguard holds
internal/vmname to the standard library, and the proxy may import it.

ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:28 -07:00
w3cjandClaude Opus 5.5 1ecd1faa73 build(nilaway): mise run nilaway against a triaged baseline, an advisory CI job, and two crashes it found
nilaway is pinned in mise.toml at its newest commit's pseudo-version (it
has no releases); bump.sh's dev-tools moves it, and TestBumpCoversPins
covers it through mise.toml:tool:*. mise run nilaway runs
scripts/nilaway.sh: devvm's own packages, not the tests or their helpers
(stubtest, backendtest), compared with testdata/nilaway-baseline.txt, the
findings triaged as false positives, each with its group (checked,
bounds, mapkey, nilsafe), keyed by file and trace without line numbers,
one line for each finding, compared as multisets. It exits 3 on a new
finding, a key found more often than the baseline has it included, and
1 when nilaway can't run, when a finding in its output can't be read,
or when a baseline line is stale or malformed. TestNilawayBaseline
checks each case with a stand-in nilaway. CI's nilaway job is
continue-on-error: it warns on new findings and lists the new and stale
ones, then every finding, in the run's summary, failing when the script
exits 1.

The first run reported 83 findings, 69 without the test helpers. Two
were real:
- agentlogin.Restore sliced above[1:] for a settings file that is one
  JSON string holding a placeholder, where above is empty, and
  devvm agent save panicked.
- agentlogin's readJSON returned a nil map, with no error, for a file
  that is null, which the Codex and opencode captures then wrote to. It
  now refuses it as not a JSON object.
The other 67 are the baseline. Both fixes get a CHANGELOG Fixed entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:36:27 -07:00
w3cjandClaude Opus 5.5 02ba74e614 build(lint): stricter linters, and the fixes they need
golangci-lint now also runs govet's nilness, unusedwrite, hostport and
waitgroup analyzers, nilnesserr, durationcheck, canonicalheader,
errchkjson, forcetypeassert, contextcheck and gochecksumtype.

- errchkjson checks each JSON encoding's error where the value could
  fail and drops it where errchkjson proves it can't, and reports
  structs without exported fields; tests may drop theirs.
- forcetypeassert holds the code; tests are exempt.
- gochecksumtype: agentlogin's format is a sum type (//sumtype:decl),
  and a switch on one names every case, default or not.
- canonicalheader: WWW-Authenticate, X-Request-ID, X-Api-Key.
- contextcheck: ctx threaded through carry, peekClientHello and sniOf,
  and through inject and value, whose cached lookup takes
  WithTimeout(WithoutCancel(ctx)), so two forbidigo nolints go;
  openTransparent takes its dialer's ctx. nolints stay where
  contextcheck can't follow: ReverseProxy's Rewrite, WithoutCancel
  alone, cobra's cmd.Context, e2e's runner window.
- No-behaviour fixes: scrubList for redact's list, the loopback
  forward's ports kept with its listeners, upgradetest's Key keeps its
  public key, a CA's leaves read through leafOf.

Contributing's Go lint rules lists each one and the sum-type convention.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 00:17:50 -07:00
w3cjandClaude Opus 5.5 246a7aac10 docs(internals): a page on devvm's processes, its listeners and why Go
Processes, under How it works: one section for each process devvm runs
on this machine for a VM (devvm itself, a VM's and a build's proxy, the
port forwarder, the link session, the ssh masters and relays, the QEMU
wrapper and its keeper, the daily tools check, the desktop relay, the
SSH agents and Lima's hostagent), each with what it holds, what it
reads from the VM, what it writes and its bounds, its confinement, and
who starts and waits for it; an inventory of the loopback listeners a
VM's bytes reach; and why devvm stays in Go.

Linked from How it works' index, the security model, Staying safe, Attack vectors (a browser login's port),
the ports, network, desktop and Lima pages, the design notes and
Contributing's package table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 00:17:50 -07:00
w3cjandClaude Opus 5.5 0856205bd9 ci(vuln): govulncheck as its own CI job, and a weekly scan of main and the releases' binaries
mise run vuln scans the code as built for Linux and for macOS. CI's vuln job
runs it on each push and pull request, apart from lint and test, with only
Go and govulncheck installed. The Vulnerabilities workflow scans main's code
and the binaries of the latest release and the newest release, prerelease or
not (govulncheck -mode=binary, after checking that SHA256SUMS lists and
matches each archive), each Monday. A read-only scan job uploads the
findings, and an issue job, run only on main, opens, updates (with a comment
when the findings change) or closes one issue, as the Pins workflow does.
Contributing's Maintaining page says what fails, what a binary's scan can
over-report and how to respond.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 00:17:50 -07:00
w3cjandClaude Opus 5.5 2e0d580e14 chore(git): ignore .worktrees, where parallel work's worktrees live
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 00:17:50 -07:00
w3cjandClaude Opus 5.5 c1cf96e4b6 fix(vm): every start pins the VM's host keys, whatever its ports
A start whose VM forwarded nothing, because other programs held every
listed port or the VM was devvm ports none, never pinned its ssh host
keys: only the port forwarder (Forwards.start, which returned before
vmssh.Checked) and the ssh config pinned them, and a start that went no
further than bringUp (devvm clone fetch, rm's fetch, the clone check)
wrote no ssh config. devvm's own ssh (ownSSH, vmssh.ReadKeys) then found
no record, and devvm clone fetch failed with clone_fetch_failed.

bringUp now pins them last, once the start or the running VM has gone
through the self-check (starter.pinHostKeys, vmssh.PinHostKeys), for a
VM whose backend's ssh the review allows. A record of the current start
is kept without reading the VM; ErrNoHostKeys is skipped, as the ssh
config skips it, and other errors fail the command. A running VM without
a record of its start, as this bug left one, gets it at its next
command.

Tests: TestFetchPinsHostKeys (forwarding none, every port taken,
running without a record), and TestUp, TestUpNetworkPolicy and
TestUpTools' calls with the pin after the self-check; testscript clone_hostkeys, its ports the
script's own listeners. fixture_v010_clone passes with 3000 and 5173
held. CHANGELOG Fixed entry; design.md's host key and security.md's ssh
into VMs say when the keys are read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-14 23:15:36 -07:00
w3cjandClaude Opus 5.5 8f04459331 docs(changelog): unreleased changes at the bottom, linked from the top
The changelog page opens on the latest release, which people read to see
what's new in the release candidate. Changes on main since then sit in
an Unreleased section at the bottom, linked from a line under the title,
and its three entries are rewritten in the docs voice with every fact
kept. Contributing's maintaining and structure pages say where entries
go between releases, and that each release moves them to the top.
scripts/publish.sh finds a release's notes by its heading, so it's
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 23:43:19 -07:00
w3cjandClaude Opus 5.5 5225d5b43e fix(links): a relay's grace waits out a slow client; CI-proof timing in two tests
TestPipeSSHGrace failed on GitHub's macos-latest runner ("talking, half
closed: the relay ended while the VM talked") twice, and
TestLinkCheckBurst once.

The relay's grace restarted only when a read from the VM completed, and
io.Copy reads nothing while its write to the client waits, so a client
that half-closed and read slowly, holding back the VM's answer, was cut
after the grace though the VM kept sending. The grace is now time the VM
sends nothing, never time a slow client takes: graceTimer runs only once
armed (the client's side closed, or the copy to the client ended with a
failed write or the VM's EOF), stops while a write to the client waits,
and starts again after each write. A client that stops reading thus
holds its relay and ssh itself, so the owner's context now also closes
the connection when it ends (context.AfterFunc), which ends a write
waiting on such a client: a forward's close, a link's removal or
LoopbackForward.Close can't hang on it.

The CI failures themselves were the test's margins: a 200 ms grace
against a stand-in that spawns sleep between writes. The talking case
now has a 2 s grace, 40 times the stand-in's 50 ms, and reads for a
second past it; pidOf waits up to 10 s for the stand-in to start.

TestLinkCheckBurst wasn't the relay changes': its 256 checks ran on the
real clock, and a burst slower than linkRunFor (1 s) looked the target
up twice. vm.Links has a clock seam, Now (time.Now unset), which
linkCheck's targetRuns uses, and the burst runs through linkCheck on a
clock that stands still. With a targetRuns made for each call, it fails
(256 Inspects).

- vmssh: graceTimer (arm, write, restart, stop) replaces reset;
  graceWriter replaces graceReader; pipeSSHFor closes the connection
  when its context ends
- vm: Links.Now, used by linkCheck; env.go names Links' Env field
- tests: TestPipeSSHGraceSlowClient and TestPipeSSHCancelEndsBlockedWrite
  (each failed on the old code); TestGraceTimer replaces
  TestGraceTimerStopped (unarmed, armed, written to, stopped, armed
  while a write waits many graces); TestPipeSSHGrace's per-case grace;
  pidOf's wait; TestLinkCheckBurst through linkCheck on a still clock
- stress, with four cores of background load: TestLinkCheckBurst and the
  relay tests under -race -count=50 -cpu 1,2 and GOMAXPROCS=1, then the
  relay and link tests of vmssh and vm under -race -count=20 -cpu 1,2:
  all pass
- coverage: internal/vmssh's baseline raised
- docs: internals/ports (how it reaches the VM), the design note (each
  connection, the lead for relays held after their client closed)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 18:34:47 -07:00
w3cjandClaude Opus 5.5 608ab43714 fix(ports): an IPv6 listen error fails the port as an IPv4 one would, and ::1 refused alone forwards on IPv4
The forwarder's open listened on 127.0.0.1, then ::1, and gave the port
up only for EADDRINUSE on ::1. Any other IPv6 error (EMFILE, ENOBUFS...)
was ignored, so the port was forwarded and recorded on IPv4 alone until
its VM's listener went and came back: a client that connects only over
IPv6 (http://[::1]:PORT, tools without fallback) didn't reach it, and
another program on this machine could take ::1 on the port.

Now any other ::1 error closes the IPv4 listener and is returned, so try
handles it as an IPv4 listen error (f76b2fa2): EADDRINUSE recorded in
use, anything else logged, not recorded, and tried again at the next
report. A host without IPv6 on its loopback (EADDRNOTAVAIL, EAFNOSUPPORT,
EPROTONOSUPPORT) still gets IPv4 alone, and so does one that refuses ::1
alone with 127.0.0.1 bound (EACCES, EPERM), logged, so a security module
denying IPv6 sockets doesn't stop forwarding. A partly open forward is
never recorded: a port is forwarded on both addresses, on IPv4 alone on
such a host, or not at all.

- vmssh: noIPv6; open's cases for ::1 (no IPv6, EACCES and EPERM logged,
  any other error returned)
- tests: TestForwarderIPv6Failures (EMFILE on ::1: not forwarded, its
  IPv4 listener closed, unrecorded, forwarded on both at the next report;
  EADDRNOTAVAIL, EAFNOSUPPORT and EPROTONOSUPPORT: IPv4 alone; EACCES and
  EPERM: IPv4 alone and logged; EADDRINUSE: in use, not tried again)
- coverage: internal/vmssh's baseline raised
- docs: internals/ports (when it can't forward), the design note
  (listening, a lead for a forward on IPv4 alone), CHANGELOG Unreleased
  Fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 16:15:45 -07:00
w3cjandClaude Opus 5.5 c63f9a3340 fix(links): relays end with their link, their master or 30 s after their client closes
A relay's ssh (-W) ends only when the VM's sshd ends its channel, so a
VM that ignored EOF could keep a relay, its ssh process and one of its
owner's 256 slots:

- A link's removal closed only its listener, so its open connections
  went on until the target's master or the session ended. The same held
  for connections through a target master replaced when the target
  started again, and for a link whose address and port named another
  target at the next sync.
- While a forward or a link lasted, a relay whose client had closed its
  side stayed for as long as the VM liked.

Each relay now gets its own context, which a link's removal, its
master's replacement or end, and its target's change cancel, as a
forward's close already did (f76b2fa2); that pattern has one owner,
relayConns, which the forward, each link and each target master use.
pipeSSH, which carries every relay of the forwarder's, the link
sessions' and a login's callback, also cancels it once the client has
closed and the VM has sent nothing for 30 s, the first byte included, or
30 s after the client can take nothing more. A client that half-closes
and waits still gets an answer the VM keeps sending; one that waits
longer than that for a first byte (nc -N in front of a slow query) is
cut. devvm link unpublish keeps the link, so its open connections stay.
No cap for each target: what a target can still hold is connections the
client's programs keep open.

- vmssh: relay.go, the relays' owner: relayConns (add, done, cutAll),
  pipeSSH moved from forward.go, pipeSSHFor, relayGrace, graceTimer
  (newGraceTimer, reset, stop), graceReader. forward.conns is a
  relayConns; linkEnd holds a *relayConns, with close, and targetMaster
  one, with end; sync cuts a link's set when it goes or its target
  changes; take reads the link and its set together; carry tracks each
  connection in its link's set and its master's (track, untrack);
  targetMaster returns the master
- structure: relay.go listed in execSites (each connection's ssh -W);
  forward.go's reason is its master alone
- tests: TestLinksEndStuckRelays (an ssh stand-in that never exits: a
  removed link's, a replaced master's and a changed target's relays end,
  their ssh gone and slots freed, no goroutine left, under -race);
  TestLinksCarryCut (a cut link's and a cut master's connection: no
  check or relay, no event, not tracked); TestPipeSSHGrace (closed,
  half-closed, talking and closed while talking clients);
  TestPipeSSHGraceWriteError (failed writes end the relay within the
  grace); TestGraceTimerStopped
- e2e: link's lkRmEnds, on a port of its own: a connection held by the
  client to a server that never closes it, whose relay ssh ends after
  devvm link rm
- docs: using/links (removing a link), internals/ports (how it reaches
  the VM, when links change), the design note (each connection for
  forwards and links, a lead for relays held after their client closed,
  not covered, two threat-check rows), CHANGELOG Unreleased Fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 16:15:34 -07:00
w3cjandClaude Opus 5.5 940f1e2d88 chore(scripts): bump.sh moves every pin in the repo, and a guard for new ones
scripts/bump.sh now covers every pinned version, so release prep is one
command, grouped as --check prints them:

- shared-tools: cursor (only when named), Cursor's CLI pinned in
  assets/shared-tools/mise.toml, checksums computed from the downloads
- e2e: e2e-curl, tests/e2e/transparent_test.go's curlImage by digest
- go: go (newest patch: go.mod, docs/go.mod, mise.toml, mise lock),
  go-minor (only when named), go-mods (direct modules, go get and go mod
  tidy; a next major's path only reported), deadcode (mise.toml's task)
- dev-tools: mise.toml's tools but go, through mise lock
- ci: ci-mise (jdx/mise-action's version follows base's mise), actions
  (uses: by tag commit from gh api, then actionlint and zizmor)
- docs: hextra (go get and hugo mod tidy in docs/), mermaid (only when
  named)

--check prints each pin's group and whether a bump is a patch, minor or
major. With no tools named, bump.sh applies patches and minors only:
never a major, a held pin or a named-only tool; naming an images or e2e
tool still applies its major, and e2e-tools always does. Holds come from
.github/dependabot.yml's ignore list (pflag < 1.1.0) and bump.sh's own
(node on its major).

The header lists every pin as "# pin KEY TOOL", or "-" and a reason, and
says why the pins outside the scanned files are left (install.sh's Lima,
the Homebrew formula, testdata, vendored files). TestBumpCoversPins in
internal/structure scans assets/, mise.toml, both go.mod files, the
workflows, tests/e2e-mise.lock, tests/e2e's consts and docs/hugo.yaml
offline, and fails on an uncovered pin or a stale line.

The Pins workflow gets mise and a token for the new checks, and its issue
lists outdated pins under their groups. testdata/script/bump.txtar covers
the new groups with stubbed upstreams, and caught newest_of failing on
an empty list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 11:25:31 -07:00
w3cjandClaude Opus 5.5 41867769be docs(changelog): 0.1.1-rc.3's New in order of interest
Cursor, devvm paste, following dotfiles' links, --clone, pins in your own
layers, then quiet hosts, as CJ ordered them. fc0703bd was meant to carry
this order and didn't.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 10:14:34 -07:00
w3cjandClaude Opus 5.5 fc0703bd60 build(release): 0.1.1-rc.3
VERSION is 0.1.1-rc.3. CHANGELOG.md's 0.1.1-rc.3 entry becomes the release
candidate's notes on GitHub: Unreleased, rewritten as what's new, changed
and fixed in the docs voice (2,304 words to about 1,280), with New ordered
from most to least interesting: Cursor, devvm paste, following dotfiles'
links, --clone, pins in your own layers, quiet hosts. It credits #38's,
#40's, #42's and #44's authors, and adds devvm paste's entry, which merged
after rc.2 without one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 10:13:12 -07:00
w3cjandClaude Opus 5.5 872670d86e chore(deps): bump jdx/mise-action and CI's mise
- jdx/mise-action: v5.2.4 (6be3c7ed4c21d4f76b208d351d95aac273ebb76d)
  -> v5.2.8 (d5574b52816a478f9d4e6529a3f6ff17a8a36785), the tag's
  commit from gh api, in ci.yml, docs.yml (three), e2e.yml and fuzz.yml
- the mise those install: 2026.10.18 -> 2026.11.8, base's mise

Up to date: actions/cache v6.1.0, actions/checkout v7.0.1,
actions/deploy-pages v5.0.1, actions/upload-artifact v7.0.2,
actions/upload-pages-artifact v5.0.0,
amannn/action-semantic-pull-request v6.1.2, nick-fields/retry v4.0.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 66d7020c43 chore(deps): bump the dev tools in mise.toml
Each with its mise.lock entries and checksums (mise lock):

- goreleaser: 2.19.0 -> 2.20.2 (checksums match its checksums.txt)
- hugo-extended: 0.168.0 -> 0.169.0
- vale: 3.25.1 -> 3.26.0
- node: 24.22.1 -> 24.22.3 (held on 24; 26.13.1 is the newest)
- markdownlint-cli2: 0.24.0 -> 0.24.1, with its lock folder
- zizmor: 1.31.1 -> 1.32.0

Up to date: golangci-lint 2.15.0, gotestsum 1.13.0, govulncheck
1.9.0, lychee 0.24.2, shellcheck 0.11.0, actionlint 1.7.12,
minisign 0.12.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 88eeca20ff chore(deps): bump the end-to-end tests' pins
scripts/bump.sh e2e-tools e2e-from e2e-ubuntu e2e-lima.

tests/e2e-mise.lock, resolved again with devvm's host mise 2026.11.8:
- node: 24.22.2 -> 24.22.3
- go: 1.27.3 -> 1.27.4
- dotnet: 10.0.403 -> 11.0.100 (shared-tools/mise.toml has
  dotnet = "latest", so users already resolve .NET 11)
- claude: 2.1.319 -> 2.1.322
- codex: 0.167.0 -> 0.167.2
- opencode: 2.2.6 -> 2.2.7
- pi: 1.5.0 -> 1.5.2
Up to date: pnpm 12.18.0, bun 1.4.4, python 3.15.2, uv 0.13.7,
rust 1.99.1.

tests/e2e/from_test.go's digests from Docker Hub:
- node:24: sha256:8fa96264f302... -> sha256:9d266751ca3d...
- ubuntu:26.04: sha256:6a06111c3b0a... -> sha256:065aa8626841...
- alpine:3: up to date

Up to date: e2eUbuntuRelease release-20261016, CI's Lima 2.3.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 aee6340ea9 chore(deps): bump assets' pinned downloads and devvm's host mise
scripts/bump.sh, every checksum from upstream's published sums:

- mise (base, and devvm's host mise): 2026.11.3 -> 2026.11.8, from
  the release's SHASUMS256.txt
- Docker's buildx: 0.38.1 -> 0.39.0
- Docker's compose: 5.7.0 -> 5.7.1
- nix: 2.35.5 -> 2.35.6, from releases.nixos.org's .sha256 files

Up to date: docker 29.9.3, containerd 2.4.2, model 1.2.9, Docker's
signing key, direnv 2.38.2, nix-direnv 3.2.0, git-lfs 3.8.1, rustup
1.29.3, crane 0.22.1, omb 94c2977eda06, eza 0.23.5, tealdeer 1.9.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 ab078ddbef chore(deps): golang.org/x modules to their latest minor releases
x/crypto 0.59.0 clears govulncheck's module finding GO-2026-5932
(x/crypto/openpgp, which devvm doesn't import; devvm uses only blake2b).

- golang.org/x/crypto: v0.58.0 -> v0.59.0
- golang.org/x/sys: v0.49.0 -> v0.50.0
- golang.org/x/term: v0.47.0 -> v0.48.0
- golang.org/x/text: v0.43.0 -> v0.44.0
- golang.org/x/tools (indirect): v0.51.0 -> v0.52.0

Left as they are: github.com/spf13/pflag v1.0.10 (v1.1.0 is a week
old and changes help output and parse errors), and the indirect
go-md2man v2.0.6, go.yaml.in/yaml/v3 v3.0.5 and the test-only modules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 9b2d903ed0 chore(deps): Go 1.27.3 -> 1.27.4
Go 1.27.4 has security fixes to cgo, the go command, the compiler, the
linker and net/http, and bug fixes to the runtime, the compiler,
crypto/tls, crypto/rsa and net.

- go.mod's go line: 1.27.3 -> 1.27.4
- docs/go.mod's go line: 1.27.3 -> 1.27.4
- mise.toml's go: 1.27.3 -> 1.27.4, and its seven mise.lock entries,
  their checksums matching go.dev/dl's

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:15:32 -07:00
w3cjandClaude Opus 5.5 326a701a2a docs(cursor): the safest devvm cursor is an allowlist VM without Cursor's CLI
CJ's checks with a real Cursor login: in a devvm cursor window on the
allowlist tier, in a VM without Cursor's CLI, the VM's editor server
tries api2.cursor.sh and downloads.cursor.com and both are blocked, yet
Agent and Tab still work, because Cursor sends their requests through
the app on this machine when the VM can't reach it. downloads.cursor.com
is the server trying to download itself into the VM before Cursor falls
back to downloading it here; with Cursor's CLI in the VM it is the same
request, not the CLI's update, whose channel devvm pins.

- SSH and editors, Cursor's Agent: the safest way first, with its
  commands and what devvm network log shows; the user-settings route for
  VMs with Cursor's CLI; the Tab troubleshooting line goes, as Tab never
  needed api3.cursor.sh from the VM.
- safety/network's quiet hosts: Tab's requests come from the app, not
  the VM.
- CHANGELOG's devvm cursor entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 08:01:23 -07:00
w3cjandClaude Opus 5.5 f76b2fa2a4 fix(ports): devvm ports says why a listed port isn't forwarded; a relay ends with its forward
The forwarder recorded every listed port it couldn't take on one line,
and devvm ports warned ports_taken ("in use on this machine") for all of
them, even a port past its limit of 256 forwards or one the host refused,
such as EACCES below 1024 on Linux. It now records why: in use
(EADDRINUSE), past its limit, or refused (EACCES, EPERM), each on a line
of its own in run/ports.forwarded (pid, forwarded, in use, limit,
refused). Any other listen error (EMFILE, ENOBUFS, EADDRNOTAVAIL...) says
nothing of the port: it's logged, not recorded, and 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 is below it. An
older devvm's three-line record, whose third line held every failure,
is read as giving no reason, so it warns of none rather than call a
refused port in use; its forwarded ports still count.

A forward's close closed its accepted connections, but each relay's ssh
(-W) waited for the VM's sshd to end the channel, so a VM that ignored
EOF kept that ssh process and one of the forwarder's 256 relay slots
until the forwarder ended. Each relay now gets its own context, cancelled
by the forward's close under mu, so CommandContext kills its ssh; a relay
that ends by itself releases its context.

- vmssh: failure (in use, limit, refused) and failedPorts; failureOf's
  ok for errors that are the port's; Forwarder.try; apply clears limit
  failures below the limit; Note takes failedPorts;
  Forwards.Unforwarded replaces Taken; record writes five lines
  (recordLines); MaxForwards exported for ports_limit; forward.conns
  holds each relay's cancel
- messages ports_limit (count, limit, ports, vm) and ports_refused
  (count, ports, vm), linked to troubleshooting's listed-port section;
  devvm ports warns each by why
- --json unchanged: it never listed failed ports
- tests: TestForwarderFailures (EACCES, EPERM and EADDRINUSE through
  Listen, EMFILE tried again unrecorded, the limit and its retry once
  below it), TestForwarderEndsStuckRelay (an ssh stand-in on PATH that
  never exits: the relay ends, the process is gone, the slot is free),
  TestForwardsHeld's record round trip, older and foreign records, and
  ports.txtar's three warnings from a record and none from an older one
- docs: internals/ports (record lines, relays, when it can't forward and
  what's retried), the design note (how many, each connection, the
  below-1024 lead, the stuck relay as confirmed and fixed, channels a VM
  never closes as listed), ports-size, troubleshooting, CHANGELOG Fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 07:38:42 -07:00
w3cjandClaude Opus 5.5 54cce97049 fix(ports): a stopped VM no longer keeps its listed ports from other VMs
Only a running VM holds a host port. Each VM's forwarder records the
ports it forwards, and those it tried and couldn't take
(run/ports.forwarded: its pid, then each list on a line; an empty one
when it starts, and devvm removes it under ports.lock before each
start). A forwarder reserves another VM's ports only while that VM has a
claim: its forwarder runs, or devvm holds its ports.lock to start one
again (the restart window). It never takes the ports such a VM forwards
now, nor those it lists unless this VM lists them too. A stopped or
crashed VM holds nothing. A reserved port the VM listens on waits and is
forwarded once free, so a VM gets its port back within about 20 s of the
other VM stopping. The host decides when a port is given up: every
forwarder closes a forward whose port is now reserved every 10 s on its
own clock (Forwarder.Recheck), so a VM that holds its session open and
stops reporting can't keep another VM's listed port, and closing a
forward closes the connections it accepted, so a browser's keep-alive
connection never reaches the old VM afterwards. Two VMs starting at once
are settled by the host's bind. The ports devvm chooses (ssh, proxy,
desktop) still avoid every VM's listed ports, running or not.

- ports: Used(d) for the allocator; Reserved, Holders and Live for the
  forwarders
- vmssh: Forwarder.Recheck, Note and release; a forward tracks and
  closes its connections; Forwards.Reserved, Held, Taken, live,
  recorded and record; a start keeps a port another VM holds in -only
  and warns ports_held for any holder, listed or every-port; Main takes
  paths.Dirs
- devvm ports warns ports_held and, for a running VM's listed port its
  forwarder recorded as a program's, ports_taken, reading the
  forwarder's record and binding nothing; --json adds held_by
- backend.CountPorts; the stub's ssh master reports again when
  guest-ports changes
- tests: TestReserved, TestForwarderWaits, TestForwarderGivesUpSilently,
  TestForwarderClosesConnections, TestForwardsHeld (restart window,
  every-port holder, no record, Taken from the record alone, another
  process's or no record), TestForwardsRecordFails, TestForwardsStart
  (old record removed), ports_stopped.txtar (CJ's case end to end, and
  an every-port VM leaving a running VM's listed port alone),
  layout.txtar
- docs: ports-size's Two VMs and one port (the browser origin) and its
  JSON, internals' Ports other VMs forward, design.md's ports note and
  the listed ports' threat check; CHANGELOG Fixed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 00:20:43 -07:00
6c36850251 feat(cursor): devvm cursor opens this folder's VM in the Cursor editor
devvm cursor is devvm code's twin for Cursor, the editor. It gets the
folder's VM ready as devvm host does, then runs
`cursor --remote ssh-remote+HOST DIR` in devvm's place, with the SSH
agent devvm started with. Without `cursor` on PATH it fails with
no_cursor_command, naming the host to connect to.

Cursor's Agent and your sign-in (from CJ's manual check with a real
login): recent Cursor runs Agent in the editor's server in the VM, which
holds your Cursor sign-in in memory only (no token on disk, in any
environment or command line) and calls Cursor from the VM. Cursor's
`cursorAgentHost.remoteInferenceRoute` is application-scoped, so it's
read only from the user settings on this machine; with it set to
"always", Agent's own requests go through the Cursor app here, while
the VM's server still talks to Cursor.

- vm: Code and Cursor share openRemote; vm.CursorCommand names the
  editor's command, apart from the CLI agent's agents.Cursor. After
  LookPath finds `cursor`, devvm reads Cursor's user settings on this
  machine (platform.AppSettingsDir: Application Support on macOS,
  $XDG_CONFIG_HOME or ~/.config on Linux) through safefile.Read, 1 MiB
  at most, read-only, as JSON with comments, and warns with
  cursor_agent_in_vm unless the route is "always". It never fails on
  the file.
- sync.sh: Cursor's ~/.cursor-server/data/Machine/settings.json gets VS
  Code's remote.autoForwardPorts, git.terminalAuthentication and
  github.gitAuthentication off, in one loop over both editors' files.
  devvm doesn't write the route there, since Cursor ignores it.
- structure: nameFree lets a literal that is an agent's name stand in
  one file, with its reason, and fails when it frees nothing.
- cli: cursor.go (--ssh-config, --here, --parent), registered beside
  code; cursor_failed, no_cursor_command, cursor_agent_in_vm and their
  doc links; ssh_host_info names Cursor too; the cli skill's judgment
  note: an editor's command is a bare verb named after the editor's.
- Tests: host_code.txtar (cursor, its full-name host, the missing
  command, the warning and no warning once the route is set),
  guest.txtar, TestCursorAgentWarning (always, absent, other values, no
  file, broken JSON, too long, a FIFO, the XDG path; never written),
  e2e network: devvm cursor passes the editor only the host and folder,
  a fake editor sign-in on this machine reaches neither the VM's home,
  its processes' environments nor the proxy's logs, and a Cursor login
  in the store reaches the CLI's methods while the agent store's are
  refused.
- Docs: SSH and editors (commands first; "Cursor's Agent": it runs in
  the VM with your sign-in, the user-settings line, what it doesn't
  cover, open only VMs you trust; if Tab doesn't work on the allowlist
  tier, devvm network allow api3.cursor.sh), the agents page's Cursor
  notes, Commands, attack vectors, design, the home page, CHANGELOG,
  generated CLI pages.

Reviewed adversarially before the push: the settings read (size, FIFOs,
links), the warning's wording and when it fires. Researched with PR
#44's design as reference only.

Co-authored-by: JB <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 00:05:36 -07:00
w3cjandClaude Opus 5.5 5d7f941678 feat(network): quiet hosts: documented telemetry stays blocked without a notice in the VM
A built-in policy's `quiet HOST[:PORT]` line, for one exact host name,
marks a host devvm leaves out on purpose. A quiet host is blocked as any
host no rule allows, and an allow of the user's still lifts it. A block is
quiet only when its reason is "not on the allowlist" (notAllowed), it isn't
refused, and no rule covers the host (an allow, a deny or one that
narrows): then it's logged with "quiet": true but never counted in
/blocked or /blocked/new, so neither the VM's prompt nor devvm-why shows
it, its 403 page suggests no command, devvm network log --blocked shows it
as a row of its own with "- (quiet)", and devvm network lock never offers
it.

- proxy: rule.quiet, parseQuiet (exact hosts only), PolicyLine.Quiet,
  policy.quiet, Allowlist.Quiet, Event.Quiet, server.blocked (proxy and
  transparent paths), notAllowed; loadPolicy skips and logs quiet lines in
  the user's files.
- netpolicy: Judge.Quiet, Block.Quiet (its own row key), FormatEvent's
  ", quiet", RuleFile.Quiet, quietMark, policy_quiet_not_own in
  PolicyWarnings.
- cli: quiet in network log --json, log --blocked --json and network
  --json; the agents' table leaves quiet lines out.
- Quiet hosts, each with its source: api3.cursor.sh (the host Cursor
  documents for Tab requests; Cursor's CLI uses it for its metrics) and
  telemetry.go.dev (Go). Not marked: Claude Code's Datadog intakes (shared
  multi-tenant hosts projects may need), .NET's telemetry (no host in
  Microsoft's docs).
- Tests: TestParseQuiet, TestQuietHosts, TestQuietOnlyWhenNoRuleAllows,
  learn/log/rules tests, network_rules.txtar, e2e network check for
  api3.cursor.sh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 23:38:24 -07:00
w3cjandClaude Opus 5.5 4baa6202cc fix(cursor): Cursor's agent stream passes, read message by message
CJ's M3 run with a real login: cursor-agent couldn't chat; it kept
reconnecting to agentn.global.api5.cursor.sh, and the VM's proxy logged
AgentService/Run as refused ("devvm couldn't read the login's token
request or reply"). The CLI's agent client compresses its requests
with gzip (connect-node's sendCompression, read from the 2026.11.11
package, for messages of 1 KiB and more), and a Connect server answers
a gzipped request with gzipped messages whatever the client accepts
(connect-go's negotiateCompression mirrors the request's; the spec has
the server assume the client takes the request's encoding). cursorReply
refused any reply with a Connect-Content-Encoding or Grpc-Encoding but
identity, so it refused Run's reply at its headers.

- frameScanner: a reply whose Content-Type is a Connect or gRPC stream
  passes message by message. Each is read whole, at most 16 MiB as it
  comes and as it decompresses, gunzipped when flagged compressed, and
  checked for a JWT's start before any of it passes, as it came.
  Connect's end of stream, and every message of a JSON stream, is also
  decoded and its strings checked, so escapes can't hide a token. An
  unknown flag, a compressed message without gzip or that isn't gzip,
  one over the limit, an envelope cut off, a token in the trailers, and
  gRPC-Web's base64 text end the stream before that message. Other
  replies keep jwtScanner; requests carry placeholders and pass as
  before.
- cursorReply takes gzip only as a stream's own message encoding, and
  refuses any other encoding as before.
- TestCursorStreams: a recorded-shape Run stream (gzipped messages, a
  plain one, an end of stream), which failed first ("an encoded reply");
  gRPC; each refusal; a token compressed, plain, at the end and escaped
  there; JSON streams. TestCursorReplyScans now uses a unary reply.
- e2e network: the fake company proxy's api2.cursor.sh answers Run as a
  Connect stream with gzipped messages, which passes whole through the
  VM's proxy, and one with a token, which ends before it.
- A focused threat review (security-audit skill): no way found for a
  token to reach the VM that the old refusal stopped; its memory and
  JSON-codec points are taken (no allocation from a declared length,
  JSON streams decoded, grpc-web-text refused). Base64 inside messages
  stays unread, as before, in internals' network page.

api3.cursor.sh, also blocked in that run, is the CLI's metrics host
(MetricsService, with a fixed key of the CLI's own, fire and forget),
which the allowlist leaves out on purpose; the CLI reaches it with
http2.connect, around HTTPS_PROXY, hence "without proxy settings".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 21:57:18 -07:00
w3cjandClaude Opus 5.5 90694a414f feat(agent): devvm agent import follows links out of an agent's folder when allowed
A link out of an agent's folder, such as a dotfiles repo's link into
~/.claude, was always left out. Now it's copied when you allow it:
config.toml's follow-links names folders whose links devvm follows
without asking, and otherwise devvm names each link and its target and
asks, a question --follow-links answers. Without a terminal and the
flag, links out are left out with a warning naming --follow-links.

- The store gets copies only: a linked file as a file, a linked folder
  as a folder of files; the next import replaces them, a folder that
  became a file included, and prunes them once the link is gone.
- Each link is resolved one name at a time (linkHops), then read through
  its allowed folder as a safefile.Root opened one folder at a time from
  / (openPhysical); a link inside is read only to a file in that root.
- Always refused: the home folder or a folder holding it, devvm's config,
  data and Lima folders, ~/.ssh, ~/.gnupg, ~/.aws, ~/Library/Keychains,
  ~/.config/devvm, ~/.netrc, ~/.config/gh, ~/.docker, ~/.kube, and every
  agent's logins and history, compared by name and identity (isIn); a
  follow-links folder in or holding one fails the import.
- A target in a VM's project folder warns, naming the VM; a chain through
  a link in a VM's folder to a place outside it is refused.
- Bounds: devvm agent save's, 20,000 entries, 128 MiB and 16 MiB a file,
  across one import.
- A settings file must link to a file and a settings folder to a folder.

Messages: agent_import_link_not_followed, agent_import_link_refused,
agent_import_link_too_big, agent_import_follow, agent_import_link,
agent_import_link_followed, agent_import_link_project,
agent_import_link_via_vm, agent_import_root_refused,
follow_links_invalid.

Tests: TestAgentImportFollowsLinks, TestAgentImportNestedLinks,
TestAgentImportRefusedPlaces, TestAgentImportRefusedRoots,
TestAgentImportProjectFolderLinks, TestAgentImportLinkThroughProject,
TestAgentImportRefusedOtherCase, TestAgentImportLinkBounds,
TestLinkSourceGrown, TestAgentImportLinkKinds, TestAgentImportLinkPrune,
TestAgentImportLinkedAgentFolder, TestLinkHops, TestOpenPhysical,
TestFollowLinks; testscript agent_import_links; e2e project section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:47:48 -07:00
w3cjandClaude Opus 5.5 a992eea850 fix(agent): opencode's links at devvm agent import get a warning, not silence
agentDirs and agentFiles list only the folders and regular files of
opencode's folder, so a link there was never looked at: devvm agent
import dropped it without the warning the other agents' links get.
agentLinks lists the links in a WholeFolder agent's folder whose names a
setting could have, and readSettings reads them as it reads any other
agent's link: a link to a file inside the folder is copied as that file,
and any other link is left out with agent_import_link_left_out.

Test: TestAgentImportOpencodeLinks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:47:36 -07:00
w3cjandClaude Opus 5.5 8da71a01bb refactor(from): --from's registries judged by proxy.Public
internal/from had its own copy of the internet-address judge
(publicAddr, nonPublic) with a shorter table than the proxy's: no NAT64
or 6to4 decoding and none of IPv6's special ranges, so a registry at
64:ff9b::10.0.0.1 or fec0::1 passed it.

- publicOnly and publicHost ask proxy.Public; publicAddr and nonPublic
  go. internal/proxy is the standard library only, so from may import it.
- forbidigo refuses netip.Addr.IsPrivate outside internal/proxy, as a
  second judge would drift; testdata/lint breaks it once, and the owners'
  table in Contributing's structure page names proxy.Public.
- TestPublicAddr checks publicHost and publicOnly, with NAT64, 6to4,
  site-local and documentation rows.
- A CHANGELOG Fixed entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:42:43 -07:00
w3cjandClaude Opus 5.5 848d07f9f8 test(e2e): a failed check keeps the sandbox's proxy logs
A block's cause is in the proxy's own log, which the run deletes with
the VM or build that wrote it, so a failed check showed the block but
never why.

- keepProxyLogs: copies every proxy.log with lines under the sandbox's
  devvm folder (VMs' and builds', not images' or tools'), read through
  os.Root, into proxy-logs/<time> in the state folder, and prints the
  folder and the last 5 lines of each written since the attempt began.
- runner.tail calls it for a failed check and a flaky check's first
  failure; runner.began is the attempt's start; newRunner empties
  proxy-logs/ (sandbox.proxyLogs).
- TestHarnessKeepProxyLogs; Contributing's testing page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:42:43 -07:00
w3cjandClaude Opus 5.5 99f57d4003 fix(proxy): 6to4 judged by its IPv4 address, and more special ranges internal
A 6to4 address (2002::/16) passed the floor as public even when the IPv4
address in it was private, and Teredo, IPv6's documentation, discard-only,
benchmarking, ORCHID, SRv6 and IPv4-translated ranges, and IPv4's
documentation ranges and 192.88.99.0/24, counted as the internet.

- withIPv4 (was nat64): the IPv6 ranges that carry an IPv4 address,
  NAT64's and 6to4's, each with its site's prefix length (6to4's /48);
  embeddedIPv4 (was nat64IPv4) reads either.
- hostAddrs.internal: the host's own address first, then the 6to4 site of
  any of its own addresses (its LAN's), then the embedded IPv4 address;
  hostAddrs.own, the address map, replaces has.
- rule.matchAddr: a 6to4 address matches as its IPv4 address for a deny
  alone, as 6to4 goes through relays anyone may run; NAT64 still matches
  for both.
- notPublic gains 2001::/32, 2001:db8::/32, 3fff::/20, 100::/64,
  2001:2::/48, 2001:10::/28, 2001:20::/28, 5f00::/16, ::ffff:0:0:0/96,
  192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 and 192.88.99.0/24.
- Tests: TestInternal's rows, TestInternalOwn6to4, TestSixToFourAllowsNot,
  TestResolveSixToFourName, a 6to4 deny in TestAddressDenyAppliesToNames;
  the learning tests' public address is 93.184.215.14 now, as
  203.0.113.5 is documentation's.
- The structure test's table name, the proxy's README, network.md's range
  list (with Teredo under a broad IPv6 allow), attack-vectors and
  safety/network, and a CHANGELOG Fixed entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:42:43 -07:00
w3cjandClaude Opus 5.5 09c5be1887 fix(proxy): a block for a name that doesn't resolve says why
A name the host's DNS couldn't resolve was blocked with "can't resolve it"
whatever the cause, and a request whose client went away mid-lookup was
logged as a block too, so a cancelled lookup looked like a DNS failure.

- egress.lookup: the resolver, a field tests set (net.DefaultResolver's
  LookupNetIP otherwise); resolve and floorUpstream go through lookupName,
  which asks once more after a temporary failure (not a not-found), within
  floorUpstream's 3 s.
- unresolvedReason: reasonNotFound ("this machine's DNS has no address for
  it"), reasonDNSTimeout, else reasonUnresolvable; the error itself stays
  in proxy.log, as before.
- floorCheck: a lookup that ended with the request's context gives
  reasonClientLeft; events.record drops a block with it, so /blocked and
  the counts never see it, and egress.abandoned names it in proxy.log,
  at most abandonedLogMax (20) a minute, as a name can carry data out.
  The Nix cache's floor gives the context's error for it.
- Tests: TestUnresolvedReason, TestCanceledLookupNotBlocked,
  TestCanceledLookupsLogCapped, TestFloorUpstreamLookupBudget;
  TestUpstreamNoProxyDirect no longer needs the real resolver.
- network.md's log files and a CHANGELOG Fixed entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 20:42:43 -07:00
w3cjandClaude Opus 5.5 d55476d3e2 feat(images): the prelude is one line, so build scripts keep their line numbers
Every script a build runs with bash, devvm's own and the user's layers,
now gets the prelude as one line, eval $'…', in place of its #! line, so
bash's errors and $LINENO give the script's own line numbers. A script
without a #! line is one line further down.

- shell.QuoteLine: ANSI-C quoting for bash, on one line of printable
  ASCII; every other byte as \xHH, so a multibyte locale's lead byte
  (Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a
  quote, and a NUL panics as a caller's bug. image's layer rule allows
  internal/shell, a leaf.
- image.WithPrelude, the one place the prelude and a script are joined
  (OwnScript calls it), used by base.sh, apt.sh, the built-in layers and
  features, the user's layers, shared-tools/build.sh and oci/build.sh.
  Every devvm script has a #! line. A leading UTF-8 BOM goes before the
  #! check.
- A build's exports for a company proxy (lima's proxyExports) and the
  user's CAs (trust's exports) end in "; ", not a newline, so they share
  the first line and move no line either; backend.Trust.Env says so.
- The stub logs a bash -s script's second line, which is the script's
  own second line with or without the prelude.
- Keys: every build script's bytes change, so base, every image and
  every shared tool image are built again once; the CHANGELOG's After
  you upgrade says so with git-lfs, and what VMs say until devvm update,
  and Breaking has its own heading.
- Tests: TestQuoteLine (every byte but NUL, a break-out word, in
  /bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK,
  zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL,
  TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real
  prelude's line gives the prelude back; a layer under set -euo pipefail
  gets the names, keeps its function and its line numbers, with and
  without exports before it).
- e2e nix: the layer copy no longer adds the prelude itself.
- Docs: images.md's prelude section, Customizing's layer bullet,
  structure.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:46:30 -07:00
w3cjandClaude Opus 5.5 6ad4f6cb63 feat(images): your own layers get the scripts' prelude
devvm now puts assets/prelude.sh before a user's layer script, as it does
for its own scripts, so a layer gets $devvm_arch, $devvm_libc and
devvm_sha and can pin a download per architecture (and per C library on
Alpine) the way devvm's scripts do.

- image.WithPrelude puts the prelude before any script; OwnScript calls it.
- build.(*Env).LayerData reads the user's layer and puts the prelude
  before it; a deleted layer is still fs.ErrNotExist (Missing).
- The layer's step holds the prelude, so its key changes on its own:
  every image with a user's layer, and every image above one, is built
  again once. base and built-in-only images, and tool images, keep
  their keys; keyFormat is unchanged. The v0.1.0 fixtures have no user
  layers, so their keys don't move.
- The prelude runs first, so a layer that sets its own devvm_ name keeps
  it.
- layer new's starter mentions devvm_sha and $devvm_arch.
- Tests: TestWithPrelude, TestUserLayerGetsThePrelude (LayerData, the key
  differing from a prelude-less build's, a deleted layer still missing);
  prelude.txtar runs a layer as a build does on gnu and musl, and one
  that overrides devvm_arch and devvm_sha.
- e2e (images): the fixture layer prints $devvm_arch, $devvm_libc and
  devvm_sha of two fake pins, which the check compares with the VM's.
- Docs: Customizing's Mailpit example uses $devvm_arch and devvm_sha;
  images.md's key table, recipe and prelude sections; structure.md;
  CHANGELOG (Breaking).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:46:30 -07:00
w3cjandClaude Opus 5.5 c597c21e85 fix(history): an export packed with macOS's tar imports
devvm history import refused an export made with macOS's tar (bsdtar):
for each file with extended attributes, such as the com.apple.provenance
that recent macOS puts on new files, bsdtar adds an AppleDouble ._ file
beside it, and ._.claude, at the top, is outside the agents' history.
bsdtar's own listing hides those entries; GNU tar's, which the VM
checks, shows them. e2e's from section packs its Alpine export on the
host, so it failed on the mini (macOS) and passed on fedora (GNU tar).
The import script is unchanged since before the agents stack, so this
isn't a regression from it.

- historyImport leaves a name whose last part starts with ._ out of the
  path check (appleDouble), and never unpacks one (--exclude=._* and
  */._*); what's below a folder so named is still checked.
- TestHistoryImportRuns (GNU tar, so Linux): an export laid out as
  macOS's tar writes it imports without its ._ files (it failed before
  the fix on fedora), ._.claude/a is still refused, and an export that
  devvm history export writes imports whole (a round trip).
- The agents' golden scripts, internals' Coding agents and the
  CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:42:38 -07:00
w3cjandClaude Opus 5.5 dd1b87bacd fix(dotnet): DigiCert's OCSP responder on dotnet's allowlist
When NuGet can't fetch DigiCert's revocation list while it checks a
package's signature, it asks DigiCert's OCSP responder, which the
allowlist blocked (seen in e2e tools on fedora, where the list's lookup
failed under load). ocsp.digicert.com on port 80 joins
crl3.digicert.com, and the toolchains page and CHANGELOG say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 7af09a596f test(cli): a failed script shows its VMs' proxy logs
A script that fails with proxy_start_failed leaves no trace of why: the
proxy's log and status file are in the sandbox, which goes with the
script. The sandbox's cleanup now logs, for a failed script only, the
last 40 lines of each VM's proxy log and its proxy's status file, before
it removes them, so the next such failure in CI shows its cause.

- logProxies, proxyLogLines

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 b30229ca19 test(fixture): a fixture's host ports are ones free here
fixture_v010.txtar launched app, scratch and web on the host ports
0.1.0 recorded on the machine that made the fixture. When any of them
was taken here, by a program or by another run of the same tests (two
checkouts' gates on one machine), the launch rightly chose another port
and edited the VM's Lima config, failing the script's check that a
launch makes no limactl edit.

fixture VERSION now maps each VM's ports.host to a port free here,
wherever the number stands on its own (vm.json, the stub's state,
lima.yaml's proxy URL, the proxy's config and status, the sandbox
profile), never inside a hash. The other fixture_v010 scripts' own
free_port and json_set of ports are no longer needed and go.

- freePorts: free_port's helper, shared with fixture
- fixtureRewrite: the paths' replacer plus the ports
- TestFixtureRewritePorts

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 17:27:34 -07:00
w3cjandClaude Opus 5.5 7f0c009d4b docs(compared): bring the comparison up to date, as tables and bullets
The compared pages predated rules by method and path, Cursor's CLI,
learning and locking a VM's hosts, your own secrets, .git protection on
Linux and in nested repos, --clone's full copy and devvm paste.

- _index: the network table's devvm row gets method and path rules,
  learning, your own secrets and Cursor's CLI, and refreshing is named
  for the agents devvm refreshes (not Cursor's, not pi's API keys);
  Docker's rules gain the port its docs list. How devvm differs is
  bullets, adding --clone, transparent mode, your own secrets and
  devvm paste. Last checked is a note, and Clawk and agent-vm get a
  bullet each.
- docker-sandboxes: method and path rules move to What's the same;
  rows for learning hosts, the clone, the clipboard; nested repos in
  the .git row; Cursor's CLI and pi in logins; choosing is two bullets,
  with rules by URL query in place of method and path. Docker's
  isolation and network rules pages read again on 2026-11-12.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 15:21:02 -07:00
w3cjandClaude Opus 5.5 5c8aeafcbc test: gosec's G703 off in test files, where it reports a helper's write on some runs only
gosec's taint analysis reported internal/gitprotect's test helper write
(G703) on some runs and not others, which failed macOS CI's lint at
4f99e407 and passed on its re-run. A nolint there would fail nolintlint
on the runs that don't report it, so .golangci.yml excludes G703 in
_test.go files, as it does for tests/e2e, and the 12 nolint:gosec
comments that only covered G703 in tests go.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 12:50:32 -07:00
w3cjandClaude Opus 5.5 4f99e40731 test(clone): don't depend on the machine's git-lfs or system git config
CI (run 43285988512, at 9535110f) failed two tests that pass on a Mac
with Apple's git and no git-lfs:

- TestSeedConfig found "filter" in the VM's config. With git-lfs on
  PATH, as on GitHub's runners, the seed's own per-clone
  git lfs install --local --skip-repo writes filter.lfs.*, which is
  what the copy is meant to do. The check now looks for this machine's
  filter (filter.crypt) and allows only filter.lfs.* besides. Reproduced
  with git-lfs 3.8.1 on PATH; passes with and without it.
- clone_uncommitted_retry wanted clone_kept_branches. That has nothing
  to do with LFS: after the failed first copy, the VM's repo is empty,
  and the script's git commit landed on the VM git's default branch.
  Apple's system gitconfig sets init.defaultBranch=main, so locally it
  was main, which the retry keeps (clone_kept_branches); on the runners
  it's master, so main was set as copied and only HEAD stayed
  (clone_kept_head). Reproduced with GIT_CONFIG_NOSYSTEM=1, which now
  fails the old script locally exactly as CI did. The script now puts
  the VM's HEAD on main before it commits, and every testscript runs
  with GIT_CONFIG_NOSYSTEM=1, so a machine's system config can't change
  what a script's git does.

The gate passes twice, with git-lfs 3.8.1 first on PATH and without it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 12:30:46 -07:00
w3cjandClaude Opus 5.5 9535110f2f docs: user-page rule covers safety, backends and compared; strict section leads with today's behaviour
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:54:42 -07:00
52bb0f467b feat(clone): a --clone VM gets the repo as it is here
A --clone VM's clone is now seeded with a snapshot, not git push, and
gets everything a working copy has. devvm clone fetch brings it all
back, and devvm rm and clone off check it before deleting.

- Refs: every branch, tag and notes ref, and a detached HEAD.
- Uncommitted changes: staged, unstaged and untracked files; files
  skip-worktree by hand get the index's version, named.
- Operations in progress (merge, rebase, cherry-pick, revert, bisect)
  and the stash; a stash's untracked part goes as its own branch.
- The repo's settings and hooks, sent as settings only where they live
  in the repo (husky); ORIG_HEAD never goes.
- Partial clones, with their promisor remote, and messages per network
  tier when it can't be reached.
- Initialised submodules, nested ones too, each with a clone of its
  own; a submodule's own folder is refused as a top-level --clone.
  vm.json gains an optional `submodules` field.
- Git LFS both ways: objects hash-checked, written under os.Root with
  no link followed, a question past 2 GiB; the filter is set only in
  the clone's repos; git-lfs 3.8.1 in base, pinned by SHA-256.
- rm and clone off keep the VM when anything the VM has didn't come
  back, and name it.
- Every shell script embedded in Go is shellchecked.
- clone.md is a guide that leads with commands; TestUserPageProse
  covers it and coding-agents.md.

After you upgrade: base and every image on it build again once, for
git-lfs.

Fixes #40, reported by @Josuesp1620. Thanks to @dhruv1220 for #42,
which found the cause (receive-pack refusing a shallow push); its
receive.shallowUpdate setting stays in the VM's repos.

Co-authored-by: Dhruv Arora <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:54:42 -07:00
d349868c31 feat(agents): one definition per coding agent, and Cursor's CLI
Every list of the coding agents now derives from internal/agents'
registry, one Def each, and Cursor's CLI (cursor-agent) is a fifth
agent.

The registry:
- each agent's login command, login formats and capture on its Def;
  one message for every agent where each had its own
- the agents' table, the README's list and the docs' history lists are
  generated from the registry (cli.DocBlocks, TestDocBlocks); scripts
  and Go tests take their lists from it too
- each agent's own code lives in a file named for it; the structure
  test lets only an agent's own files choose by its name, following
  constants named after an agent
- a VM remade by clone on/off keeps no agent's login files
  (agents.LoginFiles from every Def.Logins; Claude Code's .claude.json
  stays, as it is also history)

Cursor's CLI:
- `devvm --agents cursor`, `devvm agent login cursor`, history import
  and export of ~/.cursor/chats
- the proxy captures its login at a GET endpoint, guards a shared host
  by path, and puts the login in only where the CLI sends it, bound to
  the CLI's 57 methods
- account changes and the agent store are refused in a VM; Cursor's
  headers and trailers are scanned for tokens
- e2e: Cursor's CLI in the network section, its poll behind the fake
  company proxy

Docs: the agents' pages lead with commands, with a How it works page
for the agents.

Co-authored-by: JB <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:49:48 -07:00
w3cjandClaude Opus 5.5 a03f119427 docs: user pages lead with commands, and lint:docs fails a wall of prose
The user pages (getting-started, using, safety, backends, compared) now
show a task's command first, then lists, tables, steps and callouts.
Longer mechanism moves to the matching How it works page, linked, with
every fact kept (facts.sh against each parent).

- The rule: a line in AGENTS.md's Docs, the docs-voice skill's "Commands
  first on user pages", and Writing docs' "User pages lead with doing".
- scan.sh checks runs on every page (2+ paragraphs on user pages, 3+ in
  internals and contributing), prints each run's word counts, adds a
  `long` column (paragraphs and list items over 80 words or 4
  sentences), and exempts a colon-ended lead-in only up to 40 words.
- TestUserPageProse (internal/cli/docgen), run by lint:docs, fails a
  user page with a run of 3+ paragraphs where two are over 80 words, or
  any paragraph or list item over 150 words; TestProseProblems covers
  the rules.
- Pages: images (Base first, Outdated VMs after Rebuilding), vms,
  ports-size, links, space, settings, command-line, troubleshooting ("A
  command fails" as the skill's own after example), upgrading, desktop,
  from, customizing, safety/network, safety/git-protection,
  attack-vectors, backends.
- Moved mechanism: internals/network.md (Starting a VM on its tier,
  Requests by method and path, The VM's CA) and a new "The run log" in
  internals/overview.md.

On the user pages: runs of 3+ paragraphs 32 -> 0, paragraphs or list
items over 150 words 46 -> 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-12 11:49:47 -07:00
CJandClaude Opus 5.5 2b49967b4e chore: CI time zones, test isolation from the repo, a flaky test and the agents page (#45)
Upkeep: CI, flaky tests, dead code and the coding agents page.

- test: tests never run git on the repo they're run from. A git that
  runs the tests (a hook, git rebase --exec) sets GIT_DIR and friends,
  and the tests' plain git followed them into the real repo's config.
  Every test's git now runs through internal/stubtest (Git, GitEnv,
  NoGitRepo), the structure test enforces it, and the whole suite
  passes with GIT_DIR pointing at a decoy repo that stays untouched.
- ci: two test jobs instead of three: Linux in America/Los_Angeles
  (DST) and macOS in UTC, with lint on both, since golangci-lint checks
  only the runner's OS's files.
- test(e2e): accept Codex 0.167's wording for an API-key login.
- test: internal/safefile's swap-after-look branch is tested on purpose
  through a seam, so its coverage no longer depends on a race (97.7%
  every run).
- test(fetch): TestRetryUnanswered's "no answer" comes from a listener
  that keeps its port, so a parallel test's server can no longer take
  the freed port and answer in its place (Linux reuses ports at once).
- refactor(proxy): the test-only policy.decide and policy.byRequest
  move to the tests; the proxy already judges a host from one read of
  the rules (rulesFor).
- docs(agents): "Pasting images" moves down the coding agents page,
  before History, and its run of paragraphs becomes commands and
  lists, every fact and anchor kept.

Gate and coverage pass on each commit; e2e `network` and `project` pass
on Linux (251 passed, 4 macOS-only skips).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-11-12 07:20:42 -07:00
2f0cc97392 feat(paste): devvm paste and devvm paste rm (#38)
feat(paste): devvm paste, an image, PDF or copied file from the clipboard into the VM (#38)

devvm paste reads the host's clipboard and streams what's on it into the
running VM's paste folder over the backend's Exec, with no SSH agent and no
new channel, then copies the file's path in the VM to the host clipboard for
the agent's prompt. devvm paste rm empties the folder after a question, and
a launch that starts a stopped VM offers to.

What it reads:
- an image (PNG, JPEG, GIF, WebP; TIFF is converted to PNG), checked by its
  bytes; browsers hand over a PNG, so an animated GIF arrives as one frame
- PDF data, sent as it is, and preferred over a file reference beside it
  (Preview's page copies)
- one copied file, after a question that shows its path on this machine;
  --send-file answers it only for a file inside the project folder reached
  without links, and never for a --clone VM
- never text; several files are refused

Security:
- macOS reads file URLs only through NSPasteboard (FileURLsOnly): AppleScript's
  «class furl» coercion turned any text, such as a path a web page or the
  VM's OSC 52 put there, into a file to send
- copied files are opened with openat and O_NOFOLLOW|O_NOCTTY|O_NONBLOCK,
  following a root-owned link only in a folder only root can change, and read
  through internal/safefile (Checked), capped at 64 MiB
- osascript and pbcopy by absolute path, Linux's tools only from system
  folders, never PATH
- time limits on every clipboard tool and on paste.sh in the VM; bounded
  reads of everything the VM prints
- the path copied back is built on the host, keeping only the file's
  extension: nothing the VM says reaches the clipboard

Also: the paste-dir setting (default /tmp/devvm-paste, made at each
launch), --json with sent, the agents' guide line, messages with doc links,
stubs, CLI tests, an e2e check in the project section, and docs on
coding-agents, settings, design, security and attack-vectors.

Co-authored-by: dustypolk <[email protected]>
Co-authored-by: w3cj <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 22:29:46 -07:00
w3cjandClaude Opus 5.5 28d7eca6c8 test(e2e): never leave or trip over a project VM
Check 2 of project fails at once without check 1's VM, cleanup deletes
any VM whose folder is under the run's project folders (and its state
folder), and setup refuses a slot whose Lima home has project VMs an
earlier run left, printing the commands that delete them (not with
--reuse). leftoverVMs, projectVMs; TestHarnessLeftovers,
TestHarnessProjectVMs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ
2026-11-09 12:19:49 -07:00
w3cjandClaude Opus 5.5 a78f212a8c docs(changelog): name the network commands' real arguments
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HTFcPrY8FzzQMopN5wgpLQ
2026-11-09 11:49:19 -07:00
958 changed files with 102190 additions and 11782 deletions

No files matched your search

+9 -6
View File
@@ -13,11 +13,11 @@ The reasoning behind most rules is in the [Command Line Interface Guidelines](ht
## The tree
devvm has 34 commands at the top, plus help. Each one is in a group of the root's help, in this order. The table shows each command with its subcommands and the values a setting takes, and each command's help lists its flags.
devvm has 36 commands at the top, plus help. Each one is in a group of the root's help, in this order. The table shows each command with its subcommands and the values a setting takes, and each command's help lists its flags.
| Group | Commands |
| --- | --- |
| Your VM | devvm, with --tools, --agents and --layers; restart, stop, update, rm [VM], adopt [VM], ls, code, desktop, host, history, history export [FILE], history import [FILE] |
| Your VM | devvm, with --tools, --agents and --layers; restart, stop, update, rm [VM], adopt [VM], ls, code, cursor, desktop, host, history, history export [FILE], history import [FILE], paste, paste rm |
| Change your VM | tools (a picker in a terminal), tools add\|rm TOOL..., tools update; size, with --cpus, --memory and --disk; mount-cache [none]; ports [all\|none\|LIST], ports add\|rm LIST; network [open\|internet\|learn\|allowlist\|none], network allow\|deny\|rm RULE..., network log, network lock, network transparent [on\|off]; ssh-agent [on\|devvm\|off], ssh-agent add\|rm KEY_FILE; git-protect [on\|off]; clone [on\|off], clone fetch, clone add PATH; secret, secret set\|rm\|use\|unuse NAME; layer add\|rm LAYER... |
| Links between VMs | group, group join NAME, with --as NAME, group leave; link, link add\|rm TARGET PORT, with --as NAME on add; link publish [PORTS], link unpublish PORTS |
| Images | images, images rm IMAGE\|KEY..., build IMAGE, rebuild IMAGE, layer new NAME |
@@ -43,6 +43,7 @@ Each rule says what it looks like in devvm, and what checks it. A test's name me
11. **Usage errors are devvm messages, checked before anything runs.** They name the argument or the values the command expected, and `usage_help` follows each one with the command's own `--help`. `TestUsageErrorsEveryCommand` checks that each one is a usage error and nothing runs, and the wording is by hand ([usage errors](judgment.md#usage-errors)).
12. **devvm takes no word of its own.** `devvm WORD` is an unknown command, a usage error (`checkWord` in `internal/cli/word.go`), so an image's, a shared tool's or a layer's name is never a command line's word, and a layer may have a command's name. A toolchain's, an agent's or a layer's name points to its flag (`no_command_part`), and any other word gets a did-you-mean over the commands. `TestUnknownWord` checks it.
13. **Exit codes are 0 for success, 1 for a failure, 2 for a usage error and 130 for an interrupt.** `TestExecuteExitCodes` and `TestRanErrorIsAFailure` check them.
14. **Slow work shows a status line.** Anything that can take noticeable time, such as a host command, host git, a command in a VM, a backend's `limactl list`, a request over the network, a walk of the user's folders, a `diskutil` lookup or a wait for a lock or a timeout, runs under the UI's status line: a `LoggedCmd` step, or the Reporter's `Status` with a label from `locales/en.toml`, such as `defer e.Status(msg.ReadingVMs())()`. Work that takes the terminal, such as a VM's shell or `ssh-add` asking for a passphrase, never runs under one. A wait for a lock passes the lock a `platform.Waiting` with its own label (`msg.Waiting`), so it shows only while another devvm holds the lock. The structure test's `status-lines` rule (`statusSites`), `TestLaunchStatusLines`, `TestCommandStatusLines` and `TestSSHAddOffStatusLine` check it, and whether a label says what the user waits for is by hand ([status lines](../../../docs/content/docs/contributing/cli.md#status-lines)).
## Adding a command
@@ -57,10 +58,11 @@ Work through this list for each new command, in order, then run [the review](#re
7. **Output:** when it shows or lists something, give it `jsonFlag`, a struct of its own with snake_case `json` tags, `printJSON`, a row in `TestJSONShapes` and a section with an example on its docs page. Otherwise say why it has none in its `about`'s `noJSON`, such as `noJSON: "it deletes"`.
8. **Help:** write a `Short`, a `Long` of one to three sentences and an `Example` from `examples()`, with the docs-voice skill ([help](judgment.md#help)). Set its `Annotations` from an `about` (`internal/cli/help.go`): `docs`, the user page that covers it as `page#anchor`, and for a root command its `group`, one of `helpGroups`, such as `Annotations: about{docs: "using/vms#listing-vms", group: groupVM}.annotations()`.
9. **Messages:** every message goes in `locales/en.toml`, with the docs-voice skill's Messages rules, and then `go generate ./internal/msg`. A usage error names what the command expected ([usage errors](judgment.md#usage-errors)). The command fails by returning its error from `RunE`, as `failed(err, msg.XFailed)` when the error may not be a message, or through `a.env`, which does the same, and never prints the failure itself, because `execute` shows it (`TestExecuteShowsEachFailure`).
10. **Register it** with `AddCommand` in `NewRoot` (`internal/cli/root.go`) or under its noun, and write it in its own file, `internal/cli/<command>.go`, with what completes its arguments and flags (`ValidArgsFunction`, `RegisterFlagCompletionFunc`) set there too.
11. **Tests:** add a CLI test in `testdata/script/` for what it does and for each refusal, with `DEVVM_MESSAGES=names`. Add a sample value to `argSamples` in `internal/cli/args_test.go` when `TestUseMatchesArgs` asks for one, for a placeholder no command had, and a command on this folder's VM to `folderCommands` in `internal/cli/flags_test.go`.
12. **Docs:** add the command to its group's table on the Commands page (`docs/content/docs/getting-started/commands.md`), and to the page its `about` names, with the docs-voice skill. Then run `mise run cli-docs` and commit the pages it writes.
13. **The gate:** `mise run fmt && mise run lint && mise run test`.
10. **Status lines:** wrap each step that can take noticeable time in a status line, with a label message of its own, a lowercase phrase in `-ing` such as `reading the VMs`, and keep it off a step that takes the terminal. Its Go test records the label with a `msg.Fake`'s `OnStatus` or `Showing` ([status lines](../../../docs/content/docs/contributing/cli.md#status-lines)).
11. **Register it** with `AddCommand` in `NewRoot` (`internal/cli/root.go`) or under its noun, and write it in its own file, `internal/cli/<command>.go`, with what completes its arguments and flags (`ValidArgsFunction`, `RegisterFlagCompletionFunc`) set there too.
12. **Tests:** add a CLI test in `testdata/script/` for what it does and for each refusal, with `DEVVM_MESSAGES=names`. Add a sample value to `argSamples` in `internal/cli/args_test.go` when `TestUseMatchesArgs` asks for one, for a placeholder no command had, and a command on this folder's VM to `folderCommands` in `internal/cli/flags_test.go`.
13. **Docs:** add the command to its group's table on the Commands page (`docs/content/docs/getting-started/commands.md`), and to the page its `about` names, with the docs-voice skill. Then run `mise run cli-docs` and commit the pages it writes.
14. **The gate:** `mise run fmt && mise run lint && mise run test`.
## Changing a command
@@ -77,6 +79,7 @@ Run the command's help and read the code, then check what the tests can't:
- **Destructive commands:** it asks unless given `--force`, its question answered by `--force` and refused where devvm can't ask, and `--force` never deletes more than the command does without it. Deleting more has its own flag.
- **Help:** the `Short` names what it acts on, such as this folder's VM, the `Long` says what it does, and the rules and edge cases go on the docs page. The examples start with the common case, and each comment says what that line does.
- **Usage errors:** each one names the argument or the values the command expected, as the `Use` shows them.
- **Status lines:** each slow step shows one whose label says what the user waits for, a caller's status line that `statusSites` names covers the call, and none spans a step that takes the terminal.
- **The tree:** `devvm --help` still matches [the tree](#the-tree), and the Commands page's tables match `devvm --help`.
Then run the gate, and read the command's page in `docs/content/docs/cli/` as a user would.
+4 -2
View File
@@ -6,13 +6,15 @@ The tests in [The CLI rule tests](../../../docs/content/docs/contributing/cli.md
A command is either a verb on this folder's VM or a noun with its verbs.
- **A bare verb acts on this folder's VM.** devvm restart, devvm stop and devvm rm need no argument, because the VM is the folder's. devvm code, devvm desktop and devvm adopt are verbs of the same kind.
- **A bare verb acts on this folder's VM.** devvm restart, devvm stop and devvm rm need no argument, because the VM is the folder's. devvm code, devvm cursor, devvm desktop and devvm adopt are verbs of the same kind.
- **Anything else goes under its noun.** A secret is a thing of its own, so saving one is devvm secret set, not devvm save-secret. A rule belongs to the network policy, so adding one is devvm network allow, not devvm allow. A key belongs to devvm's own SSH agent, so loading one is devvm ssh-agent add.
- **A bare noun shows or lists.** devvm secret lists the secrets, devvm images lists the images, and devvm history lists the exports, so none of them has an `ls` or `show` subcommand. devvm ls is the one list at the top, because it lists every VM rather than something of this folder's VM.
- **The exceptions stay at the top:** ls, build, rebuild, gc, setup, doctor, upgrade, completion and limactl. Each is a verb a user reaches for by name, and moving build under images, as devvm images build, would make the most common image command the hardest to find. upgrade acts on devvm itself, not on this folder's VM, and it's the name other tools give the same verb. Add to that list only when the same is true, and say why in the commit.
Links between VMs follow the rule. A link is a thing of this folder's VM, so it's a noun: devvm link lists the VM's links, devvm link add TARGET PORT makes one, and devvm link rm TARGET PORT removes it. devvm group is a noun too, with devvm group join NAME and devvm group leave.
An editor devvm opens the VM in is a bare verb named after its command, as devvm code is VS Code's `code` and devvm cursor is Cursor's `cursor`. A name an editor shares with an agent is the editor's at the top, and the agent is reached only through `--agents`, as in `devvm --agents cursor`. The agent's own commands in the VM are `cursor-agent` and `agent`, so the two never meet on a command line.
When a command could go in two places, put it where a user who knows the rest of the tree would look first. A user who wants to stop forwarding a port types devvm ports, because the ports are what change, and finds devvm ports rm there.
**In a review:** would a user who knows devvm ports and devvm network guess this command's name?
@@ -64,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.
@@ -0,0 +1,70 @@
---
name: codebase-standards
description: devvm's standards for keeping its code clean and safe, as a short checklist for a commit and a review, drawn from what reviews of devvm's history kept finding (fallbacks that fail open, unbounded or trusted input from a VM, secrets in arguments, hand-rolled parsers, swallowed errors, processes without an owner, runs that a kill or a second devvm breaks, slow work with no status line, copies of an owner, running VMs at an upgrade, overclaims, fixes without a failing test, tests that need one machine), and how new code matches the existing code's style. Use before a commit, when reviewing a change or a branch, and when a review's finding may be one a standard covers.
---
# devvm's codebase standards
Reviews of devvm's code kept finding the same mistakes, in code that different people and agents wrote for different features. This skill turns each of those into a standard, so a change meets it before a review has to find it, and it says how new code matches the code already there. It isn't a rulebook to apply line by line: a standard matters where a change touches its ground, and each one is here because it recurred or because missing it was costly.
- [standards.md](standards.md) has a section for each standard: the rule, what the reviews found, sometimes a pair of devvm's code that breaks it and code that keeps it, and its guard.
- [rules.md](rules.md) lists the rules that AGENTS.md and the Contributing pages hold, each with what guards it, so a reviewer knows what the gate checks and what's left to read.
A command follows the [cli skill](../cli/SKILL.md), prose and messages follow the [docs-voice skill](../docs-voice/SKILL.md), and a sandbox or a backend's emulation gets its threat check with the security-audit skill, so this skill doesn't restate them.
## The checklist
Go through the items that a change touches. Each links to its section in [standards.md](standards.md).
Safety:
1. **[Fail closed, on every path.](standards.md#fail-closed-on-every-path)** A refusal, a failure or a retry leaves things as strict as they were, and a weaker mode is visible, documented and chosen.
2. **[Bound what you don't control.](standards.md#bound-what-you-dont-control)** What a VM or another process can make devvm read, hold or wait for has a cap in size, count and time.
3. **[Treat what a VM can write as hostile.](standards.md#treat-what-a-vm-can-write-as-hostile)** Reach its files by descriptor, check what it hands back, escape its text, and run nothing it can plant.
4. **[Keep secrets and host data on the host.](standards.md#keep-secrets-and-host-data-on-the-host)** A secret stays out of arguments and shared environments, and only an allowlist crosses into a VM.
5. **[Parse once, with a real parser.](standards.md#parse-once-with-a-real-parser)** The function that checked a value reads it, and an address check knows IPv6.
Failures and processes:
1. **[Never fail silently, and name the real cause.](standards.md#never-fail-silently-and-name-the-real-cause)** An error is never dropped without a reason, and a message names the cause the code found.
2. **[Give every process an owner that ends it.](standards.md#give-every-process-an-owner-that-ends-it)** A context cancels it, something waits for it, and an accept loop goes on through `daemon.AcceptRetry`.
3. **[Survive a kill and a second devvm.](standards.md#survive-a-kill-and-a-second-devvm)** One good copy survives every step, and an OS file lock guards a change, with the state read again under it.
4. **[Show what devvm waits for.](standards.md#show-what-devvm-waits-for)** Slow work runs under a status line, a `Status` or a `LoggedCmd` step with a label message, never across work that takes the terminal, and its test records the label.
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'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:
1. **[Prove each fix with a test that fails without it.](standards.md#prove-each-fix-with-a-test-that-fails-without-it)** Its oracle comes from outside the code, an absence check has a control, and a sandbox is proven by attacking it.
2. **[Write tests that pass on any host, at any load.](standards.md#write-tests-that-pass-on-any-host-at-any-load)** A test stays off the real clock, assumes nothing about the machine, and uses stubs that behave like the real tool.
## Match the codebase
New code reads like the code around it. Before writing, read a neighbour in the same package and follow it. These are the habits that hold across the codebase, each with a place to see it:
- **Names** are short and plain: `bounded`, `target`, `parsePort`, `vmLog`, and a getter has no `Get` prefix. A file holds one concern and is named for it in lower case, its words run together, such as `linksession.go` or `cloneseed.go`. A `_` in a file's name marks a build tag, a test, a generated file or a part of a parent's file, such as `internal/cli`'s `gc_caches.go` for a subcommand, since each Cobra command has its own file. A large package maps its files in a `doc.go`, as `internal/vm/doc.go` does, or in a README, as `internal/proxy` does.
- **Comments** are full sentences that say what a thing is and why it's that way, starting with its name, as `bounded` in `internal/vm/bounded.go` explains why its buffer isn't embedded. A struct's fields have a comment each where the name isn't enough, as in `vm.Options` and `vm.Env`. A test starts with a comment that states the behavior it checks, and comments describe the code as it is, never its history.
- **Errors** that the user sees are messages: `msg.PortInvalid(strconv.Quote(v)).Because(err)`, never prose built with `fmt` ([Messages](../../../docs/content/docs/contributing/cli.md#messages)). An error usually passes up as it is, as `return err`. When a caller adds context, the wrap is lower case, says what was being done or on what, and uses `%w`, such as `fmt.Errorf("reading devvm's %s: %w", name, err)` or `fmt.Errorf("backend %s: %w", name, err)`. A sentinel is a package-level `ErrX` or `errX` from `errors.New`, such as `safefile.ErrTooLong`, and callers test it with `errors.Is`.
- **Dependencies are fields.** A type's dependencies and test seams are exported fields that its constructor fills and a test replaces, as `NewEnv` fills `vm.Env`'s and a test changes the ones it needs. A call's choices go in a struct of fields, as `vm.Options` holds what `devvm` was asked for, never functional options. A package's type embeds the one `msg.Reporter` its constructor takes, and a package-level variable is rare enough that the structure test lists each one.
- **Tests** are table tests next to the code, as a map from input to what's wanted, as `TestPortsRows` has, or a slice of structs (`for _, tc := range []struct{…}{…}`), with `t.Run` where cases need names of their own. They use the standard library alone, with no assertion library, call `t.Fatal` on a setup step's error, and name the case and what came out against what was wanted, such as `t.Errorf("rows for %s: %v, want %s", shown, got, want)`. They compare a message by its ID (`msg.IDOf`, `msg.Recorder`) and run host commands through `stubtest` ([Go test helpers](../../../docs/content/docs/contributing/tests.md#go-test-helpers)).
- **Scripts in the VM** follow AGENTS.md's rules for bash 3.2 and pins, and they run on every base devvm supports, Alpine's BusyBox included, which has no `findmnt`.
- **Prose** follows the docs-voice skill, and Go follows [Go conventions](../../../docs/content/docs/contributing/_index.md#go-conventions), which the linters and the structure test enforce.
## Reviewing a change
1. **Read the whole diff,** and the code around each change, because a path used twice or a copy of an owner spans more than the lines that changed.
2. **Check each standard the change touches,** and the style of the code it adds against its neighbours.
3. **Check the claims** that the change adds or touches, in the docs, the CHANGELOG, comments and the commit message, against the code.
4. **Prove the fixes:** revert each fix and run its test, which must fail.
5. **Hand off what another skill owns:** a command to the cli skill's review, prose to the docs-voice skill, and a sandbox or a backend's emulation to the security-audit skill.
6. **Run the gate,** `mise run fmt && mise run lint && mise run test`, and the end-to-end sections for what changed when the change touches VMs.
7. **Report each finding** with the standard it breaks, where it is and what would fix it. A finding that no standard covers is fine to report as it is.
## Adding a standard
A finding becomes a standard when it has recurred, or when missing it was costly, and when a contributor can apply it while writing or reviewing a change. A one-off, a rule that a linter or a test already enforces, or a detail of one backend doesn't qualify. Before adding one, look for a standard it extends, because a short list gets used. A new standard gets a section in [standards.md](standards.md) with its rule, what the reviews found and its guard, and a line in the checklist. When a check that enforces it lands, the standard names that check as its guard.
+114
View File
@@ -0,0 +1,114 @@
# The rules with an owner elsewhere
These rules are written in [AGENTS.md](../../../AGENTS.md) and the [Contributing](../../../docs/content/docs/contributing/_index.md) pages, which stay their one home. Each table gives a rule in a few words, links to where it's written in full, and names what guards it, so a reviewer can skip what the gate already checks and read for the rest. A guard that names a test or a linter fails the gate when the rule breaks, except for the end-to-end checks, which `mise run e2e` runs, and the CI jobs a row names. "Review only" means nothing fails, so the reviewer checks it.
## Go code
| Rule | Written in | Guard |
| --- | --- | --- |
| Only `internal/ui` prints, and only `cmd/devvm` calls `os.Exit` | [Go lint rules](../../../docs/content/docs/contributing/_index.md#go-lint-rules) | forbidigo (`fmt.Print*`, `os.Stdout`, `os.Stderr`, `os.Exit`) |
| A function takes its caller's context, and a fresh one says why | [Go lint rules](../../../docs/content/docs/contributing/_index.md#go-lint-rules) | forbidigo (`context.Background`, `context.TODO`), contextcheck |
| Every `//nolint` names its linters and says why | [Go lint rules](../../../docs/content/docs/contributing/_index.md#go-lint-rules) | nolintlint |
| A function stays within 100 statements, 160 lines and a cognitive complexity of 75 | [Go lint rules](../../../docs/content/docs/contributing/_index.md#go-lint-rules) | revive |
| No type has more than 24 methods, no `func init`, and few package vars | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `max-methods`, `no-init` and `package-vars` |
| Packages import only down their layers | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `layers` |
| Test seams are fields, never package vars | [Go conventions](../../../docs/content/docs/contributing/_index.md#go-conventions) | reassign, and the structure test's `package-vars` |
| Dependencies stay on the allowlist, and the proxy's packages use the standard library alone | [Go lint rules](../../../docs/content/docs/contributing/_index.md#go-lint-rules) | depguard |
| External tools run as commands, through the UI's `LoggedCmd`, a backend's `Runner` or `internal/hostgit` | [CLI conventions](../../../docs/content/docs/contributing/cli.md#cli-conventions) | the structure test's `owners` (`commands`, `execSites`) |
| A string that goes into a shell is quoted with `shell.Quote` | [Go conventions](../../../docs/content/docs/contributing/_index.md#go-conventions) | the structure test's `literals` (`'\''` outside `internal/shell`), and `TestEmbeddedScripts` for scripts in Go strings |
| A `Wait`'s error and a `strconv` parse's are never assigned to `_` outside tests, but where `droppedErrors` says why | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `dropped-errors` (`droppedErrors`) |
| An `io.ReadAll` outside tests reads through an `io.LimitReader`, but where `unboundedReads` says why | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `read-limits` (`unboundedReads`) |
| Two folders' identities are compared only by `platform.SameFolder`, but where `exactFolderIDs` says why | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `folder-ids` (`exactFolderIDs`) |
| Code for one system goes behind build tags in `internal/platform` | [Go conventions](../../../docs/content/docs/contributing/_index.md#go-conventions) | forbidigo for the host's CPUs, memory and free space outside `internal/platform`, and the rest is review only |
| devvm builds with `CGO_ENABLED=0` | [Go conventions](../../../docs/content/docs/contributing/_index.md#go-conventions) | `mise.toml` and `.goreleaser.yaml` set it, and CI's `nocgo` job runs `internal/landlock`'s and `internal/proxy`'s tests that way |
| A nil value that may reach a dereference is fixed or triaged | [Nil checks](../../../docs/content/docs/contributing/_index.md#nil-checks) | `mise run nilaway` and CI's `nilaway` job, which warn without failing, and `mise run nilaway:linux`, which fails on a new finding or a stale baseline line and must pass before a push to `main` |
| A dependency with a known vulnerability is updated | [Tools and tasks](../../../docs/content/docs/contributing/_index.md#tools-and-tasks) | `mise run vuln` and CI's `vuln` job |
## Owners
| Rule | Written in | Guard |
| --- | --- | --- |
| Before adding a helper, a parser, a path, a reader, a message or a table, extend its owner | [One owner for each concern](../../../docs/content/docs/contributing/structure.md#one-owner-for-each-concern) | the checks below where an owner has one, and otherwise review only and [the consolidation pass](../../../docs/content/docs/contributing/structure.md#the-consolidation-pass) before a release |
| Each owner that has a check: `fetch`'s HTTP clients, `daemon`'s signals, `state`'s whole files, `safefile`'s reads, `paths`' folders and home, `msg.Safe`, `proxy.Public`, `proxy.NormHost`, `vmname.VM`, `redact.Secret`, `hostgit`, the agents' and toolchains' registries, and the rest | [The checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners) | the check each row of that table names, a forbidigo rule or the structure test, with `TestOwnersDoc` and `TestOwnersAgree` keeping the table and the checks together |
| A file a VM can write or swap is changed through what opened it, never by its path, in `internal/proxy`, `internal/vmlog` and `internal/vmssh` | [The checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners) | forbidigo (`os.Chmod`, `os.Chtimes`, `os.Chown`, `os.Lchown`, `os.Truncate`), with a `nolint` that says why for a socket devvm has just made |
| A secret's value is a `redact.Secret`, revealed only where it's used, and a file that holds one writes it through its own wire type | [Secrets in the code](../../../docs/content/docs/contributing/structure.md#secrets-in-the-code) | forbidigo (`Reveal`), the structure test's checks of embedding and `Reveal() string`, and `TestSecret`, while a new secret held in a string is review only |
| Two places that must agree but can't be one have a test that they agree | [Agreement tests](../../../docs/content/docs/contributing/structure.md#agreement-tests) | each pair's own test, such as `TestDefsComplete` and `TestToolchainsComplete`, while a new pair is review only |
## Processes and goroutines
| Rule | Written in | Guard |
| --- | --- | --- |
| Every goroutine has something that waits for it, or says why nothing does | [The structure test](../../../docs/content/docs/contributing/structure.md#the-structure-test) | the structure test's `goroutines` (`goroutineSites`) |
| A package that starts goroutines checks for leaks | [Goroutine leaks](../../../docs/content/docs/contributing/tests.md#goroutine-leaks) | the structure test's `goroutines`, which requires `leaktest.Main`, and `leaktest.Check` in a test that starts and stops them |
| The startup check only reports, and devvm never installs host software without asking | [AGENTS.md's Rules](../../../AGENTS.md#rules) | review only |
| A command fails by returning its error, and `execute` alone prints it | [CLI conventions](../../../docs/content/docs/contributing/cli.md#cli-conventions) | `TestExecuteShowsEachFailure`, and forbidigo's printing rule |
| Whatever a failure would leave registers a cleanup with `AddCleanup`, which gets a fresh context | [CLI conventions](../../../docs/content/docs/contributing/cli.md#cli-conventions) | review only |
| A VM's state changes through `state.VM.Update`, under its lock, taken in order | [The checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners), in its paragraph on `vm.json` | `TestLockOrder`, as test builds panic on a lock taken out of order, and forbidigo's `os.WriteFile` rule |
## The command line and messages
| Rule | Written in | Guard |
| --- | --- | --- |
| A new or changed command follows the cli skill's checklist, then its review | [the cli skill](../cli/SKILL.md) | the tests each of its rules names, and its review for the rest |
| Arguments and flag values are checked before anything runs, and a usage error exits with 2 | [Command arguments](../../../docs/content/docs/contributing/cli.md#command-arguments) | `TestUsageErrorsEveryCommand` |
| Every message is in `locales/en.toml`, called through its generated function, with its doc link | [Messages](../../../docs/content/docs/contributing/cli.md#messages) | `TestGeneratedFileIsCurrent`, `TestEveryMessageRenders`, `TestEveryMessageIsUsed` and `TestDocLinks` |
| Prose is never built with `fmt` | [Messages](../../../docs/content/docs/contributing/cli.md#messages) | review only |
| Every question declares what answers it | [Questions](../../../docs/content/docs/contributing/cli.md#questions) | `TestQuestionsDeclareAnswers` |
| Slow work runs under a status line, a `Status` with a label message or a `LoggedCmd` step, and none spans work that takes the terminal | [Status lines](../../../docs/content/docs/contributing/cli.md#status-lines) | the structure test's `status-lines` (`statusSites`), a lock's wait included, a test build's panic on a `nil` `Waiting` (`platform.CheckWaiting`), forbidigo's `syscall.Flock` rule, `TestLaunchStatusLines` and `TestCommandStatusLines` for the backend's calls, `TestVMLockWaits` and `TestCheckLayoutWaits` for the state's locks, `TestSSHAddOffStatusLine` for `ssh-add`, and `TestMessagesClearTheStatusLine`, `TestQuestionsHoldTheStatusLine`, `TestSecretAndPickerHoldTheStatusLine`, `TestTerminalHoldsTheStatusLine` and `TestStatusLinesNest` for the UI, while a caller's status line that `statusSites` names, a backend's methods in a command the tests don't run, and a wait's label are review only |
| Tests check which message and with what, never its wording | [Names mode](../../../docs/content/docs/contributing/cli.md#names-mode) | the CLI tests run in names mode unless a script turns it off, while a Go test is review only |
| Messages follow the docs voice, only shorter | [the docs-voice skill's Messages](../docs-voice/SKILL.md#messages) | review only, with its `scan.sh` |
## State and releases
| 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 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 |
## Backends
| Rule | Written in | Guard |
| --- | --- | --- |
| A backend implements `backend.Backend`'s four roles, declares `Caps` for every feature and returns its errors | [How a backend plugs in](../../../docs/content/docs/contributing/extending.md#how-a-backend-plugs-in) | `TestRegisterChecksCaps`, `TestCapsCheck`, the conformance suite (`TestConformance`, `TestConformanceFinds`) and the structure test's `guardOwner` |
| A missing feature fails, naming the VM and what to do, and never falls back silently | [How a backend plugs in](../../../docs/content/docs/contributing/extending.md#how-a-backend-plugs-in) | the registry's guard (`TestGuardRefuses`, `TestGuardRoles`) |
| Every emulation is refused until it's reviewed | [AGENTS.md's Backends](../../../AGENTS.md#backends) | `TestUnreviewedEgressRefused` and `TestUnreviewedLetThrough`, and the review itself is a design note, a threat check and end-to-end checks |
| Lima edits only what differs, in one edit | [AGENTS.md's Backends](../../../AGENTS.md#backends) | `TestStartEditsOnlyWhatDiffers`, `TestStartWantInOneEdit`, and the fixture scripts' launches without a Lima edit |
## Images, assets and scripts in the VM
| Rule | Written in | Guard |
| --- | --- | --- |
| An image's key hashes everything that goes into it, the backend included | [AGENTS.md's Rules](../../../AGENTS.md#rules) | `TestKeyChangesWithEachField`, while a new input that bypasses `image.Input` is review only |
| Every download in `assets/` is pinned and checked | [AGENTS.md's Rules](../../../AGENTS.md#rules) | `TestBumpCoversPins` checks that `scripts/bump.sh` moves every pin, and a review checks that each download has one |
| A script sources the prelude before it reads its variables | [One owner for each concern](../../../docs/content/docs/contributing/structure.md#one-owner-for-each-concern) | `TestPreludeUsers` |
| Scripts in the VM are bash 3.2-safe and shellcheck-clean | [AGENTS.md's Rules](../../../AGENTS.md#rules) | shellcheck in `mise run lint:code`, and `TestEmbeddedScripts` for scripts in Go strings, while bash 3.2 is review only |
| Shared tools stay read-only in VMs | [AGENTS.md's Rules](../../../AGENTS.md#rules) | the end-to-end `tools` section's checks that the share is read-only, even for root, while a write redirected elsewhere is review only |
| Credentials never go into images, the host's agent history never goes into VMs, and devvm's own files never get a shared copy on disk | [AGENTS.md's Rules](../../../AGENTS.md#rules) | review only |
| A new or changed shared tool updates its page and follows Contributing's checklist | [Adding a toolchain](../../../docs/content/docs/contributing/extending.md#adding-a-toolchain) and [Adding a coding agent](../../../docs/content/docs/contributing/extending.md#adding-a-coding-agent) | `TestToolchainsComplete`, `TestDefsComplete`, `TestSharedToolsPolicies` and `TestConfigTools` |
| No build script is JavaScript but the docs' `docs/render-diagrams.mjs`, and no npm package is installed outside mise's tools but its pinned pele | [AGENTS.md's Rules](../../../AGENTS.md#rules) | review only |
## Tests
| Rule | Written in | Guard |
| --- | --- | --- |
| New logic gets a Go table test and a CLI test | [Go test helpers](../../../docs/content/docs/contributing/tests.md#go-test-helpers) | the coverage baselines ([Coverage](../../../docs/content/docs/contributing/tests.md#coverage)) |
| Tests never touch the Keychain, real VMs or your folders | [Go test helpers](../../../docs/content/docs/contributing/tests.md#go-test-helpers) | `scripts/test.sh` gives the tests a throwaway `HOME`, and the CLI tests run in a sandbox against the stubs, and the rest is review only |
| Timeouts and lifecycles are tested in a synctest bubble | [Time and lifecycles](../../../docs/content/docs/contributing/tests.md#time-and-lifecycles) | review only ([Write tests that pass on any host](standards.md#write-tests-that-pass-on-any-host-at-any-load)) |
| A test runs git only through `stubtest.Git` | [Go test helpers](../../../docs/content/docs/contributing/tests.md#go-test-helpers) | the structure test |
| The tests pass in any time zone | [Any time zone](../../../docs/content/docs/contributing/testing.md#any-time-zone) | CI runs `mise run test` in UTC on macOS and with `TZ=America/Los_Angeles` on Linux |
| A change that touches VMs passes the end-to-end sections for what changed | [End-to-end tests](../../../docs/content/docs/contributing/tests.md#end-to-end-tests) | review only |
## Docs and commits
| Rule | Written in | Guard |
| --- | --- | --- |
| Every behavior change updates its page in the same change | [AGENTS.md's Rules](../../../AGENTS.md#rules) | review only |
| 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 |
@@ -0,0 +1,274 @@
# What reviews kept finding
Reviews of devvm's code found the same kinds of mistake again and again, in code that different people and agents wrote for different features. Each section here is one of them, written as the standard that would have prevented it: the rule, what the reviews found, sometimes a short pair of devvm's code that breaks the rule and code that keeps it, and what guards it. A guard that names a test means `mise run test` fails when that test's case breaks, and "review only" means the reviewer checks it by hand.
A standard applies where a change touches its ground, and judgment decides the rest. A change to how the CLI prints a table has no VM input to bound, and a refactor that keeps its tests passing needs no new failing test.
## Fail closed, on every path
A path that refuses, fails, falls back or tries again leaves things at least as strict as they were. A security step, such as a VM's confinement, its `.git` protection or a host check, sits on the one path that every start, retry and restart takes, rather than in each branch, so a new branch can't miss it. What a confined process reports about itself is checked against what devvm gave it, and when devvm can't tell whether something still holds, it stops the thing it can't vouch for and says so.
A weaker mode is fine when the user sees it, the docs describe it and the maintainers chose it. devvm warns and runs a VM's proxy without its sandbox on a host that has none, for example, rather than refusing to start. What's never fine is a fallback that nobody sees.
The reviews found this on the start's paths more than a dozen times. An export and rm's check of a `--clone` VM started it without the launch's `.git` check and network policy self-check, until both went through the launch's own start. The broker counted its own `SIGTERM` to a hung child as a failure of `sandbox-exec` and started the child again unconfined, and it took the confinement that a child's ready named, so a child it had started unconfined could report `full seatbelt`. A refused tier change could leave a looser proxy running.
Wrong, keeping a running VM's proxy whatever it enforces:
```go
if _, up := p.PID(vm); up && !touched {
p.Warn(msg.NetProxyKept(vm))
return c, err
}
return c, unproxied(ctx, p, b, vm, err)
```
Right, as `netpolicy.Proxy.PrepareRunning` has it, keeping it only while it enforces the state's tier and both of its processes run:
```go
if _, up := p.PID(vm); up && childProc(p, vm).Running() && !touched && enforcesNow(p, st) {
p.Warn(msg.NetProxyKept(vm))
return c, err
}
return c, unproxied(ctx, p, b, vm, err)
```
**Guard:** each refusal and fallback that exists has tests, such as `TestPrepareRunningRefused`, `TestStartChildSandbox`, `TestSandboxFailed` and `TestReadConfined`, and the backend registry's guard refuses a missing feature (`TestGuardRefuses`). A new path is review only.
## Bound what you don't control
Anything that a VM, the proxy's child, a peer on a socket or another process can make devvm read, hold, wait for or do again has a bound in size, in count and in time. The bound goes on what devvm reads and holds, never on the pattern that recognizes it, so a long value is still found. A listener whose bytes a VM controls has read and header timeouts and a cap on its connections, and a wait on something another process holds, such as a lock, gives up after a deadline and says so. Arithmetic on a size a VM gave checks for overflow.
The reviews found a rotation that read a sparse `proxy.log` whole into memory, a redaction that read one unended line from its start every second, locks that a child could hold for ever, and a password pattern given a length limit that then skipped a registry's long token. A writer that caps what it keeps must not embed its buffer, because `io.Copy`, as `os/exec` copies a command's output, then reads past the cap through the buffer's `ReadFrom`, as `bounded` in `internal/vm/bounded.go` explains.
Wrong, as the proxy once read a log to rotate it:
```go
data, err := os.ReadFile(r.path)
```
Right, as `internal/proxy/rotate.go` reads one, through its descriptor and no more than it keeps:
```go
from := copyFrom(r.fd, fi.Size(), 2*r.limit)
if err := copyAtomic(r.path+".1", io.NewSectionReader(r.fd, from, fi.Size()-from), 0o600); err != nil {
```
**Guard:** `safefile`'s reads and `fetch.ReadCapped` have their caps, `safefile.Walk` reads a folder in batches and stops at its bound on the entries it reads (`TestWalkBound`), where `fs.WalkDir` reads each folder whole first, the structure test's `read-limits` rule fails on an `io.ReadAll` outside tests whose reader isn't an `io.LimitReader` made in the call, unless `unboundedReads` lists its function with why, and tests keep the bounds that reviews found: `TestRotateCopiesAHugeLog`, `TestInLongLine`, `TestLongSecrets`, `TestRotateLockHeld`, `TestNixLockWaits`, `TestBounded`, and `FuzzBrokerFrames` and `FuzzFrameStreams` for the broker's frames. A new input is review only.
## Treat what a VM can write as hostile
A VM can write its project folder, its logs folder and the shared Nix cache, and it controls every byte it sends back. devvm reads all of it as an attacker's:
- **Files by descriptor.** A file in a folder that a VM can write is opened once, without following a link in any part of its path and without blocking on a FIFO, through `internal/safefile`, an `os.Root` or `proxy.OpenLog`, and checked to be a regular file with one link. From then on, devvm reads, writes, empties and changes it through that descriptor (`f.Truncate`, `f.Chmod`, `futimes`), never by its path again, because the VM can swap the name between two uses. A folder, such as the project folder, is checked by its identity rather than its path.
- **Checked against what it can't choose.** What a VM hands back is checked against a source the VM can't pick. The packages a build VM records are checked on the host against Ubuntu's signed archive lists, every pocket's included, and a cached package file is hashed again before devvm keeps it.
- **Escaped for where it goes.** Text from a VM is data. It's escaped for the format it's written into, such as a systemd unit, a plist, YAML or the ssh config, and control characters are refused or dropped (`msg.OneLine`, `msg.Printable`).
- **Nothing it can plant runs on the host.** Host tools run by absolute path, with a minimal environment, and without anything that a project's config can name, such as git's hooks, filters or `core.sshCommand` (`internal/hostgit`).
The reviews found devvm opening `proxy.log` again by its path at each start and emptying it by its path at each rotation, which would have followed a link a child left there into a file of yours, and a VM started on a project folder that was replaced after the finder found it. Host git once ran programs that a repo's config named.
Wrong, as the Nix cache once marked a file used, by its path:
```go
func touch(file string) {
now := time.Now()
_ = os.Chtimes(file, now, now)
}
```
Right, as `internal/proxy/nixcache.go` marks the file it opened (`touchFile` is `futimes` on macOS and `utimensat` with no path on Linux):
```go
func touch(f *os.File) { _ = touchFile(f, time.Now()) }
```
**Guard:** forbidigo refuses `os.Open`, `os.OpenFile`, `os.ReadFile` and `os.Root`'s openers in the files that the `safefile` row of [the checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners) lists, and forbidigo refuses `os.Chmod`, `os.Chtimes`, `os.Chown`, `os.Lchown` and `os.Truncate` in `internal/proxy`, `internal/vmlog` and `internal/vmssh`, but for a socket devvm has just made, with a `nolint` that says why. The child's seccomp filter on Linux refuses it a change by path (`TestSelf`). `TestOpenLogReplacesWhatIsPlanted`, `TestRotateCopiesWithoutItsPath`, `TestTrimNixCachePlanted`, `TestOneLineDropsInvisible` and `internal/hostgit`'s tests, such as `TestCommandNoHooks` and `TestCommandSSHOnly`, keep what reviews found, and the end-to-end `network` and `nix` sections plant links, FIFOs and hard links. A path-based change elsewhere is review only.
## Keep secrets and host data on the host
A secret never goes into a process's arguments, which any local user can read with `ps`, or into an environment that more than one process shares. It goes on standard input, into a file only you can read, or into the environment of the one child that needs it. A secret's value is a `redact.Secret`, revealed only where it's used ([Secrets in the code](../../../docs/content/docs/contributing/structure.md#secrets-in-the-code)).
What crosses into a VM is an allowlist: the fields devvm parsed and knows, never a whole file with the known secrets taken out. A log that a VM can drive goes through `internal/vmlog`, which caps and redacts it, or through the proxy's own rotating log, and a rotation masks the start of a secret its cut leaves (`redact.Unended`). Credentials never go into an image, and your agents' history never goes into a VM.
This was the most frequent security finding, about 15 times for secrets in arguments or a shared environment and about 11 for whole files sent to a VM. The VM's proxy password reached the guest through `limactl edit --set`, visible to `ps`, Codex and Claude Code VMs got every field of their login files rather than the ones devvm knows, and Lima's boot script, which runs under `set -x`, put the proxy password into the serial console log.
**Guard:** forbidigo refuses `Reveal` without a `nolint` that says why, `TestStartConfined` checks that the proxy's password is in no command's arguments and goes into the VM's `lima.yaml` instead, and `TestRotateCutSecret`, `TestUnended` and `FuzzSplit` keep the redaction. The end-to-end `network` section's `netNoLeaks` looks for each VM's proxy password and the section's tokens in every run log, proxy log and Lima log. A new argument, environment variable or file sent to a VM is review only.
## Parse once, with a real parser
A value is read with a real parser for its format, such as `BurntSushi/toml` for mise's lock or `net/netip` for an address, never with a regular expression or `strings.Split` over a format that has quoting or escapes. The function that checked a value is the one that reads it later, so the two can't disagree, and when devvm needs a tool's effective setting, it asks the tool rather than parsing its config again. A check of an address handles IPv6, and the IPv6 forms that carry an IPv4 address (`::ffff:`, NAT64 and 6to4), as `proxy.Public` does.
About 17 fixes came from this. Network policy files had a lenient reader in one place and a strict one in another, so a broken deny rule was skipped rather than refused. A ports value with a bad entry read as port 0, because one of several port parsers dropped `strconv.Atoi`'s error, until `backend.ParsePortRanges` became the only one. Transparent mode logged IPv6 connections as refusals, and a 6to4 address whose IPv4 address was private passed the proxy's floor as public.
**Guard:** each owner's parser has its table tests and often a fuzz target, such as `TestParsePortRanges`, `FuzzPublicHostSite` and `TestInternalOwn6to4`, and [the checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners) keep some readers in their owner. A new hand-rolled parser is review only.
## Never fail silently, and name the real cause
No error is dropped without a reason in a comment: not a `Wait`'s, not a parse's, not a `|| true` in a script. A loop that skips an item it can't handle says so, and a check whose output is empty or shorter than it should be fails rather than passing. An error that devvm turns into a message keeps its cause with `.Because(err)`.
Before a message names a cause, the code finds that cause. Errors that need different actions get different messages, and the advice in each one works in the state the user is in. A message that tells a user whose VM can't start to run devvm restart sends them in a circle.
The reviews found about 16 swallowed errors and about 17 messages that named the wrong cause. A shared tool that failed to mount was skipped with only a line on standard error, which no page described and nobody had chosen, so mise downloaded it into the VM instead. The proxy's floor, which refuses this machine's addresses, refused none when it read no addresses. A name the host couldn't resolve was blocked with "can't resolve it" whatever the cause, so a lookup cancelled because its client went away looked like a DNS failure.
**Guard:** errorlint, nilerr and nilnesserr catch some of it in the linters, and `TestExecuteShowsEachFailure` checks that a command's failure reaches the user. The structure test's `dropped-errors` rule fails on a `Wait`'s error or a `strconv` parse's assigned to `_` outside tests, unless `droppedErrors` lists its function with why. Any other error assigned to `_`, and a message's cause, are review only.
## Give every process an owner that ends it
Every process and goroutine devvm starts has an owner that bounds it and ends it: a context that cancels it, a `WaitDelay` for its pipes, a stopper that kills a half-started pipeline, and something that waits for it. An accept loop goes on after an error that leaves its listener open, through `daemon.AcceptRetry`, because a loop that returns at the first `EMFILE` leaves its port bound and dead, while `http.Server`'s `Serve` tries again itself.
The reviews found relays that outlived their forward and their link, and an ssh that a stuck relay held open. They also found the same accept loop written four ways, two of them returning at the first error, before `daemon.AcceptRetry` became its owner.
**Guard:** the structure test's `goroutines` rule lists every function that starts a goroutine with what waits for it, `leaktest.Main` and `leaktest.Check` fail on a goroutine that outlives its tests ([Goroutine leaks](../../../docs/content/docs/contributing/tests.md#goroutine-leaks)), and only `internal/daemon` and `internal/platform` signal a process by its pid (forbidigo). `TestAcceptRetry` and each loop's own test, such as `TestForwarderAcceptRetries`, keep the accept loops, and `TestProcStop` stops real processes. A process's bound is review only.
## Survive a kill and a second devvm
Assume the last run was killed at the worst moment, and that another devvm runs beside this one:
- **Killed runs.** A destructive step is ordered so that one good copy survives at every point, a "done" marker is written last, a file is written whole through `state.WriteFile`, and a cancelled or failed result is never cached.
- **Concurrent runs.** Two runs that change the same thing take an OS file lock (`platform`'s locks, `state.VM.Update`), and read the state again once they hold it. A lock is never a folder or a pid file, which a killed run leaves behind.
About 13 fixes each came from these. A second devvm took a remake that was still running for one that had stopped and finished it, and an undo that failed partway could leave the saved home deleted. The remake holds the VM's lock and reads its state again under it, and it deletes the saved home only after its record is gone. Two runs that pinned a VM's host keys at once could lose one's change to `known_hosts`, and retention's lock was a folder, which a crash left held.
**Guard:** forbidigo keeps whole-file writes in `internal/state`, and `TestLockOrder` panics in test builds on a lock taken out of order. The order of a destructive step is review only.
## Show what devvm waits for
Any work that can take noticeable time runs under the UI's status line, so the user sees what devvm waits for rather than a terminal that looks hung. Slow work is anything whose time devvm doesn't control: a host command, host git, a command in a VM, a backend's own commands, such as `limactl list` or `limactl --version`, a request over the network, a walk of a folder the user owns, a lookup of a folder's disk with `diskutil`, and a wait for a lock, a timeout or another process. A logged command shows its step on its own (`LoggedCmd`, a backend `Runner`'s `Run`), and the rest shows one with the Reporter's `Status`, its label a message in `locales/en.toml`. Status lines nest, so a phase can show one around steps that show their own. Work that takes the terminal never runs under one: a VM's shell, `ssh-add` asking for a passphrase, an agent's login in the VM.
The reviews found the newest commands' slow work all without one: devvm agent import walked and copied up to 128 MiB and ran git on each marketplace's config, devvm ls looked up each folder's disk after Lima's list, and devvm doctor read every VM's state, each with nothing on the screen. They also found the status line itself drawing over what devvm said: a warning landed on its line, and its redraw erased a question's prompt.
Wrong, as devvm ls read the VMs, Lima's list and a `diskutil` for each folder with nothing on the screen:
```go
inv, err := vm.ReadInventory(cmd.Context(), env.Dirs, env.Registry, vm.AllBackends)
```
Right, as `vm.ListAll` has it, under one status line that its steps' own lines nest in:
```go
defer e.Status(msg.ReadingVMs())()
inv, err := ReadInventory(ctx, e.Dirs, e.Registry, AllBackends)
```
A test records the label rather than a terminal: a `msg.Fake` gives each label to its `OnStatus`, and `Showing` is the one showing, so a seam the slow work goes through records what showed meanwhile, as `TestAgentImportStatus` does:
```go
im.Opencode = func(context.Context, ...string) ([]byte, error) {
m, _ := im.fake.Showing()
during = append(during, "opencode: "+m.ID())
return nil, exec.ErrNotFound
}
```
**Guard:** the structure test's `status-lines` rule fails on a function that makes a host command, runs host git, walks a folder, looks up a volume, makes a request through `internal/fetch`, waits for a lock whose `platform.Waiting` is `nil` or `platform.NoWait`, which show nothing while another devvm holds it, or runs a backend's command outside a step with no status line of its own, unless `statusSites` lists it with why, such as the caller's status line it runs under. A test build's locks panic on a `nil` `Waiting` at run time (`platform.CheckWaiting`), and forbidigo refuses a raw `syscall.Flock` outside `internal/platform`. `TestLaunchStatusLines` fails on a backend call that a launch makes with no status line showing, `TestCommandStatusLines` on one that the other commands on a VM make, its setters included, `TestVMLockWaits`, `TestCheckLayoutWaits` and each lock's own test, such as `TestGitLockWaits`, `TestImageLocksWait`, `TestPinOriginWaits`, `TestYoursLockWaits` and `TestForwardsLockWaits`, on a wait with no label or the wrong one, `TestSSHAddOffStatusLine` on an `ssh-add` under one, and `TestMessagesClearTheStatusLine`, `TestQuestionsHoldTheStatusLine`, `TestSecretAndPickerHoldTheStatusLine`, `TestTerminalHoldsTheStatusLine` and `TestStatusLinesNest` keep the status line off what devvm says and asks. That a caller's status line covers a listed call, a backend's methods in a command the tests don't run, and a wait's label are review only.
## Extend the owner, and wait for a third copy
Before adding a helper, a parser, a path, a file reader, a constant, a limit, a message or a table, find its owner and extend it, as [One owner for each concern](../../../docs/content/docs/contributing/structure.md#one-owner-for-each-concern) says. When the owner is out of reach, as most packages are for the proxy, move the owner to a package both can import.
An owner that exists is always extended. Code that has no owner yet is different: a second copy of it is a judgment call, because a copy can be cheaper than the wrong shared helper, so wait for a third before extracting one. The exception is a copy of a judge, such as what counts as a public address or the one form of a host, because two judges that drift apart let through what one of them refuses. Those get one owner at once, and a forbidigo rule or a structure-test check where the check can be exact.
The reviews found hosts read by hand in five packages besides the proxy, each lowercasing and trimming a dot in its own way, so a deny rule and the check it guarded could read one host as two, and `--from`'s registries judged public by a copy of `proxy.Public`.
Wrong, as `netpolicy.RiskOf` once read a host:
```go
host = strings.ToLower(strings.TrimSuffix(host, "."))
```
Right, in the one form that every judge of a host compares:
```go
h := proxy.NormHost(given)
```
**Guard:** the structure test's owner checks and the forbidigo rules in [the checks on owners](../../../docs/content/docs/contributing/structure.md#the-checks-on-owners), with `TestOwnersDoc` and `TestOwnersAgree` keeping that table current. Any other copy is review only, in [the consolidation pass](../../../docs/content/docs/contributing/structure.md#the-consolidation-pass) before a release.
## Mind what's already running and released
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 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 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.
## Claim only what the code does, where precision belongs
The How it works pages, Staying safe, Contributing, the CHANGELOG, comments, commit messages and messages say what the code does, with its limits. A guarantee with "never", "only", "every" or "no" holds on every path, or it names the paths where it doesn't. Before a commit, check each claim the change makes, and each existing claim about the code it changed, against that code.
The README, the home page and Getting started keep their short headline claims, such as "ready in seconds" or "reach only the hosts you allow", without qualifiers. A wrong fact gets fixed everywhere, but the precision goes on the safety and How it works pages, which those pages link to.
Nearly every review found an overclaim on a precise page. The docs of an IPv6 fix said that every lookup in a confined VM with transparent mode off waits 35 to 40 seconds on a Linux host, from one tool's behavior. An end-to-end run on Fedora showed `getent` failing within 3 seconds and curl at once, and only workerd under wrangler dev waiting about 40 seconds.
Wrong, from one case:
```markdown
every lookup waits 35 to 40 seconds on a Linux host
```
Right, as the measurement showed:
```markdown
most tools fail at once on macOS and Linux alike, and a few, such as workerd under wrangler dev, can wait about 40 seconds on a Linux host
```
**Guard:** `TestCommandLines` checks every devvm command line in the repo, `TestDocLinks` the messages' doc links, lychee the docs' links and `TestReferenceIsCurrent` the CLI reference, and the docs-voice skill's `facts.sh` checks that a rewrite kept every fact. Whether a claim is true is review only.
## Prove each fix with a test that fails without it
A fix lands with a test that fails without it: revert the fix, or break the code it guards, watch the test fail, then put the fix back. Code that has no test gets one that pins its current behavior before it changes. When a change breaks an assertion, either the change is wrong or the commit says why the assertion changed, and an assertion is never loosened to make a test pass.
- **The oracle comes from outside the code under test:** the specification, a frozen copy of the old behavior, a list written by hand from the source, or the real program, never the code's own table or logic, which agrees with any bug.
- **An absence check has a control** that shows the probe can find what it looks for, such as the guest's own environment holding the token that `ps` must not show.
- **A security boundary is proven by attacking it.** A change to a sandbox, such as the proxy child's Seatbelt profile, its Landlock rules or its seccomp filter, is tested by a process under the real sandbox that tries what an attacker would, and other ways to the same thing, rather than by reading the rules back. The change also gets a threat check with the security-audit skill.
The reviews found tests that still passed with their fix reverted, expected values taken from the function under test, and absence checks that couldn't have found anything. The Landlock filter took three rounds of review, because each attack found a call the filter allowed, such as `prlimit64` setting another process's CPU limit.
Wrong, an oracle that is the code's own list:
```go
if got := SSHPorts(); !slices.Equal(got, sshPorts) {
```
Right, as `TestSSHPorts` builds its own from the Fetch standard's list and Chromium's gaps:
```go
want := slices.DeleteFunc(slices.Clone(fetch), func(n int) bool { return n < 1024 || slices.Contains(chromiumGaps, n) })
if got := SSHPorts(); !slices.Equal(got, want) || len(got) != 17 {
```
**Guard:** the coverage baselines fail `mise run test` when a package's coverage falls ([Coverage](../../../docs/content/docs/contributing/tests.md#coverage)), and `TestSelf` and `TestChildProfileConfines` attack the proxy child's sandboxes. That a test fails without its fix, and where its oracle comes from, are review only.
## Write tests that pass on any host, at any load
A test passes on a loaded Linux CI runner, on a Mac in another time zone, and under `git rebase --exec`, as it does on your machine:
- **Off the real clock.** A test of a timeout, a grace or a close runs in a `testing/synctest` bubble on stand-ins in memory ([Time and lifecycles](../../../docs/content/docs/contributing/tests.md#time-and-lifecycles)). A test that must use the real clock waits for the event, an absence included, rather than for a duration, and fails at once when what it waits on has exited.
- **No assumptions about the host.** A test brings its own git config (`stubtest.Git`), time zone, ports from its sandbox's block and temp folders, and it doesn't assume Linux or macOS, the number of CPUs, or GNU or BSD tools.
- **Stubs behave like the real tool.** A stub or fake is held to the real tool by a contract test or by golden output from the real tool, as the backend conformance suite holds the fake backend, the limactl stub and real Lima to one set of cases.
- **Stress what's timing-sensitive.** A test whose result depends on timing or order passes `go test -race -count=20` on a loaded Linux host before it counts as done, and a test that opens many connections has a cap and runs on a test host rather than your own machine.
Tests that assumed their host failed about 25 times, on a machine's git-lfs or system git config, a time zone, a BSD tool's flags or a CPU count. The broker's start tests failed on loaded Linux hosts, because hashing the test binary took most of the 4 seconds a start waits, and a reviewer's flood test used up a Mac's local ports and broke every ssh to the test hosts.
Wrong, sleeping out a grace on the real clock with a margin:
```go
time.Sleep(grace + time.Second)
if !fired.Load() {
```
Right, as `TestGraceTimer` checks the moment itself:
```go
synctest.Test(t, func(t *testing.T) {
var fired atomic.Bool
g := newGraceTimer(grace, func() { fired.Store(true) })
tc.steps(g)
time.Sleep(grace - time.Nanosecond)
synctest.Wait()
if fired.Load() {
```
**Guard:** the structure test checks that a test runs git only through `stubtest.Git`, CI runs the tests in UTC on macOS and with `TZ=America/Los_Angeles` on Linux ([Any time zone](../../../docs/content/docs/contributing/testing.md#any-time-zone)), each CLI test's sandbox holds a block of ports, and `TestConformance` runs the backend conformance suite on the limactl stub and on real Lima's instances, while `TestConformanceFinds` checks that the suite fails a backend that breaks it. A real-clock test, the stress run and a flood's cap are review only.
+43 -2
View File
@@ -17,9 +17,50 @@ 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
The user pages, in Getting started, Using devvm, Staying safe, Backends and Compared (`getting-started/`, `using/`, `safety/`, `backends/` and `compared/`), are where readers go to get something done or to learn what they can rely on, so each section there that has a task starts with what to type: a copyable command block, or a numbered list of steps, with a comment on each line that says what it does. Explanation follows, and it stays short.
- **One paragraph is fine.** A paragraph that says why, next to the command it's about, is good, and so is one that gives the details a reader needs while doing the task, such as a limit, a question devvm asks or the flag that answers it.
- **The target is paragraphs back to back.** Two or more prose paragraphs with no command, list, table or callout between them are the sign that mechanism has crept in. Split them with the command each one describes, turn parallel facts into a short list, or move the mechanism to its How it works page.
- **Move mechanism, don't delete it.** How devvm does something, such as what it checks, in what order, and why an attack fails, goes to its How it works page in `internals/`, under a heading that a link from the user page names. Leave a sentence that says what the reader gets and links there.
- **Keep every fact.** A move is a cut and a paste, not a summary. Run `facts.sh --all REV` after a move, so a fact that went to another page doesn't show as removed, and add the heading on the How it works page first if it doesn't exist.
- **Lists for parallel facts only.** A list of modes, refusals, limits or what a command keeps is easier to scan than a paragraph. Facts that build on each other stay prose, as [Bold-label bullets](tropes.md#bold-label-bullets-boldlabel) says.
`scan.sh -p paras FILE` lists each run of paragraphs, two or more on a user page and three or more in `internals/` and `contributing/`, with each paragraph's words, its line and its heading. A paragraph of 40 words or fewer that ends with a colon doesn't count, because it introduces the block after it. `scan.sh -p long FILE` lists each paragraph or list item over 80 words or 4 sentences. A run or a long paragraph is a candidate, not an error: leave one that a reader needs in one piece, such as a warning and the action that follows it. `mise run lint:docs` fails on the worst of them on a user page: a run of three or more paragraphs where two are over 80 words, and a paragraph or list item over 150 words.
Before, from Troubleshooting's A command fails (five paragraphs in a row, abridged):
> devvm prints its own steps, and it sends the output of the commands it runs to a log instead of the terminal. When a step fails, devvm prints the end of the log.
>
> To see the commands' output as they run, add `-v` or `--verbose` to any command, as in `devvm -v build base` or `devvm -v`. devvm then shows each line on standard error … and devvm drops the control characters a command prints …
>
> Each run that runs a command has one log, `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log` … A command that devvm runs in a VM adds at most 4 MiB of output to the log … A VM's proxy key and the build proxy's password are written as `devvm:<key>@` …
>
> Lima keeps a log of its own for each VM, `ha.stderr.log` … devvm replaces each password there with as many `*` …
>
> In a terminal and without `-v`, a status line shows the step, how long it has run, and the log's latest line …
After:
> devvm prints its own steps and sends the output of the commands it runs to a log, and when a step fails, it prints the end of that log. To watch the output as it runs, add `-v`:
>
> ```sh
> 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 when a step fails it names the log instead of printing its end again. Without `-v`, a status line in a terminal shows the step, 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.
>
> - **The log** is `~/.local/share/devvm/logs/runs/<date>-<time>-<pid>.log`, one for each run, which only you can read, and devvm keeps the newest 20.
> - **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`, and How it works would have the rest.
The rest would move to a new The run log section on How it works' Overview, which the after version links to: the 4 MiB cap on a VM command's output and the `devvm: truncated` line, the build proxy's password, a proxy address without a scheme, passwords written in pieces, the VM's setup and a `devcontainer.json`'s commands being covered, `-v` showing the log's own lines with control characters dropped, and Lima's `ha.stderr.log`, where devvm replaces each password with as many `*`, warns when it can't and lets you delete the file.
## Scope
All prose in the repo:
@@ -28,7 +69,7 @@ All prose in the repo:
- The command help that generates those CLI pages: `Short` and `Long` in `internal/cli/*.go`. Run `mise run cli-docs` after editing them.
- `README.md`, `SECURITY.md`, `CONTRIBUTING.md`, `assets/oci/README.md` and `internal/proxy/README.md`.
- The messages in `locales/en.toml`, which also follow the [Messages](#messages) rules below.
- The cli skill, `.agents/skills/cli/`.
- The cli skill, `.agents/skills/cli/`, and the codebase-standards skill, `.agents/skills/codebase-standards/`.
These follow their own rules and are out of scope:
+75 -1
View File
@@ -7,6 +7,12 @@
# scan.sh -v FILE... each hit: file:line: [pattern] the line as written
# scan.sh -p NAME FILE.. -v for one pattern only
#
# paras counts runs of prose paragraphs back to back, two or more on a user
# page and three or more in internals/ or contributing/, and long counts
# paragraphs and list items over 80 words or 4 sentences. -v, -p paras and
# -p long show each with its words. A colon-ended paragraph of 40 words or
# fewer introduces the block after it, so it doesn't count in a run.
#
# A .toml file is scanned as messages (locales/en.toml): only the other and
# one strings, with their {{.fields}} read as code spans. -v shows each hit's
# message ID, and -m REGEX scans only the messages whose ID matches.
@@ -28,7 +34,7 @@ while [ $# -gt 0 ]; do
shift
;;
-h | --help)
sed -n '2,12s/^# \{0,1\}//p' "$0"
sed -n '2,18s/^# \{0,1\}//p' "$0"
exit 0
;;
--) shift && break ;;
@@ -131,6 +137,61 @@ shown() { # file line
fi
}
# The paragraphs of one file, for paras or long (what), one per line.
# paras: each run of prose paragraphs, as its first line, the count, each
# paragraph's words joined with + and the heading above it; a user page's runs
# start at two paragraphs, any other page's at three. long: each paragraph or
# list item over 80 words or 4 sentences, as its line, words, sentences and
# heading. Code fences, lists, tables, callouts, shortcodes, HTML and headings
# end a run, and a line that is only an HTML comment neither counts nor ends
# one. A paragraph of at most 40 words whose last line ends with a colon
# introduces the next block, so it doesn't count in a run.
paras() { # file what
local min=2
case $1 in */internals/* | */contributing/*) min=3 ;; esac
awk -v what="$2" -v min="$min" '
function flush() {
if (what == "paras" && n >= min) printf "%d\t%d\t%s\t%s\n", start, n, sizes, head
n = 0
sizes = ""
}
function endblock( t, w, s) {
if (kind != "") {
t = text
gsub(/`[^`]*`/, "x", t)
gsub(/\]\([^)]*\)/, "]", t)
w = split(t, _, /[[:space:]]+/)
if (t ~ /^[[:space:]]/) w--
s = gsub(/[a-z0-9)x*][.!?]([[:space:]]|$)/, "&", t)
if (what == "long" && kind != "o" && (w > 80 || s > 4))
printf "%d\t%d\t%d\t%s\n", from, w, s, head
if (kind == "p" && !(last ~ /:[[:space:]]*$/ && w <= 40)) {
if (n == 0) start = from
n++
sizes = sizes (sizes == "" ? "" : "+") w
}
}
kind = ""
text = ""
}
function block(k) { endblock(); kind = k; from = NR; text = $0; last = $0 }
BEGIN { head = "(no heading)" }
NR == 1 && /^---$/ { front = 1; next }
front { if (/^---$/) front = 0; next }
/^[[:space:]]*(```|~~~)/ { endblock(); flush(); fence = !fence; next }
fence { next }
/^[[:space:]]*<!--.*-->[[:space:]]*$/ { next }
/^[[:space:]]*$/ { endblock(); next }
/^[[:space:]]*([-*+]|[0-9]+\.)[[:space:]]/ { block("l"); flush(); next }
kind == "p" || kind == "l" { text = text " " $0; last = $0; next }
kind == "o" { next }
/^#/ { endblock(); flush(); head = $0; next }
/^[[:space:]]*[|><]/ || /^[[:space:]]*\{\{/ { block("o"); flush(); next }
/^[[:space:]]+[^[:space:]]/ { block("l"); flush(); next }
{ block("p") }
END { endblock(); flush() }' "$1"
}
hits() { # flags regex: matching lines (-n) or matches (-o) from stdin
local flags=$1 re=$2 mode=$3 opts=-E
case $flags in *w*) opts="$opts -w" ;; esac
@@ -144,6 +205,7 @@ if [ "$verbose" = 0 ]; then
while IFS=' ' read -r name _ _; do printf ' %5.5s' "$name"; done <<EOF
$patterns
EOF
[ "$mode" = toml ] || printf ' %5s %5s' paras long
printf '\n'
fi
@@ -159,6 +221,16 @@ for f in "$@"; do
done <<EOF
$patterns
EOF
if [ "$mode" = md ] && { [ -z "$only" ] || [ "$only" = paras ]; }; then
paras "$f" paras | while IFS=' ' read -r n count sizes head; do
printf '%s:%s: [paras] %s paragraphs (%s words) under %s\n' "$f" "$n" "$count" "$sizes" "$head"
done
fi
if [ "$mode" = md ] && { [ -z "$only" ] || [ "$only" = long ]; }; then
paras "$f" long | while IFS=' ' read -r n words sents head; do
printf '%s:%s: [long] %s words, %s sentences under %s\n' "$f" "$n" "$words" "$sents" "$head"
done
fi
continue
fi
words=$(printf '%s\n' "$text" | wc -w | tr -d ' ')
@@ -169,5 +241,7 @@ EOF
done <<EOF
$patterns
EOF
[ "$mode" = toml ] || printf ' %5s %5s' "$(paras "$f" paras | wc -l | tr -d ' ')" \
"$(paras "$f" long | wc -l | tr -d ' ')"
printf '\n'
done
+3 -2
View File
@@ -1,6 +1,7 @@
# Monthly updates, each ecosystem in one grouped pull request, for devvm's Go modules and the actions its workflows pin by SHA. Their titles follow
# Conventional Commits, as the PR title check asks. Pinned downloads in assets/, the shared tools' lock
# and the e2e pins are bumped with scripts/bump.sh, which Dependabot doesn't know.
# Conventional Commits, as the PR title check asks. scripts/bump.sh moves these too, and every pin
# Dependabot doesn't know, and holds each module or action as an ignore entry below does: keep each
# one's dependency-name line followed by a versions: [">= X"] line, the form it reads.
version: 2
updates:
- package-ecosystem: gomod
+130 -7
View File
@@ -26,25 +26,148 @@ concurrency:
jobs:
check:
# The tests run in UTC, then again on Linux in a zone with DST, so a
# test that depends on the zone fails here, not only on a laptop.
# The tests run on macOS in UTC and on Linux in a zone with DST, so a
# test that depends on the zone fails here, not only on a laptop. Lint
# runs on both, because golangci-lint checks only the files built for
# the runner's OS, such as internal/platform's *_darwin.go or *_linux.go.
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, tz: UTC }
- { os: macos-latest, tz: UTC }
- { os: ubuntu-latest, tz: America/Los_Angeles }
- { os: macos-latest, tz: UTC }
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
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.
- name: Cache npm downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('docs/package-lock.json') }}
- run: mise run lint
if: matrix.tz == 'UTC'
- run: mise run test
env:
TZ: ${{ matrix.tz }}
# Its own job, so a newly published vulnerability fails this check alone,
# and lint and test still report. The Vulnerabilities workflow scans main
# and the releases' binaries each week.
vuln:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Only Go and govulncheck, cached apart from the check jobs' full set.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
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.
- run: mise run vuln
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
# child of the confinement's own tests confines itself on the runner's
# kernel, Landlock and the seccomp filter, and is refused what it must
# be. (The CLI tests' devvm is built without cgo in the check jobs too.)
nocgo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Only Go, cached apart from the check jobs' full set.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.11.14
install_args: go
cache_key_prefix: mise-v1-nocgo
- run: go test -count=1 ./internal/landlock/... ./internal/proxy/...
env:
CGO_ENABLED: "0"
# Advisory: nilaway's findings include false positives, so they never fail
# CI. A finding testdata/nilaway-baseline.txt hasn't triaged is a warning
# on the run, and the run's summary lists the new ones, then every
# finding. The job fails only when the check itself breaks (nilaway
# can't run, its output can't be read, a stale baseline line), and that
# blocks nothing either.
nilaway:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Only Go and nilaway, cached apart from the other jobs' tools.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
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
# otherwise non-zero when nilaway couldn't run, its output couldn't be
# read or a baseline line is stale: the job fails then, after the
# summary.
- name: Run nilaway
env:
MISE_TASK_RUN_AUTO_INSTALL: "false"
run: |
set -uo pipefail
out=$RUNNER_TEMP/nilaway.txt
mise run nilaway 2>&1 | tee "$out"
status=${PIPESTATUS[0]}
n=$(grep -c '^new: ' "$out" || true)
{
echo "## nilaway: $n new findings"
echo
echo "A new finding needs triage: see [Nil checks](https://next.devvm.dev/docs/contributing/#nil-checks)."
echo
# Four backticks: nilaway's own backticks can't end the block.
echo '````'
grep -E '^(new|stale): |^nilaway: ' "$out" || echo "none"
echo '````'
echo
echo "Every finding, the triaged ones included:"
echo
echo '````'
cat "$out"
echo '````'
} >> "$GITHUB_STEP_SUMMARY"
if (( n > 0 )); then
echo "::warning title=nilaway::$n new possible nil dereferences: see the run's summary"
fi
if (( status != 0 && status != 3 )); then
echo "nilaway's check failed with status $status: see the run's summary" >&2
exit "$status"
fi
+40 -9
View File
@@ -57,12 +57,13 @@ jobs:
persist-credentials: false
# Full history, for each page's last updated date.
fetch-depth: 0
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
install_args: go hugo-extended node markdownlint-cli2 vale lychee
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
# It draws the diagrams first (docs:diagrams), which the build below uses too.
- run: mise run lint:docs
# The site's address is baseURL in docs/hugo.yaml.
- run: hugo -s docs --minify
@@ -88,12 +89,14 @@ jobs:
with:
persist-credentials: false
fetch-depth: 0
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
install_args: go hugo-extended
version: 2026.11.14
install_args: go hugo node
# What's published is built from no cache.
cache: false
# The diagrams, drawn before the build (docs/render-diagrams.mjs).
- run: mise run docs:diagrams
# docs/next.yaml over docs/hugo.yaml: next.devvm.dev's address, the banner and noindex.
- run: hugo -s docs --minify --config hugo.yaml,next.yaml -d "$RUNNER_TEMP/next"
# The key is checked out only after the build, which never sees it.
@@ -127,6 +130,10 @@ jobs:
(github.event_name == 'release' && !github.event.release.prerelease) ||
(github.event_name == 'workflow_dispatch' && inputs.site == 'devvm.dev')
runs-on: ubuntu-latest
env:
# Only the tools the install step picks: mise run and a shim would otherwise install every
# tool in the tag's mise.toml, and a tool it missed fails the build rather than downloads.
MISE_AUTO_INSTALL: "false"
steps:
- id: tag
name: The release's tag
@@ -154,12 +161,36 @@ jobs:
persist-credentials: false
# Full history, for each page's last updated date.
fetch-depth: 0
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
install_args: go hugo-extended
version: 2026.11.14
# The next step installs only what the build needs.
install: false
# What's published is built from no cache.
cache: false
# Only what the build needs, at the versions of the tag's own mise.toml, as mise reads it: Go,
# for Hugo's modules, Hugo by the name the tag gives it (hugo-extended in a tag from before Hugo
# 0.170), and Node when the tag draws its diagrams.
- run: |
want='^(go|hugo|hugo-extended)$'
if [ -f docs/render-diagrams.mjs ]; then
want='^(go|hugo|hugo-extended|node)$'
fi
mapfile -t tools < <(mise ls --current --json |
jq -r --arg f "$(pwd -P)/mise.toml" 'to_entries[] | select(any(.value[]; .source.path == $f)) | .key' |
grep -E "$want")
if ! printf '%s\n' "${tools[@]}" | grep -qE '^hugo(-extended)?$'; then
echo "::error::The tag's mise.toml names no Hugo."
exit 1
fi
# --locked, as mise-action adds where the tag has a mise.lock: every download from the lock.
mise install --locked "${tools[@]}"
# The tag's diagrams, drawn before the build, when its docs draw them (docs/render-diagrams.mjs);
# an older tag's pages load Mermaid instead.
- run: |
if [ -f docs/render-diagrams.mjs ]; then
mise run docs:diagrams
fi
# The tag's docs/hugo.yaml, whose baseURL is devvm.dev.
- run: hugo -s docs --minify
- uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
+2 -2
View File
@@ -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@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
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
+150 -14
View File
@@ -1,11 +1,16 @@
name: Fuzz
# go test runs only each fuzz target's seeds; this runs every target for a
# few minutes a week. The list is read from the tests, so a new target is
# fuzzed without editing this file.
# go test runs only each fuzz target's seeds; this fuzzes every target for
# five minutes each night, starting from the inputs its earlier nights found
# (its corpus, which a cache keeps). The list is read from the tests, so a
# new target is fuzzed without editing this file. The targets that fail go in
# one open issue, which closes once a night's targets all pass: a failing
# input is kept in its target's corpus, so it fails again each night until
# the code is fixed. The fuzz jobs have only read access; the issue job,
# which can write issues, runs no code of the repo's.
on:
schedule:
- cron: "17 6 * * 1"
- cron: "17 3 * * *"
workflow_dispatch:
permissions:
@@ -18,13 +23,17 @@ concurrency:
jobs:
targets:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
matrix: ${{ steps.list.outputs.matrix }}
count: ${{ steps.list.outputs.count }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Each target as {"pkg","name"}, the proxy's first.
# Each target as {"pkg","name"}, the proxy's first. A name is a
# target's alone, as its artifacts and its line in the issue are
# named by it.
- id: list
run: |
set -euo pipefail
@@ -32,34 +41,161 @@ jobs:
| sed -E 's#^(.*)/[^/]*:func (Fuzz[A-Za-z0-9_]*)$#\1 \2#' \
| sort -u | awk '{print ($1 ~ /^internal\/proxy$/ ? 0 : 1), $0}' | sort -k1,1n -k2 | cut -d' ' -f2-)
test -n "$lines"
dup=$(printf '%s\n' "$lines" | cut -d' ' -f2 | sort | uniq -d)
if [[ -n $dup ]]; then
echo "fuzz targets of one name in two packages: $dup" >&2
exit 1
fi
matrix=$(printf '%s\n' "$lines" | awk 'BEGIN{printf "["} {if (NR>1) printf ","; printf "{\"pkg\":\"./%s\",\"name\":\"%s\"}", $1, $2} END{printf "]"}')
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
echo "count=$(printf '%s\n' "$lines" | wc -l)" >> "$GITHUB_OUTPUT"
fuzz:
needs: targets
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
max-parallel: 4
max-parallel: 8
matrix:
target: ${{ fromJSON(needs.targets.outputs.matrix) }}
name: ${{ matrix.target.name }}
env:
NAME: ${{ matrix.target.name }}
PKG: ${{ matrix.target.pkg }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: jdx/mise-action@6be3c7ed4c21d4f76b208d351d95aac273ebb76d # v5.2.4
# Only Go, cached apart from the other workflows' tools.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.10.18
- run: go test -run '^$' -fuzz "^${NAME}\$" -fuzztime 2m "$PKG"
env:
NAME: ${{ matrix.target.name }}
PKG: ${{ matrix.target.pkg }}
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
# package's import path and the target's name.
- id: corpus
run: |
set -euo pipefail
dir="$(go env GOCACHE)/fuzz/$(go list "$PKG")/$NAME"
echo "dir=$dir" >> "$GITHUB_OUTPUT"
echo "key=fuzz-${PKG#./}-$NAME" >> "$GITHUB_OUTPUT"
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.corpus.outputs.dir }}
key: ${{ steps.corpus.outputs.key }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: ${{ steps.corpus.outputs.key }}-
# Each new input is minimized in at most 1,000 runs: by time, a
# target whose runs write files, such as FuzzUnpack, spends its five
# minutes minimizing.
- id: fuzz
run: go test -run '^$' -fuzz "^${NAME}\$" -fuzztime 5m -fuzzminimizetime 1000x "$PKG"
# A failing input lands in the package's testdata/fuzz/<target>/;
# committed there, go test runs it as a seed.
- if: failure()
# committed there, go test runs it as a seed. It goes in the corpus
# too, so the next night starts with it and fails until it's fixed.
- if: failure() && steps.fuzz.outcome == 'failure'
env:
DIR: ${{ steps.corpus.outputs.dir }}
run: |
set -euo pipefail
shopt -s nullglob
mkdir -p "$DIR"
for f in "$PKG/testdata/fuzz/$NAME"/*; do
cp "$f" "$DIR/"
done
- if: failure() && steps.fuzz.outcome == 'failure'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: crash-${{ matrix.target.name }}
path: ${{ matrix.target.pkg }}/testdata/fuzz/${{ matrix.target.name }}/
if-no-files-found: ignore
# Saved whatever the night found, a failure included.
- if: always() && steps.corpus.outputs.dir != ''
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.corpus.outputs.dir }}
key: ${{ steps.corpus.outputs.key }}-${{ github.run_id }}-${{ github.run_attempt }}
# The target's line for the issue job: its package, its name and how
# its run ended.
- if: always()
env:
OUTCOME: ${{ steps.fuzz.outcome }}
run: |
set -euo pipefail
mkdir -p "$RUNNER_TEMP/result"
echo "$PKG $NAME $OUTCOME" > "$RUNNER_TEMP/result/$NAME.txt"
- if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: result-${{ matrix.target.name }}
path: ${{ runner.temp }}/result/
if-no-files-found: error
retention-days: 7
# Only main's run reports, so a run started on another branch never
# closes the issue as main's.
issue:
needs: [targets, fuzz]
if: always() && github.ref == 'refs/heads/main' && needs.targets.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write # to open, update and close the one issue of the failing targets
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: result-*
merge-multiple: true
path: ${{ runner.temp }}/results
- name: Open, update or close the issue
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
COUNT: ${{ needs.targets.outputs.count }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
shopt -s nullglob
title="Fuzzing found failing inputs"
# Each target's line, with only the characters a package path, a
# target's name and an outcome have.
files=("$RUNNER_TEMP"/results/*.txt)
cat ${files[@]+"${files[@]}"} /dev/null | LC_ALL=C tr -cd '0-9A-Za-z._/ \n-' > "$RUNNER_TEMP/all.txt"
awk '$3 != "success" { print "- `" $2 "` in `" $1 "`: " $3 }' "$RUNNER_TEMP/all.txt" | sort > "$RUNNER_TEMP/failed.txt"
# A target whose job reported nothing failed too.
reported=$(wc -l < "$RUNNER_TEMP/all.txt")
if (( reported < COUNT )); then
echo "- $((COUNT - reported)) targets didn't report" >> "$RUNNER_TEMP/failed.txt"
fi
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/failed.txt ]]; then
if [[ -n $number ]]; then
gh issue close "$number" --comment "Every fuzz target passed tonight, its failing inputs included: $RUN_URL"
fi
exit 0
fi
{
echo "The nightly fuzzing found inputs that fail these targets:"
echo
cat "$RUNNER_TEMP/failed.txt"
echo
echo "The run, with each failing input as an artifact named \`crash-<target>\`: $RUN_URL"
echo
echo "Put each input in its package's \`testdata/fuzz/<target>/\` folder, fix the code, and commit both."
echo "The input stays in the target's corpus, so it fails each night until the fix is on main,"
echo "and this issue closes on the first night every target passes:"
echo "see [Fuzzing](https://next.devvm.dev/docs/contributing/testing/#fuzzing)."
} > "$RUNNER_TEMP/body.md"
if [[ -z $number ]]; then
gh issue create --title "$title" --label bug --body-file "$RUNNER_TEMP/body.md"
exit 0
fi
# A night's new failures get a comment, which notifies; the same
# targets failing again only update the run's link.
gh issue view "$number" --json body --jq .body | tr -d '\r' > "$RUNNER_TEMP/old.md"
if ! grep '^- ' "$RUNNER_TEMP/old.md" | cmp -s - "$RUNNER_TEMP/failed.txt"; then
gh issue comment "$number" --body "The failing targets changed: the description lists tonight's."
fi
gh issue edit "$number" --body-file "$RUNNER_TEMP/body.md"
+54 -14
View File
@@ -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"
@@ -25,7 +26,19 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# mise for the dev tools' newest versions; no tools, as nothing builds.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.11.14
install: false
cache: false
- name: Check the pins
# 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 }}
run: |
set -euo pipefail
scripts/bump.sh --check | tee "$RUNNER_TEMP/check.txt"
@@ -38,26 +51,53 @@ jobs:
run: |
set -euo pipefail
title="Pinned versions to bump"
grep -F ' -> ' "$RUNNER_TEMP/check.txt" > "$RUNNER_TEMP/outdated.txt" || true
# 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 "$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 TOOL…\` (the tools named above), or \`scripts/bump.sh\` for all."
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"
+1 -1
View File
@@ -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:
+97
View File
@@ -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
+186
View File
@@ -0,0 +1,186 @@
name: Vulnerabilities
# govulncheck once a week, on main's code for Linux and macOS and on the
# binaries of the latest release and of the newest release, prerelease or not:
# what it finds goes in one open issue, which closes when every scan finds
# nothing. CI's vuln job checks each push, and this catches a vulnerability
# published since, and one in what users run. The scan job has only read
# access; the issue job, which can write issues, runs no govulncheck.
on:
schedule:
- cron: "37 6 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: vuln
cancel-in-progress: false
jobs:
scan:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Only Go and govulncheck.
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
with:
version: 2026.11.14
install_args: go go:golang.org/x/vuln/cmd/govulncheck
cache: false
- name: Scan main and the releases
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
shopt -s nullglob
work=$RUNNER_TEMP/scan
mkdir -p "$work" "$RUNNER_TEMP/findings"
found=$RUNNER_TEMP/findings/found.txt
# A fixed first line, so the artifact is never empty; the issue
# job checks it and skips it.
echo "# govulncheck findings" > "$found"
# scan NAME ARGS…: govulncheck exits 3 when it finds a vulnerability,
# and any other failure fails the job, so a scan that didn't run
# never closes the issue.
scan() {
local name=$1 status=0
shift
govulncheck "$@" > "$work/report.txt" || status=$?
cat "$work/report.txt"
case $status in
0) ;;
3)
{
echo "[$name]"
grep -E '^Vulnerability #|^ +(Found|Fixed) in: ' "$work/report.txt"
} >> "$found"
;;
*)
echo "govulncheck failed on $name with status $status" >&2
exit 1
;;
esac
}
# What mise run vuln runs: the code for each OS devvm ships for.
GOOS=linux scan "main linux" ./...
GOOS=darwin scan "main darwin" ./...
latest=$(gh release view --json tagName --jq .tagName)
newest=$(gh release list --exclude-drafts --limit 1 --json tagName --jq '.[0].tagName')
printf '%s\n' "$latest" "$newest" | sort -u > "$work/tags.txt"
while IFS= read -r tag; do
if [[ ! $tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
echo "unexpected release tag: $tag" >&2
exit 1
fi
version=${tag#v}
dir=$work/$tag
mkdir -p "$dir"
gh release download "$tag" --dir "$dir" --pattern SHA256SUMS --pattern "devvm-$version-*.tar.gz"
archives=("$dir"/devvm-"$version"-*.tar.gz)
if (( ${#archives[@]} == 0 )); then
echo "$tag has no archives" >&2
exit 1
fi
# Every archive has a line in SHA256SUMS, so --ignore-missing
# skips none of them.
for archive in "${archives[@]}"; do
base=${archive##*/}
if ! awk -v b="$base" '$2 == b { f = 1 } END { exit !f }' "$dir/SHA256SUMS"; then
echo "$tag's SHA256SUMS has no line for $base" >&2
exit 1
fi
done
(cd "$dir" && sha256sum --check --ignore-missing --strict SHA256SUMS)
for archive in "${archives[@]}"; do
platform=${archive##*/devvm-"$version"-}
platform=${platform%.tar.gz}
tar -xzf "$archive" -C "$dir" "devvm-$version-$platform/devvm"
scan "$tag $platform" -mode=binary "$dir/devvm-$version-$platform/devvm"
done
done < "$work/tags.txt"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: findings
path: ${{ runner.temp }}/findings/found.txt
if-no-files-found: error
retention-days: 7
# Only main's run reports, so a run started on another branch never
# closes the issue as main's.
issue:
needs: scan
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: findings
path: ${{ runner.temp }}/findings
# govulncheck's report holds the vulnerability database's text: it goes
# through files, never into a script.
- name: Open, update or close the issue
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
title="Known vulnerabilities in devvm"
# Each scan's vulnerabilities and versions, with only the characters
# those lines use, so no text from the database 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.
found=$RUNNER_TEMP/findings/found.txt
if [[ $(head -n 1 "$found") != "# govulncheck findings" ]]; then
echo "the findings don't start with the scan job's first line" >&2
exit 1
fi
tail -n +2 "$found" | LC_ALL=C tr -cd '0-9A-Za-z.+~_ ()#@:/,\133\135\n-' > "$RUNNER_TEMP/clean.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/clean.txt ]]; then
if [[ -n $number ]]; then
gh issue close "$number" --comment "govulncheck finds no known vulnerability in main's code or in the releases' binaries."
fi
exit 0
fi
{
echo "govulncheck found known vulnerabilities in main's code or in the releases' binaries:"
echo
# Four backticks: a line from the database can't end the block early.
echo '````'
cat "$RUNNER_TEMP/clean.txt"
echo '````'
echo
grep -oE 'GO-[0-9]{4}-[0-9]+' "$RUNNER_TEMP/clean.txt" | sort -u | sed 's#.*#- https://pkg.go.dev/vuln/&#'
echo
echo "A binary's scan lists the vulnerable code it holds, and can name a package that isn't linked,"
echo "so check one with \`go version -m\` and \`govulncheck -mode=binary -show traces\` before releasing for it."
echo "A vulnerability in the standard library is fixed by the Go release that fixes it: \`scripts/bump.sh go\`,"
echo "or \`scripts/bump.sh go-minor\` when only a newer minor has the fix."
echo "One in a module is fixed by the module's fixed version: \`scripts/bump.sh go-mods\` or \`go get\`."
echo "A release's binaries keep theirs until the next release ships the fix:"
echo "see [Known vulnerabilities](https://next.devvm.dev/docs/contributing/maintaining/#known-vulnerabilities)."
} > "$RUNNER_TEMP/body.md"
if [[ -z $number ]]; then
gh issue create --title "$title" --label bug --body-file "$RUNNER_TEMP/body.md"
exit 0
fi
# An edit alone notifies nobody, so changed findings, the lines in
# the body's code fence, get a comment; a change to the rest of the
# text only edits the body.
gh issue view "$number" --json body --jq .body | tr -d '\r' > "$RUNNER_TEMP/old.md"
if ! cmp -s "$RUNNER_TEMP/old.md" "$RUNNER_TEMP/body.md"; then
gh issue edit "$number" --body-file "$RUNNER_TEMP/body.md"
if ! awk '/^````$/ { n++; next } n == 1' "$RUNNER_TEMP/old.md" | cmp -s - "$RUNNER_TEMP/clean.txt"; then
gh issue comment "$number" --body "The scans' findings changed: the description lists what they find now."
fi
fi
+3
View File
@@ -1,7 +1,10 @@
.dex/
.worktrees/
/.claude/
dist/
docs/public/
docs/resources/
docs/.hugo_build.lock
docs/.build/
docs/node_modules/
/devvm
+155 -7
View File
@@ -9,14 +9,21 @@ linters:
default: standard
enable:
- bodyclose
- canonicalheader
- contextcheck
- depguard
- durationcheck
- errchkjson
- errorlint
- exhaustive
- forbidigo
- forcetypeassert
- gochecksumtype
- gocritic
- gosec
- misspell
- nilerr
- nilnesserr
- noctx
- nolintlint
- reassign
@@ -26,27 +33,70 @@ linters:
settings:
depguard:
rules:
# The proxy, and the background-process helper and the file
# reader it uses: the standard library alone.
# The proxy, and the background-process helper, the file reader,
# the child's confinement, the VM names and the secrets' type it
# uses: the standard library alone, and each other; and the leak
# checks and the network in memory, which their tests use.
proxy:
list-mode: strict
files:
- "**/internal/proxy/**"
- "**/internal/landlock/**"
- "**/internal/daemon/**"
- "**/internal/safefile/**"
- "**/internal/vmname/**"
- "**/internal/leaktest/**"
- "**/internal/redact/**"
- "**/internal/memnet/**"
allow:
- $gostd
- github.com/devvmhq/devvm/internal/proxy
- github.com/devvmhq/devvm/internal/landlock
- github.com/devvmhq/devvm/internal/daemon
- github.com/devvmhq/devvm/internal/safefile
- github.com/devvmhq/devvm/internal/vmname
- 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/**"
- "!**/internal/safefile/**"
- "!**/internal/vmname/**"
- "!**/internal/leaktest/**"
- "!**/internal/redact/**"
- "!**/internal/memnet/**"
allow:
- $gostd
- github.com/devvmhq/devvm
@@ -61,16 +111,22 @@ 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
files:
- $test
- "!**/internal/proxy/**"
- "!**/internal/landlock/**"
- "!**/internal/daemon/**"
- "!**/internal/safefile/**"
- "!**/internal/vmname/**"
- "!**/internal/leaktest/**"
- "!**/internal/redact/**"
- "!**/internal/memnet/**"
allow:
- $gostd
- github.com/devvmhq/devvm
@@ -102,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)$
@@ -112,6 +170,31 @@ linters:
msg: ask msg.Safe which characters reach the terminal (msg.Printable and msg.OneLine drop the rest); a check that isn't about the terminal says why in a nolint.
- pattern: ^(os\.(Open|OpenFile|ReadFile|OpenRoot|OpenInRoot|DirFS)|os\.Root\.(Open|OpenFile|ReadFile|FS))$
msg: read a file a VM can write through internal/safefile (Read, Open, OpenRoot), which never waits on a FIFO or follows a link it wasn't asked to, and reads only a regular file within its cap; what opens a file to write, or a folder, says why in a nolint.
- pattern: ^os\.(Chmod|Chtimes|Chown|Lchown|Truncate)$
msg: change a file through what opened it (os.File's Chmod, Chown and Truncate, or an os.Root's methods), never by its path, which a VM can swap for a link between the open and the change; a path only devvm writes, such as a socket it just made, says why in a nolint.
- pattern: ^netip\.Addr\.IsPrivate$
msg: ask proxy.Public whether an address is on the internet, the one table of the ranges that aren't.
- pattern: ^(syscall|unix)\.Flock$
msg: take a lock with internal/platform's LockFile, LockFileShared or LockDir, which wait until the context ends and show their wait (platform.Waiting); a blocking flock waits for ever and shows nothing.
- pattern: ^msg\.StatusOf$
msg: show a lock's wait through the Reporter your constructor takes (msg.Waiting with its Status); only internal/state and internal/trust, which take none, read the run's status from the context.
- pattern: ^redact\.Secret\.Reveal$
msg: pass the redact.Secret on; its value is revealed only where it must be used (a header, a file only the user can read, the Keychain), with a //nolint:forbidigo that says why.
# A value errchkjson proves encodes without fail drops the error; any
# other checks it, so a field that could fail gets its check back.
errchkjson:
check-error-free-encoding: true
report-no-exported: true
# A switch on a sum type's type (//sumtype:decl) names every case, as
# exhaustive holds a switch on an enum's values to.
gochecksumtype:
default-signifies-exhaustive: false
govet:
enable:
- hostport
- nilness
- unusedwrite
- waitgroup
nolintlint:
require-explanation: true
require-specific: true
@@ -137,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.
@@ -148,6 +246,21 @@ linters:
- path: ^tests/e2e/
linters: [gosec]
text: G204|G304|G702|G703
# A test's helpers write the paths its own temp folder names. gosec's
# taint analysis reports some of them on some runs and not others
# (internal/gitprotect's write), so a nolint would fail nolintlint.
- path: _test\.go$
linters: [gosec]
text: G703
# A test's assertion that fails panics, which fails the run and names
# the line.
- path: _test\.go$
linters: [forcetypeassert]
# Tests encode values they built or decoded themselves, of strings,
# numbers, lists and maps, which always encode.
- path: _test\.go$
linters: [errchkjson]
text: is not checked
- path: ^internal/ui/
linters: [forbidigo]
text: fmt\.Print|os\.(Stdout|Stderr)|context\.(Background|TODO)
@@ -157,6 +270,10 @@ linters:
- path: ^internal/cli/
linters: [forbidigo]
text: testbuild\.On
# proxy.Public is the judge of internet addresses.
- path: ^internal/proxy/
linters: [forbidigo]
text: ask proxy\.Public
# daemon and platform signal processes; tests signal their own
# children (exec.Cmd's Process).
- path: ^internal/(daemon|platform)/
@@ -170,6 +287,20 @@ 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]
text: msg\.StatusOf
# platform's locks themselves; the proxy's log rotation's (the proxy
# imports the standard library alone); test stubs; and tests, which
# hold locks as another devvm would.
- path: ^internal/(platform|stubtest)/|^internal/proxy/rotate\.go$|_test\.go$
linters: [forbidigo]
text: (syscall|unix)\.Flock
# state's own writer; the proxy's (standard library only); the
# message generator (a leaf); test stubs; and tests' fixtures.
- path: ^internal/(state|proxy|msg/gen|stubtest)/|_test\.go$
@@ -182,14 +313,31 @@ linters:
text: devvm's environment never changes
# The readers of files a VM can write, or swap, are held to
# internal/safefile: the project folder's (devcontainer.json, its
# default.nix, .git's), devvm agent save's store, the agents' logins and
# the policy files. Tests make their own fixtures.
- path-except: ^internal/(gitprotect/|vm/(devcontainer|detect|agentsave[a-z_]*)\.go$|agentlogin/|netpolicy/rules\.go$|proxy/(config|policy)\.go$)|^testdata/lint/
# default.nix, .git's), devvm agent save's store, devvm paste's copied
# file, the agents' logins and the policy files, the logs a VM drives
# (vmlog, and the proxy's rotate.go) and the Nix cache. Tests make
# their own fixtures.
- path-except: ^internal/(gitprotect/|vm/(devcontainer|detect|paste|agentsave[a-z_]*)\.go$|agentlogin/|netpolicy/rules\.go$|proxy/(config|policy|rotate|nixcache)\.go$|vmlog/)|^testdata/lint/
linters: [forbidigo]
text: internal/safefile
- path: _test\.go$
linters: [forbidigo]
text: internal/safefile
# The packages that change files a VM can write or swap (the proxy's
# logs and Nix cache, the logs vmlog keeps, and vmssh's sockets and
# files beside the VM's) change them through what opened them. Tests
# make their own fixtures.
- path-except: ^internal/(proxy|vmlog|vmssh)/|^testdata/lint/
linters: [forbidigo]
text: never by its path
- path: _test\.go$
linters: [forbidigo]
text: never by its path
# A secret's value is revealed where it's used, each call with a
# //nolint:forbidigo that says why. Tests check the values.
- path: _test\.go$
linters: [forbidigo]
text: pass the redact\.Secret on
paths:
- ^\.agents/
+10
View File
@@ -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
+11
View File
@@ -3,3 +3,14 @@ config:
MD013: false
# Lists may follow a paragraph directly.
MD032: false
# A heading may repeat under another parent, as each release's Fixed
# 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
@@ -9,8 +9,8 @@ importers:
.:
dependencies:
markdownlint-cli2:
specifier: 0.24.0
version: 0.24.0
specifier: 0.24.2
version: 0.24.2
packages:
@@ -42,15 +42,12 @@ packages:
'@types/[email protected]':
resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==}
ansi-regex@6.4.0:
resolution: {integrity: sha512-KzTVk2tCWAHtYrvvvaP8bJKJq2pVinhLcGEQdtLIYPbmNGNyYe8QwNaTUYQp2J7/vIsUKt5QCqAfUkYyG9DkOw==}
ansi-regex@6.6.0:
resolution: {integrity: sha512-XZ5apbzreCbXSKwPjJstu8R0zOi247w3XYwWxtwBXgpZrCyc1Ka7p9/xY0A9/diMewmHbEKz+FIraWaEWjlN5g==}
engines: {node: '>=12'}
argparse@2.0.1:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
[email protected]:
resolution: {integrity: sha512-Sn98ftV3KfsO8xfLPHG6oT8y+b0yvbrLgZjgPDXsharNY15tTAjqIsIju4S32nl6/iEUNNE4v+yL2Zhm8ooP3w==}
argparse@3.0.4:
resolution: {integrity: sha512-fwWK3Zq22l4XJJjx5mcBHGikIk+hJqO+32dPm0Jur7+rtG5x1scOjSfdT9ZKeWHPpsya/l0HHK4tDImBkTrtvA==}
[email protected]:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
@@ -115,8 +112,8 @@ packages:
resolution: {integrity: sha512-c8B/VNLmxRcmqqenRA9t+9IyOjf9+V6lTxPaUJLqOCONdQkWZ0ETYgX0qbtJqPsgCNusT9MZ5Jeidw8Eb9tn2g==}
engines: {node: '>=20'}
[email protected]3:
resolution: {integrity: sha512-2E8Q6rh+1RRSq/YdaGsNfXsEZy9FVqv6BSSrkmZJP7BnaoPnRfKL+YaofPvP+5rzdk144qSm6i4+hvPgUcbV4Q==}
[email protected]6:
resolution: {integrity: sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==}
engines: {node: '>= 4'}
[email protected]:
@@ -147,8 +144,8 @@ packages:
resolution: {integrity: sha512-lJJV/5dYS+RcL8uQdBDW9c9uWFLLBNRyFhnAKXw5tVqLlKZ4RMGZKv+YQ/IA3OhD+RpbJa1LLFM1FQPGyIXvOA==}
engines: {node: '>=12'}
js-yaml@5.4.3:
resolution: {integrity: sha512-yzzNtgczwgoVHNigCyKTXcQJU4Y8t/ikU4UxXW0BvrLfHTGWZhsNcOT2s/a7vn81/4KqVnNmHjaUEPlvWnNwVw==}
js-yaml@5.5.0:
resolution: {integrity: sha512-paNr4LFIFPjeeSmwNYdrb8FafLLG/Cr2Af3GjbsHJ5CxIjH4r0c2emlmRdAtpPAieP1gRVzk6buBbVP5gBMGAg==}
hasBin: true
[email protected]:
@@ -174,13 +171,13 @@ packages:
peerDependencies:
markdownlint-cli2: '>=0.0.4'
[email protected].0:
resolution: {integrity: sha512-c5hU2MDoTlS230MLzdNlkIyxImXq5acxGKz4nYz4aDhH/2BgFtpsA7iK9/OoTHMgZ4FuR0wedTQA31K6Lp9I/Q==}
[email protected].2:
resolution: {integrity: sha512-bgxzhJkgR7t2puRgePHZYVqKzC90etPzxOC+9ZNATjAVJB2zs7EAolfF1inVsrkgYN+ykVIHIxk0WypG2VVLZA==}
engines: {node: '>=22'}
hasBin: true
[email protected].0:
resolution: {integrity: sha512-kzsCV/rPWRFn3jUhcB919YF4Qgeh0g9tcogoXFadGSo6Zxj6662YOqWXv0jDn8nv5KCCxDfMKJZv6N4HkNkvTg==}
[email protected].2:
resolution: {integrity: sha512-IhlUBVT+kHBX+u3EjEsQdFB4q0Rl0Hx+JsGsvVkonNut1/n8Kv8yXzwk0pazC9uF35JlwMZ+LxV4CQ9YNAbG8w==}
engines: {node: '>=22'}
[email protected]:
@@ -289,9 +286,9 @@ packages:
[email protected]:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
re2js@2.8.6:
resolution: {integrity: sha512-xLgQil4kIUCrAzVk9fRSkxkFNwmygLFjVxXrLc65aE1F0+Zsb8rxumFBy4XKyvgMCTL6kilDq3EZ0piE2dP/Dg==}
engines: {node: '>=18.0.0'}
re2js@2.9.1:
resolution: {integrity: sha512-JIT3bEEUZTOR2YS1walNEIfH4cF/cQeZcBUFq7ldqO6lR6g0X5CBq/S8rsa9omzZcsNf8qc36jCkWpKKtncrZg==}
engines: {node: '>=20.0.0'}
[email protected]:
resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==}
@@ -353,11 +350,9 @@ snapshots:
'@types/[email protected]': {}
ansi-regex@6.4.0: {}
ansi-regex@6.6.0: {}
argparse@2.0.1: {}
[email protected]: {}
argparse@3.0.4: {}
[email protected]:
dependencies:
@@ -413,13 +408,13 @@ snapshots:
dependencies:
'@sindresorhus/merge-streams': 4.0.0
fast-glob: 3.3.3
ignore: 7.0.13
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]3: {}
[email protected]6: {}
[email protected]: {}
@@ -442,9 +437,9 @@ snapshots:
[email protected]: {}
js-yaml@5.4.3:
js-yaml@5.5.0:
dependencies:
argparse: 2.0.1
argparse: 3.0.4
[email protected]: {}
@@ -460,32 +455,32 @@ snapshots:
[email protected]:
dependencies:
argparse: 3.0.3
argparse: 3.0.4
entities: 8.1.0
linkify-it: 6.1.0
mdurl: 2.1.0
punycode.js: 2.3.1
uc.micro: 3.0.0
[email protected]([email protected].0):
[email protected]([email protected].2):
dependencies:
markdownlint-cli2: 0.24.0
markdownlint-cli2: 0.24.2
[email protected].0:
[email protected].2:
dependencies:
globby: 16.2.4
js-yaml: 5.4.3
js-yaml: 5.5.0
jsonc-parser: 3.3.1
jsonpointer: 5.0.1
markdown-it: 15.0.3
markdownlint: 0.42.0
markdownlint-cli2-formatter-default: 0.0.6([email protected].0)
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].0:
[email protected].2:
dependencies:
micromark: 4.0.3
micromark-core-commonmark: 2.0.4
@@ -495,7 +490,7 @@ snapshots:
micromark-extension-gfm-table: 2.1.2
micromark-extension-math: 3.1.0
micromark-util-types: 2.0.3
re2js: 2.8.6
re2js: 2.9.1
string-width: 8.3.0
transitivePeerDependencies:
- supports-color
@@ -705,7 +700,7 @@ snapshots:
[email protected]: {}
re2js@2.8.6: {}
re2js@2.9.1: {}
[email protected]: {}
@@ -724,7 +719,7 @@ snapshots:
[email protected]:
dependencies:
ansi-regex: 6.4.0
ansi-regex: 6.6.0
[email protected]:
dependencies:
@@ -2,6 +2,6 @@
"name": "mise-npm-install",
"private": true,
"dependencies": {
"markdownlint-cli2": "0.24.0"
"markdownlint-cli2": "0.24.2"
}
}
+4
View File
@@ -21,6 +21,10 @@ devvm.Filler = NO
[.agents/skills/cli/*.md]
BasedOnStyles = devvm
# The codebase-standards skill is prose for contributors too.
[.agents/skills/codebase-standards/*.md]
BasedOnStyles = devvm
# Not checked: .agents/skills/docs-voice/tropes.md, whose lists and examples
# are the very words and quoted phrases every devvm rule flags, and
# .agents/skills/security-audit/, which is vendored.
+31 -18
View File
@@ -8,26 +8,31 @@ 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; a project VM's name grammar |
| `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 |
| `internal/project/`, `internal/gitprotect/`, `internal/hostsafety/`, `internal/hostgit/` | a project folder; `.git` protection; the folder's other host checks; every host git command devvm runs |
| `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 |
| `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 |
| `internal/safefile/` | every read of a file a VM can write or swap |
| `internal/landlock/` | Linux's sandbox for the proxy's child: Landlock and the hand-written seccomp filter (`Self`) |
| `internal/devcontainer/`, `internal/jsonc/` | a project's devcontainer.json; JSON with comments |
| `internal/tools/` | the shared tools: the lock, host mise, the daily check, tool image builds, the share |
| `internal/netpolicy/`, `internal/secrets/` | network policy; tokens on the host, the VM's bindings and your own secrets |
| `internal/trust/` | your CAs, and each VM's own CA |
| `internal/agents/` | the coding agents' registry: one `Def` each, which every list of the agents derives from |
| `internal/agentlogin/` | agents' login and settings files on the host, and their placeholders |
| `internal/proxy/` | the proxy, run as `devvm _proxy`; see its `README.md` |
| `internal/proxy/` | the proxy: its broker, `devvm _proxy`, and the child that reads the VM's network, `devvm _proxy-child`; see its `README.md`; every host's one form (`NormHost`); the VM's SSH agent relay, the only way a VM reaches an agent |
| `internal/daemon/` | devvm's background processes; the only place a process is signalled by pid |
| `internal/seatbelt/` | macOS's sandbox: `sandbox-exec`, profile strings and real paths, the proxy child's profile |
| `internal/desktop/` | devvm desktop's relay on the host |
| `internal/backend/` | `Backend`, its roles, `Caps`, the registry and its guard; `backendtest/`, `registry/`, `lima/` |
| `internal/vmssh/` | devvm's own ssh to a VM (`Checked`), the port forwarder (`Forwards`), each start's host keys |
@@ -36,23 +41,24 @@ 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/` | the test stubs |
| `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 |
| `.agents/skills/security-audit/` | the security-audit skill, for backend reviews |
| `.agents/skills/cli/` | the cli skill: devvm's command line rules, the checklist for adding a command, the tests behind each rule, `judgment.md` for the rest |
| `.agents/skills/docs-voice/` | the docs-voice skill: the voice of the prose and messages, terms, tropes, `scan.sh` and `facts.sh` |
| `.agents/skills/codebase-standards/` | the codebase-standards skill: the checklist for a commit and a review from what reviews kept finding, matching the codebase's style, every rule's guard |
## Tasks
`mise run <task>`: `fmt`, `lint` (`lint:code`, `lint:docs`), `test`, `coverage` (commit the baselines it raised with the change), `vuln`, `deadcode` (anything but the tests' helpers gets a caller or goes), `cli-docs` (after changing a command's help, flags or docs page; commit the pages), `docs`, `e2e`: [Tools and tasks](docs/content/docs/contributing/_index.md#tools-and-tasks).
`mise run <task>`: `fmt`, `lint` (`lint:code`, `lint:docs`), `test`, `coverage` (commit the baselines it raised with the change), `vuln`, `nilaway` (advisory: a new finding gets a fix and a test, or a line in `testdata/nilaway-baseline.txt`), `nilaway:linux` (must pass before a push to `main`), `deadcode` (anything but the tests' helpers gets a caller or goes), `cli-docs` (after changing a command's help, flags or docs page; commit the pages), `docs`, `e2e`: [Tools and tasks](docs/content/docs/contributing/_index.md#tools-and-tasks).
## Rules
@@ -61,17 +67,20 @@ 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.
- **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)).
- **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, 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)).
- **Docs by reader:** user pages name no repo paths, Go identifiers or message names; How it works explains mechanisms; Contributing has the paths and identifiers ([Writing docs](docs/content/docs/contributing/docs.md#writing-docs)).
- **Extend the owner, don't copy it:** before adding a helper, parser, path, file reader, message or table, find its owner and extend it; a new owner gets a forbidigo rule or a structure-test check only when a second copy would be a bug ([Contributing](docs/content/docs/contributing/structure.md#one-owner-for-each-concern)).
- **User pages lead with doing:** in `getting-started/`, `using/`, `safety/`, `backends/` and `compared/`, a task shows its command, and prose never runs to back-to-back paragraphs; one explanatory paragraph is fine, and longer mechanism moves to How it works, linked, every fact kept.
- **Extend the owner, don't copy it:** before adding a helper, parser, path, file reader, message or table, find its owner and extend it (code with no owner yet gets one at its third copy, a judge at its second); a new owner gets a forbidigo rule or a structure-test check only when a second copy would be a bug ([Contributing](docs/content/docs/contributing/structure.md#one-owner-for-each-concern)).
- **Edit files with the editor tools,** not `sed`, `awk`, `python`, heredocs or `cat >`.
- **Ask first** before anything outward-facing (publishing, releases, repos, pushing) and before deleting anything you didn't create.
- **A task that turns out wrong or incomplete:** say so and propose the change; don't quietly do something else.
@@ -80,12 +89,13 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
- **Only `internal/ui` prints, functions take their caller's `ctx`, and every `//nolint` names its linters and says why;** functions stay within revive's limits ([Go lint rules](docs/content/docs/contributing/_index.md#go-lint-rules)).
- **Fail by returning:** `RunE` returns the error and `execute` alone prints it; signals, exit codes and the run log: [CLI conventions](docs/content/docs/contributing/cli.md#cli-conventions).
- **Only `cmd/devvm` and `internal/cli` import `internal/ui`;** other packages print and ask through the one `msg.Reporter` their constructors take ([Messages](docs/content/docs/contributing/cli.md#messages)).
- **Only `cmd/devvm` and `internal/cli` import `internal/ui`;** other packages print and ask through the one `msg.Reporter` their constructors take ([Messages](docs/content/docs/contributing/cli.md#messages)); a lock's wait shows through `msg.Waiting` with its `Status`, and only `internal/state` and `internal/trust`, which take none, read it from the context (`msg.StatusOf`).
- **Arguments and flag values are checked before anything runs**, with `args.go`'s checks, never Cobra's; a usage error exits 2 ([Command arguments](docs/content/docs/contributing/cli.md#command-arguments)).
- **Cleanups:** whatever a failure would leave (a build VM, a temp file) registers with the UI's `AddCleanup` and is removed once done; one only for interrupts checks `Interrupted()` and stays once interrupted, as the cleanups run after the command returns. Cleanups get a fresh context.
- **External commands run with the UI's `LoggedCmd(ctx, step, cmd)`**, a failure after one returned as `backend.Logged(m)` ([CLI conventions](docs/content/docs/contributing/cli.md#cli-conventions)).
- **OS-specific code goes behind build tags** in `internal/platform` (`*_darwin.go`, `*_linux.go`, `*_other.go`).
- **Dependencies:** the depguard allowlist (cobra, pflag, cobra/doc, go-i18n, BurntSushi/toml, x/text, x/term, x/sys, x/crypto's `blake2b` only (minisign's prehash); go-internal in tests; cobra/doc's own deps never imported directly). `internal/proxy`, `internal/daemon` and `internal/safefile` are stdlib only. Adding one: ask.
- **OS-specific code goes behind build tags** in `internal/platform` (`*_darwin.go`, `*_linux.go`, `*_other.go`); packages the proxy imports keep their own (`internal/safefile`, `internal/daemon`, `internal/proxy`, `internal/landlock`).
- **Dependencies:** the depguard allowlist (cobra, pflag, cobra/doc, go-i18n, BurntSushi/toml, x/text, x/term, x/sys, x/crypto's `blake2b` only (minisign's prehash); go-internal in tests; cobra/doc's own deps never imported directly). `internal/proxy`, `internal/landlock`, `internal/daemon`, `internal/safefile`, `internal/vmname`, `internal/leaktest`, `internal/memnet` and `internal/redact` are stdlib only. Adding one: ask.
- **A secret's value is a `redact.Secret`:** each `Reveal` with a `//nolint:forbidigo` saying why, and a file that holds one writes it through its own wire type ([Secrets in the code](docs/content/docs/contributing/structure.md#secrets-in-the-code)).
- **External tools are commands, never linked** (`limactl`, `docker`, `security`, `git`, `chflags`…); prefer the standard library to shelling out. Strings into a shell are quoted with `shell.Quote`.
- **Test seams are fields** tests set (`Host`, `Exec`, `Runner`, `OS`, `Reporter`…), never package vars (reassign: no package sets another's); `internal/proxy`'s are its `server`'s, which each test makes.
- **The structure test** holds types to 24 methods, bans `func init`, limits package vars, checks the layers and keeps each concern in its owner (its failure names the owner: extend that); read [The structure test](docs/content/docs/contributing/structure.md#the-structure-test) before raising a limit or listing an exception, and regenerate [the checks on owners](docs/content/docs/contributing/structure.md#the-checks-on-owners) after changing its tables (`go test ./internal/structure -run TestOwnersDoc -update`).
@@ -96,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)).
@@ -111,13 +121,15 @@ Each package's concerns and identifiers: [The packages](docs/content/docs/contri
- **New logic needs a test:** Go table tests next to the code, and CLI tests (testscript against the built binary and the stubs); neither touches the Keychain, real VMs or your folders ([Tests](docs/content/docs/contributing/tests.md)).
- **Never touch VMs, images or containers devvm's tests didn't make:** your own stay as they are. Manual runs: `DEVVM_LIMA_HOME=~/.lt LIMA_HOME=~/.lt XDG_DATA_HOME=/tmp/x/data XDG_CONFIG_HOME=/tmp/x/config DEVVM_SECRET_SERVICE=devvm-sandbox-test` (devvm's Lima home is `$XDG_DATA_HOME/devvm/lima` unless `DEVVM_LIMA_HOME`; `LIMA_HOME` is for your `limactl`). Add a `config.toml` with `features = []` and pass `--network TIER` so nothing prompts. Delete test Keychain items. Never use your own tokens or logins: a network-policy VM reads its agent's login file from `HOME`, so give it its own (the Keychain needs the real `HOME`: test it apart).
- **Timeouts and lifecycles** are tested in a `testing/synctest` bubble on fakes in memory (`memnet`, the seams' fields), never by sleeping on the real clock; each kind keeps one real-process test ([Time and lifecycles](docs/content/docs/contributing/tests.md#time-and-lifecycles)).
- **Goroutines:** a package that starts them calls `leaktest.Main` in its `TestMain`, and each function that does is in the structure test's `goroutineSites`, with what waits for them or `detached:` and why ([Goroutine leaks](docs/content/docs/contributing/tests.md#goroutine-leaks)).
- **End-to-end:** `mise run e2e -- --only SECTIONS` in the background for what changed, `--from` before merging `assets/` or `--from` changes ([End-to-end tests](docs/content/docs/contributing/tests.md#end-to-end-tests)).
- **Linux hosts:** `LIMA_HOME=~/.lt-linux-go`, VM `linuxhost`, set up as [Linux hosts](docs/content/docs/contributing/testing.md#linux-hosts) says, apart from any Lima home of your own.
- **Unreviewed emulations** are checked through `DEVVM_UNREVIEWED=backend:feature`, in test builds only ([Unreviewed emulations](docs/content/docs/contributing/testing.md#unreviewed-emulations)).
- **Delete test VMs and temp files afterwards.** Long builds run in the background. Tests that `chflags` real files unlock them (`chflags -R nouchg`), only in their own temp folders.
- **The testscript runner stops the sandbox's proxies** (`pkill -f` on `_proxy -config` in the sandbox): the stub hostagent is gone before they look, so they'd wait 15 minutes. It also stops the sandbox's port forwarders, link sessions and stub ssh masters.
- **The testscript runner stops the sandbox's proxies** (`pkill -f` on `_proxy -config` in the sandbox, then `_proxy-child -for`): the stub hostagent is gone before they look, so they'd wait 15 minutes. It also stops the sandbox's port forwarders, link sessions and stub ssh masters.
- **`limactl shell` reads stdin:** give it none unless the input is meant for it.
- **Boot problems:** read `<devvm's Lima home>/<vm>/serialv.log` before restarting; every start overwrites it.
- **Boot problems:** read `<devvm's Lima home>/<vm>/serialv.log` (and its `.1`, past 10 MiB) before restarting; every start overwrites it.
## Gotchas learned
@@ -134,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.
+215 -12
View File
@@ -1,5 +1,155 @@
# Changelog
What's changed on `main` since the latest release is in [Unreleased](#unreleased), at the bottom of this page.
## 0.2.0-rc.1
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.
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.
### Highlights
- 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)).
### What to do
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
- `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
A release candidate for 0.1.1, adding to 0.1.1-rc.2. Install it with `devvm upgrade --to 0.1.1-rc.3`, the install script's `--version 0.1.1-rc.3`, or `brew install devvmhq/tap/devvm-rc`. Homebrew's `devvm` stays on 0.1.0.
### Breaking
- **Your layers run after devvm's prelude:** devvm puts one line of its own in place of your layer's `#!` line, which gives the layer `$devvm_arch`, `$devvm_libc` and `devvm_sha`. A layer that sets its own `devvm_arch` or another `devvm_` name keeps its own. In a layer without a `#!` line, the line numbers in bash's errors are one more than the file's ([your own layers](https://next.devvm.dev/docs/using/customizing/#your-own-layers)).
### After you upgrade
- Base, every image built on it and every shared tool image are built again once, because base now has `git-lfs` and each build script starts with devvm's prelude on one line, which keeps the line numbers in a build's errors the script's own.
- 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 each of its shared tools again, one at a time, which takes several minutes.
- An existing `--clone` VM gets `git-lfs` only once it's made again, with `devvm clone off`, then `devvm update`, then `devvm clone on`. Until then, its Git LFS files stay pointers.
### New
- **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)).
- **Pins in your own layers:** a layer of yours can pin a download for each architecture and fetch the right one with `devvm-fetch "$URL" "$(devvm_sha TOOL)" OUT`, as devvm's own scripts do ([the example](https://next.devvm.dev/docs/using/customizing/#example-mailpit)).
- **Quiet hosts:** Cursor CLI's metrics host, `api3.cursor.sh`, and Go's `telemetry.go.dev` stay blocked, but their blocks no longer show before the VM's prompt, in `devvm-why` or in `devvm network lock`. `devvm network log` still lists them, each line ending `, quiet` ([quiet hosts](https://next.devvm.dev/docs/safety/network/#quiet-hosts)).
### Changed
- **`--clone` in a folder of repos or a git worktree** copies each repo as above. A worktree's clone also gets the repo's default branch, remote-tracking branches and tags, and devvm says that the repo's other local branches stay on this machine.
- **`--clone` refuses a repo with a grafts file** before it makes the VM, and says what to do ([requirements](https://next.devvm.dev/docs/using/clone/#requirements)).
- **The proxy counts more addresses as internal:** a 6to4 address, in `2002::/16`, is judged by the IPv4 address in it, as a NAT64 address is, so `2002:a00:1::1` is as private as `10.0.0.1`. A deny for an IPv4 address also covers its 6to4 form, but an allow doesn't, because anyone may run a 6to4 relay. Teredo, IPv6's and IPv4's documentation ranges and other special ranges are refused unless a rule names the address, and `--from`'s registries are judged by the same list ([the proxy](https://next.devvm.dev/docs/internals/network/#the-proxy)).
- **Pins:** base's mise is 2026.11.8, Docker's buildx is 0.39.0 and compose 5.7.1, and Nix is 2.35.6.
### Fixed
- **`--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)).
- **dotnet on the allowlist tier** can reach DigiCert's OCSP responder, `ocsp.digicert.com` on port 80, which NuGet asks when it can't fetch DigiCert's revocation list ([dotnet](https://next.devvm.dev/docs/using/toolchains/#dotnet)).
- **`devvm history import FILE`** takes a `.tar.gz` made with macOS's `tar`, leaving out its AppleDouble `._` files ([importing history](https://next.devvm.dev/docs/using/coding-agents/#importing-history)).
- **opencode's links at `devvm agent import`** are copied or named as the other agents' are, where they were dropped without a word ([importing from this machine](https://next.devvm.dev/docs/using/coding-agents/#importing-from-this-machine)).
## 0.1.1-rc.2
A release candidate for 0.1.1, adding to 0.1.1-rc.1. Install it with `devvm upgrade --to 0.1.1-rc.2`, the install script's `--version 0.1.1-rc.2`, or `brew install devvmhq/tap/devvm-rc`. Homebrew's `devvm` stays on 0.1.0.
@@ -14,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)).
- **Rules by HTTP method and path:** `devvm network allow|deny HOST --method … --path …`, such as `devvm network deny api.github.com --method POST,PUT,PATCH,DELETE`.
- **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
@@ -65,3 +215,56 @@ The first release of devvm, which gives each project folder an isolated VM of it
- **Managing VMs and space:** `devvm ls`, `devvm stop`, `devvm restart`, `devvm update` and `devvm rm` manage VMs, and `devvm images`, `devvm gc`, `devvm space` and `devvm retention` show and clean up the images, shared tools and exports devvm keeps. devvm never deletes a project VM on its own, because it may hold unsaved work.
- **Installing and upgrading:** install devvm with Homebrew (`brew trust --formula devvmhq/tap/devvm`, then `brew install devvmhq/tap/devvm`) or with the install script, which checks the release's minisign signature and checksum and asks before it installs what devvm needs, such as Lima. `devvm doctor` checks this machine, and `devvm upgrade` installs a newer release once it has checked the signature.
- **For scripts:** many commands take `--json`, and `--no-input` makes devvm fail where it would ask, naming the flag that answers the question.
## 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>
+19 -1
View File
@@ -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
@@ -59,7 +77,7 @@ devvm
## What's supported
- **Toolchains:** devvm detects them from the project's files, so a folder with `package.json` gets node, and the [toolchains](https://devvm.dev/docs/using/toolchains/) page lists them all.
- **Coding agents:** Claude Code, Codex, opencode and pi run in the VM, with your settings, skills and MCP servers. devvm keeps their settings and logins in a store of its own, and `devvm agent import` copies them in from an agent you already use on your machine ([coding agents](https://devvm.dev/docs/using/coding-agents/)).
- **Coding agents:** <!-- the agents' names, generated from internal/agents by mise run cli-docs -->Claude Code, Codex, opencode, pi and Cursor CLI<!-- end of the agents' names --> run in the VM, with your settings, skills and MCP servers. devvm keeps their settings and logins in a store of its own, and `devvm agent import` copies them in from an agent you already use on your machine ([coding agents](https://devvm.dev/docs/using/coding-agents/)).
- **Layers:** the built-in `docker`, `nix` and `desktop` layers, and your own from `devvm layer new` ([layers](https://devvm.dev/docs/using/images/#layers)).
- **Backend:** devvm runs its VMs on [Lima](https://lima-vm.io) ([backends](https://devvm.dev/docs/backends/)).
+1 -1
View File
@@ -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:
+1 -1
View File
@@ -1 +1 @@
0.1.1-rc.2
0.2.0-rc.1
+2 -1
View File
@@ -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
+8 -1
View File
@@ -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"
+148
View File
@@ -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")
}
})
}
}
+2 -1
View File
@@ -7,7 +7,7 @@ You're running in a devvm VM. devvm gives each project folder on the user's mach
- The project folder is mounted read-write at the same path as on the host, so the user's editor sees your changes at once. It's the only folder of the host's that the VM can write to: the agent store's folders and the shared tools are mounted read-only.
- Your home folder is on the VM's own disk, not the host's. The coding agents' settings, skills and logins come from devvm's agent store, and the folders among them are mounted read-only.
- devvm update, devvm layer add and devvm layer rm make the VM again from a newer or another image. The project folder and your home folder survive, and everything else on the disk is lost, such as packages installed with apt, programs installed outside your home and Docker's images. Shell settings of your own go in `~/.bashrc.d`, because the image owns `~/.bashrc`.
- In the project folder, git can commit, branch, fetch and pull, but `.git`'s hooks and config are locked, so `git config`, `git remote add`, `push -u` to a new branch and hook installers fail with `Operation not permitted`. Ask the user to change them on the host. A VM made with `--clone` has its own clone of the repo instead, and the user fetches its branches with `git fetch devvm`.
- In the project folder, git can commit, branch, fetch and pull, but `.git`'s hooks and config are locked, so `git config`, `git remote add`, `push -u` to a new branch and hook installers fail with `Operation not permitted`. Ask the user to change them on the host. A VM made with `--clone` has its own clone of the repo instead, and the user fetches its work with `devvm clone fetch`, its branches, a detached HEAD's commits, stash entries and Git LFS objects.
## Network and secrets
@@ -49,3 +49,4 @@ These commands run on the host, in the project folder, so ask the user to run th
| the GitHub token in this VM | `devvm secret set github`, then `devvm secret use github` |
| an agent logged in | `devvm agent login AGENT`, such as `devvm agent login claude` |
| `.git`'s hooks or config changed | devvm git-protect off, with the VM stopped, then devvm git-protect on |
| an image, a PDF or a file from the host, such as a screenshot or pages copied from a PDF | `devvm paste`, which puts it in the paste folder, `/tmp/devvm-paste` unless the user set `paste-dir`, and gives the user its path to paste to you |
+47
View File
@@ -0,0 +1,47 @@
#!/bin/sh
# devvm paste's side in the VM, run as sh -c SCRIPT devvm-paste COMMAND DIR [NAME] with the
# script itself as the argument, so nothing of it is left on disk. The host names the folder DIR
# (config.toml's paste-dir) and the file NAME, both from a fixed set of characters.
# put DIR NAME writes stdin to DIR/NAME: to NAME.part first, mode 600, then renamed over NAME,
# so a reader never sees half of it. DIR is made, mode 700, when it's missing, and
# refused when it's a symbolic link, isn't a folder or isn't this user's.
# count DIR prints how many files devvm paste left in DIR
# rm DIR deletes them and prints how many
# count and rm see only regular files at DIR's top level whose names devvm paste gives, and its
# .part leftovers, never anything else in a folder that may be yours.
set -eu
cmd=$1 dir=$2
h='[0-9a-f]'
d='[0-9]'
pat="paste-$d$d$d$d$d$d$d$d-$d$d$d$d$d$d-$h$h$h$h$h$h$h$h*"
# mine lists devvm paste's files in $dir, one a line: regular files, never links, named from the
# characters devvm uses and no other, so a name with a newline past devvm's prefix, which would
# read as two lines, isn't devvm's.
mine() { find "$dir" -maxdepth 1 -type f -name "$pat" ! -name '*[!A-Za-z0-9._-]*'; }
case $cmd in
put)
name=$3
if [ -L "$dir" ]; then echo "devvm: $dir is a symbolic link, so devvm paste can't use it" >&2; exit 1; fi
if [ ! -e "$dir" ]; then (umask 077 && mkdir -p "$dir"); fi
if [ ! -d "$dir" ]; then echo "devvm: $dir isn't a folder, so devvm paste can't use it" >&2; exit 1; fi
if [ -z "$(find "$dir" -prune -user "$(id -un)")" ]; then
echo "devvm: $dir isn't yours, so devvm paste can't use it" >&2; exit 1
fi
umask 077
cat > "$dir/$name.part"
mv -f "$dir/$name.part" "$dir/$name"
;;
count)
[ -d "$dir" ] || { echo 0; exit 0; }
mine | wc -l | tr -d ' '
;;
rm)
[ -d "$dir" ] || { echo 0; exit 0; }
n=$(mine | wc -l | tr -d ' ')
mine | while IFS= read -r f; do rm -f -- "$f"; done
echo "$n"
;;
*)
echo "devvm: paste.sh: unknown command $cmd" >&2; exit 2
;;
esac
+171 -18
View File
@@ -1,11 +1,16 @@
#!/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 from devvm's store, copied into ~
# 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
# or per-project history), merged in (MCP servers' env values and headers are
# placeholders)
# claude-credentials.json the store's Claude Code OAuth login, placeholders only, merged into
# ~/.claude/.credentials.json (merge_claude_credentials)
# env exports (LANG, CLAUDE_CODE_OAUTH_TOKEN, GH_TOKEN: placeholders), installed as
# ~/.config/devvm/env
# ca/ the CAs the VM trusts besides its system's, one certificate per file:
@@ -15,9 +20,14 @@
# DEVVM_PROXY (the proxy URL, empty when the guest has none),
# DEVVM_NO_PROXY (what reaches the VM itself without the proxy; its links go through it),
# DEVVM_LOCAL_PROXY (ADDRESS:PORT on the VM's loopback, where devvm-local-proxy
# listens; empty without a proxy), and DEVVM_TRANSPARENT_ADDR and
# listens; empty without a proxy), DEVVM_TRANSPARENT_ADDR and
# DEVVM_TRANSPARENT_HOST (transparent mode's stand-in address, empty for off, and the
# proxy's reserved target; transparent.sh)
# 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),
# 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
@@ -78,6 +88,20 @@ if [[ -n "$DEVVM_TZ" ]]; then
[[ "$(readlink /etc/localtime)" == "/usr/share/zoneinfo/$DEVVM_TZ" ]] || sudo ln -sfn "/usr/share/zoneinfo/$DEVVM_TZ" /etc/localtime
fi
fi
# The paste folder (devvm paste): made once, the user's own, mode 700, by the user, or by root where
# the user can't make it, such as a folder under /srv. One that's there keeps its mode. A link, a
# file or another user's folder there is left alone, with a warning, as is one that can't be made,
# under a file say: paste.sh refuses them too, and the rest of the setup goes on.
if [[ -n "${DEVVM_PASTE_DIR:-}" ]]; then
p=$DEVVM_PASTE_DIR
if [[ -L $p ]]; then echo "devvm: $p is a symbolic link, so devvm paste can't use it" >&2
elif [[ -e $p && ! -d $p ]]; then echo "devvm: $p isn't a folder, so devvm paste can't use it" >&2
elif [[ -d $p && ! -O $p ]]; then echo "devvm: $p isn't yours, so devvm paste can't use it" >&2
elif [[ ! -e $p ]]; then
(umask 077 && mkdir -p "$p") 2>/dev/null || sudo install -d -m 700 -o "$(id -u)" -g "$(id -g)" "$p" \
|| echo "devvm: $p can't be made, so devvm paste can't use it" >&2
fi
fi
# musl (Alpine) has no locales to generate.
if [[ -n "$DEVVM_LANG" ]] && command -v locale-gen >/dev/null && ! locale -a | grep -qix "${DEVVM_LANG/UTF-8/utf8}"; then
sudo locale-gen "$DEVVM_LANG" >/dev/null
@@ -100,7 +124,9 @@ sudo /usr/local/sbin/devvm-tools
cat "$s/tool-alias.toml"
echo
echo '[tools]'
while read -r _ tool version; do [[ -z $tool || $tool == rust ]] || echo "$tool = \"$version\""; done < "$s/tools"
# rust is rustup's; cursor's folder holds its own node, rg and helpers, which shims would put
# ahead of the VM's, so it has links of its own (below).
while read -r _ tool version; do [[ -z $tool || $tool == rust || $tool == cursor ]] || echo "$tool = \"$version\""; done < "$s/tools"
cat <<'T'
[settings]
@@ -125,7 +151,7 @@ T
} > "$s/mise.toml"
cmp -s "$s/mise.toml" /etc/mise/config.toml 2>/dev/null || sudo install -D -m 644 "$s/mise.toml" /etc/mise/config.toml
# Links into tools this VM doesn't have any more (devvm tools rm, devvm tools update).
for l in ~/.rustup/toolchains/* ~/.local/bin/claude; do
for l in ~/.rustup/toolchains/* ~/.local/bin/claude ~/.local/bin/cursor-agent ~/.local/bin/agent; do
[[ -L $l && ! -e $l && "$(readlink "$l")" == /opt/devvm/tools/* ]] && rm "$l"
done
# Rust: rustup in ~/.cargo (installed once, from the tool image) with the shared toolchain linked in.
@@ -158,6 +184,13 @@ fi
# Claude Code checks for itself at ~/.local/bin/claude.
claude=$(awk '$2 == "claude" { print $3 }' "$s/tools")
if [[ -n $claude ]]; then mkdir -p ~/.local/bin; ln -sfn /opt/devvm/tools/claude/"$claude"/claude ~/.local/bin/claude; fi
# Cursor's CLI is cursor-agent, and agent, where its own installer links them, made again at every
# launch, so it stays the shared release devvm pins (its channel, below).
cursor=$(awk '$2 == "cursor" { print $3 }' "$s/tools")
if [[ -n $cursor ]]; then
mkdir -p ~/.local/bin
for l in cursor-agent agent; do ln -sfn /opt/devvm/tools/cursor/"$cursor"/cursor-agent ~/.local/bin/"$l"; done
fi
mise reshim 2>/dev/null || true
# A command over ssh runs bash non-interactively, and bash then reads ~/.bashrc instead of BASH_ENV:
# its first line, before the "not interactive: return". Features (oh-my-bash) and users replace ~/.bashrc.
@@ -184,6 +217,35 @@ 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
[[ -n "$rel" ]] || continue
[[ ! -L ~/"$rel" ]] || rm -f ~/"$rel"
mkdir -p ~/"$rel"
done < "$s/own-dirs"
while IFS= read -r rel && IFS= read -r mount; do
[[ -n "$rel" && -e "$mount" ]] || continue
mkdir -p "$(dirname ~/"$rel")"
@@ -211,6 +273,36 @@ merge_claude_json() {
if [[ -f "$s/claude.json" ]]; then
merge_claude_json ~/.claude.json "$s/claude.json" ~/.local/state/devvm/claude-mcp-copied.json
fi
# merge_claude_credentials VM STORE: the store's Claude Code login (claudeAiOauth, its placeholder)
# replaces the VM's, or takes it away when STORE has none, and the rest of the VM's file stays: what
# Claude Code keeps there of its own, such as its logins to MCP servers (mcpOAuth), which never leave
# the VM. A VM file that's a link, not JSON or not one object is replaced by STORE, and said; a folder
# is left, and said. It's written whole, mode 600: a temp file in ~/.cache, which no export or remake
# carries, moved over, and removed when that fails.
merge_claude_credentials() {
local vm=$1 store=$2 tmp
if [[ -d $vm && ! -L $vm ]]; then
echo "devvm: $vm is a folder, so Claude Code in this VM doesn't get devvm's login" >&2
return 0
fi
mkdir -p ~/.cache "$(dirname "$vm")"
tmp=$(mktemp ~/.cache/devvm-credentials.XXXXXX)
if [[ -L $vm || ! -f $vm ]] || ! jq -n --slurpfile v "$vm" --slurpfile s "$store" '
if ($v | length) == 1 and ($v[0] | type) == "object"
then ($v[0] | del(.claudeAiOauth)) + ($s[0] | with_entries(select(.key == "claudeAiOauth")))
else error("not one object") end' > "$tmp" 2>/dev/null; then
if [[ -L $vm || -e $vm ]]; then
echo "devvm: $vm couldn't be read as a file of one JSON object, so devvm's login replaced it, with any MCP servers' logins in it" >&2
fi
cat "$store" > "$tmp" || { rm -f "$tmp"; return 1; }
fi
# A link goes first, so mv never follows it into a folder.
[[ ! -L $vm ]] || rm -f "$vm"
mv -f "$tmp" "$vm" || { rm -f "$tmp"; return 1; }
}
if [[ -f "$s/claude-credentials.json" ]]; then
merge_claude_credentials ~/.claude/.credentials.json "$s/claude-credentials.json"
fi
# The project folder moved since the last setup: Claude Code's sessions and settings, kept by its old
# path, follow it.
# shellcheck source-path=SCRIPTDIR source=claude.sh
@@ -222,19 +314,40 @@ if [[ -f "$s/moved" ]]; then
claude_project_moved "$moved_from" "$moved_to" "$claude_from" "$claude_to"
fi
# VS Code over Remote-SSH (devvm code): its settings for this machine turn off what reaches the host
# beyond the editor itself: forwarding ports the VM's programs open (to the host's localhost, which
# devvm ports doesn't cover) and answering git's credential prompts with the host's GitHub sign-in.
# The VM can change this file back; it's here so ordinary use is safe.
vsc=~/.vscode-server/data/Machine/settings.json
vsc_off='{"remote.autoForwardPorts": false, "git.terminalAuthentication": false, "github.gitAuthentication": false}'
mkdir -p "$(dirname "$vsc")"
if [[ ! -s $vsc ]]; then
echo "$vsc_off" | jq . > "$vsc"
elif jq -e 'type == "object"' "$vsc" >/dev/null 2>&1; then
jq --argjson off "$vsc_off" '. + $off' "$vsc" > "$vsc.tmp" && mv "$vsc.tmp" "$vsc"
else
echo "devvm: $vsc isn't plain JSON, so VS Code's port forwarding and git sign-in stay as they are there" >&2
# VS Code and Cursor over Remote-SSH (devvm code, devvm cursor): their settings for this machine turn
# off what reaches the host beyond the editor itself: forwarding ports the VM's programs open (to the
# host's localhost, which devvm ports doesn't cover) and answering git's credential prompts with the
# host's GitHub sign-in. The VM can change these files back; they're here so ordinary use is safe.
# A file or folder of theirs devvm can't write warns and leaves the rest of the setup to run.
editor_off='{"remote.autoForwardPorts": false, "git.terminalAuthentication": false, "github.gitAuthentication": false}'
editor_settings() {
local es=$1
mkdir -p "$(dirname "$es")" 2>/dev/null || return 1
if [[ ! -s $es ]]; then
echo "$editor_off" | jq . > "$es" 2>/dev/null || return 1
elif jq -e 'type == "object"' "$es" >/dev/null 2>&1; then
jq --argjson off "$editor_off" '. + $off' "$es" > "$es.tmp" 2>/dev/null && mv "$es.tmp" "$es" 2>/dev/null || return 1
else
echo "devvm: $es isn't plain JSON, so the editor's port forwarding and git sign-in stay as they are there" >&2
fi
}
for es in ~/.vscode-server/data/Machine/settings.json ~/.cursor-server/data/Machine/settings.json; do
editor_settings "$es" ||
echo "devvm: $es can't be written, so the editor's port forwarding and git sign-in stay as they are there" >&2
done
# Cursor's CLI has no variable that turns its updates off: on its static channel, which its config
# (host-copied, or its own) keeps through its own writes, it skips them.
if [[ -n $cursor ]]; then
c=~/.cursor/cli-config.json
mkdir -p ~/.cursor
if [[ ! -s $c ]]; then
echo '{"version":1,"channel":"static"}' > "$c"
elif jq -e 'type == "object" and .channel != "static"' "$c" >/dev/null 2>&1; then
jq '.channel = "static"' "$c" > "$c.devvm" && mv "$c.devvm" "$c"
elif ! jq -e 'type == "object"' "$c" >/dev/null 2>&1; then
echo "devvm: $c isn't plain JSON, so Cursor's CLI could update itself in this VM" >&2
fi
fi
# Codex has no env-var opt-out: append the off switches unless the (host-copied) config sets them.
@@ -489,6 +602,46 @@ else
if $systemd; then sudo rm -f "$dropin"; else conf_block "$dropin"; fi
[[ ! -f ~/.ssh/config ]] || proxy_block ~/.ssh/config
fi
# A confined VM's resolver (DEVVM_RESOLVER, 127.0.0.1): glibc asks that one name server itself, as
# musl does on Alpine, not systemd-resolved's stub, so a lookup fails at once when nothing answers
# there (transparent mode off). The stub, with 127.0.0.1 as its only server, can keep retrying it
# over UDP and TCP without answering, so a lookup waited out its timeout. /etc/resolv.conf, the
# stub's link, becomes devvm's file, with the stub's search line and a second's timeout, tried
# twice (dnsmasq answers in the VM); on an open VM, devvm's file goes back to the stub's link, and
# systemd-resolved restarts, which forgets what it read from devvm's file. The file is written only
# on systemd guests that have the stub's file, whose /etc/resolv.conf is its link or devvm's file;
# going back needs devvm's file alone.
# resolver_conf FILE STUB: FILE (/etc/resolv.conf) as DEVVM_RESOLVER has it, STUB the stub's file.
resolver_conf() {
local f=$1 stub=$2 was first want tmp
local mark='# devvm: a confined VM asks its one name server directly (DEVVM_RESOLVER)'
was=$(readlink "$f" 2>/dev/null || true)
first=$(head -n 1 "$f" 2>/dev/null || true)
if [[ -z ${DEVVM_RESOLVER:-} ]] || ! $systemd; then
# devvm's file alone is enough to go back: it's only ever written in place of the stub's link.
[[ -z $was && $first == "$mark" ]] || return 0
sudo ln -sfn "$stub" "$f"
# systemd-resolved took devvm's file as its own servers and search domain ("." routes every
# name to 127.0.0.1), and keeps them once the file is its link again, until it restarts.
! $systemd || sudo systemctl try-restart systemd-resolved || true
[[ -e $stub ]] || echo "devvm: $f leads to $stub again, which systemd-resolved hasn't made, so names may not resolve in this VM" >&2
return 0
fi
[[ -e $stub ]] || return 0
[[ (-n $was && "$(readlink -f "$f")" == "$(readlink -f "$stub")") || (-z $was && $first == "$mark") ]] || return 0
want=$(printf '%s\nnameserver %s\n' "$mark" "$DEVVM_RESOLVER"
grep '^search ' "$stub" 2>/dev/null || true
echo 'options timeout:1 attempts:2')
[[ -n $was || "$(cat "$f")" != "$want" ]] || return 0
tmp=$(mktemp)
printf '%s\n' "$want" >"$tmp"
if ! { sudo install -m 644 "$tmp" "$f.devvm" && sudo mv -f "$f.devvm" "$f"; }; then
sudo rm -f "$f.devvm"
echo "devvm: couldn't write $f, so with transparent mode off a lookup in this VM may wait out its timeout" >&2
fi
rm -f "$tmp"
}
resolver_conf /etc/resolv.conf /run/systemd/resolve/stub-resolv.conf
# Transparent mode (transparent.sh, devvm-transparent) on a confined VM: every name resolves to the
# stand-in address, whose ports 80, 443 and those the rules name go to the proxy, which reads the host
# from the connection. The proxy URL, which holds the password, goes on stdin, never in arguments.
+15 -4
View File
@@ -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
+55 -12
View File
@@ -4,11 +4,14 @@
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.3
mise_sha256_arm64=a9a2a66bbbe87ea9cc849e1f006606ae2b34f3d3ba56a54d5cd5d64b6557d164
mise_sha256_amd64=c2f7e814cb39f60b7f67a0ff36cb805e94128bf2dff09d175309d0f095b8cc3b
mise_sha256_arm64_musl=78c87fb8c8af031755f9241cbcd1886cd458c75e8f324020015445a776789e38
mise_sha256_amd64_musl=72f1cb4591ee2ba90150022c3ee8aea4dd88fadac10c56d04ede4faffb5a1b03
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
export DEBIAN_FRONTEND=noninteractive
# Alpine (--from alpine): apk, OpenRC and musl. Its packages come from the release's repositories,
@@ -39,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
@@ -87,11 +117,24 @@ 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
# config, never the system's, so a VM that mounts its folder keeps the pointers as they are. One static
# build for glibc and musl.
devvm-fetch "https://github.com/git-lfs/git-lfs/releases/download/v$git_lfs_version/git-lfs-linux-$devvm_arch-v$git_lfs_version.tar.gz" \
"$(devvm_sha git_lfs)" /tmp/git-lfs.tar.gz
tar -xzf /tmp/git-lfs.tar.gz -C /tmp "git-lfs-$git_lfs_version/git-lfs"
sudo install -m 755 "/tmp/git-lfs-$git_lfs_version/git-lfs" /usr/local/bin/git-lfs
rm -rf /tmp/git-lfs.tar.gz "/tmp/git-lfs-$git_lfs_version"
# Every shell finds the tools: login shells through profile.d, interactive ones through mise activate
# (it follows `cd` into projects with other versions), and the rest (`bash -c` from agents, editors
# over SSH) through BASH_ENV and mise's shims. Read-only installs can't take global packages or update
+4 -4
View File
@@ -5,11 +5,11 @@ set -euxo pipefail
: "${devvm_libc:?}" # devvm's prelude (prelude.sh) comes before this script
# Pinned downloads (scripts/bump.sh updates them). Docker's repository has no snapshots: its packages
# are pinned by version.
docker_version=29.9.3
docker_version=29.10.0
containerd_version=2.4.2
buildx_version=0.38.1
compose_version=5.7.0
model_version=1.2.9
buildx_version=0.39.1
compose_version=5.8.0
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
+3 -3
View File
@@ -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.5
nix_sha256_arm64=34b8d0c0658321e63143f892086bd2d9623a81bf96e4ffefc1551092d80caedb
nix_sha256_amd64=c349f0559b7849a2cb3b20b8584e532b3fcf5025092cb6180eb0b99240d7b96c
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
View File
@@ -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
+3 -1
View File
@@ -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
+12
View File
@@ -0,0 +1,12 @@
# cursor: its API, where its login polls too (api2), its agent's hosts, which api2's server config
# names (agent.api5 and its regional hosts, which its package doesn't name, so all of them), and its
# codebase indexing (repo42). Its metrics host (api3), its updates (downloads.cursor.com) and Sentry are
# left out: blocking them costs nothing, and its updates are off.
api2.cursor.sh
api5.cursor.sh
*.api5.cursor.sh
repo42.cursor.sh
# The host Cursor documents for Tab requests; Cursor's CLI uses it for its metrics, its
# MetricsService's reports, fire and forget (the metricsUrl in the 2026.11.17 package's
# service-urls, read, not run): https://cursor.com/docs/enterprise/network-configuration
quiet api3.cursor.sh
+5 -3
View File
@@ -1,8 +1,10 @@
# dotnet: NuGet's packages and tools, and the revocation lists of DigiCert, which issues NuGet's
# signing certificates, that NuGet checks each package's signatures against; the SDKs mise installs
# for a global.json's version (the install script at dot.net, the SDK's archive). Microsoft's
# telemetry is left out.
# signing certificates, that NuGet checks each package's signatures against, with DigiCert's OCSP
# responder, which it asks when a list can't be fetched; the SDKs mise installs for a
# global.json's version (the install script at dot.net, the SDK's archive). Microsoft's telemetry
# is left out.
api.nuget.org
crl3.digicert.com:80
ocsp.digicert.com:80
dot.net
builds.dotnet.microsoft.com
+2
View File
@@ -3,3 +3,5 @@ proxy.golang.org
sum.golang.org
go.dev
dl.google.com
# Go's telemetry uploads, which every VM turns off: https://go.dev/doc/telemetry
quiet telemetry.go.dev
+7 -1
View File
@@ -1,6 +1,8 @@
# The shared tools (the docs' images page, "Shared tools"). devvm resolves each, per user, to upstream's newest
# release matching its version here, into ~/.local/share/devvm/mise.lock with each download's checksum
# per platform. A version here is a hold (node = "24"); nothing is pinned.
# per platform. A version here is a hold (node = "24"), but for cursor, which publishes neither a
# version list nor checksums: devvm pins its release and each platform's SHA-256 here, and the lock
# takes them as they are.
# Where each tool that isn't one of mise's own (core:) comes from, named here so that mise's registry
# can't move it to another source: its first choice can change between mise releases (opencode 2
@@ -10,6 +12,7 @@ claude = "aqua:anthropics/claude-code"
codex = "aqua:openai/codex"
opencode = "github:anomalyco/opencode" # its GitHub releases: a musl build of its own, attested
pi = "github:earendil-works/pi" # its GitHub releases: one Bun-built program per platform, glibc only
cursor = "http:cursor" # Cursor's CLI package: its bundled node and programs, glibc only
pnpm = "aqua:pnpm/pnpm"
uv = "aqua:astral-sh/uv"
@@ -26,6 +29,9 @@ claude = "latest"
codex = "latest"
opencode = "2" # upstream marks its 1.x releases as GitHub's latest, which "latest" resolves to
pi = "latest"
# The address and checksums are those of the package Cursor's install script (cursor.com/install) fetches for
# this version; the musl platforms get the same, which their VMs refuse (glibc only).
cursor = { version = "2026.11.17-f532c45", platforms = { linux-x64 = { url = "https://downloads.cursor.com/lab/2026.11.17-f532c45/linux/x64/agent-cli-package.tar.gz", checksum = "sha256:189ed41d8963cd22dcdafbbd62f072cc55ac08374c922dbd04aee525f4018ab6" }, linux-arm64 = { url = "https://downloads.cursor.com/lab/2026.11.17-f532c45/linux/arm64/agent-cli-package.tar.gz", checksum = "sha256:dff929e5e5ace2ced880290095df5938545267d73fd1d84be669be75dbdc1558" } } }
[settings]
experimental = true
+26
View File
@@ -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)
}
+52 -14
View File
@@ -1165,31 +1165,69 @@ html.dark .highlight .chroma .go {
}
}
/* Diagrams (mermaid code blocks, themed in layouts/_partials/scripts/mermaid.html): at their own size,
centered, scrolled sideways when wider than the page. */
.content pre.mermaid {
/* Diagrams (mermaid code blocks, drawn before the build by render-diagrams.mjs and inlined by
layouts/_markup/render-codeblock-mermaid.html): at their own size, centered. One wider than the
text reaches into the article's padding on the right, the page's right margin, as far as it needs,
and when that's not enough, into the padding on the left for the rest; the hook sets its width
(--devvm-diagram-width), and 100% in a margin is the text's width. One wider than the text and both
paddings scrolls sideways. The browser skips drawing one until it nears the screen
(content-visibility), and keeps its place at its height, which the hook sets
(contain-intrinsic-block-size), so the page doesn't jump. pele's variables give them the palette:
panels on the surface color with blue borders, lime lines and arrows, and text in Departure Mono,
which render-diagrams.mjs measures. */
.content .devvm-diagram {
/* Hextra's article padding: 1.5rem, and 3rem from its md breakpoint. */
--devvm-diagram-reach: 1.5rem;
--devvm-diagram-over: max(0px, calc(var(--devvm-diagram-width, 0px) - 100%));
display: flex;
justify-content: safe center;
overflow-x: auto;
margin: 1.5rem 0;
padding: 0;
font-family: var(--devvm-font-pixel);
font-size: 14px;
margin-block: 1.5rem;
margin-inline-end: calc(-1 * min(var(--devvm-diagram-reach), var(--devvm-diagram-over)));
margin-inline-start: calc(-1 * min(var(--devvm-diagram-reach), max(0px, calc(var(--devvm-diagram-over) - var(--devvm-diagram-reach)))));
content-visibility: auto;
font-synthesis: none;
--pele-bg: var(--devvm-bg);
--pele-fg: var(--devvm-text);
--pele-fg-on-dark: var(--devvm-text);
--pele-muted: var(--devvm-text-secondary);
--pele-line: var(--devvm-accent);
--pele-accent: var(--devvm-accent);
--pele-surface: var(--devvm-surface);
--pele-surface-alt: var(--devvm-bg);
--pele-border: var(--devvm-blue);
--pele-font: var(--devvm-font-pixel);
--pele-font-mono: var(--devvm-font-pixel);
--pele-radius: 0;
}
.content pre.mermaid svg {
@media (min-width: 768px) {
.content .devvm-diagram {
--devvm-diagram-reach: 3rem;
}
}
.content .devvm-diagram svg {
flex: none;
}
/* Labels' lines on the font's cell, 18px at 14px, not the page's line height. Mermaid measures them in
the page, so their boxes fit. */
.content pre.mermaid foreignObject p {
margin: 0;
line-height: 18px;
/* Subgraphs and sequence diagrams' lifelines in the darker border color. */
.content .devvm-diagram .pele-cluster > rect,
.content .devvm-diagram .pele-lifeline {
stroke: var(--devvm-border);
}
.content pre.mermaid rect {
/* Notes on black, in that border, with secondary text. */
.content .devvm-diagram .pele-note > rect {
fill: var(--devvm-bg);
stroke: var(--devvm-border);
}
.content .devvm-diagram .pele-note > text {
fill: var(--devvm-text-secondary);
}
.content .devvm-diagram rect {
shape-rendering: crispEdges;
}
+1 -1
View File
@@ -96,7 +96,7 @@ devvm ships the `docker`, `nix` and `desktop` layers, which you choose when you
- The base image comes with [optional extras](docs/using/customizing.md#base-image-features) that you choose, such as oh-my-bash, fzf, zoxide (`z`), tree and tldr.
- Every VM gets your git name and email, so the commits made in it are authored by you or your agent.
- Ports forward on their own, so a dev server on `:5173` in the VM opens at `localhost:5173` on your machine ([ports](docs/using/ports-size.md#ports)).
- `devvm code` opens the VM in VS Code over Remote-SSH ([devvm code](docs/using/ssh.md#devvm-host-and-devvm-code)).
- `devvm code` and `devvm cursor` open the VM in VS Code or Cursor over Remote-SSH ([devvm code and devvm cursor](docs/using/ssh.md#devvm-host-devvm-code-and-devvm-cursor)).
{{< /feature >}}
+2 -1
View File
@@ -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 >}}
+4
View File
@@ -22,6 +22,10 @@ On macOS, `.git` protection uses your machine's file flags, so it doesn't depend
An image's key includes its backend, so a backend never uses an image another backend built.
```sh
devvm doctor # Lima's features, and what devvm needs on this machine
```
`devvm doctor` lists Lima's features, which are what Lima does itself, what devvm builds from other parts of it, and what it can't do. These are backend features, not the base image features you choose with `devvm setup`, even though `devvm doctor` calls both "features". [How it works › Backends](../internals/backends.md) explains them.
## A VM's backend
+12 -4
View File
@@ -69,13 +69,15 @@ On Linux, QEMU shares the project folder with the VM over 9p, and the VM's kerne
Lima's own default for a writable folder is `mmap`, which caches the files' contents in the VM, and Linux's 9p client loses data with it in two ways. When a program reads a file's size while another write is making the file longer, the VM can take the older size from this machine and drop the new data, even after `fsync` succeeded, so the file ends up empty or cut to 4096 bytes, and Claude Code's edits are one way to set it off. And when a program locks a file it has written, its next read of that file returns zeros. That stops SQLite at its second write with `file is not a database`, whatever its journal mode, and Gradle's second build with `Unexpected lock protocol found in lock file`.
A VM made before devvm chose `none` keeps `mmap`, and devvm doesn't change its mount on its own, so each launch of such a VM warns until you switch it. `devvm mount-cache` shows how this folder's VM caches its project folder, and `devvm mount-cache none` switches it from the VM's next start, so in a terminal devvm offers to restart a running VM now. `none` is the only mode devvm sets, so any other value is refused.
A VM made before devvm chose `none` keeps `mmap`, and devvm doesn't change its mount on its own, so each launch of such a VM warns until you switch it:
```sh
devvm mount-cache
devvm mount-cache none
devvm mount-cache # how this folder's VM caches its project folder
devvm mount-cache none # switch it to none from the VM's next start
```
`devvm mount-cache none` switches the mode from the VM's next start, so in a terminal devvm offers to restart a running VM now. `none` is the only mode devvm sets, so any other value is refused.
A [`--clone` VM](../using/clone.md) mounts no project folder, so it has no cache mode until `devvm clone off` mounts the folder, which then gets `none`. On macOS, VMs share the project folder with virtiofs, which has no cache mode to choose, so there `devvm mount-cache` refuses. On Linux it refuses the same for a VM whose project folder isn't a 9p mount, such as one whose Lima config you gave another mount type.
### When the cache mode changes
@@ -120,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
+3
View File
@@ -18,6 +18,7 @@ Every devvm command, with its arguments and flags. `devvm <command> --help` prin
- [devvm clone fetch](devvm_clone_fetch.md): Fetch the work of this folder's --clone VM into each of its repos
- [devvm code](devvm_code.md): Open this folder's VM in VS Code over Remote-SSH
- [devvm completion](devvm_completion.md): Print the shell completion script for bash, zsh or fish
- [devvm cursor](devvm_cursor.md): Open this folder's VM in Cursor over Remote-SSH
- [devvm desktop](devvm_desktop.md): Open this folder's VM's desktop in a VNC viewer
- [devvm doctor](devvm_doctor.md): Check what devvm needs on this machine
- [devvm gc](devvm_gc.md): Delete stale images, unused tools, old files and the Nix cache over its cap
@@ -50,6 +51,8 @@ Every devvm command, with its arguments and flags. `devvm <command> --help` prin
- [devvm network log](devvm_network_log.md): Show what this folder's VM connected to and what its proxy blocked
- [devvm network rm](devvm_network_rm.md): Remove rules from this folder's VM
- [devvm network transparent](devvm_network_transparent.md): Show or change transparent mode for this folder's VM
- [devvm paste](devvm_paste.md): Send the clipboard's image, PDF or copied file to this folder's VM
- [devvm paste rm](devvm_paste_rm.md): Delete the files devvm paste left in this folder's VM
- [devvm ports](devvm_ports.md): Show or change which ports this folder's VM forwards
- [devvm ports add](devvm_ports_add.md): Forward more ports from this folder's VM
- [devvm ports rm](devvm_ports_rm.md): Stop forwarding some ports from this folder's VM
+2
View File
@@ -62,6 +62,7 @@ devvm [flags]
- [devvm clone](devvm_clone.md): Show or change whether this folder's VM has its own clone of the repo
- [devvm code](devvm_code.md): Open this folder's VM in VS Code over Remote-SSH
- [devvm completion](devvm_completion.md): Print the shell completion script for bash, zsh or fish
- [devvm cursor](devvm_cursor.md): Open this folder's VM in Cursor over Remote-SSH
- [devvm desktop](devvm_desktop.md): Open this folder's VM's desktop in a VNC viewer
- [devvm doctor](devvm_doctor.md): Check what devvm needs on this machine
- [devvm gc](devvm_gc.md): Delete stale images, unused tools, old files and the Nix cache over its cap
@@ -76,6 +77,7 @@ devvm [flags]
- [devvm ls](devvm_ls.md): List the project VMs
- [devvm mount-cache](devvm_mount-cache.md): Show or change how this folder's VM caches its project folder
- [devvm network](devvm_network.md): Show or change the network tier of this folder's VM
- [devvm paste](devvm_paste.md): Send the clipboard's image, PDF or copied file to this folder's VM
- [devvm ports](devvm_ports.md): Show or change which ports this folder's VM forwards
- [devvm rebuild](devvm_rebuild.md): Build an image again, and delete the old one
- [devvm restart](devvm_restart.md): Restart this folder's VM and open a shell in it
+8 -6
View File
@@ -7,7 +7,7 @@ Copy the agents' settings and logins from this machine into devvm's store
## Synopsis
Copy the settings and logins of AGENT, claude, codex, opencode or pi, or of every agent, from your home folder into devvm's store, never their history. It follows no link out of an agent's folder, and it asks before replacing what the store has.
Copy the settings and logins of AGENT, claude, codex, opencode, pi or cursor, or of every agent, from your home folder into devvm's store, never their history. It copies what a link out of an agent's folder leads to only from a folder that config.toml's follow-links names, or after naming the link and asking, which --follow-links answers. It asks before replacing what the store has.
```text
devvm agent import [AGENT...] [flags]
@@ -16,16 +16,18 @@ devvm agent import [AGENT...] [flags]
## Examples
```text
devvm agent import # copy every agent's settings and logins, asking before replacing the store's
devvm agent import claude codex # copy only Claude Code's and Codex's
devvm agent import --force # replace the store's without asking, as a script must
devvm agent import # copy every agent's settings and logins, asking before replacing the store's
devvm agent import claude codex # copy only Claude Code's and Codex's
devvm agent import --force # replace the store's without asking, as a script must
devvm agent import --follow-links # copy what links out of the agents' folders lead to as well, such as into a dotfiles repo
```
## Options
```text
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
-h, --help help for import
--follow-links copy what links out of the agents' folders lead to, naming each, without asking (default: ask in a terminal)
-f, --force don't ask to confirm, which devvm needs without a terminal or with --no-input
-h, --help help for import
```
## Options inherited from parent commands
+1 -1
View File
@@ -7,7 +7,7 @@ Log an agent in, in this folder's VM, and save the login in devvm's store
## Synopsis
Log AGENT in inside this folder's VM, and keep the login in devvm's store for every VM with the agent, which gets only placeholders. claude logs in to your Claude subscription in a browser on any machine, whose code you paste back, or gets a long-lived Claude Code token with --setup-token. codex and opencode log in to ChatGPT in a browser on this machine, or with a code with --device-code, or save an API key with --api-key, which is pi's only login.
Log AGENT in inside this folder's VM, and keep the login in devvm's store for every VM with the agent, which gets only placeholders. claude logs in through a browser on any machine, whose code you paste back, or gets a long-lived Claude Code token with --setup-token. codex and opencode log in to ChatGPT in a browser on this machine, or with a code with --device-code, or save an API key with --api-key, which is pi's only login.
```text
devvm agent login AGENT [flags]
+1 -1
View File
@@ -7,7 +7,7 @@ Copy the agents' settings from this folder's VM into devvm's store
## Synopsis
Copy the settings of AGENT, claude, codex, opencode or pi, or of every agent this folder's VM has, from the VM into devvm's store, so every VM with the agent gets them, never its logins or history. It shows what changed and asks first, so it runs only in a terminal without --no-input, and devvm starts a stopped VM for it.
Copy the settings of AGENT, claude, codex, opencode, pi or cursor, or of every agent this folder's VM has, from the VM into devvm's store, so every VM with the agent gets them, never its logins or history. It shows what changed and asks first, so it runs only in a terminal without --no-input, and devvm starts a stopped VM for it.
```text
devvm agent save [AGENT...] [flags]
+10 -9
View File
@@ -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
+1 -1
View File
@@ -7,7 +7,7 @@ Copy one more repo into this folder's --clone VM
## Synopsis
Copy the repo at PATH, a folder in this folder's --clone VM's folder, into the VM at the same path, with its current and default branches, starting the VM if it's stopped. The repo gets a remote for the VM, as each of the VM's repos has.
Copy the repo at PATH, a folder in this folder's --clone VM's folder, into the VM at the same path, with its branches, tags and remote-tracking branches, checked out as it is here, starting the VM if it's stopped. The repo gets a remote for the VM, as each of the VM's repos has.
```text
devvm clone add PATH [flags]
+1 -1
View File
@@ -7,7 +7,7 @@ Fetch the work of this folder's --clone VM into each of its repos
## Synopsis
Fetch every branch of each repo in this folder's --clone VM into the repo on this machine, as remote-tracking branches of its remote for the VM, such as devvm/main, starting the VM if it's stopped. Then list the branches that are new or moved, each with the repos it's in.
Fetch every branch of each repo in this folder's --clone VM into the repo on this machine, as remote-tracking branches of its remote for the VM, such as devvm/main, starting the VM if it's stopped. When a repo's HEAD in the VM is detached at commits no branch has, fetch those into a new local branch, saved/devvm/HEAD, and each stash entry the VM made into saved/devvm/stash-N. Then list the branches that are new or moved, each with the repos it's in.
```text
devvm clone fetch [flags]
+1 -1
View File
@@ -38,7 +38,7 @@ devvm code [flags]
## Docs
[The docs page for devvm code](../using/ssh.md#vs-code) explains it in full.
[The docs page for devvm code](../using/ssh.md#vs-code-and-cursor) explains it in full.
## See also
+45
View File
@@ -0,0 +1,45 @@
---
title: devvm cursor
explainer: "Open this folder's VM in Cursor over Remote-SSH"
---
Open this folder's VM in Cursor over Remote-SSH
## Synopsis
Get this folder's VM ready as devvm host does, then open its folder in the Cursor editor over Remote-SSH, with Cursor's cursor command.
```text
devvm cursor [flags]
```
## Examples
```text
devvm cursor # open this folder's VM in Cursor
devvm cursor --ssh-config # the same, adding devvm's Include line to ~/.ssh/config without asking
```
## Options
```text
-h, --help help for cursor
--here use this folder's own VM, never that of a folder it's inside
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
--ssh-config add devvm's Include line to ~/.ssh/config without asking
```
## Options inherited from parent commands
```text
--no-input never ask, and fail where devvm would ask, naming the flag that answers it
-v, --verbose show the output of the commands devvm runs instead of a status line
```
## Docs
[The docs page for devvm cursor](../using/ssh.md#vs-code-and-cursor) explains it in full.
## See also
- [devvm](devvm.md): Open a shell in this folder's VM, creating it first
+1 -1
View File
@@ -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]
+1 -1
View File
@@ -38,7 +38,7 @@ devvm host [flags]
## Docs
[The docs page for devvm host](../using/ssh.md#devvm-host-and-devvm-code) explains it in full.
[The docs page for devvm host](../using/ssh.md#devvm-host-devvm-code-and-devvm-cursor) explains it in full.
## See also
+7 -6
View File
@@ -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
+7 -6
View File
@@ -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
+49
View File
@@ -0,0 +1,49 @@
---
title: devvm paste
explainer: "Send the clipboard's image, PDF or copied file to this folder's VM"
---
Send the clipboard's image, PDF or copied file to this folder's VM
## Synopsis
Put the image, the PDF, or the one copied file, that's on this machine's clipboard into this folder's VM, which must be running, as a new file in its paste folder, and copy that file's path to the clipboard. A copied file is sent after asking, showing its path on this machine, and only a file in this folder, which the VM already reads, is sent without asking, with --send-file. Then paste the path into the agent with your terminal's paste shortcut.
```text
devvm paste [flags]
```
## Examples
```text
devvm paste # send the copied image, and copy its path in the VM
devvm paste --json # the same, printing the path and what was sent as JSON
devvm paste --send-file # send a copied file in this folder without asking, as a script must
devvm paste rm # delete the files devvm paste left in the VM
```
## Options
```text
-h, --help help for paste
--here use this folder's own VM, never that of a folder it's inside
--json print it as one JSON object, for scripts
--parent use the VM of the nearest folder this one is inside, even across a git repo of its own
--send-file send a copied file in this folder without asking
```
## Options inherited from parent commands
```text
--no-input never ask, and fail where devvm would ask, naming the flag that answers it
-v, --verbose show the output of the commands devvm runs instead of a status line
```
## Docs
[The docs page for devvm paste](../using/coding-agents.md#pasting-images) explains it in full.
## See also
- [devvm](devvm.md): Open a shell in this folder's VM, creating it first
- [devvm paste rm](devvm_paste_rm.md): Delete the files devvm paste left in this folder's VM
+45
View File
@@ -0,0 +1,45 @@
---
title: devvm paste rm
explainer: "Delete the files devvm paste left in this folder's VM"
---
Delete the files devvm paste left in this folder's VM
## Synopsis
Delete the images and files that devvm paste put in this folder's VM's paste folder, after asking, and nothing else in that folder. The VM must be running.
```text
devvm paste rm [flags]
```
## Examples
```text
devvm paste rm # delete them after asking
devvm paste rm --force # delete them without asking, as a script must
```
## 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
--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
```text
--no-input never ask, and fail where devvm would ask, naming the flag that answers it
-v, --verbose show the output of the commands devvm runs instead of a status line
```
## Docs
[The docs page for devvm paste rm](../using/coding-agents.md#pasting-images) explains it in full.
## See also
- [devvm paste](devvm_paste.md): Send the clipboard's image, PDF or copied file to this folder's VM
+9 -7
View File
@@ -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
+7 -6
View File
@@ -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
+16 -7
View File
@@ -6,13 +6,14 @@ weight: 50
devvm gives each project folder a VM of its own on your machine, with the project's toolchains shared read-only between VMs, a proxy on this machine that confines the VM's network, and your secrets kept outside the VM. Other tools sandbox coding agents in other ways: in a microVM, in an OS sandbox around the agent's process, or on a vendor's servers. This page sets devvm beside the ones you're most likely to weigh it against.
Last checked on 2026-11-08, against each tool's own docs, which the [sources](#sources) list. These tools change every week, so check a tool's own docs before you rely on a row here, and [open an issue](https://github.com/devvmhq/devvm/issues) when a row is out of date.
> [!NOTE]
> Last checked on 2026-11-08, against each tool's own docs, which the [sources](#sources) list. These tools change every week, so check a tool's own docs before you rely on a row here, and [open an issue](https://github.com/devvmhq/devvm/issues) when a row is out of date.
## Boundary and where it runs
| | Boundary | Runs on | Project files | Open source | Account and cost |
| --- | --- | --- | --- | --- | --- |
| devvm | a full VM with its own kernel, on Lima | macOS 13 or newer and Linux, on arm64 or x86_64 | mounted read-write at the same path, or the VM's own clone with `--clone` | yes, MIT | no account, free |
| devvm | a full VM with its own kernel, on Lima | macOS 13 or newer and Linux, on arm64 or x86_64 | mounted read-write at the same path, or with `--clone`, the VM's own clone of the repo as `git status` shows it here | yes, MIT | no account, free |
| [Docker Sandboxes](docker-sandboxes.md) | a microVM with its own kernel and Docker Engine | macOS 14 or newer on Apple silicon, Windows 11, Ubuntu 24.04 or newer, and Docker's cloud | mounted read-write, a private clone, or none | no | a Docker sign-in; free locally, cloud paid by use |
| NVIDIA OpenShell | containers on Kubernetes, Podman or Docker with Landlock and seccomp, or a microVM you choose | Linux, macOS on Apple silicon through Docker Desktop, and Windows through WSL2 as an experiment | copied in and out | yes, Apache-2.0 | no account, free |
| microsandbox | a microVM with its own kernel, running as root inside | macOS on Apple silicon, Linux and Windows | mounted read-write by default | yes, Apache-2.0 | no account, free locally |
@@ -26,8 +27,8 @@ Last checked on 2026-11-08, against each tool's own docs, which the [sources](#s
| | Network by default | Rules by | API keys | Agent logins | Agents |
| --- | --- | --- | --- | --- | --- |
| devvm | the allowlist tier: devvm's built-in hosts, your secrets' hosts and yours, enforced outside the VM | host and port | placeholders in the VM, real values added by the proxy on this machine | made through the proxy or imported, kept and refreshed on this machine, with placeholders in the VM | Claude Code, Codex, opencode and pi |
| Docker Sandboxes | a preset you choose at first run: open, balanced or locked down | host, and HTTP method, path and query | placeholders in the VM, real values added by a proxy on the host | kept on the host for Claude Code, Codex, Cursor and Droid, with placeholders in the VM; you log in to Claude Code inside the sandbox, and one login serves every sandbox | Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Gemini, Kiro and OpenCode |
| devvm | the allowlist tier: devvm's built-in hosts, your secrets' hosts and yours, enforced outside the VM, or the internet tier while the VM learns the hosts it needs | host and port, and HTTP method and path | placeholders in the VM, real values added by the proxy on this machine, for agents' providers and for any API key you save as your own secret | made through the proxy or imported, kept on this machine and refreshed there for Claude Code, Codex and opencode, with placeholders in the VM | Claude Code, Codex, opencode, pi and Cursor's CLI |
| Docker Sandboxes | a preset you choose at first run: open, balanced or locked down | host and port, and HTTP method, path and query | placeholders in the VM, real values added by a proxy on the host | kept on the host for Claude Code, Codex, Cursor and Droid, with placeholders in the VM; you log in to Claude Code inside the sandbox, and one login serves every sandbox | Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Gemini, Kiro and OpenCode |
| NVIDIA OpenShell | deny for hosts no rule names; method and path rules only log by default | host, port and the calling program, and method and path if you turn them on | placeholders from providers | not documented; providers take API keys from your environment | Claude Code, OpenCode, Codex and GitHub Copilot CLI, in your own image |
| microsandbox | public internet open, private addresses refused | domain, address and port | placeholders, over TLS that the host intercepts | its Claude Code guide logs in inside the VM | any, with a guide for Claude Code |
| smolvm | off | host and address range | placeholders in headers, and in form bodies if you turn it on | not documented | any |
@@ -38,9 +39,16 @@ Last checked on 2026-11-08, against each tool's own docs, which the [sources](#s
## How devvm differs
Of the tools on this page, only devvm shares toolchains read-only between VMs, so a second project that needs node uses the same copy as the first, and nothing in a VM can change it. devvm detects the toolchains from the project's files and reads a project's `devcontainer.json`. It locks a folder's `.git` hooks and config against the VM, so the VM can't add a hook that runs on this machine, which Docker Sandboxes' docs say its direct mode doesn't prevent. Its network confinement holds even against root in the VM, because devvm enforces it from outside the VM. A VM can [learn the hosts it needs](../safety/network.md#learning-the-hosts-a-vm-needs) and then keep the ones you choose, much as OpenShell shows you the hosts it blocked so that you can approve them.
Beyond the tables, these are the differences you're most likely to weigh:
devvm keeps each agent's login on this machine and refreshes it there, so a confined VM never holds it, and Docker Sandboxes does the same for Claude Code, Codex, Cursor and Droid. In both, one login for each agent serves every VM. On devvm's open tier, a program in the VM can go around the proxy and keep a login that it makes there.
- **Shared toolchains.** Of the tools on this page, only devvm shares toolchains read-only between VMs, so a second project that needs node uses the same copy as the first, and nothing in a VM can change it. devvm detects the toolchains from the project's files and reads a project's `devcontainer.json`.
- **`.git` protection.** devvm locks the hooks and config of a folder's `.git` against the VM, and those of each repo nested up to four folders below it, so the VM can't add a hook that runs on this machine, which Docker Sandboxes' docs say its direct mode doesn't prevent. On Linux the locks need no root, and where the kernel doesn't allow them, such as on Ubuntu 23.10 and newer, devvm watches `.git` instead and names what changed ([.git protection](../safety/git-protection.md)).
- **A clone of your repo as it is.** With `--clone`, the VM works on a clone of its own instead of your folder, and the clone gets your local branches, tags, uncommitted changes, stash, the repo's settings and hooks, its submodules and its Git LFS files. `devvm clone fetch` brings the VM's work back as branches, and `devvm rm` checks for work you haven't fetched before it deletes the VM ([working on a clone](../using/clone.md)).
- **Confinement from outside the VM.** devvm enforces the network policy from outside the VM, so it holds even against root in the VM. Transparent mode also sends tools that ignore the proxy settings, such as static Go binaries and containers, to the VM's proxy, on every tier but open.
- **Learning a VM's hosts.** A VM can [learn the hosts it needs](../safety/network.md#learning-the-hosts-a-vm-needs) on the internet tier, and `devvm network lock` then keeps the ones you choose, much as OpenShell shows you the hosts it blocked so that you can approve them.
- **Your own secrets.** Any API key that a tool sends in a header can be a secret of your own, so the VM gets a placeholder, and its proxy puts the real value only into requests to the hosts, methods and paths you give it ([your own secrets](../safety/network.md#your-own-secrets)).
- **Agents' logins on this machine.** devvm keeps each agent's login on this machine, so a confined VM never holds it, and Docker Sandboxes does the same for Claude Code, Codex, Cursor and Droid. In both, one login for each agent serves every VM. On devvm's open tier, a program in the VM can go around the proxy and keep a login that it makes there.
- **Images from the clipboard.** `devvm paste` sends an image, a PDF or a file you copied on this machine into the VM, and puts its path in the VM on your clipboard for the agent's prompt. It never reads text from the clipboard ([pasting images](../using/coding-agents.md#pasting-images)).
## What devvm doesn't do
@@ -54,7 +62,8 @@ devvm keeps each agent's login on this machine and refreshes it there, so a conf
## Other tools
- **Clawk** and **agent-vm** are closer to devvm in shape, with a VM for each folder on your machine. Clawk denies outbound traffic by default, but it forwards your SSH agent, and its tip for Claude Code signs every sandbox in with your Claude Code token. agent-vm runs Lima as devvm does, makes every `.git` read-only for the VM from your machine and asks you before the VM writes files such as `.envrc` and `.vscode/tasks.json`, but the VM reaches the whole internet unless you add domain rules.
- **Clawk** is closer to devvm in shape, with a VM for each folder on your machine. It denies outbound traffic by default, but it forwards your SSH agent, and its tip for Claude Code signs every sandbox in with your Claude Code token.
- **agent-vm** also gives each folder a VM on your machine, and it runs Lima as devvm does. It makes every `.git` read-only for the VM from your machine and asks you before the VM writes files such as `.envrc` and `.vscode/tasks.json`, but the VM reaches the whole internet unless you add domain rules.
- **Lima's own recipe** for coding agents mounts only the project folder, or syncs it and asks before the VM's changes reach your machine, and it leaves the network and API keys to you.
- **Dev Containers** run in a container, which shares this machine's kernel or Docker's VM, and set no network policy. Claude Code's reference container adds a firewall allowlist, and its docs warn that it doesn't stop a malicious project from sending out what's in the container, Claude Code's login included.
- **Hosted sandboxes,** such as E2B, Vercel Sandbox, Fly.io Sprites and exe.dev, run on the vendor's servers, so your code and keys go there, and each needs an account.
+12 -7
View File
@@ -4,14 +4,15 @@ explainer: devvm and Docker Sandboxes, side by side
weight: 1
---
Docker Sandboxes, the `sbx` command, is the tool closest to devvm: each sandbox is a VM with its own kernel on your machine, the project folder is mounted read-write, outbound traffic goes through a proxy on your machine, and API keys and agents' logins stay outside the VM. This page sets the two side by side. Last checked on 2026-11-08 against Docker's docs, which each row links to.
Docker Sandboxes, the `sbx` command, is the tool closest to devvm: each sandbox is a VM with its own kernel on your machine, the project folder is mounted read-write, outbound traffic goes through a proxy on your machine, and API keys and agents' logins stay outside the VM. This page sets the two side by side. Last checked on 2026-11-08 against Docker's docs, which each row links to, and against Docker's isolation and network rules pages again on 2026-11-12.
## What's the same
- **A VM with its own kernel.** Docker's sandboxes are microVMs with their own Linux kernel and Docker Engine, and the agent runs as a user with sudo ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)). devvm's VMs are full Lima VMs, whose user also has sudo.
- **The folder mounted, or a clone.** Both mount the project folder read-write by default, and both have a mode in which the VM works on a clone of its own instead ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/), [working on a clone](../using/clone.md)).
- **Placeholders for API keys.** In both, the VM holds a placeholder, and a proxy on your machine puts the real value into requests ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/), [secrets](../safety/network.md#secrets)).
- **Agents' logins on your machine.** Both keep the logins of the agents they support outside the VM and give the VM placeholders, and in both, one login for each agent serves every VM. Docker Sandboxes does this for Claude Code, Codex, Cursor and Droid ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/)), and devvm for Claude Code, Codex and opencode ([coding agents](../using/coding-agents.md#logins-made-in-a-vm)).
- **Agents' logins on your machine.** Both keep the logins of the agents they support outside the VM and give the VM placeholders, and in both, one login for each agent serves every VM. Docker Sandboxes does this for Claude Code, Codex, Cursor and Droid ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/)), and devvm for Claude Code, Codex, opencode and Cursor's CLI, and for pi's API keys ([coding agents](../using/coding-agents.md#logins-made-in-a-vm)).
- **Rules by method and path.** Both let a rule for a host name its HTTP methods and its path, so a VM can read from an API without changing anything there ([network rules](https://docs.docker.com/ai/governance/local/network-rules/), [rules by method and path](../safety/network.md#rules-by-method-and-path)).
## What differs
@@ -21,18 +22,22 @@ Docker Sandboxes, the `sbx` command, is the tool closest to devvm: each sandbox
| Usage data | none; a release check at most once a day, which you can turn off | usage data, with your Docker username when you're signed in, unless you turn it off ([FAQ](https://docs.docker.com/ai/sandboxes/faq/)) |
| Hosts | macOS 13 or newer and Linux | macOS 14 or newer on Apple silicon, Windows 11 and Ubuntu 24.04 or newer, plus Docker's cloud ([install](https://docs.docker.com/ai/sandboxes/install/)) |
| Network default | the allowlist tier | a preset you choose at first run ([network rules](https://docs.docker.com/ai/governance/local/network-rules/)) |
| Rules | host and port | host, and HTTP method, path and query ([network rules](https://docs.docker.com/ai/governance/local/network-rules/)) |
| `.git` in the folder | hooks and config locked on macOS, and read-only in the VM on Linux where the kernel allows it, or watched where it doesn't ([.git protection](../safety/git-protection.md)) | writable by the agent in direct mode, which the docs warn about, along with CI and editor config ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)) |
| Rules | host and port, and HTTP method and path | host and port, and HTTP method, path and URL query ([network rules](https://docs.docker.com/ai/governance/local/network-rules/)) |
| Learning the hosts a VM needs | `--network learn`, then `devvm network lock` keeps the hosts you choose ([learning](../safety/network.md#learning-the-hosts-a-vm-needs)) | none on its network rules page, which has a log of blocked connections ([network rules](https://docs.docker.com/ai/governance/local/network-rules/)) |
| `.git` in the folder | hooks and config locked on macOS, and read-only in the VM on Linux where the kernel allows it, or watched where it doesn't, for the folder's own repo and each repo nested up to four folders down ([.git protection](../safety/git-protection.md)) | writable by the agent in direct mode, which the docs warn about, along with CI and editor config ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)) |
| The clone | your local branches, tags, uncommitted changes, stash, the repo's settings and hooks, submodules and Git LFS files, with the work fetched back by `devvm clone fetch` as `devvm/<branch>` ([what's copied](../using/clone.md#whats-copied)) | a private clone with its own index, refs and working tree, fetched back through a `sandbox-<sandbox-name>` remote, and the docs don't say what it copies ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)) |
| Claude Code's login | you log in with `devvm agent login claude`, or in the VM; devvm keeps the login and refreshes it on your machine, and the VM gets placeholders | you log in with `/login` inside the sandbox, and a proxy on the host takes the tokens from the login's token exchange, keeps them in your host's keychain and gives the sandbox placeholders; that one login serves every sandbox ([Claude Code](https://docs.docker.com/ai/sandboxes/agents/claude-code/), [credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/), [one login](https://github.com/docker/sbx-releases/issues/74)) |
| SSH agent | off by default | forwarded by default ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)) |
| MCP servers | run in the VM | local stdio servers run on your machine ([security](https://docs.docker.com/ai/sandboxes/security/)) |
| Ports | every port from 1024 up forwarded to `localhost` unless you limit them | none until you publish one ([usage](https://docs.docker.com/ai/sandboxes/usage/)) |
| Toolchains | shared read-only between VMs, detected from the project's files | in each sandbox's own image |
| Agents | Claude Code, Codex, opencode and pi | Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Gemini, Kiro and OpenCode ([agents](https://docs.docker.com/ai/sandboxes/agents/)) |
| Agents | Claude Code, Codex, opencode, pi and Cursor's CLI | Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Gemini, Kiro and OpenCode ([agents](https://docs.docker.com/ai/sandboxes/agents/)) |
| Images from the clipboard | `devvm paste` sends an image, a PDF or a copied file into the VM, and never text ([pasting images](../using/coding-agents.md#pasting-images)) | the sandbox can read images from the host's clipboard if you turn that on, and can write text there but not read it ([isolation](https://docs.docker.com/ai/sandboxes/security/isolation/)) |
| Snapshots | none | a sandbox saved as a template ([template save](https://docs.docker.com/reference/cli/sbx/template/save/)) |
| Secrets from other stores | saved with `devvm secret set` | 1Password, AWS Secrets Manager or a command ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/)) |
| Secrets from other stores | saved with `devvm secret set`, each with the hosts, methods and paths it goes to ([your own secrets](../safety/network.md#your-own-secrets)) | 1Password, AWS Secrets Manager or a command ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/)) |
| Secrets on Linux | in files only you can read | in a file only you can read when no Secret Service runs ([credentials](https://docs.docker.com/ai/sandboxes/configuration/credentials/)) |
## Choosing between them
Choose Docker Sandboxes if you need Windows, rules by HTTP method and path, one of the agents devvm doesn't support, or a sandbox you can move to Docker's cloud. Choose devvm if you want open source without an account, toolchains shared between projects, or `.git` protected from the VM in the folder you work in.
- **Choose Docker Sandboxes** if you need Windows, rules by URL query, one of the agents devvm doesn't support, a sandbox saved as a template, or a sandbox you can move to Docker's cloud.
- **Choose devvm** if you want open source without an account, toolchains shared between projects, `.git` protected from the VM in the folder you work in and in the repos nested in it, or a VM that learns the hosts it needs before you lock its allowlist.
+52 -13
View File
@@ -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 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
@@ -34,10 +34,11 @@ mise installs every tool at the version pinned in `mise.toml`, checked against `
| golangci-lint | Go linters and formatters (`.golangci.yml`) |
| gotestsum | running the tests |
| govulncheck | checking dependencies for known vulnerabilities |
| goreleaser | release builds ([Maintaining](maintaining.md#releasing)) |
| hugo-extended | the docs site |
| nilaway | finding where a nil value may be dereferenced |
| 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 |
| node | running markdownlint-cli2, and drawing the docs site's diagrams with pele, which `docs/package.json` pins ([diagrams](docs.md#writing-docs)) |
| shellcheck | linting shell scripts |
| actionlint, zizmor | linting the GitHub workflows, and checking them for security problems |
| minisign | signing releases |
@@ -49,20 +50,48 @@ Run the tasks with `mise run <task>`:
| `fmt` | formats Go code |
| `lint` | runs `lint:code` and `lint:docs` |
| `lint:code` | runs golangci-lint, shellcheck, actionlint and zizmor |
| `lint:docs` | runs the docs linters, the message link check and the command line check, and builds the site, which fails on any warning |
| `lint:docs` | draws the diagrams (`docs:diagrams`), runs the docs linters, the message link check, the command line check and the user pages' prose check, and builds the site, which fails on any warning |
| `test` | runs the tests with the race detector, then checks each package's coverage against its [baseline](tests.md#coverage) |
| `coverage` | runs the tests, then raises each package's coverage baseline to what they reach (`scripts/test.sh --raise`) |
| `vuln` | runs govulncheck |
| `vuln` | runs govulncheck on the code as built for Linux and as built for macOS |
| `nilaway` | reports where a nil value may be dereferenced in devvm's own code, not the tests', and the findings that `testdata/nilaway-baseline.txt` hasn't triaged ([Nil checks](#nil-checks)) |
| `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` | generates the CLI reference, then serves the docs site |
| `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 |
`mise run test` needs a C compiler for the race detector: Xcode Command Line Tools on macOS, gcc on Linux. It gives each package 30 minutes rather than go test's 10, because the CLI tests run the built binary against many stubs and take far longer on a busy machine. Both test tasks run `scripts/test.sh`, which gives the tests a throwaway `HOME`.
Before and after every change, `mise run fmt && mise run lint && mise run test` must pass.
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. 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
```sh
mise run nilaway # where a nil value may reach a dereference in devvm's code, and which findings are new
```
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 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. 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 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:
- `checked`: a value used only once its error was checked, in a way nilaway doesn't follow, such as `err == nil && fi.Mode()`.
- `bounds`: a slice indexed only within its length or sliced where nil is safe, or a variadic parameter that every caller passes.
- `mapkey`: a map read with a key taken from the same map, or after its `ok`.
- `nilsafe`: a method that checks for a nil receiver itself, or values that are always set together.
The script lists the baseline's lines that match no finding any more after `stale:`, and you remove one line for each.
## Go lint rules
@@ -70,13 +99,23 @@ 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` |
| 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` and `internal/safefile` use only the standard library and each other |
| 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. `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`) |
| govet | besides its defaults, `nilness` (a nil pointer dereferenced, or a nil check that is always true or always false), `unusedwrite` (a field written to a copy of a struct that nothing reads again), `hostport` (an address built as `host + ":" + port`, which breaks on IPv6, where `net.JoinHostPort` belongs) and `waitgroup` (`WaitGroup.Add` called inside the goroutine it counts) |
| 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. 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 fresh context elsewhere, such as for a cleanup that outlives a canceled run, or a lookup that many requests share, takes `//nolint:forbidigo // <why>`.
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.
`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.
@@ -86,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`.
- **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.
+19
View File
@@ -22,6 +22,24 @@ Whatever a failure would leave behind, such as a build VM or a temporary file, r
devvm runs every external command through the UI's `LoggedCmd(ctx, step, cmd)`, which a backend gets as its `Runner`. The command's output goes to the run log, a terminal's status line shows `step`, and a failure after it is returned as `backend.Logged(m)`, which shows the end of the log with the message. `WithSteps(ctx, n)` starts a phase of `n` steps, and each `LoggedCmd` with the context it returns is numbered, as `[2/5] running base.sh`, on its status line and in the log.
### Status lines
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) {
defer e.Status(msg.ReadingVMs())()
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, 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 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, 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, 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
Each command checks its arguments and flags before it does anything else, so a usage error never looks for a VM, applies the retention settings or changes a file. `internal/cli/args.go` holds the checks:
@@ -70,6 +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, 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`.
+210
View File
@@ -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.
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`, devvm's own agent too); 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.
@@ -29,7 +31,7 @@ These settings guard against the host's ssh asking for a forward that devvm's en
**Not covered:**
- A remote forward you ask for (`ssh -R`, a `RemoteForward` of yours): [remote forwards you add](../safety/attack-vectors.md#the-network) lists what it leaves open.
- Sessions see the proxy's password, as devvm's own shells do, and VS Code relays what [VS Code](../using/ssh.md#vs-code) describes.
- Sessions see the proxy's password, as devvm's own shells do, and VS Code and Cursor relay what [VS Code and Cursor](../using/ssh.md#vs-code-and-cursor) describes.
### Ports on Lima
@@ -38,21 +40,21 @@ 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 a start empties the log once it's over 1 MiB. 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. 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. A port the forwarder couldn't take 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. 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.
- **Reserved ports.** The forwarder never takes the VM's own Lima ssh port, which Lima's `SSH` names, or its proxy port, which its state records, and the owner passes both as `-reserve`. It also never takes the ssh, proxy and desktop ports devvm chooses and records in any VM's state, or other VMs' listed ports (`ports.Used`). Every Lima VM's ssh port is one of those, whatever its tier: devvm chooses it when it makes the VM, sets it with `limactl clone --set .ssh.localPort`, and records it in the VM's `ports` section before the clone (`ports.Allocator.SSH`). One allocator, `ports.Allocator`, chooses every host port devvm chooses, the ssh, proxy and desktop ports, and records it while it holds the VM's lock and then the claims lock (`run/claims.lock`, `state.VM.Claim`) until the VM's state is written, so two devvm commands making or starting VMs at once never choose the same one. A build VM has no state, so devvm chooses its ssh port too, on every host, through the same allocator (`ports.Allocator.Build`), under the claims lock alone (`state.Claims`), and on macOS the build's Seatbelt profile names that port. It records the port by the build VM's name (`run/build-ports/<name>`), where `ports.Used` reads it, until `limactl start` returns, and by then Lima has bound the port or the start has failed. The devvm that starts the build holds a file lock on that record until then, and the kernel lets go of the lock when that devvm ends, even when it's killed. Each time devvm chooses a port, under the claims lock, it first deletes the records whose lock no process holds and that are over 15 minutes old. The age matters because a killed devvm leaves its `limactl start` running, which may still bind the port for up to Lima's 10 minutes of waiting for the VM's ssh. So a devvm killed while its build VM starts reserves that port for 15 minutes, and then only until the next port is chosen. A stopped VM gets a new one only when a program on the host has its port on any address, even one that accepts no connections, or when the VM lists it to forward, and its start then sets it with an edit. Lima binds the port only once the VM boots, a few seconds after its start, so a port Lima picked itself would be free for another VM's forwarder in that window, and Lima's own ssh, which checks no host key, would then reach the other VM (the threat check below).
- **The host key.** devvm keeps one record of a VM's host keys for each of its starts, `vms/<hash>/run/known_hosts` (`vmssh.PinHostKeys`). It removes the record before each start and reads the keys after it, through `limactl shell`, at most 64 KiB for at most 30 s, keeping only lines whose key decodes and names its own type (`vmssh.ParseHostKeys`). The record's first line names the start it was read for (`backend.Run.ID`), so a record of another start, such as one before a `limactl start` outside devvm, is read again, and keys read while the VM started again aren't recorded. The forwarder checks the VM against that record, with `HostKeyAlias` and `StrictHostKeyChecking yes`, as the ssh config, links' sessions and a `--clone` VM's git do. All of them reach the VM through one function, `vmssh.Checked`, which checks the backend's ssh and adds the record: the forwarder and the ssh config pin the keys when the record is another start's, and links' sessions and git take only a record of the current start. The pin keeps the forwarder from talking to a program on the host that takes the ssh port. It doesn't guard against the VM itself, which is already the other end of the connection.
- **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`.
- **Reserved ports.** The forwarder never takes the VM's own Lima ssh port, which Lima's `SSH` names, or its proxy port, which its state records, and the owner passes both as `-reserve`. It also never takes the ssh, proxy and desktop ports devvm chooses and records in any VM's state, the ports another VM's running forwarder forwards now, as its `ports.forwarded` record says, or the ports another VM lists while it has a claim on them, which is while its forwarder runs or while devvm holds its `ports.lock` to start one again, unless this VM lists them too (`ports.Reserved`). A stopped VM's listed ports aren't reserved from other VMs' forwarders, but the ports devvm chooses still avoid them (`ports.Used`). Every Lima VM's ssh port is one of those, whatever its tier: devvm chooses it when it makes the VM, sets it with `limactl clone --set .ssh.localPort`, and records it in the VM's `ports` section before the clone (`ports.Allocator.SSH`). One allocator, `ports.Allocator`, chooses every host port devvm chooses, the ssh, proxy and desktop ports, and records it while it holds the VM's lock and then the claims lock (`run/claims.lock`, `state.VM.Claim`) until the VM's state is written, so two devvm commands making or starting VMs at once never choose the same one. A build VM has no state, so devvm chooses its ssh port too, on every host, through the same allocator (`ports.Allocator.Build`), under the claims lock alone (`state.Claims`), and on macOS the build's Seatbelt profile names that port. It records the port by the build VM's name (`run/build-ports/<name>`), where `ports.Used` reads it, until `limactl start` returns, and by then Lima has bound the port or the start has failed. The devvm that starts the build holds a file lock on that record until then, and the kernel lets go of the lock when that devvm ends, even when it's killed. Each time devvm chooses a port, under the claims lock, it first deletes the records whose lock no process holds and that are over 15 minutes old. The age matters because a killed devvm leaves its `limactl start` running, which may still bind the port for up to Lima's 10 minutes of waiting for the VM's ssh. So a devvm killed while its build VM starts reserves that port for 15 minutes, and then only until the next port is chosen. A stopped VM gets a new one only when a program on the host has its port on any address, even one that accepts no connections, or when the VM lists it to forward, and its start then sets it with an edit. Lima binds the port only once the VM boots, a few seconds after its start, so a port Lima picked itself would be free for another VM's forwarder in that window, and Lima's own ssh, which checks no host key, would then reach the other VM (the threat check below).
- **The host key.** devvm keeps one record of a VM's host keys for each of its starts, `vms/<hash>/run/known_hosts` (`vmssh.PinHostKeys`). It removes the record before each start and reads the keys once the VM runs, whatever ports the VM forwards, and a command that finds the VM running without a record of its current start reads them too (`starter.pinHostKeys`). It reads them through `limactl shell`, at most 64 KiB for at most 30 s, keeping only lines whose key decodes and names its own type (`vmssh.ParseHostKeys`). The record's first line names the start it was read for (`backend.Run.ID`), so a record of another start, such as one before a `limactl start` outside devvm, is read again, and keys read while the VM started again aren't recorded. The forwarder checks the VM against that record, with `HostKeyAlias` and `StrictHostKeyChecking yes`, as the ssh config, links' sessions and a `--clone` VM's git do. All of them reach the VM through one function, `vmssh.Checked`, which checks the backend's ssh and adds the record: the forwarder and the ssh config pin the keys when the record is another start's, and links' sessions and git take only a record of the current start. The pin keeps the forwarder from talking to a program on the host that takes the ssh port. It doesn't guard against the VM itself, which is already the other end of the connection.
- **Its lifeline.** The forwarder follows the hostagent's pid file (`ha.pid`, the lifeline Lima's `Running` gives), as the proxy does, and exits once the file is gone, holds anything else, or its process is gone. `devvm stop` stops it with the VM, and `devvm rm` and `devvm gc --orphans` stop it before they delete its files with the VM's folder. A VM that stops some other way, such as when its self-check fails or a restart stops it, ends its forwarder through the lifeline, and the next start stops any forwarder that's left before it starts its own.
**What keeps a forward from carrying the VM out:** every connection starts on the host. A program connects to the forwarder's port, and the forwarder asks the VM's sshd to connect to the VM's loopback. The VM opens nothing to the host through the forwarder, because the master asks for no remote forward, agent, X11 or tunnel, and OpenSSH's client refuses a channel that the server opens unasked, whatever sshd root in the VM runs. The only remote forwards devvm asks a VM for are a client's links, on a link session that is a connection of its own, never the forwarder's master ([links](#links-between-vms)). What the VM sends back goes to the program that connected, as with any forward. On a confined tier, the VM's own connections stay confined by Seatbelt or QEMU's `restrict=on`, while the forwarder runs on the host as devvm, outside the hostagent's sandbox.
**What it relies on:** OpenSSH's client refusing unrequested channels and honoring `-F none`, the kernel refusing a bind without `SO_REUSEADDR` where another socket has the port (checked on macOS), and devvm's state listing every VM's ports. It also relies on Lima binding its ssh forward on the host's loopback alone, on the host key that devvm pins at the start, and on Lima honoring the ignore rules ahead of its own rule. On macOS, a confined VM relies on Seatbelt refusing the hostagent's binds instead of on the rules, and on the Virtualization framework's own process, which runs outside the profile, binding nothing: the VM's network goes through the hostagent's unix sockets.
**What it relies on:** OpenSSH's client refusing unrequested channels and honoring `-F none`, the kernel refusing a bind without `SO_REUSEADDR` where another socket has the port (checked on macOS), devvm's state listing every VM's ports, each running forwarder's record of the ports it forwards, and the forwarders' pid files and locks saying which VMs have a claim on their listed ports. It also relies on Lima binding its ssh forward on the host's loopback alone, on the host key that devvm pins at the start, and on Lima honoring the ignore rules ahead of its own rule. On macOS, a confined VM relies on Seatbelt refusing the hostagent's binds instead of on the rules, and on the Virtualization framework's own process, which runs outside the profile, binding nothing: the VM's network goes through the hostagent's unix sockets.
**What could break it:** a Lima release that forwards despite the ignore rules, or that forwards from somewhere other than `portForwards`. On macOS, a confined VM keeps the guarantee even then, because its sandbox refuses the binds. An open VM, and every VM on Linux, where QEMU's `restrict=on` doesn't cover the hostagent's own binds, still relies on Lima honoring the rules. A Lima release that needs a new bind for a confined VM, such as a resolver that can't be turned off, fails its start closed, and Lima's log names the refused bind. The end-to-end checks look at the rules, and use `lsof` or `ss` to check that the hostagent has no TCP or UDP port of the VM's and that a host program keeps its port. A program on the host could take Lima's ssh port while the VM is stopped, and the pinned host key refuses it. Lima's key logs in to every VM in devvm's Lima home, as it does for Lima's own ssh, but public key authentication never sends the key to the VM.
@@ -62,8 +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 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.
@@ -75,12 +78,20 @@ These settings guard against the host's ssh asking for a forward that devvm's en
- **A port the VM chooses:** ruled out. `-only` comes from the VM's state, less the ports a host program has, both read on the host by the forwarder's owner, and the VM's reports can't add to it. A listed port is forwarded only while a server in the VM listens on it, as with every port.
- **Port 22 listed:** ruled out as a collision. Port 22 in the VM is its sshd, and Lima's ssh forward comes from another host port, so a listed 22 forwards the VM's sshd to the host's port 22 as it would forward any server. The VM's sshd still takes only keys. A host whose own sshd has port 22 keeps it, with a `ports_taken` warning.
- **A listed proxy port:** ruled out. The forwarder reserves the VM's own proxy port whether or not it's listed, and every other VM's as well.
- **A listed port below 1024:** taken because the user asked for it. A host service that has the port keeps it, and a bind the host refuses is logged. One that isn't running yet is under **Not covered**.
- **A listed port below 1024:** taken because the user asked for it. A host service that has the port keeps it, and a bind the host refuses is logged and recorded as refused, never as in use, so `devvm ports` warns `ports_refused` rather than `ports_taken`. One that isn't running yet is under **Not covered**.
- **A forwarder left behind:** ruled out. `devvm stop` stops it, `devvm rm` stops it and removes its files, any other stop ends it through its lifeline, and a start or change whose listed ports are all taken runs none. Two devvm runs that start a VM's forwarder at once take turns on the VM's lock, so the second stops the first one's forwarder, and neither leaves one that its pid file doesn't name, which nothing would stop.
- **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 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:**
- While a VM is stopped, another VM that serves on its listed port, such as `localhost:5173`, gets that port's browser origin, with the site data, storage and service workers your browser keeps for it, as two projects on one port would on any host. A service worker that the other VM's page registers there can still answer for that origin after the first VM takes the port back.
- A VM can take a free port from 1024 up, or a listed one, on the host's loopback that a program there expects to be its own, such as one that isn't running yet or is restarting. What the VM serves there reaches whatever connects, so a page it serves to the user's browser can reach the internet from the host, past the VM's tier.
- A host program that starts on a port while the VM has it forwarded still binds it when it listens on all addresses with `SO_REUSEADDR`, as most servers do (checked on macOS). Its loopback connections then reach the VM, because the forward's address is the narrower one. A program that binds without `SO_REUSEADDR` is refused.
- The VM can make the forwarder dial a host loopback port that's in use and then close the connection at once without sending anything, because that's how the forwarder checks for a port held only by ended connections. This happens at most once per port every second, as the VM's listener on the port goes and comes back.
@@ -100,7 +111,7 @@ These settings guard against the host's ssh asking for a forward that devvm's en
- On a running VM, `devvm ports` changes the forwarder's ports at once. A port that `devvm ports add` lists has its server reach the host at once, and once `devvm ports rm` takes it out, it doesn't. The VM's boot ID is the same throughout, so it never restarted.
- `devvm stop` stops the forwarder, `limactl stop` outside devvm ends it (on macOS), and `rm` stops it and deletes its files.
- On macOS, a confined VM has a profile that denies every bind but its ssh port's over TCP and unix sockets in its Lima folder, and the same binds that work outside the profile, a TCP port and a UDP socket on the ssh port, fail under it. Its hostagent listens on its ssh port alone, with Lima's resolver off. Started again with Lima's own forwarding rule put back inside the sandbox, the hostagent tries a VM server's TCP and UDP ports and is refused, and has neither. The VM still works: ssh by name, devvm's forwarder (on the host's loopback alone), the proxy and the self-check. Its next start puts the ignore rules back.
- On a confined tier, with transparent mode stopped, DNS fails at once, and Lima's network's DNS address and the host's address on it give no answer for a name, with transparent mode running too.
- On a confined tier, with transparent mode stopped, DNS fails at once, because the guest's programs ask `127.0.0.1` alone, and Lima's network's DNS address and the host's address on it give no answer for a name, with transparent mode running too.
## devcontainer.json
@@ -175,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.
@@ -186,7 +197,7 @@ A rule can narrow a host name to some of its requests, by method, by path or bot
- **Allows add up, and a deny beats any allow, as before.** An allow that narrows allows its host for the connection and only its requests one by one, and a deny that narrows refuses only its requests. So narrowing a host that a rule allows whole, devvm's built-in GitHub among them, takes a deny, and devvm network allow warns when an allow by method and path would narrow nothing because the VM's allowlist, or every VM's with `-g`, allows its host whole (`proxy.Allowlist.CoversWhole`, `rule_narrows_nothing`). An allow that replaced the whole allows of earlier policies was ruled out: adding an allow would then take access away, and a user's file would silently override devvm's.
- **Methods from a closed list.** `proxy.Methods` are RFC 9110's, `PATCH` and `QUERY`, without `CONNECT`. A method outside them isn't a rule, so a typo in a deny, such as `PSOT`, is a broken deny, which denies everything until it's fixed, rather than a deny of nothing.
- **Paths as patterns, judged only in a plain form.** `*` within a segment, `**` for one segment or more, and a last `/` for everything below, which is what a binding's path below which its value goes in already meant. Rather than decode and clean a path, which servers do differently, the matcher takes only a path that every server reads alike (`plainPath`), as custom secrets' `--path` did. An allow, and a binding, match exactly, in case too, and never a path in another form, while a deny matches broadly, so each fails closed in its own direction. A deny matches in any case, every path that isn't plain, the path above one that ends with `/`, as `/gists` is to `/gists/` for most servers, and a last segment cut at its first `.`, as Rails and Spring route `/admin.json` to `/admin` and some servers drop a trailing dot. Cutting at the first dot rather than the last covers `/admin.tar.gz` too, and it refuses a few more requests than a deny names, which is the side a deny errs on. The cost is that a request to a host with path rules whose path has an encoded character, such as a file name with a space, is refused unless a rule without a path allows it.
- **Rules that need requests force interception, or a refusal.** A host whose requests the rules judge (`policy.byRequest`) is decrypted on `:443` with the VM's CA, and refused on any other port and without a CA, never tunneled unjudged. A host that a whole allow covers, with no deny that narrows, stays a tunnel, so the cost falls only where the rules need it. No host is spliced by name: devvm already decrypts GitHub, Anthropic's API and the agents' token endpoints for secrets, and git, the GitHub CLI and Claude Code work through it. A client that pins its certificates or ignores the VM's CA fails its handshake, which `devvm network log` shows as `TLS with the VM failed`, so devvm notes that a host is now decrypted when a rule narrows it (`rule_narrows`) rather than refusing the rule. Addresses, CIDRs and `**` can't narrow, because an address has no name to make a certificate for and `**` would decrypt every host.
- **Rules that need requests force interception, or a refusal.** A host whose requests the rules judge (`hostRules.byRequest`) is decrypted on `:443` with the VM's CA, and refused on any other port and without a CA, never tunneled unjudged. A host that a whole allow covers, with no deny that narrows, stays a tunnel, so the cost falls only where the rules need it. No host is spliced by name: devvm already decrypts GitHub, Anthropic's API and the agents' token endpoints for secrets, and git, the GitHub CLI and Claude Code work through it. A client that pins its certificates or ignores the VM's CA fails its handshake, which `devvm network log` shows as `TLS with the VM failed`, so devvm notes that a host is now decrypted when a rule narrows it (`rule_narrows`) rather than refusing the rule. Addresses, CIDRs and `**` can't narrow, because an address has no name to make a certificate for and `**` would decrypt every host.
- **Methods a request names besides its own.** Some frameworks take the method from a header, `X-HTTP-Method-Override` and its kin, which Rack and CGI read with `_` for `-`, or from a `_method` parameter. The proxy reads every override-like header (`overrideLike`) and the query's `_method`, and while a rule narrows a host by method, it refuses a request whose value isn't exactly one method, such as a list, which servers read apart, rather than guess. Judging a `_method` in the query, rather than refusing every request with one, keeps a `GET` that names `GET` working, and an allow still needs every method named to be its own. A form's `_method` in a `POST`'s body isn't read: the proxy forwards bodies unread, so it's judged as the `POST` it is.
- **Every request is judged.** The intercepted tunnel's own HTTP server calls the handler for each request, HTTP/1.1 kept alive or HTTP/2, and so does each absolute-form request, so the rules and the bindings are asked for each one, with the files as they are then. A connection's verdict and whether its requests are judged come from one read of the files (`hostRules`). A WebSocket is judged by its upgrade request, and an upgrade to anything else, such as `h2c`, and a `CONNECT` inside the tunnel are refused, as the bytes after them would pass unread. A tunnel opened before a rule narrowed its host stays a tunnel until it closes, as tunnels do for every new deny, and `rule_narrows` says so. The shared Nix cache's own fetch from cache.nixos.org is judged as a `GET` of the path the VM asked for, so its rules apply there too.
- **A proxy from another binary.** A running proxy is the devvm binary that started it, and one from before this change reads a rule by method and path as a line that isn't a rule: an allow it skips and a deny that denies everything. So devvm network allow, deny and rm warn, naming the VM, when they change such a rule while the VM's proxy runs from another binary than their own (`proxy_other_binary`, by the `devvm_sha256` of the config it started with, and when that config or this binary can't be read, as devvm can't tell), and the VM's next launch starts the proxy again. A change to a host's rule doesn't warn, as every binary reads it alike. The bindings file stays version 1 while every binding has no methods and no path but a prefix longer than `/` that ends with `/` and has no `*`, so devvm secret set and rm, which write every VM's file, don't take an older proxy's bindings away, logins included. Such a file reads alike to a proxy from after bindings gained paths; a 0.1.0 proxy 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. Writing version 2 instead would cut those proxies' logins. It's version 2 only for a binding with methods or a pattern, which such a proxy refuses, so it puts no value in rather than put one in for every method, and devvm warns about each such VM whenever it writes one, from devvm secret set, rm and use or devvm agent login --api-key (`Proxy.SecretsWritten`, `secrets_other_binary`). A path of `/`, which that proxy's prefix check refused with the whole file, is no path, as it's every path. A custom secret's path that devvm writes is marked a pattern (`path_pattern`), so a path saved as a prefix whose `*` was itself is refused rather than read as a wildcard.
@@ -217,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.
@@ -238,7 +249,9 @@ 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`).
- **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`).
- **Other bridges and protocols reaching Docker's DNAT through the stand-in address:** fixed, found in review. The NAT chains map TCP and UDP alone, and only for `lo`, `docker0` and `br-*`, so a published SCTP port, or a connection from Podman's or LXD's bridges, could reach a container through the stand-in address. Two filter chains at -150 drop both before any NAT chain (`TestTransparentRuleset`).
@@ -261,15 +274,15 @@ 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.
**What an upstream changes:** the proxy resolves a name and dials the addresses it checked only when it connects directly. Through a company proxy, the company proxy resolves the name, so the floor can't hold it to checked addresses:
- 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`). 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). 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.
- 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, 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.
@@ -291,9 +304,30 @@ The build's policy is `**` alone, so on its own the build's proxy would refuse e
**Not covered:** `https://` and `socks5://` company proxies, which devvm refuses (`upstream_proxy_scheme`); proxy auto-configuration (PAC) files and the macOS system proxy, which devvm doesn't read; Kerberos or NTLM authentication. An open VM goes through its proxy as every VM does, so no project VM gets the host's settings in its `/etc/environment`. What devvm's redaction of Lima's logs leaves open is under [your company proxy's password](../safety/attack-vectors.md#this-machine).
## 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. `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:
- **A rule's host and its `!`** read exactly as the frozen copy reads them, so a line is the same rule or no rule, and a line that starts with `!` but isn't a rule is a broken deny, which makes the policy deny everything, never a valid deny. The frozen state's policy files, bindings and links read the same too (`TestFixtureHosts`).
- **Two trailing dots** in a request's host, an SNI or a host `Allows` or `Denies` judges stay, where the copy drops one. The proxy answers `400` to both, and no rule but `**` matches either spelling, while `**` matches both.
- **The policy's own matching** (`rulesFor`, `quiet`, `byName`) and `devvm network lock`'s risks and ticks don't fold a host that isn't ASCII, where the copy folds it in Unicode. Neither meets such a host, because the proxy refuses it before the policy sees it, and the lock judges only hosts the proxy took.
- **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, 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.
- **A secret's `--host` or an MCP server's host that isn't ASCII** is refused, as the proxy refuses it, rather than taken as the ASCII host its letters fold into.
- **`--from`'s registry** isn't on the internet when its name is one the proxy doesn't take (`HostOK`), such as one with anything but printable ASCII, a bracket that a trailing dot hid (`[::1].`) or a shorthand address (`10.1`), none of which a registry's name is, so a registry is never more public than the copy finds it.
- **A partial clone's promisor remote** loses its trailing dot, so a warning names `example.com` rather than `example.com.`, and `localhost.` or `127.0.0.1.` counts as private, as the proxy refuses it. The Kelvin sign isn't folded.
- **A remote's ssh host**, which finds a VM's alias in the ssh config, keeps its own reading, lowercased with its trailing dot kept, as ssh reads it, because it's no host a policy judges.
## 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.
@@ -305,7 +339,7 @@ The build's policy is `**` alone, so on its own the build's proxy would refuse e
**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.
@@ -321,15 +355,53 @@ The tier holds as it is: the VM's proxy decides each request the local proxy sen
**Not covered:** the VM's clipboard sent to a viewer that takes it, by a server root changed; Screen Sharing itself, which no check drives, so its messages are the relay's reading of the protocol; a program on this machine with the password, which reaches the desktop as you do; a program on this machine, or a VM that reaches this machine's loopback, that keeps the relay's 8 connections busy or keeps failing its check, which keeps viewers out for as long as it does, and gets no further; the browsers themselves, which no check drives, so that they read the session's proxy variables rests on Chrome's and Firefox's documented behavior on Xfce, and the local proxy's handling of requests on its unit test (`netpolicy`'s `TestLocalProxy`) and curl.
## Pasting images
`devvm paste` gets an image, a PDF, or one copied file, from this machine's clipboard to an agent in the VM ([how](../using/coding-agents.md#pasting-images)). It keeps four things. The VM gets the clipboard only when you run the command, and only an image, a PDF or a copied file. A copied file goes only after you say yes to its path on this machine (`paste_file_ask`), because the clipboard can name any file of yours, such as one a web page or another program put there. Nothing the VM says reaches your clipboard. And devvm leaves no process of its own running for it.
`--send-file` answers the question only for a file below the folder the VM mounts, which the VM can read already. `confirmFile` decides with `sendFileAnswers`: `inFolder` compares the cleaned path that `OpenNoLinks` opened with the folder's physical path, and `OpenNoLinks` must have followed no link at all, because a root-owned link below the folder, such as one a root container made on a Linux host, can lead anywhere. It never answers for a `--clone` VM. A file anywhere else is refused where devvm can't ask (`paste_file_outside`), and so is one reached through a link (`paste_file_through_link`), so a hotkey or a script can't send a file it never showed. There's no list of credential folders that devvm refuses outright, because it could never name every place a key is kept, and the question shows every path.
**What it's built from:** `internal/platform`'s clipboard readers, `vm.Paste`, and `config.toml`'s `paste-dir`.
On macOS, `clipboard_darwin.go` runs `osascript` with a JavaScript for Automation script through `NSPasteboard`. The script takes a PDF (`com.adobe.pdf`) first, as it is, before the picture of it and the temporary file of its own that Preview puts beside it. Then it asks for file URLs alone (`readObjectsForClasses` with `NSPasteboardURLReadingFileURLsOnlyKey`), counts several and reports one's path. Otherwise it writes a PNG, JPEG, GIF or WebP as it is, or a TIFF made a PNG, to a file in a private folder devvm makes and deletes, only when it's within the cap. The copy back is `pbcopy`. Both tools run by their paths in `/usr/bin`, never found on `PATH`.
On Linux, `clipboard_linux.go` runs `wl-paste --list-types` and `--type` on Wayland, and `xclip`'s `TARGETS` and `-t` on X11, taking `application/pdf` before a file reference and the image types. The copy back is `wl-copy` or `xclip -i`. Each comes from the first of `/usr/bin`, `/bin`, `/usr/local/bin` and NixOS's `/run/current-system/sw/bin` that has it, never from `PATH`, because `PATH` can hold a project's folder, such as direnv's `PATH_add` or `node_modules/.bin`, and the VM writes those.
Every clipboard tool runs with `exec.CommandContext` (`clipboard_tool.go`), and devvm reads its output, never through the run log, so the image stays out of it. Each tool is stopped after 30 seconds, as a tool waits on a program that holds the clipboard and doesn't answer: a read gives `paste_tool_slow`, and a copy back gives a warning. Its pipes are closed a second after it ends, as a child of its may keep them.
`vm.Paste` (`internal/vm/paste.go`) finds the VM as every command does, refuses a stopped one, and reads the clipboard before touching the VM. It names the file on this machine: `paste-YYYYMMDD-HHMMSS-8hex`, then the image's or the PDF's extension, or the copied file's when it's letters and digits alone and at most 16 of them, and nothing else of the file's name. It runs `assets/guest/paste.sh` in the VM as `sh -c`'s script, so nothing of it is left on disk. `config.toml`'s `paste-dir` (`settings.PasteDir`) is the folder in every VM, which each launch makes through `sync.sh` (`DEVVM_PASTE_DIR`), mode 700 and the user's own.
**Why push, not pull.** A VM that pulls the clipboard on Ctrl+V, through a stand-in `xclip` and a channel to this machine, would need three things. It would need a server of devvm's on this machine for as long as a session lasts, and devvm runs `limactl shell` in its own place, so no devvm process exists during a session. It would need a remote forward into the VM's sshd, which allows them on `127.77.0.0/16` alone, for links. And anything in the VM could read your clipboard at any moment while a session is open, a screenshot of your password manager included. With push, only the host starts the transfer, and only an image, a PDF or a file crosses. Stand-ins for `xclip` and `wl-paste` in the VM would reach only Claude Code and pi, because Codex and opencode read X11 or Wayland in their own process, and both already handle a pasted path.
**What the VM can't do.** It can't ask for the clipboard, because devvm reads it once, when you run the command. devvm asks only for a file's reference, a PDF and image types, never text, then checks an image's or a PDF's bytes against the type (`http.DetectContentType`, for which a PDF starts with `%PDF-`). Text is never taken for a file. AppleScript's `the clipboard as «class furl»` makes any text a path, `/Users/you/.ssh/id_ed25519` as it is and `hello` as `/hello`, so the macOS reader asks `NSPasteboard` for file URLs alone, which text never gives. A copied file whose path can't be found is refused (`paste_file_gone`) rather than Finder's icon beside it sent.
It can't write to your clipboard. The path is built on this machine from `paste-dir` and a name devvm picks, both from a fixed set of characters, before the VM runs anything. Of a copied file's own name only its extension is kept, letters and digits alone, because a file in the project folder is named by the VM. So what reaches your clipboard is devvm's own path, with no space, quote or newline in it, which can't run anything when you paste it into a terminal.
It can't keep devvm reading or waiting. The one thing devvm reads back from the VM is a count, parsed as a whole number from bounded output. Each of `paste.sh`'s commands is stopped once it prints past 32 bytes on stdout or 4 MiB on stderr, so a VM that prints without end can't keep devvm reading. It's also stopped past its time, 10 minutes for `put`, which carries up to 64 MiB, and 2 for `count` and `rm`, so a VM that never answers can't keep devvm waiting. The command then fails as it does for any other failure of the script (`paste_not_sent`, `paste_count_failed`, `paste_rm_not_done`). It gets no SSH agent, because the writes and counts go through the backend's `Exec` as it is, never `target.exec`, as the clone checks do.
It can't send a file of yours through a link. A copied file may be in the project folder, which the VM writes, so its path is cleaned, never resolved first, and opened as named following no link but the system's. `platform.OpenNoLinks` opens each component from its parent with `O_NOFOLLOW`, through `golang.org/x/sys/unix`'s `Openat`, because the standard library exports no `Openat` on macOS and `internal/safefile` is standard library only. It reads a link on the way with `Readlinkat` and follows it only when `Fstatat` says root owns it, and the folder's `Fstat` says root owns that too and neither its group nor others can write it, as for macOS's `/tmp`, `/var` and `/etc` in `/`, for at most 40 hops. Root owning the link isn't enough on its own, because a link of root's can be hard-linked into a folder of yours, and in a folder only root can change, no one else can swap the link between its `Fstatat` and its `Readlinkat`. It never follows the file itself, and it opens it with `O_NONBLOCK` and `O_NOCTTY`, so a FIFO never makes devvm wait and a terminal never becomes devvm's.
A link the VM makes in a mount is the user's on this machine, never root's. So a link in the file's place, a folder's link planted before the copy or swapped in after it, and a copied folder's reference whose trailing slash hid a link all fail (`paste_file_link`) rather than send what they point to, and your own links do too. Every step goes through a file descriptor, so there's no moment for a swap between a check and the open. The file opened is then checked and read as every file a VM can write is, by `internal/safefile` (`Checked`, then `ReadAll`): a regular file within the cap of 64 MiB, the cap an image is held to as well.
In the VM, `paste.sh` writes with `umask 077` to a `.part` name and renames it, and it refuses a `paste-dir` that's a link, not a folder or not the user's. Its `count` and `rm` see only regular files at the folder's top level with devvm's names, never anything else in a folder that may be yours. Root in the VM can get around any check the VM runs, which gives it nothing it couldn't do to a file in the project folder.
**What's left on this machine:** on Linux, `wl-copy` or `xclip` serves the path until you copy something else, because a Linux clipboard's contents live in the program that copied them. It isn't devvm's process, and devvm runs it with no pipes on its output, because Go's `Wait` waits for a child that inherited them. On macOS, nothing.
**End-to-end checks** (`tests/e2e`, the `project` section): with stand-in clipboard tools in a test build's `DEVVM_CLIP_TOOLS`, `devvm paste --json` puts the copied image into the running VM, where its SHA-256 matches, mode 600 in the folder of mode 700, and the stand-in copier got the path. `devvm paste rm --force` deletes it and leaves a file of the user's in the folder, and a stopped VM is refused before the clipboard is read.
The CLI tests (`testdata/script/paste.txtar`, `paste_rm.txtar`) drive the rest against the stubs: the types read, the bytes sent, each refusal, the launch's offer and `config.toml`'s `paste-dir`. On macOS, `TestReadClipPasteboard` runs the real script against a pasteboard of the test's own, never the clipboard. Text that's a path or a `file://` URL is no file, nor is a `file://` URL as `public.url`. A file URL with Finder's `.icns` icon beside it is the file, a file reference URL is resolved, two files are counted, and a file that's gone is refused. A PNG and a TIFF are read as PNGs, beside text too. A PDF is read as it is, beside its picture and beside the temporary file a thumbnail copied in Preview names, while a file URL beside a JPEG, as Photos copies, is the file. One past the cap is refused before it's written.
**Not covered:** the real clipboard, which no automated check reads. The copies of Finder (one file URL per file, with an `.icns` icon), Photos (a JPEG and a file URL), Preview (a PDF with a TIFF, and a thumbnail's temporary file beside them), and Safari, Chrome and Firefox (a TIFF or a PNG) were checked by hand on macOS, and `TestReadClipPasteboard` writes the same types to its own pasteboard, so a change in what an app copies would need checking by hand again. Also not covered: image types other than PNG, JPEG, GIF, WebP and TIFF, which devvm doesn't read on macOS; whether macOS asks before `osascript` reads the clipboard, which depends on the release and its privacy settings; Linux's clipboard tools, which only the stubs stand in for; and the agents' own reading of a pasted path, which their releases change.
## 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
@@ -338,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.
@@ -388,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.
@@ -430,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. 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.
@@ -469,13 +541,13 @@ A link lets a program in one VM, the client, reach a TCP service in another VM,
- **What the client does through the target's service.** A link joins the two VMs' trust, as above, and [what a VM does through a link](../safety/attack-vectors.md#network) lists what that leaves open.
- **Programs of yours on the host** can connect to a link's socket and the masters' control sockets, as they can already reach the VMs.
- **Open connections outlive their link.** `devvm link rm` and `devvm link unpublish` refuse the next connection, while those that are open stay until they close, the client stops or the target does. A target can't get a tier lower than a client's that links to it, because `devvm network` refuses it then, so no open connection breaks the tier rule.
- **Open connections outlive an unpublished port.** `devvm link unpublish` refuses the next connection, while those that are open stay until they close, the client stops or the target does, because the link itself stays. A link that goes, by `devvm link rm`, `devvm rm` of its target or a group's change, ends its open connections (above). A target can't get a tier lower than a client's that links to it, because `devvm network` refuses it then, so no open connection breaks the tier rule.
- **A program in the client can take a link's address and port first,** and that link then fails with `link_port_taken` until the program lets it go. Root in the client can also edit its own `/etc/hosts`, which changes only what the client reaches.
- **A link name hides a name the client would otherwise resolve,** such as `db` under its search domain. devvm refuses `localhost`, the client's own hostname, another link's name and anything that isn't one DNS label.
- **A remote forward you ask for** into a VM, with `ssh -R` through devvm's ssh config, may bind an address in `127.77.0.0/16` in that VM, as [remote forwards you add](../safety/attack-vectors.md#the-network) says. sshd matches the rule as text and then resolves what it matched, which is why a host name that begins with `127.77.` binds whatever address it resolves to in the VM. devvm's own forwards name addresses only.
- **Many connections:** a client can keep 256 connections busy, which refuses its own further connections and makes the host run that many ssh processes.
- **The network rules don't apply to links,** through the proxy or not, so `devvm network deny db` doesn't stop the link `db`. The published ports and the policy rule between the two VMs decide a link's connections, and `devvm link rm` removes one.
- **A link's short name before its first session lists it.** Until `devvm _links` has written a client's list once, the proxy doesn't know `db` is a link, so a request for `db:5432` meets the rules, and a rule such as `**` sends it to whatever the host's resolver or a company proxy finds by that name. After that, the list stays until devvm removes the VM, and `NAME.devvm.internal` is never the rules'.
- **A link's short name before its first session lists it.** Until `devvm _links` has written a client's list once, the proxy doesn't know `db` is a link, so a request for `db:5432` meets the rules, and a rule such as `**` sends it to whatever the host's resolver finds for `db` as a full name, such as in `/etc/hosts`, never under its search domain, or a company proxy finds by that name. After that, the list stays until devvm removes the VM, and `NAME.devvm.internal` is never the rules'.
- Linux hosts are untested.
**Threat check** (the security-audit skill, guidance mode, its local IPC, data isolation and resource exhaustion companions). One row per lead, with what holds it and the end-to-end check that proves it:
@@ -495,6 +567,8 @@ A link lets a program in one VM, the client, reach a TCP service in another VM,
| A link reached on the client's localhost | Names only, numeric `127.77` addresses | Nothing from a link listens on the client's `127.0.0.1` or `::1`, and a server of the client's own there runs |
| A VM made again in the target's folder inheriting a link | The target's ID, recorded with the link | After devvm rm of the target, the client's link is gone and the client is named, and a VM made again in that folder isn't linked |
| Many connections | At most 256 at once, then refused and logged (`link_limit`), and an accept loop that takes a burst whole before it starts any relay and goes on accepting while the burst is carried or refused, so the socket's backlog never refuses one unlogged | 256 connections at once, past the socket's backlog of 128 on macOS, are all carried, and a 257th is refused and `devvm network log` shows `link_limit` |
| A target holding a relay open, so its ssh and one of the 256 stay after its link goes | Each relay's own context, which the link's removal and its target master's replacement cancel, killing its ssh and freeing its slot | A connection that a program in the client holds open, to a target's server that never closes one, has its relay's ssh on this machine end after `devvm link rm`. Unit tests check the same with an ssh stand-in that never exits, for a removed link, a replaced master and a link whose target changed, with no goroutine left under `-race` |
| A target filling the client's 256 relays while its links last, by never ending the channels of connections the client's programs have closed | The relay's grace: its ssh is killed once the client's side has closed and the target has sent nothing for 30 seconds, or 30 seconds after the client can take nothing more. One target can still hold relays that the client's programs keep open, which the client chooses, so there's no cap for each target | None end to end, as an honest target ends its channels. Unit tests check it with an ssh stand-in that never exits: a closed and a half-closed client's relay end after the grace, and one the stand-in keeps answering goes on |
| A program in the client taking a link's address first | Each link's own `-O forward`, failing alone with `link_port_taken` | A server on a link's address and port before the link is added: that link fails with `link_port_taken`, and another link of the client's works |
| A malicious target's answers | As any server's: they reach only the connection that asked | None of its own: the target's bytes go back over the same connection |
| Root in the client, or a malicious target, writing a line into the session's log that reads as the session's own, such as a false `link_port_taken` or a hidden real one | OpenSSH prints what the remote side sends, such as a disconnect's reason, with its newlines, at the `LogLevel=ERROR` the session's ssh uses. So `devvm _links` writes its ssh processes' output to its log a whole line at a time, each line behind `ssh:`, so only the session's own lines start with its prefix, which devvm link add and the launch read. A line in an error the session logs is indented, and the output of `ssh -O` is joined into one line | None of its own. A unit test (`internal/vmssh/links_test.go`) runs a stub ssh that prints a disconnect's reason holding forged lines, one of them in pieces around a line of the session's, and the log holds only the session's own lines |
@@ -518,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 says so (`group_waiting`) after 200 ms. 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.
@@ -543,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.
@@ -572,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.
@@ -597,9 +671,9 @@ 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 push over the VM's own ssh to that repo's path (`gitSSHCommand`), 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 current branch and its default branch only, because a push of every branch of ten repos takes minutes, and the user pushes any other with `git push devvm BRANCH`. 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.
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.
rm's check reads every repo at once: one script sent with the command (`cloneState`, never a copy on disk) prints each repo's branches, its status and its linked worktrees below the folder with their statuses, as length-prefixed records, so ten repos cost one ssh session, not thirty. devvm reads it as it reads anything from a VM, capped, by a parser that takes only what it asked for.
@@ -612,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 its current and default branch only 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`, `TestBranchPlan`, `TestIsWorkspace`, `TestChooseRepos`, `TestPickRepos`, `TestFindRepos`, `TestWorkspaceFiles`, `TestCloneChangesAcrossRepos`, `TestFetchedByBranch`, `TestCloneRepos`, `TestFixtureClonesReadAsOneRepo`, `TestCoversRepo`, `TestParseCloneState`, `TestCloneStateScript`, `TestOpenDir` and `TestRepoExcludes`.
**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.
@@ -640,7 +714,7 @@ The old VM's home folder is the VM's own data, which nothing on the host trusts.
- **Types:** regular files, folders and symlinks, and a hard link only to a regular file kept before it. Devices, FIFOs and anything else are dropped, so the new VM's `tar` creates none.
- **Paths:** each is cleaned, and one that's absolute, has `..` above the home folder or holds a control character is dropped, and so is the home folder's own entry, so its mode stays the new image's. So is any entry below a symlink kept before it, which `tar` would follow out of the home folder.
- **Modes and owners:** the setuid, setgid and sticky bits are dropped, and so are the entry's owner and group, so the new VM's `tar` makes everything its user's.
- **What devvm writes itself:** `~/.config/devvm` (its environment, which holds the placeholders of the VM's secrets), `~/.ssh/authorized_keys`, the agents' logins, the agents' folders that devvm links to their mounts and the files it copies from the host, all of which the new VM's setup writes again, and `~/.cache`.
- **What devvm writes itself:** `~/.config/devvm` (its environment, which holds the placeholders of the VM's secrets), `~/.ssh/authorized_keys`, every agent's login files, whichever agents the VM has, but Claude Code's `~/.claude.json`, whose per-folder state is history, the agents' folders that devvm links to their mounts and the files it copies from the host, all of which the new VM's setup writes again, and `~/.cache`.
devvm puts the file into the new VM once it has started confined, as the VM's user, with `tar --skip-old-files`, so a file or folder the new image put in the home folder, `~/.bashrc` among them, stays the image's, its metadata included, and the shell that runs `tar` there reads only the image's files. devvm's setup runs after it and writes its own files again. The file is deleted once the new disk has it, when the remake is undone, and with the VM's folder.
@@ -663,15 +737,34 @@ devvm puts the file into the new VM once it has started confined, as the VM's us
| Links reaching a different VM | The VM keeps its ID only when its state is kept, by the user's own remake in its folder, and a link session reads the new host keys once the target starts again | Unit tests (`TestAddLayers`) check every state key but the image survives, the ID included, and e2e's `project` section checks that a VM made again keeps its settings |
| A parent folder's VM made again from a subfolder | Asked only in a terminal (`remake_parent_vm_ask`), which `--force` never answers, and refused without one | The CLI tests refuse it without a terminal and keep it when the answer is no |
## 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](../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:
- **Who can forge one:** whoever can write a volume's metadata. On macOS that's root, any program running as you, which can attach a disk image it made with `hdiutil` without root and without asking, or anyone who makes a disk image, sets the UUID in its bytes and gets you to attach it. On Linux, `tune2fs -U` and `btrfstune` need write access to the block device, which is root's, and a crafted image needs a loop mount, which is root's unless your desktop lets you mount images. A crafted disk or image can set the inode and birth time too.
- **What it gets them:** what a copy of the disk that keeps all three already gets. At another path, devvm offers the VM to the folder only when nothing is left at the old path and the folder is yours, and moves it only after you confirm. On a disk image or an external disk mounted with its owners ignored, as macOS mounts them by default, a folder can read as yours whoever made it, so that check holds little there. At the folder's own path, the forged disk has to be mounted over the folder's path, and then it gets the VM as the folder's disk would.
- **What a VM can do:** nothing here. A VM can't attach a disk or write a volume's metadata on the host, and devvm reads the folder's identity, its owner, its mount point and its device from the folder opened with no link on its path, so a link a VM puts in a folder's place can't pass another folder off as it.
**Threat check** (the security-audit skill, guidance mode, with its data isolation companion):
| Lead | What holds it | Check |
| --- | --- | --- |
| 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 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.
@@ -680,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):
@@ -690,8 +788,74 @@ 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](../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:
- **`config.toml`'s `follow-links`** names folders, such as `~/dotfiles`, whose links devvm follows without asking. You choose a folder once, for every import, so devvm checks the folder as a whole: one that is, holds or is inside a refused place fails the import, because a link inside it can lead anywhere in it.
- **`--follow-links`, or a yes to the question,** follows one run's links after naming each and where it leads, so you see every target before anything is copied. Without a terminal, no link out is followed unless the flag is given, and each is named in a warning, so a script never follows a link it didn't ask for. The folder each is read through is the link's own target, or a linked file's own folder.
Whichever allows it, the same rules hold:
- **Resolved first, read inside.** devvm resolves every link on the way to the target, checks that target, then reads it through the allowed folder as a root, which it opens one folder at a time from `/`, never through a link. A link inside what it copies is read only when it leads to a file inside the same root.
- **Always refused.** devvm never follows a link to the home folder or a folder holding it, to devvm's config, data or Lima folders, to `~/.ssh`, `~/.gnupg`, `~/.aws`, `~/Library/Keychains`, `~/.config/devvm`, `~/.netrc`, `~/.config/gh`, `~/.docker` or `~/.kube`, or to any agent's logins or history, nor into one of them or to a folder holding one. The home folder holds all of them, devvm's folders hold its CA keys, binaries and every VM's disk, and the agents' logins and history are what the store exists to keep apart from VMs. The named folders are the places that commonly hold credentials, and the list can't name every one, which is why the question names each target and the setting takes folders you choose.
- **A VM's folder warns.** A target in a VM's project folder, or a `--clone` VM's source folder, is followed with a warning naming the VM, because that VM can change what every VM's agent reads from the next import on. Refusing it would refuse the common case of a dotfiles repo that you also work on in a VM, and the warning leaves the choice with you. A chain that passes through a link in a VM's folder to a place outside it is refused, though, because the VM chose that place, and it could name any file the refused list doesn't.
- **Compared by identity.** devvm compares a target with the refused places and the VMs' folders by name and by file identity, because a Mac's file system ignores case, so `~/.SSH` names `~/.ssh`.
- **Copies only.** The store gets a copy of each file and folder, never a link, and the next import replaces or takes out each copy as it does the agent's own files. devvm agent save still refuses a link the VM sends.
- **Bounded.** One import copies at most 20,000 files and folders, 128 MiB and a file of 16 MiB through links, the bounds of devvm agent save, so a link to a large tree can't fill the store.
**Not covered:**
- **The copy is as the target was at the import.** A VM that writes a followed folder later changes nothing in the store until the next import, which then copies what it wrote. The warning names that VM.
- **A refused place under another name,** such as a credential folder that the list doesn't name, is copied when a link you allowed leads to it.
- **A huge folder is read before the bounds stop it.** devvm lists each folder whole before it counts its entries, so a folder of millions of entries costs memory on this machine before the import leaves it out.
**Threat check** (the security-audit skill, guidance mode, an independent review of the code):
| Lead | What holds it | Check |
| --- | --- | --- |
| A VM swapping a link into the path of an allowed folder, or into what's being read | The root is opened one folder at a time from `/`, never through a link, and everything below it is read through it as a root, without blocking and without following a swapped-in link | `TestOpenPhysical`, `TestAgentImportNestedLinks` |
| A VM choosing the target through a link in its project folder | Every link on the way is kept, and a chain through a VM's folder to a place outside it is refused, whatever allows it | `TestAgentImportLinkThroughProject`; the review found it first, and it's fixed |
| A refused place spelled another way, such as `~/.SSH` on a Mac | Targets are compared with the places by identity as well as by name | `TestAgentImportRefusedOtherCase`; the review found it first, and it's fixed |
| A link to a secret, a login or devvm's own files | The refused places, checked on every target and every `follow-links` folder | `TestAgentImportRefusedPlaces`, `TestAgentImportRefusedRoots` |
| A write outside the store | Names come from real folder entries under the link's own path, and the store's clean-up goes through the store as a root | Reviewed |
| A FIFO, a device, a huge or growing file, a loop | Reads refuse anything but a regular file, the bounds are checked when listing and again when reading, and loops end at the bounds or the system's | `TestAgentImportLinkBounds`, `TestLinkSourceGrown`, `TestLinkHops` |
| A link followed without the user seeing it | Without a terminal nothing is followed unless the flag is given, and each link followed is named | `TestAgentImportFollowsLinks`, `agent_import_links` |
| What VMs get | Copies only, mounted read-only like the rest of the store | e2e's `project` section reads the linked skill's copy in a VM and finds root can't write it |
## 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.
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.
**Not covered:**
- **A marketplace in a folder on this machine** reaches a VM only when that folder is in the VM too, because Claude Code reads such a marketplace where it is, and a seed holds no copy of it.
- **A plugin's data stays in its VM.** A new VM, or one made from an export of another's history, starts each plugin's data afresh, and so does every VM after you install a plugin there, as the export leaves the VM's plugins folder out.
- **A plugin installed in a VM runs in that VM** with whatever it does, as a plugin does on this machine. devvm keeps it from the other VMs until you save it, and the save's diff shows what it adds.
**Threat check** (the security-audit skill, a hostile VM writing what other VMs or this machine run):
| Lead | What holds it | Check |
| --- | --- | --- |
| A VM writing the store's plugins, which every VM runs | The store's folder stays mounted read-only, and the VM's writes go to its own folder | `TestClaudePluginsSeed`, `sync`'s links and `own-dirs`, e2e's `project` section |
| A save that sends more than the seed's entries, such as a plugin's data | The VM's script sends only the seed's entries, and devvm saves nothing when the stream has any other entry of the folder | `TestReadSentClaudePlugins`, `TestAgentSaveScriptClaudePlugins`, `agent_save` |
| This machine's plugins' data reaching every VM | The import copies only the seed's entries, through links too | `TestAgentImportClaudePlugins`, `agent` |
| This machine's plugins' data that devvm 0.1.0's import left in the store | Every start takes the store's entries that a seed lacks out before the VM runs, from devvm's config folder as a root, refusing a link anywhere on the path and following none among the entries, and a VM with Claude Code doesn't start while they can't go | `TestCleanSeeds`, `TestCleanSeedsFails`, `fixture_v010_plugins` |
| 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, 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
On a Linux host, Lima's QEMU shares the project folder over 9p, and Lima mounts a writable 9p share with `cache=mmap` unless the VM's config says otherwise (read-only ones with `fscache`). The guest kernel's 9p client has a race in that mode, which [Pierre Barre's patch](https://lore.kernel.org/all/[email protected]/) describes and which isn't merged. A `stat()` that runs while a `write()` makes a file longer refreshes the inode from the server, which still has the old size, so the client takes that size over its own, and writeback then drops the pages past it. `fsync` succeeds, yet the file reaches the host empty or cut to 4096 bytes. Claude Code's Edit tool sets it off, and so can any editor or build that stats files as they're written. macOS isn't affected, because Lima's `vz` VMs mount the folder with virtiofs.
@@ -718,30 +882,210 @@ 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.
- **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, 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.
- **There's no `LogValue`.** devvm has no `log/slog` logging, so a `slog.LogValuer` would have no caller, and `Format` already covers the proxy's `log.Logger`.
- **`Reveal` is the one way to the value,** and forbidigo refuses every call to it outside tests, so each place that uses a value carries a `//nolint:forbidigo` with its reason: the proxy's password check, the headers it puts values in, the company proxy's credentials, the VM's CA key as it signs, its config file and the broker's frames to its child; the secrets' store, which writes the Keychain and the file; the VM's proxy URL and `vm.json`; and `internal/agentlogin`'s login files, refreshes and claims. A new use is a choice someone made, with its reason on the line, which the review sees. The structure test refuses a struct that embeds a `Secret`, which would take on its `Reveal`, and an interface that declares `Reveal() string`, through which a value could pass without a call forbidigo sees.
The wire types keep each file's bytes as they were, so a frozen release's `proxy.json` writes back byte for byte (`TestV010ProxyConfigs`), its `Sum` doesn't change and no running VM's proxy starts again for an upgrade. An agent's login file stays the agent's own format, read and written as a map so that fields devvm doesn't know are kept, and a key or token is a `redact.Secret` once it leaves the map, through a lookup, a refresh or a capture.
**Not covered.** The company proxy's URLs as your environment gives them, `HTTPS_PROXY` and `HTTP_PROXY`, can hold a password, and they stay strings, because devvm passes them on as they are, to `proxy.json` and to the programs it runs on the host. So do the URLs `proxy.Upstream.WithPassword` returns, which hold the saved password for devvm's own clients and the programs it runs. The VM's proxy URL, which holds its password, is a string too, because it goes into the VM's Lima config and environment, where the VM needs it. `redact.String` and `redact.In` take the passwords in such URLs out of devvm's run log and Lima's logs ([your company proxy's password](../safety/attack-vectors.md#this-machine)). Two values are strings by design:
- **The Keychain's value,** which `platform.KeychainGet` returns and `KeychainSet` takes as a string, because `internal/platform` imports no devvm package. `secrets.Store` makes it a `Secret` at once in `saved`, and reveals it only for `KeychainSet` in `save`.
- **devvm desktop's VNC password,** 8 characters that you must see to type into a VNC viewer. devvm keeps it in the desktop section of `vm.json` and shows it in `desktop_ready`.
## 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, 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](../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:**
| Part | Side | Why |
| --- | --- | --- |
| The VM's proxy port, every request and tunnel, the rules and the floor, the SNI check, interception, putting values into headers, transparent mode, `devvm.proxy`'s endpoints, and the bounds on what a VM makes the proxy hold (`maxConns` and `admit`, `maxConnects`, `maxRequests`) | child | they read the VM's bytes, which is what the child is for |
| The event log, `network.jsonl`, and the child's own lines in `proxy.log` | child | each request logs an event, so a hop to the broker would sit on every request's path |
| The shared Nix cache, its fetches and its files | child | its fetches go through the floor and the company proxy as the VM's requests do, and each VM's Nix checks what it gets |
| The company proxy as the requests' upstream, with its credentials | child, with the `proxy` secret's value from the broker | the company proxy takes its password with each plain HTTP request, so whatever sends those requests holds it |
| Looking up a name, and opening a TCP connection to an address or to the company proxy | broker, which hands the connection to the child, and judges each address again with its own policy and floor | a sandbox can't tell this machine's loopback, its own addresses and the LAN apart from the internet as a rule changes (below), so the child's sandbox refuses it every connection of its own |
| Each value's lookup: the Keychain through `security`, devvm's secrets folder, an agent's login file and its OAuth refresh (`IO.Secret`) | broker | they need the Keychain and your files |
| Capturing logins: the token request to the endpoint, its reply, saving the login and writing the bindings again (`IO.Capture`) | broker | the endpoint's reply holds the login's real tokens, its refresh token among them, which never enter the child |
| The SSH agent's relay, its socket and its connections to the agent | broker | its filter is the guarantee, and a child with the agent's socket could send the agent anything |
| Holding the backend's logs to their cap (`IO.KeepLogs`, `Config.VMLogs`) | broker | they're in Lima's folder for the VM, beside its disk and its `lima.yaml`, which a child must never write |
| Connecting to a link's socket | broker, which hands the connection to the child | devvm's run folder holds every VM's link sockets and agents' relays, and the ssh masters' control sockets, each a way into a VM |
| Finding a request's host in the links' list | child, checked again by the broker | the child decides for each request whether it's for a link, before any rule |
| `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 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 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 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.
- **The network:** no connection of its own. It accepts on its listener, reads and writes the connections it accepted and those that the broker hands it, and on Linux binds its netlink route socket, which reaches the kernel alone. It sends no UDP, and it listens on nothing.
- **Nothing else:** no read of your home folder or of devvm's data, config or run folders, no Keychain, no unix socket but its own two descriptors, no Lima folder, no signal to another process, no tracing, and no fork or `exec`.
The floor fails open if it reads no addresses for the host, because `hostAddrs` then refuses none of them, so the child's check after it confines itself needs a read of the host's addresses that isn't empty, and a later read that fails keeps the last good one.
**The protocol.** The broker makes one unix stream socketpair, close-on-exec from the start (`SOCK_CLOEXEC` on Linux, and `syscall.ForkLock` held with `CloseOnExec` on macOS), so no program the broker runs, such as `security`, holds an end, and the child's end is its descriptor 3. Each message is a frame: a 4-byte big-endian length, then a JSON object of at most 2 MiB with its `type`, its `id` and its fields, which the reader decodes refusing unknown fields. Bytes, such as a file, a body or a header's value, cross as `[]byte`, which JSON holds in base64, so `encoding/json` never changes bytes that aren't UTF-8 and a 1 MiB file takes about 1.4 MiB of a frame. Every read is a `recvmsg` with room for one descriptor, and a read whose control data was cut short (`MSG_CTRUNC`) breaks the rules. Each read asks for no more than the bytes left in its frame, and the writer sends each frame whole under one lock, with its descriptor on the frame's first bytes, so a descriptor always arrives with the frame it belongs to. The broker's first frame is `start`, with the protocol's version, 1, the SHA-256 of the broker's own executable, which the broker reads first thing as it starts, and everything the child runs with, as the start below says. The child answers `ready`, with the same version, the SHA-256 of its own executable, which it reads before it confines itself on Linux and through its profile on macOS, the address it serves and how it's confined, or `failed`, with why. After that only the child asks, and the broker answers each request with a frame of the same `id`, in any order:
| Request | What the child sends | What the broker answers |
| --- | --- | --- |
| `value` | a binding's kind, agent and name (`valueKey`) | the value and when the broker looked it up, or an error |
| `file` | a watched file's number in the start's list | the file's bytes and the stamp it read, or that it's missing or refused, and why |
| `link` | a request's host and port | a connection to the link's socket, as the frame's one descriptor (`SCM_RIGHTS`), or an error |
| `token` | a captured request's host, its clean path, method and query, its headers, at most 64 KiB, and its body, at most 64 KiB (`captureRequestMax`) | the reply the VM gets, its status and its few headers, and the agent whose login it was, or an error |
| `lookup` | a host name, absolute, with its one trailing dot | its addresses, or an error |
| `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, 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 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 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.
- **`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, 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 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, 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.** `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, 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, 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.
**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, `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. 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, 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.
**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, 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](../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, 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, 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.
- **A network namespace for the child with nothing but its own loopback,** with the broker dialing every connection: it costs what the `dial` request does, it needs an unprivileged user namespace, which Ubuntu's AppArmor restricts from 24.04 and other systems turn off, and which the child's filter refuses (`unshare`), so the broker would have to make it. The filter refuses the same connections without a namespace.
- **The broker signing the interception's certificates:** the child already sees every byte of its VM's traffic, so the VM's CA key gives it nothing more, and no other VM trusts that CA.
- **The agent's relay in the child, through a connection from the broker:** that connection would carry whatever the child sends, so the broker would have to filter it, which is the relay's whole job.
- **A process each for the relay, the logs and the lookups:** each would be unconfined, as the broker is, so more processes would add lifecycles but no boundary.
**Threat check** (the security-audit skill, guidance mode, with its local IPC, protocols, data isolation and resource exhaustion companions, on this design, and an independent review of it against today's code, whose findings are folded in). Leads, each ruled out by the design, changed in review, or listed:
- **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, 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: 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, 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: `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.
- **The folders the child writes:** changed in review. A child that a VM takes over could leave a link or a FIFO in its logs folder or the Nix cache, and devvm opened `proxy.log` again by its path at the next start, copied and emptied it by its path at each rotation, opened `links.log` and `ports.log`, read the event log, and trimmed the cache through `nar/`, each following the link. That would have written the VM's bytes into a file of yours, copied one into the log the child reads, emptied or deleted yours, or hung a command on a FIFO. The child now makes regular files alone, and devvm opens everything in those folders through `internal/safefile` or an `os.Root`, never following a link, and rotates `proxy.log` through its descriptor.
- **The disk:** listed. Only the child's own code bounds its logs and the shared Nix cache, so a child that a VM takes over can fill the disk, write what it likes into its VM's logs, which devvm network log and devvm network lock read, replace `links.log` and `ports.log` with files of its own, so the link session's report after a start can show warnings it forged or miss real ones, and write what it likes into the cache. Each VM's Nix checks a cached NAR against cache.nixos.org's signature and its `NarHash`, so the other VMs fetch such a NAR again rather than trust it.
- **The Nix cache's lock and its names:** changed in review, and listed. A child that held `.lock` forever would have hung every other VM's `/nix/` requests and devvm gc's trim, so each takes the lock with a deadline of a few seconds, trying it without blocking, and past it answers `404` or skips the trim and says so. A child can still slow the cache down by holding the lock, and list the store paths that other VMs fetched.
- **The logs' locks:** changed in review, and listed. The broker and its child share `proxy.log`'s lock, and the child and `devvm _links` the event log's, so a child that held one for ever would have stopped the broker at its next line, and the broker logged before it closed the socket when the hostagent ended, so the pair would have outlived the VM. Now the broker closes the socket and starts its kill's timer before it logs anything, and every writer tries each log's lock without blocking for at most 200 ms, then writes its line without the lock or skips the rotation. A child can still make each of the broker's lines wait that long, and make a rotation lose the lines written as it copies.
- **A log made huge:** changed in review, and listed. A rotation of `proxy.log` read the whole file into memory, so a child that made it huge, or sparse at a terabyte, could have made the broker run out of memory and write as much. Now a rotation copies at most the last twice its limit, 20 MiB, from a line's start, streamed into its copy. A child can still fill the disk, as the disk's row says.
- **What `stat` shows:** listed. Landlock doesn't restrict `stat`, so a child that a VM takes over on Linux learns whether any file of yours exists, its size and when it changed, though not what it holds. Changed: it read every file below `/etc` that you can, which its resolver needed, and now that the broker looks up its names, it reads none. On macOS the profile refuses `stat` outside the child's files, but a refused path answers `EPERM` and a missing one `ENOENT`, so a child there learns whether a path exists, though nothing else of it.
- **The services the profile allows on macOS:** listed, and changed. A child that a VM takes over can ask `trustd` to check certificates, which reads your trust settings, and that holds no secret of yours and isn't the Keychain. `trustd` can fetch a missing issuer's certificate or an OCSP answer from the URL in a certificate, from its own unconfined process, which a review raised as a way to send a request to loopback or the LAN. Checked: a leaf whose issuer was missing and whose issuer, OCSP and CRL URLs named a server on this machine's loopback or its LAN address made `trustd` fetch nothing, through Go's verifier under the profile and without it, and through `security verify-cert`, which allows network fetches, with revocation required or not, on macOS 27. Listed: when it fetches is Apple's to change, and the worst it could do is a request, whose answer the child never sees, to loopback or the LAN. The profile allowed mDNSResponder's socket for the resolver, so a child could browse the local network's Bonjour services, announce services of its own there, and register any `.local` record it liked (`DNSServiceRegisterRecord`), and now that the broker looks up its names, the profile allows no unix socket. `com.apple.trustd.agent` also takes changes to your trust settings, which macOS asks your password for through its authorization services (`com.apple.authd`), and the profile allows neither those nor `com.apple.SecurityServer`, so a child can't trust a CA of its own. devvm's tests didn't try such a change.
- **A confined start made unconfined:** ruled out, and changed in review. The broker starts the child again unconfined only for a failure of `sandbox-exec` itself, an exit status of its own or `SIGABRT` or `SIGKILL` before the child answered, which comes before devvm's code runs and reads nothing of a VM's, so a child that a VM took over, or what it left in its folders, can't make the next start unconfined. The broker counted any signal, after its own stop of a child that hadn't answered in time, so a child that hung, which its stop then ended with `SIGTERM`, counted as the sandbox's failure. It now decides before its stop, only for a child that had already ended, and only for those two signals. Listed: a program of yours that kills the child in that moment makes the start unconfined, which the proxy's log and devvm doctor say. A child that fails after that, such as on a planted file, or that hangs, fails the start, which leaves the VM without a network until its next start, as before.
- **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 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.
**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.
## Failed attempts
- **Claude's host login in VMs:** on macOS it's in the Keychain, which can't be shared. VMs get a login made in a VM instead, which the VM's proxy captures. The first token saved by hand was the code the browser shows, so `devvm secret set claude` refuses one without the `sk-ant-oat01-` prefix.
@@ -762,6 +1106,7 @@ devvm keeps its state in plain files in two folders, which [State files](overvie
- **Lima locks each additional disk to one running VM,** so images shared across VMs go through a shared folder (virtiofs on macOS, 9p on Linux) and are loop-mounted from it.
- **Read-only mounts are enforced by the host:** even root in the VM can't write to them, but root can unmount a nested one and reach what's underneath.
- **Codex and opencode refreshing their OAuth logins in a VM can rotate the token and sign the host out.** On every tier the VM holds only placeholders, and devvm refreshes the logins on the host when the proxy asks it for their values (`internal/agentlogin`). Codex decodes `id_token`'s claims and the access token's `exp` without checking signatures, so placeholders are unsigned JWTs with the real account claims and a far-off `exp`.
- **On macOS, a socket in transit over `SCM_RIGHTS` can lose the data it held** and read as ended when the same process closes, at that moment, a unix socket that still holds descriptors no one received. It fails closed, as an ended connection. The broker and its child close such a socket only as the pair ends, and the test that reads a handed-over link's data asks for the link once more when it reads empty.
- **A process passes the files it was given on to the processes it starts,** unless they're marked close-on-exec. Go marks only the files it opens itself, so a terminal, an editor or a test harness that gives devvm another one (a pty on descriptor 3, the end of a pipe) would have it held by devvm's proxy, its port forwarder and Lima's processes, which keep that terminal or pipe open for as long as they run. So devvm marks every file it was given past standard input, output and error close-on-exec as it starts, and keeps them open itself.
- **No existing tool** gives Lima Dockerfile-style layers with sharing at run time; nerdbox and Kata do it on VM runtimes of their own.
- **Where devvm fits,** next to sbx and Colima: sbx puts agents first; devvm gives a full Linux VM per project, with agents optional.
@@ -773,12 +1118,12 @@ User-facing limits are in [Known limits](../using/limits.md), and what devvm lea
- **`--from`:** a moved tag is noticed only at the next build, not when listing images; devvm doesn't log in to registries, so private images work only through Docker; registries over plain HTTP (`localhost:5000`) aren't supported.
- **Alpine:** `rc-status` as a normal user shows `acpid` and `syslog` as crashed, as their pid files are root's (`sudo rc-status` is clean).
- **Free-space floors:** the free space devvm wants before each build and new VM ([free space](../using/ports-size.md#free-space)) is set by Lima's own package, and for shared tool images in `internal/backend/disk.go`, where the comments give what each number was measured from. The measurements are free space, read with statfs before, during and after each step, in e2e runs on macOS with Lima `vz`, and for shared tool images also with devvm's data folder on a tmpfs of its own on Linux. On Linux hosts, Lima's numbers add a copy of base's disk to an image's and a tools build's, but they haven't been measured there yet. A `--from` base converts its image in the host's temporary folder, which devvm doesn't check, because on Linux that's often a small tmpfs.
- **Workspace clones:** each repo's seed is pushed one after another, so a folder of many big repos takes a push per repo; pushes in parallel, bounded, aren't built. A repo made in the VM stays there until the user clones it out by hand, and nothing of the folder's own files comes back ([workspace clones](#workspace-clones)).
- **Workspace clones:** each repo's seed is copied one after another, so a folder of many big repos takes a copy per repo; copies in parallel, bounded, aren't built. A repo made in the VM stays there until the user clones it out by hand, and nothing of the folder's own files comes back ([workspace clones](#workspace-clones)).
- **x86_64 hosts** are untested on real hardware; on Intel Macs, `--from`'s kernel is untested with `vz`.
- **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).
+21 -7
View File
@@ -8,11 +8,23 @@ 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 the browser draws when the page loads. `docs/layouts/_partials/scripts/mermaid.html` takes the place of Hextra's partial of the same name. It loads the Mermaid version that `hugo.yaml` pins in `params.mermaid.base`, which Hugo fetches when it builds the site, and it gives every diagram the same theme, so a diagram never sets its own colors or font. The theme uses the site's palette: panels on the surface color with blue borders, lime arrows, and text in Departure Mono at 14px, larger than the home page's art so labels read easily. It uses Mermaid's classic look, because its newer neo look draws a decision's hexagon 70px taller than its label. A diagram can set its own layout in front matter, as Staying safe's three columns set `minNodeWidth`, but never its own colors or font. Mermaid draws each diagram at its own size and never scales it to fit, and a diagram wider than the page scrolls sideways. Keep labels short, and break a long one with `<br>`. In a label, write `<` as `#lt;` and `>` as `#gt;`. 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.
- **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.
- **The layout** is pele's own, with the Mermaid settings that `render-diagrams.mjs` passes, such as right-angled edges. A diagram can set its own layout in front matter, as Staying safe's three columns set `minNodeWidth`, but never its own colors or font. pele lays subgraphs out from left to right in the order they're written.
- **Measuring labels:** the script measures each label by Departure Mono's metrics, where every character is 350/550 of the font size wide, so labels fit their boxes. pele draws edge labels, messages and notes at seven-eighths of the size, 12px, and has no option to change it, so the measurer gives that text its width at 14px and the script then writes it at 14px. A self-check, before anything is drawn, fails the run when pele no longer measures and writes that text as the script expects, and every group of small text that pele draws must carry the 12px size the script replaces. The script also puts a newline after each label, where the SVG draws nothing, so the site's search sees one label's last word apart from the next label's first.
- **Size:** each diagram is drawn at its own size and never scaled to fit. The hook sets each diagram's width on it, and a diagram wider than the text reaches into the page's right margin, the article's padding, as far as it needs, and into the padding on the left for whatever the right margin can't hold, so it never covers the table of contents. A diagram wider than the text and both paddings scrolls sideways, as the widest ones do on a narrow screen. `custom.css` gives each one `content-visibility: auto`, so the browser draws it only when it nears the screen, and the hook sets the diagram's height as its `contain-intrinsic-block-size`, so the page doesn't jump while you scroll.
- **Accessibility:** every diagram has an `accTitle` and a one-line `accDescr`, which become the SVG's title and description that screen readers read, and the script fails on a diagram without them. The description says in full sentences what the diagram shows.
- **Labels:** keep labels short, and break a long one with `<br>`. In a label, write `<` as `#lt;` and `>` as `#gt;`.
- **pele's version** is pinned exactly, and `scripts/bump.sh pele` moves it ([updating pinned versions](maintaining.md#updating-pinned-versions)).
- **Style:** succinct and direct. Commands are written as devvm x or in backticks, never in quotes. No `please`, `simply` or `note that`.
- **The home page** is `docs/content/_index.md`, on Hextra's `hextra-home` layout: its hero shortcodes, then plain Markdown. `custom.css` styles it through the one `div` that the layout wraps its content in. After the hero, the page has a quick start, what's supported, why to use devvm with its feature cards, a short FAQ, and a closing call to action with the hero's buttons. It keeps a marketing tone, but each of its claims matches the docs page it links to, it uses the same terms, and it says each thing once.
- **The quick start** shows the three commands to run first, each after a comment short enough to fit a phone's width, because a comment after its command would scroll out of view there.
@@ -22,7 +34,7 @@ The site is [Hugo](https://gohugo.io) with the [Hextra](https://imfing.github.io
- **Other content per operating system** goes in `{{</* os-tabs */>}}`, with a `{{</* os-tab name="macOS" */>}}` and then a `{{</* os-tab name="Linux" */>}}` inside it, each holding Markdown, as Installing's requirements tables do. It uses the same tabs, styles and script as the install commands, so the visitor's system is selected, and the build fails unless the tabs are macOS's, then Linux's.
- **Colors:** the site is dark only (`hugo.yaml`'s `params.theme`). Its palette is in `docs/assets/css/custom.css`: a black background and one lime accent, `#7fff00`, which sets Hextra's primary color. The home page's illustrations also use `#0086b3`, the blue that Hextra's syntax highlighting gives commands like `cd`, and `#ff5370` (`--devvm-red`), the JustBlack theme's red, which marks only what an attack has compromised. The red's contrast is 6.7:1 on the black and 6.0:1 on the surface color, and it's much darker than the lime, so the two stay apart for readers who can't tell red from green.
- **Fonts:** the site uses Instrument Sans for text, Martian Mono for code, and Departure Mono, a pixel font, for the logo and the home page's headings, badge and buttons. All three are in `docs/static/fonts/`, each in its own folder with its license, and `docs/layouts/_partials/custom/head-end.html` declares them. Instrument Sans and Martian Mono are upstream's variable WOFF2 files, so one file holds every weight, and the partial's comment records where each font came from, at which commit or release, and its SHA-256. To update a font, download the new version from the same place, check its SHA-256, and update the comment. Departure Mono is sharp at multiples of 11px and has one weight.
- **No third-party requests:** devvm.dev and next.devvm.dev load every script, stylesheet, font and image from the site itself, so a visitor's browser asks no other host for anything. `mise run lint:docs` checks this after it builds the site: `TestNoThirdPartyLoads` in `internal/cli/docgen/site_test.go` reads every page and stylesheet and fails on a link, script, image, frame or CSS `url()` that points at a host other than the ones in `hugo.yaml`'s and `next.yaml`'s `baseURL`. Hugo fetches FlexSearch, which Hextra's search uses, and the Mermaid version that `hugo.yaml` pins when it builds the site, and the site serves both itself, so they pass. Links that a visitor clicks, such as GitHub's, aren't loads, and the check ignores them. The social cards draw it from `docs/assets/fonts/departure-mono/`, which has the same release's OTF and license, because Hugo can't draw text from a WOFF2.
- **No third-party requests:** devvm.dev and next.devvm.dev load every script, stylesheet, font and image from the site itself, so a visitor's browser asks no other host for anything. `mise run lint:docs` checks this after it builds the site: `TestNoThirdPartyLoads` in `internal/cli/docgen/site_test.go` reads every page and stylesheet and fails on a link, script, image, frame or CSS `url()` that points at a host other than the ones in `hugo.yaml`'s and `next.yaml`'s `baseURL`. Hugo fetches FlexSearch, which Hextra's search uses, when it builds the site, and the site serves it itself, so it passes. Diagrams are SVGs inside the pages, so they load nothing. Links that a visitor clicks, such as GitHub's, aren't loads, and the check ignores them. The social cards draw it from `docs/assets/fonts/departure-mono/`, which has the same release's OTF and license, because Hugo can't draw text from a WOFF2.
- **The logo** in the navbar is the branding page's `devvm-logo-on-dark.svg` at its own size, which `hugo.yaml`'s `params.navbar.logo` names, with the site's title as its alt text. Right-clicking it opens the branding page instead of the browser's menu, through a script in `docs/layouts/_partials/custom/footer.html`. A left click, or Enter on the focused logo, still goes to the home page.
- **The branding page** is `docs/content/branding.md`, at `/branding/`, on its own layout, `docs/layouts/branding.html`, which is Hextra's home layout with the home page's look and the script that copies a swatch's hex. Its front matter keeps it out of the sidebar. It has the logo as box-drawing text in a code block, the logo's SVGs and PNGs, the icons, the social card, the palette, the fonts, how to use the logo and the credits.
- **Its downloads** are in `docs/static/branding/`, and `{{</* brand-asset */>}}` tiles inside `{{</* brand-assets */>}}` show each one on its background, with a link to each file. The build fails when a file doesn't exist, and it reads each PNG's size for its link. `devvm-logo-on-dark.svg` and `devvm-logo-on-light.svg` are the logo, drawn on a pixel grid as the favicon is, made from Departure Mono's 11px glyphs. The prompt and devvm are at twice the glyphs' size, the box is in 1-pixel lines, and the lock, a block with a keyhole under a 2-pixel arch, sits on the box's bottom-right corner, with the box's lines stopping short of it so that the arch stands clear. The version for light backgrounds is black, with its prompt in the dark lime, `#408000` (`--devvm-accent-dark`), which is the lime's hue at half its lightness, with a contrast of 4.9:1 on white, where the lime has 1.2:1. Each logo's PNG is its SVG at four times its size on a transparent background, and `devvm-icon-64.png` to `devvm-icon-1024.png` are `docs/static/favicon.svg` at 4 to 64 times its size. After changing an SVG, render its PNGs again with headless Chrome's `--screenshot` at the exact size, passing `--default-background-color=00000000` for the logos' transparency, and look at each one.
@@ -64,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.
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
@@ -76,14 +88,16 @@ mise run cli-docs
It runs `internal/cli/docgen`, which replaces every page in that folder: `_index.md`, listing the commands, and a page per command named after its path (`devvm_build.md`), with `title` and `explainer` front matter, the explainer being the command's `Short`, and links to the other pages as files. Each page has the command's examples, and a Docs section before See also that links to the command's docs page on the site. Hidden commands (`_msg`, `_qemu`) and Cobra's help command are left out. The pages carry no dates, so the same commands give the same files. They carry no weight either, so Hugo sorts the section by title, and a new command adds its own page and changes only `_index.md` and the root's `devvm.md`; `TestPagesHaveNoWeight` checks this. The `.gitattributes` file marks the pages as generated, so GitHub collapses them in a diff.
`mise run cli-docs` also writes the generated blocks of hand-written pages, which `cli.DocBlocks` in `internal/cli/docblocks.go` lists: the Supported agents table in `using/coding-agents.md`, and the README's list of the agents. Each block sits between two HTML comments that name it, and docgen replaces only the text between them, from the registry of agents, `agents.Defs`, and each agent's policy in `assets/shared-tools/`. So don't edit a block by hand: change the agent's `Def`, its `Docs` included, or its policy, then run `mise run cli-docs`.
### A command's help
Every command's help, which its reference page also shows, has the same shape. `Short` is an action in sentence case without a full stop, such as `List the project VMs`. `Long` is one to three short sentences on what the command does, and the rules and edge cases go on its docs page. `Example` comes from `examples` in `internal/cli/help.go`, which takes each command line with a short comment and lines the comments up, the most common invocation first. A flag's description is short, and its long explanation goes on the page.
Each command describes itself where it's made, so its docs page and group are in its own file, not in tables elsewhere. Its `Annotations` come from an `about` in `internal/cli/help.go`: `docs`, the user page that covers it as `page#anchor`; `group`, its section of the root's help; and `noJSON`, why a command without `--json` has none. `addDocs` gives the root Cobra's usage template with a Docs section at the end, which shows the address of the command's page, and the root's help also ends with the issue tracker, `msg.IssuesURL`. The CLI reference links each command's page too, and `TestDocLinks` in `internal/msg` reads those links from the reference and checks that each page and heading exists and is a user page. `helpGroups` in the same file lists the root's sections, in order, and `addGroups` adds each group that has a command and sets its commands' `GroupID`, so a group whose commands don't exist yet stays out of the help. A subcommand can name a group too, such as layer add in Change your VM, when it belongs in another group than its parent. `addGroups` then adds that group to the parent, so the parent's own help groups its subcommands the same way, and the usage template lists the subcommand by both names in the root's group, after the group's own commands. Cobra lists a group's commands in alphabetical order, and `help` goes in Cobra's own Additional Commands.
The tests fail when the checked-in pages are stale: `TestReferenceIsCurrent` in `internal/cli/docgen` generates the reference into a temporary folder and compares it with `docs/content/docs/cli/`. `mise run docs` regenerates it before serving the site.
The tests fail when the checked-in pages are stale: `TestReferenceIsCurrent` in `internal/cli/docgen` generates the reference into a temporary folder and compares it with `docs/content/docs/cli/`, and it checks each generated block against its page too, which `TestStaleBlockIsCaught` proves it catches. `mise run docs` regenerates it before serving the site.
### Building the site
`mise run docs` serves the site at `http://localhost:1313/` and reloads on every change. `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)).
+12 -10
View File
@@ -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.
- `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,17 +41,19 @@ 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 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 own login, a ChatGPT login or API keys) and whether `config.toml`'s `[pass-keys]` takes it. The commands' help, `--agents`, the picker and shell completion list the agents 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.
- `assets/shared-tools/<name>.policy`: the hosts its allowlist allows.
- `testdata/mise.lock` and `tests/e2e-mise.lock`: its lock entry, which `scripts/bump.sh e2e-tools` writes into the second.
- `docs/content/docs/using/coding-agents.md`: its row in the Supported agents table, in the registry's order, and a section on its login when it has one.
- `README.md`, whose short list of the agents stays in step with the table.
- When it keeps a login file: a format for each of its kinds in `internal/agentlogin`, a type with the `format` interface's methods in a file of its own (and `keyFormat` or `chatGPTFormat` when its `Def` says it saves API keys or holds a ChatGPT login), added to `formats` in `format.go`, with its fixture in `goldenLogins` (`internal/agentlogin/golden_test.go`) and its golden file, and its format's section in `internals/network.md`.
- `docs/content/docs/using/coding-agents.md`: a section on its login when it has one.
- `CHANGELOG.md`: its entry.
- `tests/e2e/network_test.go`: its name in the network section's `--agents` list, which launches one VM with every agent, and the checks of its allowlist, its login and its copies there.
- `assets/guest/sync.sh`, only when it needs setup in the VM beyond its settings and logins, as Claude Code's link in `~/.local/bin` and Codex's lines in its `config.toml` do.
- When it keeps a login file: a format for each of its kinds in a file of its own in `internal/agentlogin`, named for the agent, with the `format` interface's methods, `kind` naming its kind (and `keyFormat` or `chatGPTFormat` when its `Def` says it saves API keys or holds a ChatGPT login, and `captureFormat` when the VM's proxy captures its logins: its token endpoints, the start of its `User-Agent` when another agent shares an endpoint, its capture and its reply to the VM's own refresh), added to the list in `formats` in `format.go`, with its fixture in `goldenLogins` (`internal/agentlogin/golden_test.go`) and its golden file, and its format's section in `internals/network.md`.
Then `mise run cli-docs` writes the CLI pages whose help lists the agents, and the golden files in `internal/vm/testdata/golden` take its paths with `UPDATE_GOLDEN=1 go test ./internal/vm -run Golden`. `TestDefsComplete`, `TestFormatsCoverLogins`, `TestSharedToolsPolicies` and `TestConfigTools` fail until those files match the registry, and the structure test fails on any string literal elsewhere that is the agent's name or holds its folder, so code of the agent's own, such as a settings filter or a login of its own, names it by its constant in `internal/agents`. The network section of the e2e tests drives every agent, so the new one gets its checks there.
Then `mise run cli-docs` writes the agent's row in the Supported agents table, its name in the README's list and the CLI pages whose help lists the agents, and the golden files in `internal/vm/testdata/golden` take its paths with `UPDATE_GOLDEN=1 go test ./internal/vm -run Golden`. `TestDefsComplete`, `TestFormatsCoverLogins`, `TestSharedToolsPolicies`, `TestConfigTools` and `TestReferenceIsCurrent` fail until those files match the registry. Code of the agent's own, such as a settings filter or a login of its own, goes in a file named for the agent, such as `claude.go` or `agentlogin_claude.go`, and names the agent by its constant in `internal/agents`, so the code for every agent calls a hook there rather than asking which agent it has. The structure test fails on a string literal elsewhere that is the agent's name or holds its folder, on code outside the agent's own files that compares with its constant, has a `case` for it, looks for it or keys a map on it, on a list in Go that names every agent, tests included, and on a CLI test script's line that lists agents as a message does, which `$AGENT_CHOICES`, `$LOGIN_AGENTS` and `$KEY_AGENTS` stand in for. The network section of the e2e tests drives every agent, so the new one gets its checks there.
### Adding a provider
@@ -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.
+211 -17
View File
@@ -1,26 +1,97 @@
---
title: Maintaining
explainer: Bump pinned versions, release devvm and run the docs sites
explainer: Bump pinned versions, fix known vulnerabilities, release devvm and run the docs sites
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
- `scripts/bump.sh --check` lists every pin against upstream; `scripts/bump.sh [tool...]` rewrites the pins (all tools by default) and prints a summary for the commit message. It writes a value only if it has the shape of a pin (a version, a 64-hex checksum, a dated release, a commit), since some of the edited files run on the host, and edits nothing unless every value is good. It needs `curl` and `jq`. 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.
- 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, and closes it once none is left. It never bumps anything: you run `scripts/bump.sh` with the tools it lists, then the `--from` tier of the [end-to-end tests](tests.md#end-to-end-tests), because pin bumps change images.
- The tools: `docker`, `nix`, `direnv`, `nix-direnv`, `mise`, `rustup`, `crane`, `omb`, `eza`, `tealdeer`, `e2e-tools`, `e2e-from`, `e2e-ubuntu`, `e2e-lima`. 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.
`scripts/bump.sh` moves every version pinned in the repo, so preparing a release's pins is one command:
```sh
scripts/bump.sh --check # every pin, by group, against upstream; changes nothing
scripts/bump.sh # every patch and minor bump, then a summary for the commit message
scripts/bump.sh docker pele # only these tools, with a named images or e2e tool's major
```
- `--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. 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.
- `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, 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 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, 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 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.
- `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, `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: 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` 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-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.
- Edited scripts change image keys, so the affected images rebuild on next use. An edit to `assets/prelude.sh` changes the key of every image and every shared tool image. Build them in a sandbox of their own (`LIMA_HOME`, `DEVVM_LIMA_HOME`, `XDG_DATA_HOME`, `XDG_CONFIG_HOME`) before committing (`devvm build docker`, or a VM made with the tools whose build script changed), then `devvm gc`, and run the [end-to-end tests](tests.md#end-to-end-tests).
## Known vulnerabilities
govulncheck checks devvm against the Go vulnerability database. `mise run vuln` scans the code twice, once as built for Linux and once as built for macOS, because some files build for only one of them, and it reports a vulnerability only when devvm's code calls the vulnerable function. Two workflows run it:
- **CI's `vuln` job** runs `mise run vuln` on every push and pull request that CI runs on, as a job of its own, so a vulnerability published since the last change fails that check alone, and `lint` and `test` still report.
- **The Vulnerabilities workflow** (`.github/workflows/vuln.yml`) runs every Monday, and you can start it by hand from the Actions tab. It scans `main`'s code for both systems, then downloads the archives of the latest release and of the newest release, prerelease or not, and checks that `SHA256SUMS` lists each archive and matches it. Then it scans each platform's binary with `govulncheck -mode=binary`, because a release's binaries keep the Go and modules they were built with.
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. 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:
```sh
mise run vuln # what govulncheck finds in your checkout, and the calls that reach it
scripts/bump.sh go # Go's newest patch release, for one in the standard library
scripts/bump.sh go-minor # Go's newest minor release, when only a newer minor has the fix
scripts/bump.sh go-mods # the direct modules' newest patches and minors, for one in a module
```
A module that only `go.mod`'s indirect requirements hold moves with `go get <module>@<fixed version>` and `go mod tidy`. Once `main` is fixed, its scan passes, but the issue stays open while the latest release or the newest release still has the vulnerability, and it closes only when a release with the fix is the latest. A vulnerability that affects devvm's users calls for a release ([Releasing](#releasing)), and one that devvm's code reaches only in a way that doesn't matter can wait for the next one.
## Fuzzing failures
The Fuzz workflow (`.github/workflows/fuzz.yml`) fuzzes every target each night and keeps its failures in one issue, "Fuzzing found failing inputs", which names each failing target and links the night's run. For each target there, download its `crash-<target>` artifact from that run, and fix it as [Fuzzing](testing.md#fuzzing) says:
```sh
cp ~/Downloads/crash-FuzzNoProxy/* internal/proxy/testdata/fuzz/FuzzNoProxy/ # the input, in its target's seeds
go test -run '^FuzzNoProxy$' ./internal/proxy # fails until the code is fixed
```
Commit the input with the fix and its test. The input stays in the target's corpus, so the target fails on it each night until the fix is on `main`, and the issue closes on the first night every target passes ([the nightly run](testing.md#the-nightly-run)).
## Checking base against Ubuntu's newest
The end-to-end tests pin base to `e2eUbuntuRelease`, so they never build base the way a user's first build does, from Ubuntu's newest cloud image and the mirrors' newest packages. An upstream change can break those builds before any test sees it. For example, vz's direct kernel boot needs an uncompressed arm64 kernel, and a VM shuts down only when its kernel has `gpio_keys`. `mise run e2e -- --newest-base` builds base as a user's first build does and runs the checks that prove it works: `images`, then `project` (a VM that boots, stops, starts again and shuts down) and `tools`. `--only` chooses other sections in their place.
@@ -38,17 +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.
- **Each release:** bump `VERSION`, add the `CHANGELOG.md` entry 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 |
@@ -60,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
@@ -73,5 +266,6 @@ The docs have two sites, and the Docs workflow (`.github/workflows/docs.yml`) de
- **devvm.dev** is GitHub Pages, in the repo's `github-pages` environment, which accepts deployments from `main` and from `v*` tags, and only admins can create a `v*` tag. When a release is published, and it isn't a prerelease, the workflow builds the docs in that release's tag and deploys them. A release event runs the workflow file that the tag has, so a release whose tag predates this workflow doesn't deploy on its own. Pushes to `main` never change devvm.dev.
- **To deploy a release's docs by hand,** for a release that didn't deploy on its own or to put devvm.dev back on a release, run the Docs workflow from `main` in the repo's Actions tab, or with `gh workflow run docs.yml --repo devvmhq/devvm -f site=devvm.dev -f ref=v0.1.0`. The site is `devvm.dev` unless you choose another one, and the ref is the release's tag, which has to look like `v0.1.0`, so a prerelease's tag is refused. Without a ref, the workflow deploys the latest release, as `gh release view` names it.
- **next.devvm.dev** is Cloudflare Pages, serving the files on the `main` branch of the repo `devvmhq/docs-next`, and Cloudflare builds nothing. On each push to `main` that touches the docs, the workflow lints and builds `main`'s docs for next.devvm.dev, then replaces everything in `devvmhq/docs-next` but its `README.md` with the build, and commits it as `Build from devvm <short sha>`. When the build is the same as the last one, it commits nothing. `gh workflow run docs.yml --repo devvmhq/devvm -f site=next.devvm.dev` runs it by hand. Nobody edits `devvmhq/docs-next` by hand, because the next build replaces it.
- **Every build draws the diagrams first,** with `mise run docs:diagrams`, so each of the workflow's jobs installs Node through mise. A release whose tag predates the drawing script, `docs/render-diagrams.mjs`, loads Mermaid in its pages instead, so the release job draws them only when the tag has that script.
- **The deploy key** that pushes to `devvmhq/docs-next` is the secret `DOCS_NEXT_DEPLOY_KEY` in the `docs-next` environment, which only `main` can deploy from. It's an ed25519 key with write access to `devvmhq/docs-next` and to nothing else. The workflow checks that repo out with it only after the site is built, so the build never sees the key. To rotate it, make a new key, add its public half to `devvmhq/docs-next` as a deploy key with write access, put its private half in the secret, then delete the old deploy key.
- **The next build** is `hugo -s docs --minify --config hugo.yaml,next.yaml`, which reads `docs/next.yaml` over `docs/hugo.yaml`. It sets the site's address to `https://next.devvm.dev/` and puts a banner on every page that says these docs are for the next devvm and links to devvm.dev. It also sets `noindex`, so Hextra gives every page a `noindex, nofollow` robots meta tag, and `docs/layouts/robots.txt` disallows everything, so search engines don't index the site. devvm.dev's build, `hugo -s docs --minify`, never reads `docs/next.yaml`, so it has no banner, its pages say `index, follow`, and its `robots.txt` allows everything.
+89 -48
View File
@@ -15,14 +15,19 @@ weight: 3
| `package-vars` | a package-level `var` is a blank interface check, an `Err*`/`err*` sentinel from `errors.New` or `fmt.Errorf`, a `regexp.MustCompile`, `template.Must` or `sync.Once*` result, a `//go:embed` file, or listed in `allowedVars`; anything else becomes a field, a const or a local |
| `layers` | which packages import which, in non-test files (tests may wire packages together) |
| `owners` | in non-test files, only its owner runs a host command that `commands` lists, only the files `execSites` lists make a host command, only `guardOwner` asserts a backend package's type, only `envOwner` reads a `DEVVM_` variable, but the settings `envSettings` lists, only its file in `envOwners` reads `HOME`, only its owner's string literals hold a text that `literals` lists, only its owner's string literals are, whole, a name that `names` lists, only its owner's calls to package `strings` split or join on a separator that `separators` lists, only `pathsOwner` builds a path in devvm's data or config folder, and only its file in `callers` calls a function that `callers` lists ([details](#the-checks-on-owners)) |
| `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 `!=`, 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` 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` and `internal/safefile`.
- `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` and `internal/safefile` import no devvm package; `internal/agentlogin` only `internal/agents`, `internal/fetch`, `internal/jsonc`, `internal/proxy`, `internal/safefile` and `internal/state`, because it holds agents' logins; `internal/msg` only `locales`; `internal/paths` only `internal/msg`; `internal/state` only `internal/msg`, `internal/paths`, `internal/platform` and `internal/vmname`; `internal/image` only `assets`, `internal/agents`, `internal/msg` and `internal/paths`; `internal/devcontainer` only `internal/image`, `internal/jsonc`, `internal/msg` and `internal/shell`.
- 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 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`:
@@ -31,66 +36,80 @@ 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). 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.
- **`callers`** maps a function to the one file outside its package that calls it, and a listed file that no longer calls it fails. A method is listed as `pkg.Type.Name`, such as `internal/paths.Dirs.AgentSettings`, and any call of a method by that name outside its package counts, because the check reads no types, so a listed method's name is its type's alone.
`TestRulesFail` breaks each rule, and each layer, on small sources and checks the failure names it.
Shell scripts that live in Go strings get shellcheck too, since lint's shellcheck only finds files with a shebang. `TestEmbeddedScripts` in `internal/structure` finds every call site that runs a script as `sh -c`, `/bin/sh -c` or `bash -c` (or `-lc`), in a `[]string` literal or a call's arguments, outside tests and the stubs. When the script is a constant, a literal, or a sum of them, such as `seedApply` with `seedMarker` in it, the test writes it to a file and runs `shellcheck -s sh` or `-s bash`, as its shell reads it, at `-S warning`, skipping when shellcheck isn't installed. A script built at run time can't be read there, so the test fails on one until `dynamicScripts` lists its file and expression with why: a fixed command around quoted paths, a devcontainer's own command, or a builder that a test of its package checks, as `internal/vm`'s `TestBuiltScriptsShellcheck` does for the scripts built from the agents' registry. A listed site that's gone fails too, so the list stays current. A shell given any other flag, such as `sh -ec` or `sh -e -c`, fails as well, because the test would miss its script: put options such as `set -e` in the script instead. `-s`, for a script on standard input, is fine.
## 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. [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
Each package owns these concerns, and a package's `doc.go`, where it has one, maps the package itself. `internal/fetch`, `internal/redact`, `internal/agents`, `internal/jsonc`, `internal/shell`, `internal/vmname`, `internal/safefile` and `internal/daemon` use the standard library alone, and `internal/proxy` uses it with `internal/daemon` and `internal/safefile` and nothing else. `internal/devcontainer` imports no module from outside devvm, but it uses `internal/image`, `internal/jsonc`, `internal/msg` and `internal/shell`.
Each package owns these concerns, and a package's `doc.go`, where it has one, maps the package itself. `internal/fetch`, `internal/redact`, `internal/agents`, `internal/jsonc`, `internal/shell`, `internal/vmname`, `internal/safefile`, `internal/landlock` and `internal/daemon` use the standard library alone, and `internal/proxy` uses it with `internal/daemon`, `internal/landlock`, `internal/redact`, `internal/safefile` and `internal/vmname` and nothing else. `internal/devcontainer` imports no module from outside devvm, but it uses `internal/image`, `internal/jsonc`, `internal/msg` and `internal/shell`.
| Package | Owns |
| --- | --- |
| `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 |
| `internal/shell` | quoting for a POSIX shell (`Quote`, `QuoteJoin`) and its variables' names (`EnvName`), with the standard library alone |
| `internal/vmname` | a project VM's name grammar (`Prefix`, `HashLen`, `IsVM`, `HashOf`, `SlugOf`, and a remake's `Aside`), with the standard library alone |
| `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 or filters, ssh only, none of the environment's `GIT_*` variables and no prompts |
| `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` 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, and `File` for another program's log, in place and keeping its length |
| `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/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 `devvm _proxy`, as its `README.md` describes |
| `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, and the lifeline. It's the only place that signals a process by its pid |
| `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 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 |
| `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` and `Below`, where `resolve.go` says which one is for what) |
| `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). 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 and is read through `image.OwnScript`. `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
@@ -105,41 +124,48 @@ 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 |
| forbidigo, `os.Open`, `os.OpenFile`, `os.ReadFile`, `os.OpenRoot`, `os.OpenInRoot`, `os.DirFS` and `os.Root`'s `Open`, `OpenFile`, `ReadFile` and `FS`, in the code that reads files a VM can write or swap: `internal/gitprotect`, `internal/agentlogin`, `internal/vm`'s `devcontainer.go`, `detect.go` and `agentsave*.go`, `internal/netpolicy/rules.go`, and `internal/proxy`'s `config.go` and `policy.go` | `internal/safefile`, which imports only the standard library, so the proxy reads with it too. Its `Read` and `Open` open a file without blocking and, unless the caller passes `Follow`, without following a symbolic link at the path's end. They then check the file they opened, not its name, so a FIFO, a device or a folder is refused with `ErrNotRegular`, a file past its cap with `ErrTooLong`, and, with `OneLink`, a file with another hard link with `ErrLinked`. A FIFO that the VM swaps in after a check can't hold devvm, and a link to `/dev/zero` can't flood it. `OpenRoot` opens beneath a folder through `os.Root`, never through a link out of it, and its `FS` lists and stats what's there but opens only regular files | every other file, which is devvm's own or the user's; tests, which make their own fixtures; and, with a `nolint` saying why, what opens a file to write it or a folder to lock it |
| 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, 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, and tests, which use `t.Setenv` |
| forbidigo, `os.Open`, `os.OpenFile`, `os.ReadFile`, `os.OpenRoot`, `os.OpenInRoot`, `os.DirFS` and `os.Root`'s `Open`, `OpenFile`, `ReadFile` and `FS`, in the code that reads files a VM can write or swap: `internal/gitprotect`, `internal/agentlogin`, `internal/vm`'s `devcontainer.go`, `detect.go`, `paste.go` and `agentsave*.go`, `internal/netpolicy/rules.go`, `internal/vmlog`, and `internal/proxy`'s `config.go`, `policy.go`, `rotate.go` and `nixcache.go` | `internal/safefile`, which imports only the standard library, so the proxy reads with it too. Its `Read` and `Open` open a file without blocking and, unless the caller passes `Follow`, without following a symbolic link at the path's end. They then check the file they opened, not its name, so a FIFO, a device or a folder is refused with `ErrNotRegular`, a file past its cap with `ErrTooLong`, and, with `OneLink`, a file with another hard link with `ErrLinked`. A FIFO that the VM swaps in after a check can't hold devvm, and a link to `/dev/zero` can't flood it. `Checked` checks a file its caller opened another way in the same way, such as devvm paste's copied file, which `platform.OpenNoLinks` opens following no link but the system's, through `openat`, which the standard library doesn't have on macOS. `OpenRoot` opens beneath a folder through `os.Root`, never through a link out of it, and its `FS` lists and stats what's there but opens only regular files and, never through a link at the name's end, folders to list. `Walk` walks a folder that a VM can fill, reading each folder in batches and stopping at its bound on the entries it reads, as `devvm agent import` walks an agent's folder | every other file, which is devvm's own or the user's; tests, which make their own fixtures; and, with a `nolint` saying why, what opens a file to write it or a folder to lock it, such as the proxy's logs and the Nix cache's lock, each opened never through a link or waiting on a FIFO and checked once open |
| forbidigo, `os.Chmod`, `os.Chtimes`, `os.Chown`, `os.Lchown` and `os.Truncate`, in the code that changes files a VM can write or swap: `internal/proxy`, `internal/vmlog` and `internal/vmssh` | the file's own descriptor, from `internal/safefile`, an `os.Root` or the proxy's `OpenLog`: `os.File`'s `Chmod`, `Chown` and `Truncate`, an `os.Root`'s methods, and the proxy's `touchFile` (`futimes`, or `utimensat` with no path), because a VM can swap a name for a link between the open and the change, which would then reach a file of yours | every other package, whose files are devvm's own or the user's; tests, which make their own fixtures; and, with a `nolint` saying why, a unix socket devvm has just made in its own folder (the proxy's SSH agent relay and the link session's sockets), whose mode only its path can set |
| 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 or filters, over ssh only, without the environment's `GIT_*` variables and prompts | tests, which run git to make their repos |
| 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`, shell quoting | `internal/shell`, whose `Quote` and `QuoteJoin` quote words for a POSIX shell, so a value never runs as a command | 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`, the coding agents | `internal/agents`, whose `Defs` hold every fact devvm keeps of each agent, so no copy of an agent's list or paths goes stale when one is added. A string literal that is an agent's name or a login file's kind, whole, or that holds an agent's folder below the home folder, fails, and code of one agent's own names the agent by its constant there ([adding a coding agent](extending.md#adding-a-coding-agent)) | `internal/stubtest`, whose stubs are named after the commands they stand in for, and 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 |
| the structure test's `owners`, hosts | `internal/proxy/host.go`, whose `NormHost` reads a host as the proxy judges it, the one form every judge of a host compares: a host of printable ASCII lowercased, in ASCII alone, and its one trailing dot dropped unless it's an address, whose dot can only be its IPv6 zone's, and any other host left as it is, which `HostOK` refuses, so no Unicode fold makes another name match. An address is bare, or an IPv6 address in one pair of brackets, never one with a stray bracket. Its `Host` is what a matcher takes, such as a rule's `matchHost` and `NO_PROXY`'s. A call to package `strings` that drops a dot (`Trim`, `TrimLeft` or `TrimRight` with a cutset that holds `.`, `TrimSuffix` or `CutSuffix` with `"."`), or that folds or trims an argument named for a host (`ToLower`, `ToUpper`, `EqualFold`, `TrimFunc`, `TrimLeftFunc` or `TrimRightFunc` of `host`, `sni` or `u.Hostname()`), fails, and so does a conversion to `proxy.Host` of anything but a literal. The check goes by names and calls, so it doesn't see a host's case folded in a variable named otherwise, a dot dropped by slicing, or a host mapped rune by rune (`strings.Map`) | the functions `free` lists by file and name, each with why: `trimDots` in `internal/proxy/request.go`, which drops a path's segments' trailing dots; `urlHost` in `internal/vm/cloneseed.go`, which reads a remote's ssh host as ssh does, to find a VM's alias, its case folded and its trailing dot kept; `safeIndexPath` in `internal/vm/cloneworktree.go`, which drops a path segment's trailing dots and spaces as Windows does; and `machines.fillPassword` in `internal/backend/lima/start.go` and `transportHelper` in `internal/vm/cloneconfig.go`, which check that a string has only the characters of a set that holds `.`; and tests |
| the structure test's `owners`, the coding agents | `internal/agents`, whose `Defs` hold every fact devvm keeps of each agent, so no copy of an agent's list or paths goes stale when one is added. A string literal that is an agent's name or a login file's kind, whole, or that holds an agent's folder below the home folder, fails, and code of one agent's own names the agent by its constant there. Comparing with that constant, or with one named after it such as `secrets.ClaudeToken`, a `case` for it, looking for it with `slices.Contains` or `slices.Index`, looking it up in a map, a map literal keyed on it and `strings.HasPrefix`, `HasSuffix`, `EqualFold` or `Contains` with it fail too, outside the files named for the agent, such as `claude.go`, so the rest of devvm asks the agent's `Def` and a new agent changes none of it. A list that holds every agent's name, tests included, fails as a copy of `agents.Names()`, and so does a CLI test script's line that lists agents as a message does, for which the runner gives `$AGENT_CHOICES`, `$LOGIN_AGENTS` and `$KEY_AGENTS` ([adding a coding agent](extending.md#adding-a-coding-agent)) | `internal/stubtest`, whose stubs are named after the commands they stand in for, and tests; for a name, the value of a constant that `devvmNameFree` lists with its reason and the only files that may use it: `vm.CursorCommand`, the Cursor editor's `cursor` command, which `devvm cursor` runs and isn't the agent's, used in `internal/vm/ssh.go` and `internal/cli/cursor.go` alone and compared with as an agent's constant is; for the comparisons, the files whose names hold the agent's name as a word, and the constants `devvmSwitchFree` lists in one file each with its reason: the claude secret's own checks, which are a secret's, and Codex's binding name in `logins.go` |
| the structure test's `owners`, the toolchains | `internal/image`, whose `SharedTools` holds every fact devvm keeps of each toolchain: its members, the files that call for it, its installer, its guest environment, its `PATH` folders and its version files. A string literal that is a toolchain's name or a member's, whole, fails, so code elsewhere asks the table, and a new toolchain is an entry there ([adding a toolchain](extending.md#adding-a-toolchain)) | `internal/stubtest`, and tests |
| the structure test's `owners`, image names | `internal/image`, whose `Name` is an image's name and splits it into its layers (`Layers`, `Parent`, `Has`), whose `NameOf` joins layers into one, and whose `ParseName` reads the name the user gives, which `build.Names`' `Parse` checks against the layers there are. `devvm build`, `devvm rebuild` and `devvm images rm` read their names there once, and the rest of devvm passes the `image.Name` on | tests |
| the structure test's `owners`, `state.ReadHash` and `project.Parents` | the finder in `internal/vm/finder.go`, whose `target` finds the VM every command acts on: the folder's own, the nearest parent folder's under `--here` and `--parent` (`resolveFolder`), or one named (`devvm rm VM`). It finds a folder's VM by the state that records the folder (`finder.state`, by the path's hash first, then `recorded`), offers to move a VM whose folder moved there (`moveHere` in `internal/vm/move.go`, the match `here.movedFrom`), and names a new VM by the first of the folder's names whose VM folder is free (`newName`, `project.Nth`). Its `need` says what the command needs of the VM, and `need.check` is the one place that refuses one that isn't there, one made for an earlier folder at its path, one whose remake didn't finish and one whose creation didn't, the last with `refuseUnfinished`, which every start (`starter.bringUp` in `internal/vm/start.go`) makes too. It reads the folder devvm runs in only then, so the commands that act on no folder's VM run in a folder that's gone. The VM it finds is a `target` (`internal/vm/target.go`). It holds what the VM's backend told the finder, which each start and stop of the VM then updates, and it runs what a command does with that VM: `exec`, `shell`, `stop`, `running`, `ownSSH` and the name of its ssh config entry | `internal/state`, and tests |
| the structure test's `owners`, `hostsafety.Walk` | the start in `internal/vm/start.go`, whose `starter.walk` walks a VM's project folder once for each check of the folder on the host, for the git repos nested in it, which `.git` protection goes by (`gitprotect.Protector.Nested`), and on Linux hosts its set-id files, so a check never walks the folder twice. It walks when a VM is made and when a check finds it stopped, at a launch or at `devvm stop` (`starter.hostChecks`), and at `devvm git-protect` on a stopped VM, never at a launch into a running VM | `internal/hostsafety`, and tests |
| the structure test's `owners`, `state.ReadAll` | the inventory in `internal/vm/inventory.go`, which reads every VM's state (`ReadStates`), and with `ReadInventory` the backends' lists too, each within its wait, for every listing of VMs: `devvm ls`, `devvm space`, `devvm images` and `devvm gc`, the ssh config, `devvm gc --orphans`, the links, `devvm secret`'s list, finding a VM by its name and the mounts that devvm's SSH agent checks a key against. Its one failure policy is that a backend that can't list fails a listing (`Inventory.Err`) only when some VM's state names it, and that a state that can't be read is a row of its own, which the readers leave out and `ToolsInUse` and `Mounts` fail on. `state.VMNames`, which fails on such a state, stays for the readers below `internal/vm`: `netpolicy`, `ports` and `sshconfig.ChooseAlias` | `internal/state`, and tests |
| the structure test's `owners`, `state.ReadAll` | the inventory in `internal/vm/inventory.go`, which reads every VM's state (`ReadStates`), and with `ReadInventory` the backends' lists too, each within its wait, for every listing of VMs: `devvm ls`, `devvm space`, `devvm images` and `devvm gc`, the ssh config, `devvm gc --orphans`, the links, `devvm secret`'s list, finding a VM by its name and the mounts that devvm's SSH agent checks a key against. Its one failure policy is that a backend that can't list fails a listing (`Inventory.Err`) only when some VM's state names it, and that a state that can't be read is a row of its own, which the readers leave out and `ToolsInUse` and `Mounts` fail on. `state.VMNames`, which fails on such a state, stays for the readers below `internal/vm` that must count every VM: `netpolicy`'s secrets, `ports` and `sshconfig.ChooseAlias`; `state.ReadableVMs`, which leaves such a state out, is for those that only warn: `netpolicy`'s warnings of every VM and doctor's policy warnings | `internal/state`, and tests |
| the structure test's `owners`, `paths.Dirs.AgentSettings` and `paths.Dirs.AgentLogins` | devvm's agent store: `agentStore` in `internal/vm/agents.go` for the agents' settings, which the mounts, the setup's copies, a remake's home and `devvm agent import` take, and `secrets.LoginFile` in `internal/secrets/secrets.go` for their logins, which the setup's copies and the proxy read, so nothing reads an agent's files from the home folder but `vm.AgentImport` | `internal/paths`, and tests |
| the structure test's `owners`, paths in devvm's folders | `internal/paths`, whose `Dirs` and `VM` name every file and folder devvm keeps, so the layout, its golden listing in `testdata/script/layout.txtar` and a VM's teardown miss none. A `filepath.Join` onto a `Data` or `Config` field fails, and so does an `os.MkdirTemp` or `os.CreateTemp` there whose name is a literal; a name from `paths`, such as `paths.ToolsBuildPrefix`, passes | tests |
<!-- end of the generated table -->
forbidigo matches only the function a call names, so the checks that look at a call's arguments are in the [structure test](#the-structure-test). It finds a host command in an `exec.Command` or `exec.CommandContext` call that names it, as a literal or as a constant, whatever name the file imports `os/exec` under. It finds a `DEVVM_` variable in a call to any function or field named `Getenv` or `LookupEnv`, in any case, so `t.Getenv` and a `getenv` parameter count as well as `os.Getenv`, and it finds `HOME` the same way. The settings `envSettings` lists are the ones users set, `DEVVM_NO_TOOL_CHECK`, `DEVVM_NO_RELEASE_CHECK`, `DEVVM_LIMA_HOME`, `DEVVM_SECRET_SERVICE` and `DEVVM_FROM`; names mode, `DEVVM_MESSAGES`, which any build has; and the variables devvm sets for its own processes, `DEVVM_GUESTFWD` for `devvm _qemu` and `DEVVM_DAEMON_STATUS` for each background process `internal/daemon` starts.
The structure test also finds a copy of an owner's code by its text, in `literals`. A string literal outside tests that holds `'\''`, the escaped quote a shell quoter writes, belongs in `internal/shell`, and one that holds `[0-9a-f]{14}`, the hash at the end of a project VM's name, belongs in `internal/vmname`. A quote written as a rune, such as `'\''` in Go, isn't a string literal, so it doesn't count. One that holds a coding agent's folder below the home folder, such as `.codex/` or `.pi/agent`, belongs in `internal/agents`, and so does one that is an agent's name or a login file's kind, whole, such as `"opencode"` (`names`), so code of one agent's own names it by its constant there, such as `agents.Opencode`, and a longer text that mentions an agent, such as a command's example, doesn't count. A literal that is a toolchain's name or one of its members', whole, such as `"dotnet"` or `"pnpm"`, belongs in `internal/image` in the same way, so code elsewhere finds a toolchain's facts in its `image.SharedTools` entry. In the same way, `separators` finds a copy of a parser by what it splits on: a call to any function of package `strings` with `+` as an argument, as a literal or as a constant, splits or joins an image's layers, so it belongs in `internal/image`. A call with another argument that holds a `+`, such as `strings.ContainsAny(arg, "+,")`, doesn't count.
The structure test also finds a copy of an owner's code by its text, in `literals`. A string literal outside tests that holds `'\''`, the escaped quote a shell quoter writes, belongs in `internal/shell`, and one that holds `[0-9a-f]{14}`, the hash at the end of a project VM's name, belongs in `internal/vmname`. A quote written as a rune, such as `'\''` in Go, isn't a string literal, so it doesn't count. One that holds a coding agent's folder below the home folder, such as `.codex/` or `.pi/agent`, belongs in `internal/agents`, and so does one that is an agent's name or a login file's kind, whole, such as `"opencode"` (`names`), so code of one agent's own names it by its constant there, such as `agents.Opencode`, and a longer text that mentions an agent, such as a command's example, doesn't count. A literal that is a toolchain's name or one of its members', whole, such as `"dotnet"` or `"pnpm"`, belongs in `internal/image` in the same way, so code elsewhere finds a toolchain's facts in its `image.SharedTools` entry. A literal that is `"push"`, whole, belongs only in `internal/hostgit`, which holds none, so no package passes `push` to git: a `--clone` VM's copy goes through the backend's `Exec` instead (`internal/vm/cloneseed.go`, [the copy into a clone VM](../internals/git-protection.md#the-copy-into-a-clone-vm)), because git's receive-pack refuses shallow and SHA-256 repos, and a second transport would drift. A literal that is `"diff-files"`, whole, belongs only in `internal/hostgit` too, whose `DiffFiles` adds `--ignore-submodules=all`, because git diff-files otherwise runs git status in each submodule or embedded repo, where that repo's own config can name a filter that devvm's git doesn't turn off. In the same way, `separators` finds a copy of a parser by what it splits on: a call to any function of package `strings` with `+` as an argument, as a literal or as a constant, splits or joins an image's layers, so it belongs in `internal/image`. A call with another argument that holds a `+`, such as `strings.ContainsAny(arg, "+,")`, doesn't count.
The shared tools have one owner too, the table `image.SharedTools` in `internal/image/tool.go`, whose agents' entries it makes from the coding agents' registry, `agents.Defs` ([adding a coding agent](extending.md#adding-a-coding-agent)). Each entry, an `image.ToolDef`, holds a tool's name, its kind (a toolchain or an agent), its members (the tools in the lock that its name stands for, such as pnpm and bun for node), the files in a project folder that call for it, and its installer, which is mise for every tool but rust, which rustup installs, and dotnet, which `assets/shared-tools/build.sh` unpacks from Microsoft's SDK archive. A toolchain's entry also holds the environment that every VM's shells get for it, such as `NPM_CONFIG_PREFIX` and .NET's telemetry switch (`Env`), the folders of the VM's home that go on every VM's `PATH`, where its global installs go (`PathDirs`), and the members whose version files mise reads in a project (`VersionFiles`). mise locks dotnet's version without a download, because its own installer runs Microsoft's install script, which checks nothing, so devvm adds each platform's archive and its SHA-512 from Microsoft's release metadata to the lock (`withSDKDownloads` in `internal/tools/dotnet.go`), and `Share.Build` passes them to build.sh (`image.OwnDownload`), which checks the archive with `devvm-fetch`. `image.Toolchains`, `image.Agents`, `image.GroupTools`, the files that make devvm choose a toolchain for a new VM, the lock's check for downloads (`image.NoDownload`) and the `devcontainer.json` features that devvm maps to a toolchain all come from it. So do the files that every launch's setup writes for the toolchains: `/etc/devvm/toolchains.sh`, with every toolchain's environment and `PATH` folders (`image.GuestEnv` and `image.GuestPath`), which base's `/etc/profile.d/devvm-tools.sh` reads in every shell, as it reads the agents' `/etc/devvm/agents.sh`, and the VM's mise setting that names the tools whose version files it reads (`image.VersionFileTools`). The image builds read none of them, so a toolchain's environment changes no image. The structure test fails on a string literal outside `internal/image` that is a toolchain's name or a member's, whole, so code elsewhere asks the table, through `image.Def`, an entry's `Installer` or its other fields, rather than naming a toolchain. [Adding a toolchain](extending.md#adding-a-toolchain) and [adding a coding agent](extending.md#adding-a-coding-agent) list the files a new shared tool needs, and the [agreement tests](#agreement-tests) fail until the table and those files match.
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.
`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. `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
When two places must agree but can't be one, a test checks that they agree. `TestEveryPartHasAPolicy` checks that every image part has its policy, `TestSharedToolsPolicies` that the policies in `assets/shared-tools/` are one for each shared tool in `image.SharedTools`, `TestConfigTools` that `assets/shared-tools/mise.toml` lists each shared tool's members and nothing else, `TestBuiltinPolicies` that every policy devvm ships parses, `TestEveryMessageIsUsed` that every message has a caller, `TestDocLinks` that every doc link is a message and a heading, `TestPreludeUsers` that only the scripts that get the prelude use it, `TestDefsComplete` that every coding agent has its `[tool_alias]` line and its row in the docs' Supported agents table, `TestProvidersComplete` that every provider in `agents.Providers` has its row in the docs' table of the API keys the proxy puts in, `TestToolchainsComplete` that every toolchain has files that call for it and its row and section on the toolchains page, which names those files and its `PATH` folders, `TestFormatsCoverLogins` that every agent's login file has its format in `internal/agentlogin`, and `TestReferenceIsCurrent` that the CLI reference matches the commands. A new pair of places that must agree gets such a test.
When two places must agree but can't be one, a test checks that they agree. `TestEveryPartHasAPolicy` checks that every image part has its policy, `TestSharedToolsPolicies` that the policies in `assets/shared-tools/` are one for each shared tool in `image.SharedTools`, `TestConfigTools` that `assets/shared-tools/mise.toml` lists each shared tool's members and nothing else, `TestBuiltinPolicies` that every policy devvm ships parses, `TestEveryMessageIsUsed` that every message has a caller, `TestDocLinks` that every doc link is a message and a heading, `TestPreludeUsers` that only the scripts that get the prelude use it, `TestDefsComplete` that every coding agent has its `[tool_alias]` line and its row in the docs' Supported agents table, `TestProvidersComplete` that every provider in `agents.Providers` has its row in the docs' table of the API keys the proxy puts in, `TestToolchainsComplete` that every toolchain has files that call for it and its row and section on the toolchains page, which names those files and its `PATH` folders, `TestFormatsCoverLogins` that every agent's login file has its format in `internal/agentlogin`, `TestBumpCoversPins` that `scripts/bump.sh` moves every pin it finds, or says why it's left ([updating pinned versions](maintaining.md#updating-pinned-versions)), and `TestReferenceIsCurrent` that the CLI reference matches the commands. A new pair of places that must agree gets such a test.
### The consolidation pass
@@ -155,9 +181,24 @@ A review of a body of work, and the review before a release, look across the cod
Each copy gets one of three outcomes: extend the owner, make one owner, or leave it. Leave it when the only shared helper would be the wrong one, because a copy costs less than the wrong helper, and wait for a third copy before making one. The pass is part of those reviews, not a step every change runs.
### 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](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 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, 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`.
To add a field that holds a secret, give it the type `redact.Secret`. If a struct with it is written to a file, add the field to that file's wire type, and check that a frozen release's files still read and write the same bytes: `TestV010ProxyConfigs` does it for `proxy.json`, `TestFixtureVMStates` for `vm.json`'s sections, `TestFixtureStoreGet` for a secret's file on Linux, and `TestFixtureAgentStore` for the agents' login files, which every read leaves as they were.
## 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.
@@ -183,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, and nothing else changes. 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 section for the release it goes out in. 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
+81 -7
View File
@@ -117,7 +117,7 @@ cd tests/e2e && CGO_ENABLED=0 go test -tags e2e -count=1 -timeout 0 -run '^TestE
Run `go test` from `tests/e2e` without naming a package, because only then does `go test` show the run's lines as they come, and in a package list it holds them until the package ends. `TestE2E` refuses any `-timeout` but `0`, because `go test`'s default of 10 minutes would end a long section in the middle of a check, and `-count=1` keeps `go test` from showing a cached result. The run's flags, which [Contributing](tests.md#end-to-end-tests) lists, come after `-args`. `--reuse` keeps the VMs that a section makes with `Reuse` for the next run, which takes each one as it finds it when it's still running, so iterating on one check doesn't launch its VM again.
The runner uses a sandbox for each slot, with its own fixed ports, it refuses your real Lima home, and it builds devvm from the checkout into `src-go` in the sandbox's state folder, as a test build with its files embedded. It writes a `config.toml` that chooses base's features, so nothing asks, and puts the pinned tool lock in place, after checking the lock's first line. Base starts from the dated Ubuntu release in `e2eUbuntuRelease` (`tests/e2e/sandbox_test.go`), which `scripts/bump.sh e2e-ubuntu` moves. The runner takes the slot's lock, a symlink to its pid, and it deletes only the VMs, files and project folders that it made. Before anything else, it names each host command that the chosen sections need and this machine lacks, with what installs it. Its lines are each section's `== name` heading, then `PASS`, `FAIL`, `SKIP` or `RETRY` with `[n/N]`, the check's title, its time, the run's time and the time left. A heartbeat every minute shows the newest line of the check's output or devvm's run log, and the run ends with a summary line. It keeps each section's times in slot 0's timings folder, under its tier, and beside them a checksum of `tests/e2e`'s Go files, so a section's check count is compared only with a run of the same Go files. With `--slots`, it plans, seeds and runs the slots, each slot a run of the same test binary, and it adds up their results. On macOS it seeds each slot with APFS clones (`clonefile`), and on Linux with reflinks. With `--newest-base`, its last lines name the release Ubuntu lists as its newest and the one devvm pinned, and a failure is named as upstream drift.
The runner uses a sandbox for each slot, with its own fixed ports, it refuses your real Lima home, and it builds devvm from the checkout into `src-go` in the sandbox's state folder, as a test build with its files embedded. It writes a `config.toml` that chooses base's features, so nothing asks, and puts the pinned tool lock in place, after checking the lock's first line. Base starts from the dated Ubuntu release in `e2eUbuntuRelease` (`tests/e2e/sandbox_test.go`), which `scripts/bump.sh e2e-ubuntu` moves. The runner takes the slot's lock, a symlink to its pid, and it deletes only the VMs, files and project folders that it made, which include any VM whose folder is in one of the run's project folders, even one that a failed check made without registering it. Before the first section, it stops with a setup failure when the slot's Lima home has a project VM that an earlier run left, unless `--reuse` keeps them, and it prints the commands that delete each one and its state folder. Before anything else, it names each host command that the chosen sections need and this machine lacks, with what installs it. Its lines are each section's `== name` heading, then `PASS`, `FAIL`, `SKIP` or `RETRY` with `[n/N]`, the check's title, its time, the run's time and the time left. A heartbeat every minute shows the newest line of the check's output or devvm's run log, and the run ends with a summary line. It keeps each section's times in slot 0's timings folder, under its tier, and beside them a checksum of `tests/e2e`'s Go files, so a section's check count is compared only with a run of the same Go files. With `--slots`, it plans, seeds and runs the slots, each slot a run of the same test binary, and it adds up their results. On macOS it seeds each slot with APFS clones (`clonefile`), and on Linux with reflinks. With `--newest-base`, its last lines name the release Ubuntu lists as its newest and the one devvm pinned, and a failure is named as upstream drift.
Each check's time limit is three times its longest time in its section's last complete run, and the steps between two checks get an hour. Each command a check runs is in a process group of its own, and when the check's time runs out, the group gets TERM, then KILL 30 seconds later. The check then fails with the heartbeat's last line, and the run goes on to the next check. The runner's own tests, the `TestHarness` tests, need no VM, and `mise run test` runs them with the `e2e` tag.
@@ -134,7 +134,7 @@ s.Check("gc deletes a tool image no VM uses, with its record", func() error {
})
```
The check passes when its function returns nil. Its title is its key in the timings, so a changed title starts its times again: give a new check a title that says what it proves. When a check fails, the runner prints its error, each line led by `failed:`, and then the last 5 lines that its commands printed, or as many as `Tail(n)` asks for. A check that the run has nothing for is `s.Skip(title, why)`, which counts it, so that runs compare their counts.
The check passes when its function returns nil. Its title is its key in the timings, so a changed title starts its times again: give a new check a title that says what it proves. When a check fails, the runner prints its error, each line led by `failed:`, and then the last 5 lines that its commands printed, or as many as `Tail(n)` asks for. It also copies every proxy log in the sandbox that has lines, each VM's and each build's, into `proxy-logs/` in the sandbox's state folder, because the run deletes the VMs and builds that wrote them, and it prints that folder and the last 5 lines of each log written since the check began. The next run empties `proxy-logs/` before its first check. A check that the run has nothing for is `s.Skip(title, why)`, which counts it, so that runs compare their counts.
The commands a check runs go through the section, so that they run in the sandbox's environment and within the check's time limit, and their output goes into the check's log:
@@ -208,15 +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`). 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, 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
@@ -277,7 +283,7 @@ To go back to the large host later in the same script, set the large values agai
## Any time zone
The tests pass in any time zone and on any date, because a test that compares times counts them from an instant it parsed or fixed, or works in UTC, and never sets `time.Local`. A testscript that needs an old file uses a date far in the past, such as `touch -t 202001010000`, and one that needs a file that stays new uses a date far in the future, such as an export named `20991231-235959`, so the scripts keep passing as the calendar moves on. CI runs `mise run test` in UTC on macOS and Linux, and a third job runs it on Linux with `TZ=America/Los_Angeles`, which has daylight saving time, so a test that only passes in one zone fails in CI and not only on a laptop. To check a change the same way, run the tests with another zone, including one with an odd offset or a half-hour DST change:
The tests pass in any time zone and on any date, because a test that compares times counts them from an instant it parsed or fixed, or works in UTC, and never sets `time.Local`. A testscript that needs an old file uses a date far in the past, such as `touch -t 202001010000`, and one that needs a file that stays new uses a date far in the future, such as an export named `20991231-235959`, so the scripts keep passing as the calendar moves on. CI runs `mise run test` on macOS in UTC and on Linux with `TZ=America/Los_Angeles`, which has daylight saving time, so a test that only passes in one zone fails in CI and not only on a laptop. To check a change the same way, run the tests with another zone, including one with an odd offset or a half-hour DST change:
```sh
TZ=America/Los_Angeles mise run test
@@ -287,7 +293,75 @@ TZ=Australia/Lord_Howe mise run test
## Fuzzing
`go test` runs only the seed inputs of each fuzz target, so the Fuzz workflow in `.github/workflows/fuzz.yml` fuzzes every target for two minutes each Monday, and you can start it by hand from the Actions tab. 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. When a target fails, the workflow uploads the input that broke it as an artifact named `crash-<target>`. Put that file in the package's `testdata/fuzz/<target>/` folder, fix the code, and commit both, because `go test` then runs the input as a seed every time. To fuzz one target on your machine, run `go test -run '^$' -fuzz '^FuzzParseRule$' -fuzztime 1m ./internal/proxy`.
devvm's fuzz targets use Go's built-in fuzzing, and each one checks a property of what it fuzzes, not only that nothing panics. `go test` runs only each target's seed inputs, the ones its `f.Add` lines give and the files in its package's `testdata/fuzz/<target>/` folder, so every run of the tests checks them. To fuzz one target on your machine, or to run one failing input again:
```sh
go test -run '^$' -fuzz '^FuzzNoProxy$' -fuzztime 2m ./internal/proxy # fuzz one target for two minutes
go test -run '^$' -fuzz '^FuzzNoProxy$' -parallel 2 ./internal/proxy # with two workers, on a busy machine
go test -run '^$' -fuzz '^FuzzUnpack$' -fuzzminimizetime 1000x ./internal/upgrade # minimizing each new input in 1,000 runs
go test -run '^FuzzNoProxy/e9e4d242dc7b413a$' ./internal/proxy # one input in testdata/fuzz/FuzzNoProxy/
```
When a target fails, `go test` writes the input that broke it to the package's `testdata/fuzz/<target>/` folder. Fix the code, add a test of the fix beside the code's other tests, and commit the input with them, because `go test` then runs it as a seed every time.
### 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 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 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, 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 |
| --- | --- | --- |
| `FuzzCursorFrames` | `internal/proxy` | A reply from a Cursor host, of any type, encodings, body and trailers, read in reads of any size, passes only what came, from its start. A Connect or gRPC stream passes whole messages alone, none over `frameMax` as it came or as it decompresses, so a gzip bomb is refused, and none holding a JWT's start once decompressed and, in JSON, with its escapes undone. Another body passes no JWT's start of up to `jwtWindow` bytes, and a trailer holding one never lets the body end cleanly. |
| `FuzzInject` | `internal/proxy` | Whatever a request's host, method, path and headers, each binding's value goes in only for a host the binding names, judged apart from the policy's matcher, in `NormHost`'s form, for a path and methods it allows. It goes in its own header alone, once, and only when exactly one of that header's values held its exact placeholder. Every other header stays as it came. |
| `FuzzParseBindings` | `internal/proxy` | A bindings file is read only at a version the proxy knows, with each binding's kind, path, methods and scheme ones it takes, and none of version 1 that a proxy of that version reads otherwise. A file that's read reads back as itself from what `Encode` writes. |
| `FuzzLinkList` | `internal/proxy` | A links list is read only at its version, and a host and port find only an entry that names them, at a link's address in `127.77.0.0/16` as `netip` writes it, whose socket is this VM's link's for that address and port. |
| `FuzzBrokerFrames` | `internal/proxy` | Whatever frame a child sends, the broker's read never panics, refuses a frame past 2 MiB without reading it, takes only a frame of a type the protocol's version knows, with its fields alone, and answers a request only with what its own config names: a value looked up with its own binding, a file of its own list, no link its list lacks, a token exchange at its own endpoints for its own VM, a lookup of a host name alone, and a connection only to an address that its own floor allows, never this machine's loopback or its own address, which no rule of its names. |
| `FuzzFrameStreams` | `internal/proxy` | Whatever stream of frames reaches either side, the broker answers each request with a frame of its ID and type and one of the protocol's error codes alone, the child takes no reply to a request it never sent, nor a second start, and both end at the first frame that breaks the rules or at the stream's end, never panicking or hanging. |
| `FuzzParseUpstream` | `internal/proxy` | A company proxy's URL is taken only as `http://`, with a host, a port that is one or none, and no path but `/` or query, and the upstream made of it has that host and port and Basic credentials only when it names a user. Its errors hold no more of the URL than its scheme. |
| `FuzzNoProxy` | `internal/proxy` | Each `NO_PROXY` entry sends directly only what it names: every host for `*`, addresses alone for an address or a CIDR, a name and the names under it, only those after a leading `.` or `*.`, and only the port an entry names. A list sends directly what any of its entries does. |
| `FuzzParseNarinfo` | `internal/proxy` | A narinfo is taken only when `cache.nixos.org-1` signed it, for the path asked for, and what the signature doesn't cover keeps to its forms: a NAR's URL named by its `NarHash` or `FileHash`, and sizes from 1 byte to 1 TiB. |
| `FuzzParseTokenRequest` | `internal/agentlogin` | A token request is read only as a form, or with no type, or as one JSON object alone, with no field named twice however its name is written, and its fields are what it sent. |
| `FuzzRedact` | `internal/agentlogin` | No secret planted in an agent's settings file, JSON or TOML, survives into the VM's copy, which reads back: a known key's shape as a value or among other words, a URL's password or query value, a value under a secret-looking key, an env or headers table's value, and a flag's argument. Claude Code's own settings in its top-level `env` stay, as Redact keeps them. |
| `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/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. |
| `FuzzParsePorts` | `internal/vmssh` | A forwarder's record, which other VMs' forwarders read, gives only ports that are ones, each an entry of its line, in order, and the ports it writes read back as themselves. |
| `FuzzParseCloneState` | `internal/vm` | A `--clone` VM's answer to the check is taken only whole: every repo asked for is gone or has its branches and status, within `cloneRefsMax` branches in all and `cloneWorktreesMax` worktrees a repo, each worktree once, at a clean path below the project folder, with a commit's name or none for its HEAD. Nothing taken is more than the answer. |
| `FuzzParseInit` | `internal/vm` | The VM's answer to its repos' setup names a seed as landed, or of another format, only when a line names that seed's path, and an old git only by what `git --version` prints, else as unknown. |
| `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, 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:…}` 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. |
## Manual checks
@@ -297,6 +371,6 @@ What the end-to-end tests leave out, as it would change something of yours or ne
- **A VM's clock after this machine sleeps:** e2e can't sleep a Mac, and hosted CI can't either. With an open VM and an allowlist VM running, compare each VM's `date +%s.%N` over ssh with this machine's clock, halfway through the ssh round trip. Then sleep the Mac for over 30 minutes and compare again right after it wakes and 2 minutes later. Each VM stays within about 0.1 s of this machine, the same as before the sleep, and the clock catches up without NTP: chrony in the allowlist VM has never synced, yet it stays right, while chrony in each VM logs `Forward time jump detected!` after the wake. Before you sleep the Mac, check that `pmset -g assertions` shows `PreventSystemSleep 0`. An app running `caffeinate -s` on AC power turns a sleep into a dark wake where the CPU keeps running, so the VMs never pause and the check proves nothing. In a real sleep, a measurement you run every few minutes in the background leaves a gap.
- **workerd under `wrangler dev`, without proxy settings:** e2e stands in for it with curl and a static Go client, because npm's download of workerd would make the run depend on it. In a node VM on the allowlist tier with `devvm network allow api.open-meteo.com`, make a Worker whose `fetch` handler returns `fetch("https://api.open-meteo.com/v1/forecast?latitude=0&longitude=0&current=temperature_2m")`, then run `npx wrangler dev` and `curl localhost:8787` in the VM. It answers with the forecast, and `devvm network log` has `api.open-meteo.com:443` `without proxy settings`. With the host taken out of the rules, the Worker's `fetch` fails with the proxy's `403` or a certificate error, as workerd may not trust the VM's CA, and the log has the block.
- **workerd under `wrangler dev`, without proxy settings:** e2e stands in for it with curl and a static Go client, because npm's download of workerd would make the run depend on it. In a node VM on the allowlist tier with `devvm network allow api.open-meteo.com`, make a Worker whose `fetch` handler returns `fetch("https://api.open-meteo.com/v1/forecast?latitude=0&longitude=0&current=temperature_2m")`, then run `npx wrangler dev` and `curl localhost:8787` in the VM. It answers with the forecast, and `devvm network log` has `api.open-meteo.com:443` `without proxy settings`. With the host taken out of the rules, the Worker's `fetch` fails with the proxy's `403` or a certificate error, as workerd may not trust the VM's CA, and the log has the block. With `devvm network transparent off` and a launch, the `fetch` fails at once, and `wrangler dev`'s output has `Temporary failure in name resolution`. Run it from a folder in the VM's home, such as a copy in `~/wk`, because workerd's SQLite fails with `SQLITE_IOERR_SHMMAP` in the project folder on a Linux host's 9p mount.
- **`--from` an image only Docker has** (built locally, never pushed): it would build an image in your Docker. Build a small one (`docker build -t devvm-local-test .` from a `Dockerfile` with `FROM alpine:3`), run `devvm --from devvm-local-test` in a new folder, check the VM boots from it, then `devvm rm` and `docker image rm devvm-local-test`.
+70 -12
View File
@@ -9,11 +9,41 @@ weight: 6
Every change to devvm's logic comes with a test, and Go tests are table tests next to the code they test. Neither the Go tests nor the [CLI tests](#cli-tests) touch the Keychain, real VMs or your own folders. A Go test that writes state points the XDG folders at `t.TempDir()`, and a Go test makes VMs only on the fake backend, `backendtest`. The CLI tests run the built devvm against the [stubs](#stubs), so only the [end-to-end tests](#end-to-end-tests) make real VMs. The Go tests share a few helpers, so each one reads the same way:
- **`stubtest.New(t)`** puts the [stubs](#stubs) first on `PATH` for one test, as the CLI tests have them, with a new folder under `/tmp` as their `STUB_DIR` and its `calls` file as their `STUB_LOG`. The folder goes when the test ends. `stubtest.New(t, "ssh")` puts only the stubs it names on `PATH`, so the host's other commands, such as git, stay. Its `Calls` returns the calls the stubs logged, `Reset` forgets them, and `Touch`, `Write` and `Read` work on the files the stubs read, such as a switch, a file whose presence makes a stub fail. `VM`, `Size` and `VMs` set and read Lima's instances in the stubs' state, and `Keychain` and `SetKeychain` the Keychain's items. `stubtest.Command(t, "mise")` returns the path of one stub, for a test that runs it by its path, as `DEVVM_HOST_MISE` does.
- **`stubtest.Git(ctx, args...)`** is plain git for a test's own repo, and a test runs git only through it, which the structure test checks. Its environment is the test's without git's variables that pick a repo, its files or its config, such as `GIT_DIR`, `GIT_WORK_TREE` and `GIT_CONFIG_PARAMETERS` (`stubtest.GitEnv`), and it reads no global or system config. A git that runs the tests, such as a hook's or `git rebase --exec`'s, sets some of those variables, and a test's git that kept them would work on the checkout itself, writing its config and commits there. A test that runs something else that runs git, such as a script or a stub, calls `stubtest.NoGitRepo(t)` first, which takes the same variables out of the test's environment until it ends, and `stubtest.New` calls it for the stubs. The CLI tests' environment leaves them out too.
- **`stubtest.ExecRunner`** is a backend's runner that runs each command as it is, with no run log, so a backend under test runs the stubs.
- **`msg.IDOf(err)`** returns the ID of the message an error carries, or "" when it carries none, and **`msg.NamesOf(err)`** returns the message's names, as names mode prints them, or the error's own text when it isn't a message. A test compares either with what it expects.
- **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.
- **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, 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 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 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.
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. 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.
- **A `daemon.Proc`** asks its `Alive`, `Args` and `Signal` fields about its process, so a test of `Stop` gives it a process table of its own (`fakeProc`).
- **A test's own HTTP server**, when the test sends the requests itself, is `httptest.NewTestServer`'s, which serves in memory, and the test sends through its `Client()`, which reaches it whatever the request's host.
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 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
@@ -43,26 +73,32 @@ 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 |
| `DEVVM_CLIP_TOOLS` | the stubs' folder, so devvm paste runs the clipboard stubs in place of the system's tools, such as macOS's `/usr/bin/osascript`, and no script reaches the real clipboard |
| `MISE_STUB_LOCK` | `testdata/mise.lock`, the lock the `mise` stub writes |
| `TOOLCHAINS`, `AGENTS` | the toolchains' and the coding agents' names, in the registries' order and joined with spaces, as devvm's messages list them, so a script that checks a list names no toolchain or agent itself (`stderr 'names='$TOOLCHAINS'$'`) |
| `AGENT_CHOICES`, `LOGIN_AGENTS`, `KEY_AGENTS` | every agent's name, those that `devvm agent login` logs in, and those with a key for each provider, in the registry's order and joined with a comma and a space, as a message of choices lists them (`stderr 'choices='$AGENT_CHOICES' command='`) |
| `DEVVM_BIN` | the folder of the built `devvm`, alone |
| `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 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. `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 10 seconds for a file to appear, such as one a stub writes when it gets somewhere. 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
The stubs stand in for every host command devvm runs, so tests never run the real tools: `limactl`, `docker`, `security`, `ssh`, `ssh-add`, `ssh-agent`, `ssh-keygen`, `qemu-img`, `qemu-system-aarch64`, `qemu-system-x86_64`, `chflags`, `tmutil`, `sw_vers`, `uname`, `open`, `code` and `mise`. They are one Go program, `internal/stubtest/stub`, which does what the command it's run as would do: the binary is named `stub`, each command's name is a link to it, and it reads its name from its `argv[0]`. `internal/stubtest` builds it once, into `$TMPDIR/devvm-stubs-<hash>` with its links, where the hash covers the stub's sources and Go's version. Every test process, and every later run until the sources change, finds that folder and uses it, so the binary builds only once, and a folder of an older build is removed once it's a day old. `TestScript` puts that folder on `PATH` right after `devvm`'s, ahead of the real commands.
The stubs stand in for every host command devvm runs, so tests never run the real tools: `limactl`, `docker`, `security`, `ssh`, `ssh-add`, `ssh-agent`, `ssh-keygen`, `qemu-img`, `qemu-system-aarch64`, `qemu-system-x86_64`, `chflags`, `tmutil`, `sw_vers`, `uname`, `open`, `code`, `mise`, and the clipboard tools `wl-paste`, `wl-copy`, `xclip`, `osascript` and `pbcopy`, which read a clipboard the test lays out in `$STUB_DIR` (`clip-types`, `clip`, `clip-file`) and write what's copied to `$STUB_DIR/copied`. They are one Go program, `internal/stubtest/stub`, which does what the command it's run as would do: the binary is named `stub`, each command's name is a link to it, and it reads its name from its `argv[0]`. `internal/stubtest` builds it once, into `$TMPDIR/devvm-stubs-<hash>` with its links, where the hash covers the stub's sources and Go's version. Every test process, and every later run until the sources change, finds that folder and uses it, so the binary builds only once, and a folder of an older build is removed once it's a day old. `TestScript` puts that folder on `PATH` right after `devvm`'s, ahead of the real commands.
Each stub logs its call to `$STUB_LOG` as one line, its name and its arguments joined by spaces. The stub writes the line itself, in one write to the log opened for appending, so lines from stubs running at once never mix, and its arguments never go to another process's command line. That matters because endpoint security tools such as CrowdStrike Falcon kill a process whose arguments look like an ssh option next to a proxy URL with a password, which is what a start's `limactl edit` passes. `stub_calls` prints the log for `stdout` or `cmp` to check, `! stub_calls` fails if anything was logged, and `stub_reset` empties the log, so the next check sees only the calls after it:
@@ -100,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 runs on the host, on `$STUB_DIR/vmfs/<folder>`, and `ssh` pushes to and fetches from there (it fails with `$STUB_DIR/ssh-fails`). `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.
@@ -124,6 +160,7 @@ There's no target percentage: a package is judged by what's untested in it, not
| State | `/tmp/devvm-go-e2e` (`XDG_DATA_HOME`, `XDG_CONFIG_HOME`) |
| Keychain | service `devvm-go-e2e` (`DEVVM_SECRET_SERVICE`), fake tokens only, deleted at the end |
| Lock | `/tmp/devvm-go-e2e.lock`, a symlink to the pid of the run that holds it, so only one run uses the sandbox at a time |
| Git identity | `GIT_AUTHOR_*` and `GIT_COMMITTER_*` of its own, so the harness's commits and tags work on a machine with no git config, and yours never goes into them; devvm's own git ignores them |
```sh
mise run e2e # every section but desktop and from
@@ -146,17 +183,17 @@ A change that touches VMs passes the sections for what it changed, with `--only`
The sections so far:
- `images`: building base and fixture layers, rebuilds, a failed script and Ctrl+C during a build, then base's recorded packages, each in the cache under its SHA-256, and base built again under the same key with `ubuntu-mirror` set to an address nothing answers on, whose apt reads only the build's own folder of packages.
- `project`: devvm in a new project folder (under `/tmp/devvm-go-e2e/p`) makes a VM from base and opens a shell there, which reads its commands from devvm's input. The folder and the shared tools are mounted and nothing else is, there's no SSH agent, no Docker (no docker layer) and the hostname is the folder's. The ssh config lists it as `devvm-web` with its host keys pinned; through an `~/.ssh/config` of the run's own that includes it under a `Host *` forwarding the agent, `ssh devvm-web` works, forwards no agent (a throwaway one), and refuses a changed host key. `.git` is locked (macOS) and git in the VM can still commit. `devvm stop` stops it and drops its entry, and on macOS reports and locks a submodule git folder the VM added. `TestE2EExecQuoting` in `internal/backend/registry`, which runs only there (`DEVVM_E2E_VM` names the VM), checks that arguments with spaces, quotes, `$`, newlines and globs, a folder and input reach the guest as given, through the `Exec` of the backend the VM's state records, so one test covers every backend. Then a VM from a `devcontainer.json`, with no ports by default: its `forwardPorts` said and not forwarded, none reaching this machine, its `containerEnv` in the shell and its commands, its `postCreateCommand` run once in the folder, its `postStartCommand` at each start (again after `devvm restart`), nothing written to the folder, and a changed file warned about without changing the VM. Then a claude VM with a fake agent config, history, git identity and token in a home of its own: `devvm agent import` copies the agent's settings into the sandbox's agent store without the history or the links out of its folder, the store's folder is mounted read-only and linked into the VM's home, and the home folder's isn't mounted, its settings are copied and its history isn't, the VM gets the git identity, the timezone and its hostname, and, open as it is, the token's placeholder and never the token. `devvm agent save` without a terminal shows the VM's changed `settings.json` as a diff and its new `commands` folder's file, then refuses and saves nothing, and after a yes it saves both into the store, but neither the VM's fake login beside them nor the folder's link out of it. Then SSH agents, with a home of their own and throwaway keys: a `--ssh-agent` VM uses a throwaway agent standing for yours; after `devvm ssh-agent add` and `devvm ssh-agent devvm` it keeps yours, in its shell and by name, until a restart, then uses only devvm's own agent's key, in its shells and by name; after `devvm ssh-agent off`, none.
- `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 only its current and default 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.
- `project`: devvm in a new project folder (under `/tmp/devvm-go-e2e/p`) makes a VM from base and opens a shell there, which reads its commands from devvm's input. The folder and the shared tools are mounted and nothing else is, there's no SSH agent, no Docker (no docker layer) and the hostname is the folder's. The ssh config lists it as `devvm-web` with its host keys pinned; through an `~/.ssh/config` of the run's own that includes it under a `Host *` forwarding the agent, `ssh devvm-web` works, forwards no agent (a throwaway one), and refuses a changed host key. `.git` is locked (macOS) and git in the VM can still commit. `devvm stop` stops it and drops its entry, and on macOS reports and locks a submodule git folder the VM added. With stand-in clipboard tools in `DEVVM_CLIP_TOOLS`, `devvm paste --json` puts the copied image into the running VM's paste folder, where its SHA-256 matches, mode 600 in a folder of mode 700, and the stand-in copier got the path; `devvm paste rm --force` deletes it and leaves a file of the user's; and a stopped VM is refused before the clipboard is read. `TestE2EExecQuoting` in `internal/backend/registry`, which runs only there (`DEVVM_E2E_VM` names the VM), checks that arguments with spaces, quotes, `$`, newlines and globs, a folder and input reach the guest as given, through the `Exec` of the backend the VM's state records, so one test covers every backend. Then a VM from a `devcontainer.json`, with no ports by default: its `forwardPorts` said and not forwarded, none reaching this machine, its `containerEnv` in the shell and its commands, its `postCreateCommand` run once in the folder, its `postStartCommand` at each start (again after `devvm restart`), nothing written to the folder, and a changed file warned about without changing the VM. Then a claude VM with a fake agent config, history, git identity and token in a home of its own: `devvm agent import` copies the agent's settings into the sandbox's agent store without the history or the links out of its folder, naming each link it leaves out, and with `config.toml`'s `follow-links` naming a dotfiles folder, it copies the skill folder a link leads to there as a folder, never a link, and still none of the links to a file outside it. The store's folder is mounted read-only and linked into the VM's home, the linked skill's copy with it, which root can't write either, and the home folder's isn't mounted, its settings are copied and its history isn't, the VM gets the git identity, the timezone and its hostname, and, open as it is, the token's placeholder and never the token. `devvm agent save` without a terminal shows the VM's changed `settings.json` as a diff and its new `commands` folder's file, then refuses and saves nothing, and after a yes it saves both into the store, but neither the VM's fake login beside them nor the folder's link out of it. Then SSH agents, with a home of their own and throwaway keys: a `--ssh-agent` VM uses a throwaway agent standing for yours; after `devvm ssh-agent add` and `devvm ssh-agent devvm` it keeps yours, in its shell and by name, until a restart, then uses only devvm's own agent's key, in its shells and by name; after `devvm ssh-agent off`, none.
- `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 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; 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 placeholder in `GH_TOKEN`, never the token, which the proxy puts in for `api.github.com`; `secret unuse` and `rm` take the binding and the token away. `TestE2ESelfCheck` in `internal/netpolicy` runs the self-check on the VM: it passes, then, once the VM is started outside devvm, it fails and stops the VM. `devvm stop` stops the VM and its proxy at once. `devvm network open` makes its next start direct, its proxy set in the guest and answering, and the open VM holds no real secret either: the token is nowhere in it, its environment and Codex's login hold only its placeholders, its proxy puts the token in over TLS the VM verifies with its own CA, and a request that goes around the proxy carries only the placeholder and gets a 401 from the token's host. Then `devvm network internet` and `devvm network none` change its tier at once, the VM running on. Restarted behind the run's company proxy on this machine's loopback, named in the shell's `HTTPS_PROXY` with a fake password that the check reads from a file, the guest has the proxy and reaches GitHub through it, while devvm's run logs hold the password only as `<password>` and Lima's `ha.stderr.log` only as stars. `devvm network allowLine 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. 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.
@@ -173,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.
+14 -12
View File
@@ -13,22 +13,25 @@ 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)) |
| `devvm code` | get this folder's VM ready as `devvm host` does, then open its folder in VS Code over Remote-SSH ([VS Code](../using/ssh.md#vs-code)) |
| `devvm code` | get this folder's VM ready as `devvm host` does, then open its folder in VS Code over Remote-SSH ([VS Code and Cursor](../using/ssh.md#vs-code-and-cursor)) |
| `devvm cursor` | get this folder's VM ready as `devvm host` does, then open its folder in Cursor over Remote-SSH ([VS Code and Cursor](../using/ssh.md#vs-code-and-cursor)) |
| `devvm desktop [--clipboard] [--no-open]` | serve this folder's VM's desktop on `127.0.0.1` with its password until Ctrl+C, and open it in Screen Sharing on macOS ([details](../using/desktop.md)) |
| `devvm host` | get this folder's VM ready for ssh and editors, and show the host name they reach it by, such as `devvm-website` ([details](../using/ssh.md#devvm-host-and-devvm-code)) |
| `devvm host` | get this folder's VM ready for ssh and editors, and show the host name they reach it by, such as `devvm-website` ([details](../using/ssh.md#devvm-host-devvm-code-and-devvm-cursor)) |
| `devvm history` | list the exports of agents' history that devvm saved in `~/.local/share/devvm/exports` ([details](../using/coding-agents.md#history)) |
| `devvm history export [FILE]` | save the history of this folder's VM's agents to FILE, or to a new `.tar.gz` in `~/.local/share/devvm/exports` ([details](../using/coding-agents.md#history)) |
| `devvm history import [FILE]` | put the agents' history in FILE, or in the newest export devvm saved for this folder, into this folder's VM ([details](../using/coding-agents.md#importing-history)) |
| `devvm paste [--json] [--send-file]` | send the image, the PDF, or the one copied file, after asking about a file, on this machine's clipboard into this folder's running VM's paste folder, and copy its path there for your terminal's paste shortcut ([details](../using/coding-agents.md#pasting-images)) |
| `devvm paste rm [--force]` | delete the files devvm paste left in this folder's running VM, after asking ([details](../using/coding-agents.md#deleting-pasted-files)) |
In a folder without a VM of its own, each of these commands but `devvm adopt` uses the VM of the nearest folder with one that it's inside, and says which VM that is. `--here` and `--parent` choose which VM a command uses ([a subfolder](../using/vms.md#a-subfolder)).
These options are for a new VM, and only `devvm` takes them. A VM that exists ignores them with a warning ([what a new VM gets](../using/images.md#what-a-new-vm-gets)).
These options are for a new VM, so a VM that exists ignores them with a warning, and only `devvm` takes them ([what a new VM gets](../using/images.md#what-a-new-vm-gets)):
| | |
| --- | --- |
@@ -50,9 +53,8 @@ These options are for a new VM, and only `devvm` takes them. A VM that exists ig
| | |
| --- | --- |
| `devvm --clone` | make this folder's VM with its own clone of the repo, copy your branches into it and open a shell in the clone ([details](../using/clone.md)) |
| `git fetch devvm` | on this machine, fetch the VM's work as `devvm/<branch>`, to review before you merge it ([details](../using/clone.md#fetching-the-vms-work)) |
| `devvm clone fetch [--json]` | fetch the VM's work into every repo it has a clone of, and list the new or moved branches, each with its repos ([details](../using/clone.md#fetching-the-vms-work)) |
| `devvm --clone` | make this folder's VM with its own clone of the repo, copy your repo into it and open a shell in the clone ([details](../using/clone.md)) |
| `devvm clone fetch [--json]` | on this machine, fetch the VM's work as `devvm/<branch>` into every repo it has a clone of, with its Git LFS objects, to review before you merge it, and list the new or moved branches, each with its repos ([details](../using/clone.md#fetching-the-vms-work)) |
| `devvm clone add PATH` | copy one more repo of a folder of repos into the VM, at the same path ([details](../using/clone.md#adding-a-repo)) |
| `devvm rm` | delete the VM, first offering to keep the work you haven't fetched as `saved/devvm/<branch>` branches ([details](../using/clone.md#deleting-the-vm)) |
| `devvm clone on\|off` | make an existing VM again with its own clone of the repo, or with the folder mounted once devvm has offered to keep the clone's work as `devvm rm` does ([details](../using/clone.md#switching-a-vm-that-exists)) |
@@ -82,13 +84,13 @@ These options are for a new VM, and only `devvm` takes them. A VM that exists ig
| `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
+4 -1
View File
@@ -16,4 +16,7 @@ These pages explain how devvm does what the other sections describe, for readers
- [Security model](security.md): what devvm protects on your machine and how, and what it doesn't protect.
- [Backends](backends.md): each backend's features, native or emulated, and what happens when one is missing.
- [Lima](lima.md): devvm's Lima home, confinement, clones and port forwarding on Lima.
- [Design notes](design.md): why devvm is built this way, what failed, and what's still open.
- [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.
Why devvm is built this way, what failed and what's still open is in the [design notes](../contributing/design.md), under Contributing.
+166
View File
@@ -0,0 +1,166 @@
---
title: Coding agents
explainer: How agents' settings, logins and history reach a VM
weight: 11
---
This page explains how devvm gives the coding agents in a VM their settings, logins and history, and what it checks on the way, for the tasks that [Coding agents](../using/coding-agents.md) shows. How the proxy holds the agents' secrets is in [agents' logins and settings](network.md#agents-logins-and-settings).
## The guide in every VM
Each launch installs the guide again whenever it differs from devvm's, and it belongs to root and is read-only, so nothing that the VM's user runs without `sudo` can change what the agents read, and a change made with `sudo` lasts only until the next launch.
## 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](../contributing/design.md#pasting-images).
## Each agent's variables
Every VM sets `OPENCODE_DISABLE_AUTOUPDATE=1`, as it sets `DISABLE_AUTOUPDATER=1` for Claude Code, because the agents are read-only shared tools that can't update themselves, and devvm keeps their versions. For the same reason every VM sets `PI_SKIP_VERSION_CHECK=1`, so pi doesn't ask you to run `pi update`, and `PI_TELEMETRY=0`, which turns off pi's report of its install and the attribution headers it adds to some providers' requests. Claude Code's telemetry and error reports are off with `DISABLE_TELEMETRY=1` and `DISABLE_ERROR_REPORTING=1`, and `CLAUDE_CODE_PLUGIN_CACHE_DIR` and `CLAUDE_CODE_PLUGIN_SEED_DIR` name its plugins folder and its seed ([Claude Code's plugins](#claude-codes-plugins)). devvm writes every agent's variables into each VM at every launch, whichever agents the VM has, and every shell in the VM gets them, login or not, so an agent that an editor's terminal or `ssh` runs gets them too. pi would download `fd` and `rg` into `~/.pi/agent/bin` whenever they're missing, so base has both, from Ubuntu's or the container image's own packages, and pi finds Ubuntu's and Debian's `fd` by its name there, `fdfind`.
## Importing
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 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. 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 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.
- **What it lists.** A linked folder's folders and files are listed under the link's own path, and a link inside it is listed as a file when the root resolves it to a regular file. Anything else is left out with a warning.
- **The bounds.** It counts every entry it reads, a folder's read 256 at a time, and the size of every file, across all the links of one import, and leaves out a link that would pass 20,000 entries, 128 MiB or a file of 16 MiB, the bounds of [saving a VM's settings](#saving-a-vms-settings). The walks of all the links read at most 80,000 entries, those of links left out included, and once they have, each link left is left out unread, with the same warning. A file that grows past them between the listing and the read fails the import.
- **A VM's folder.** It reads the state of every VM devvm has, and warns once for each link and VM when the link's target is in that VM's project folder or holds it, or when a link inside a linked folder resolves into it. While a VM's state can't be read, it follows no link out of an agent's folder, as [importing](#importing) says.
## 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. 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, 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.
## Mounts
Absolute paths in the mounted folders, such as Claude Code's plugin paths, still work, because each is mounted at the same path as in the store on this machine. The VM follows a symlink in these folders among its own files, so a link to a file outside the folder, by a relative or an absolute path, doesn't reach that file on this machine, on macOS's virtiofs mounts and on Linux's 9p mounts alike. devvm doesn't mount a folder whose path has a comma, on any backend, and it warns you. Lima can't mount such a path ([Lima's limits](../backends/lima.md#limits)).
The VM reads every file in these folders, a Claude Code marketplace's git clone included, so when `devvm agent import` or `devvm agent save` copies a marketplace, it checks the clone for a credential and warns of each one. It reads, with git itself and without its includes, every git config below the clone's `.git`, a submodule's included, and each file a config includes from inside the clone, which the copy holds too, and it looks for an `http.extraHeader` and a URL with a password or an access token in its user info: a remote's or a submodule's URL, a push URL, a proxy, or the base of an `insteadOf`. It judges a URL as `--clone` judges a remote, so an scp-like `git@host:path` is a name, not a credential. It also checks each marketplace's source in `known_marketplaces.json`. A warning names the keys, never the credential, and a URL in a key's name that holds one shows as `<url>`. When git can't read such a config, devvm warns that it couldn't check it, with git's reason, as the VM reads the file whatever git makes of it.
## 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](../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.
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 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.
## 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 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.
## Codex's and opencode's logins
The proxy reads the real API keys and logins from the login files in devvm's store as it needs them and refreshes ChatGPT logins there. The proxy puts in opencode's API keys for the providers that [API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in) lists, and its OpenAI and GitHub Copilot logins. The VM's entry for such an API key holds only its type and the placeholder, so the entry's other fields, such as its `metadata`, stay on this machine.
The VM's copy of Codex's `auth.json` holds only what Codex needs for its API key and its ChatGPT login: the placeholders, how it logs in, when it last refreshed, and the IDs of the account and the login. devvm keeps every other field on this machine, because the VM's proxy can't put it in, and it names those fields at every launch. That includes Codex's other ways to log in, such as a personal access token or an Amazon Bedrock key, so Codex in a VM can't use them. devvm treats Claude Code's account state in `~/.claude.json` the same way, so the VM gets only the account fields that Claude Code writes there today, and devvm names any other field at every launch.
devvm keeps every other entry of opencode's `auth.json` on this machine too, because devvm doesn't know which hosts it's for, so the VM gets that entry without its key or its tokens, and devvm warns you about each at every launch. That's an API key for any other provider, such as Azure's or a local model server's, a well-known login, which an organization's own opencode config sets up, and any other OAuth login, such as Copilot Enterprise's. The VM keeps only the fields of a withheld entry that name the account or how it logs in, such as its type, its `enterpriseUrl` and its expiry, so opencode in the VM doesn't use that provider.
## Logging in
When you approve a browser login, the browser comes back to `localhost:1455`, where the agent's own server in the VM waits, so devvm forwards this machine's `localhost:1455`, and `localhost:1457`, which Codex uses when 1455 is taken in the VM, to the same ports in the VM. The forward lasts only while the login runs, and it ends when the login ends, fails or you press Ctrl+C, which ends the agent's login in the VM too.
Codex in a VM keeps its login in `~/.codex/auth.json`, never in a keyring, because devvm sets `cli_auth_credentials_store = "file"` in the VM's `~/.codex/config.toml` on every launch.
With `--api-key`, devvm gives the running VM its copy of the login, with a placeholder in place of the key, and the VM's proxy puts the key in at once. opencode keeps its logins in its own database in the VM, and it reads its `auth.json` only when it first makes that database, so when opencode has already run in the VM, devvm also gives it the key's placeholder with `opencode auth import`. devvm reads at most 1 MiB of what that import prints in the VM, and when it prints more, devvm stops it and fails, so running devvm in the VM's folder tries again. Every other VM with opencode gets the key's placeholder at its next launch, the same way, and any credentials that you added to opencode in a VM yourself stay in its database.
## Logins made in a VM
When Codex or opencode in a VM logs in to OpenAI, whether `devvm agent login` runs it or you run it yourself, the VM's proxy saves the login in devvm's store, in the agent's own `auth.json`, and the agent in the VM gets only placeholders, so on every tier but open the VM never holds the login's tokens. The VM you logged in from uses the login at once, and every VM with that agent gets it from its next launch. opencode reads its `auth.json` only when it first makes its database, so in a VM where opencode has already run, devvm adds the store's logins to opencode's database at each launch when they changed since the VM last got them, and makes them the ones opencode uses. Credentials that you added to opencode in the VM yourself stay in its database, labeled with your names rather than devvm, and `opencode auth switch` changes back to one of them. A login that shows a code to type into a browser on any machine works in a VM as it is, such as `codex login --device-auth` and opencode's Codex device code login. opencode's Sign in with ChatGPT doesn't work in a VM, because it gets its tokens from another endpoint, whose replies the VM's proxy refuses so that they never reach the VM, so choose one of opencode's Codex logins instead, as `devvm agent login opencode` does. A new login replaces the one in the store, together with Codex's API key, so every VM with the agent uses the account you logged in to last. A VM saves a login only for an agent that it has, so a VM without Codex can't replace the store's Codex login, and a VM without opencode can't replace opencode's. When a VM sends a login for an agent it doesn't have, such as one that a program installed in the VM itself, its proxy refuses the login, devvm saves nothing, and the proxy's own log says so. In a VM with both Codex and opencode, devvm tells their logins apart by the program that sends them. `devvm network log` shows a `login` line for each login it saved. 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](network.md#logins-made-in-a-vm)). Claude Code's logins in a VM are saved in the same way ([Claude Code login](../using/coding-agents.md#claude-code-login)).
## pi's logins
`devvm agent login pi --api-key --provider PROVIDER` saves the key in the store's `~/.local/share/devvm/logins/pi/.pi/agent/auth.json`, in pi's own format, beside pi's other providers, as opencode's `--api-key` does ([logging in with devvm agent login](../using/coding-agents.md#logging-in-with-devvm-agent-login)). The VM's `~/.pi/agent/auth.json` holds a placeholder in place of each of those keys, and the VM's proxy puts the key into pi's requests to that provider's hosts, on every network tier, and allows those hosts, as the table in [API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in) describes. The VM's entry for such a provider holds only its type and the placeholder, so it gets none of the entry's other fields, such as its `env`, whose values pi uses before the environment's, and the store keeps them on this machine.
devvm keeps every other entry of pi's `auth.json` on this machine too, and the VM gets that entry without its key, its `env` or its tokens, and devvm warns you about each. That's an API key for any other provider, such as a local model server's, a key that's a command for pi to run, such as `!security find-generic-password`, and a key that pi fills in from a variable, such as `$KEY` or `${KEY}`, even for a provider whose key the proxy puts in, because devvm can't tell what pi would send. The VM keeps only the fields of a withheld entry that name the account or how it logs in, such as its type, its `accountId` and its expiry.
pi's Claude and ChatGPT logins use the same token endpoints as Claude Code's, Codex's and opencode's logins, whose replies the VM's proxy captures for those agents, and devvm never keeps such a login as pi's. In a VM that also has the matching agent, Claude Code for a Claude login and Codex or opencode for a ChatGPT login, the proxy saves pi's login as that agent's own, in place of the one devvm keeps for every VM with that agent. In a VM with none of them, the proxy refuses pi's login and devvm saves nothing ([logins made in a VM](#logins-made-in-a-vm)).
## Cursor's CLI
The VM's proxy puts the real login only into the requests for the methods that devvm found the CLI calling in its package, on Cursor's API, its agent's hosts and its codebase indexing, and into no other. It refuses every other request below `/auth/` on those hosts, the methods that make or show a key, a token, a secret or a sign-in, the methods that change your account, and any path it can't read as Cursor's hosts do. Those are the real control. As a defence in depth, the proxy also reads every reply from those hosts as it passes, its headers and the agent's streams included, and cuts one off where a token starts. devvm checked this against one release of the CLI, by reading its code, and against Cursor's own answers to a login that isn't there, so a method that Cursor adds that hands out a token in a shape devvm doesn't know would reach the VM. Such a token would work without the proxy, so if you suspect that one reached a VM, log in again with `devvm agent login cursor` ([logins made in a VM](network.md#logins-made-in-a-vm)). Neither does devvm guard Cursor's hosts that the CLI doesn't use: if one of them also answered `/auth/poll`, a VM could finish a login there and keep its tokens, though none is known to.
Your Cursor agents on every machine and in the cloud share Cursor's agent store, your cloud agents follow the skills in it, and your team shares a store of its own, so a VM that could write there could leave instructions for them. So no VM gets the store ([why](network.md#logins-made-in-a-vm)).
## API keys
The proxy puts in opencode's and pi's API keys for the providers that [API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in) lists, in the headers it names. OpenRouter's key goes in either of its two headers, because pi sends it in `x-api-key` for OpenRouter's Anthropic models, as Anthropic's own API takes a key, and in `Authorization` for every other model. The proxy swaps the placeholder only when the header holds the placeholder and nothing else, or for `Authorization`, `Bearer`, one space and the placeholder, which is how opencode and pi send each of these keys. A header that holds anything else beside the placeholder, or a second header of the same name, keeps the placeholder, so code in the VM can't surround your key with text of its own, which a provider that quotes part of a key it refuses could show back to it.
The placeholder for an OpenAI key starts with `sk-`, as an OpenAI API key does, because pi takes an OpenAI key that starts any other way for a Sign in with ChatGPT login and then leaves settings such as the longest reply it wants out of its requests.
The placeholder keeps a key out of the VM only from the launch that first gives the VM the placeholder. A VM that was given one of these keys as it was before then, such as through `[pass-keys]` when the proxy didn't put that provider's key in, may still hold copies of it. They can be in opencode's database, its write-ahead log and its freed pages, in the disk's free space and anywhere that the VM's own code copied the key. While opencode in the VM fails to import the placeholder, devvm's record of opencode's last import, `~/.local/state/devvm/opencode-import.json`, holds the key too.
With some of these keys, code in the VM can make a credential of its own that works without the proxy. Google Gemini's key gets 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. xAI's key gets a realtime client secret that lasts as long as the VM chooses, and OpenAI's key gets one that lasts up to 2 hours. opencode's experimental voice mode asks for these itself, so the proxy allows those requests ([attack vectors](../safety/attack-vectors.md#secrets-and-keys-the-vm-may-use)). Some of these providers' own tools also fetch the URLs that a request names, such as Google Gemini's URL context and Search grounding, xAI's live search, Groq's compound models and Mistral's agents with web search, so code in the VM can reach hosts that the allowlist doesn't have through them, as it can through Anthropic's and OpenAI's.
## 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)). 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 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.
+8 -6
View File
@@ -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
@@ -71,6 +71,8 @@ devvm checks each feature an image or a VM needs this way:
```mermaid
flowchart TD
accTitle: How devvm checks a feature
accDescr: A feature that the image or the VM needs is allowed when the backend has it natively, or emulates it and the emulation is reviewed. An unreviewed emulation, or none, is refused, and devvm stops and names the VM, the feature and the backend, except egress-proxy for a new open VM, which is made open, as asked.
need["a feature the image<br>or the VM needs"] --> how{{"how the backend has it"}}
how -- "native" --> ok["allowed"]
how -- "emulated, reviewed" --> ok
@@ -95,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 characters other than letters and digits turned into dashes, and 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, or starts or ends with a dash, isn't a project VM's.
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)).
+3 -3
View File
@@ -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. `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:
@@ -33,11 +33,11 @@ devvm's [port forwarder](ports.md#what-it-forwards) never forwards a server on `
Each connection to the port goes through devvm's relay, which runs in `devvm desktop`:
1. The relay speaks VNC's protocol (RFB 3.8, and 3.7 and 3.3 for older viewers) as a server, and offers VNC's own authentication alone. It sends a random challenge and checks the viewer's answer against the VM's password, with one check at a time, so a wrong answer holds every other viewer's check for a second. A viewer whose answer is wrong is refused and never reaches the VM.
1. The relay speaks VNC's protocol (RFB 3.8, and 3.7 and 3.3 for older viewers) as a server, and offers VNC's own authentication alone. It sends a random challenge and checks the viewer's answer against the VM's password, with one check at a time, so a wrong answer holds every other viewer's check for a second, and at one guess a second, guessing the password would take thousands of years. A viewer whose answer is wrong is refused and never reaches the VM.
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.
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
+117 -12
View File
@@ -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. 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. 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.
@@ -124,15 +124,120 @@ devvm's own git commands on the host run no program that a repo's config or `.gi
- `filter.NAME.clean`, `smudge` and `process` emptied, and `filter.NAME.required=false`, for each filter driver the repo's config names, so git hashes files without running a filter and doesn't fail on a required one.
- `protocol.allow=never` and `protocol.ssh.allow=always`, so git reaches nothing but ssh, not a path, `file://`, `ext::`, `git://` or `http`. A repo's config could still allow one protocol by its own key, such as `protocol.ext.allow=always`, which git takes over `protocol.allow`, so devvm also sets `GIT_ALLOW_PROTOCOL=ssh`, which git takes over every `protocol` setting.
- `maintenance.auto=false` and `gc.auto=0`, so a fetch starts no maintenance or gc.
- `log.showSignature=false`, and `gpg.program`, `gpg.ssh.program` and `gpg.x509.program` all `false`, so no log or reflog command runs the signing program a repo's config names to check a signed commit.
- `advice.graftFileDeprecated=false`, so git doesn't warn about the grafts file that the next paragraph sets.
Its ssh is `false`, which reaches nothing, in place of a repo's `core.sshCommand` (`GIT_SSH_COMMAND=false`, with `GIT_SSH_VARIANT=ssh` over a repo's `ssh.variant`), unless the command is a `--clone` VM's push or fetch, and it fetches nothing lazily (`GIT_NO_LAZY_FETCH=1`), so a repo that says it's a partial clone can't make `git rev-list` or `git status` connect anywhere for an object it lacks.
Its ssh is `false`, which reaches nothing, in place of a repo's `core.sshCommand` (`GIT_SSH_COMMAND=false`, with `GIT_SSH_VARIANT=ssh` over a repo's `ssh.variant`), unless the command is a `--clone` VM's fetch, and it fetches nothing lazily (`GIT_NO_LAZY_FETCH=1`), so a repo that says it's a partial clone can't make `git rev-list` or `git status` connect anywhere for an object it lacks. It sees a repo's real objects and history, not what its replace refs (`GIT_NO_REPLACE_OBJECTS=1`) or a grafts file (`GIT_GRAFT_FILE=/dev/null`) would show, so what it walks, packs or looks up is what the repo holds.
It runs without any `GIT_*` variable of devvm's own environment, such as `GIT_DIR`, `GIT_WORK_TREE` or `GIT_CONFIG_GLOBAL`, so a hook or a rebase you run devvm from can't point it at another repo or config, and it reads your global config from its usual place. It keeps only the absolute folders of `PATH`, because git looks programs up, ssh among them, from the repo's folder, and it runs with `GIT_TERMINAL_PROMPT=0`. Its `git status` adds `--no-optional-locks`, so it writes no index, and `--ignore-submodules=all`, so it never enters a submodule, whose own config could name filters of its own.
A `--clone` VM's push adds `--no-verify`, `--no-recurse-submodules` and `--no-signed`, so no signing program runs, and its fetch adds `--no-recurse-submodules` and an empty `--refmap=`, so it updates only the branches its own refspecs name, never those of a remote that the repo's config names after the clone's address. Both run git with devvm's own `GIT_SSH_COMMAND`, which ignores the host, port and options git passes to ssh. It always connects to the VM's own address and port, the host's loopback port that the VM's backend gives, as the VM's user with the VM's own key, and it reads no ssh config (`-F none`). It checks the host keys devvm pinned for the VM's current start, with the VM's own known hosts file and no global one, `-o HostKeyAlias=` the VM's name and `-o StrictHostKeyChecking=yes`, and it runs with `-o BatchMode=yes`, `-o ForwardAgent=no` and `-o ClearAllForwardings=yes`. In the VM it runs only `git-receive-pack` or `git-upload-pack`, whichever git asks for, on the clone's path, and it refuses any other command. So no `url.*.insteadOf`, `pushInsteadOf` or remote URL in the repo's config can send the push or the fetch to another host or to another path, and they forward neither your agent nor any port. A repo's `core.sshCommand` doesn't apply, because devvm sets `GIT_SSH_COMMAND`, and its `diff.external`, textconv drivers and pager never run, because none of devvm's commands shows a diff or writes to a terminal.
A `--clone` VM's fetch adds `--no-recurse-submodules` and an empty `--refmap=`, so it updates only the branches its own refspecs name, never those of a remote that the repo's config names after the clone's address. It runs git with devvm's own `GIT_SSH_COMMAND`, which ignores the host, port and options git passes to ssh. It always connects to the VM's own address and port, the host's loopback port that the VM's backend gives, as the VM's user with the VM's own key, and it reads no ssh config (`-F none`). It checks the host keys devvm pinned for the VM's current start, with the VM's own known hosts file and no global one, `-o HostKeyAlias=` the VM's name and `-o StrictHostKeyChecking=yes`, and it runs with `-o BatchMode=yes`, `-o ForwardAgent=no` and `-o ClearAllForwardings=yes`. In the VM it runs only `git-receive-pack` or `git-upload-pack`, whichever git asks for, on the clone's path, and it refuses any other command. So no `url.*.insteadOf` or remote URL in the repo's config can send the fetch to another host or to another path, and it forwards neither your agent nor any port. devvm's own copy into the VM uses no git transport at all ([the copy into a clone VM](#the-copy-into-a-clone-vm)). A repo's `core.sshCommand` doesn't apply, because devvm sets `GIT_SSH_COMMAND`, and its `diff.external`, textconv drivers and pager never run, because none of devvm's commands shows a diff or writes to a terminal.
Before a `--clone` VM is made, and again before its push, devvm checks that what git reads in the folder is the repo's own, so the push can't copy another repo into the VM. The folder's `.git` is a folder with no `commondir`, or it's the `.git` file of a linked worktree whose link git made both ways. That `.git` file names `<repo>/.git/worktrees/<name>`, that entry's `gitdir` file names the folder's `.git` back, and its `commondir` leads to that `<repo>/.git`, which has no `commondir` of its own. Neither the git dir nor the common dir has `objects/info/alternates`, or a `packed-refs` or `reftable` that's a symlink, or anything in `objects` or `refs` that's a symlink, such as a pack folder or a loose object's folder that leads to another repo's objects. Then `git rev-parse --absolute-git-dir --git-common-dir` must name the same two folders. A worktree's push sends only its branch and that branch's upstream, when the upstream is one ref, so the repo's other branches stay on this machine. A `branch.<name>.merge` that's a pattern, such as `refs/heads/*`, would make the upstream push every branch, so devvm then pushes only the branch.
Before a `--clone` VM is made, and again before its copy, devvm checks that what git reads in the folder is the repo's own, so the copy can't take another repo into the VM. The folder's `.git` is a folder with no `commondir`, or it's the `.git` file of a linked worktree whose link git made both ways. That `.git` file names `<repo>/.git/worktrees/<name>`, that entry's `gitdir` file names the folder's `.git` back, and its `commondir` leads to that `<repo>/.git`, which has no `commondir` of its own. Or it's the `.git` file of a submodule, whose git dir is below its parent repo's: the parent is the nearest folder above with a `.git`, itself its own repo by these same checks, and the `.git` file names a folder `modules/<name>` below the parent's git dir, a nested submodule's below its parent submodule's, where it resolves, so no symbolic link leads it out of that git dir, with no `commondir`, and whose config's one `core.worktree`, in a file that includes no other, leads back to the folder. Neither the git dir nor the common dir has `objects/info/alternates`, or a `packed-refs` or `reftable` that's a symlink, or anything in `objects` or `refs` that's a symlink, such as a pack folder or a loose object's folder that leads to another repo's objects. Then `git rev-parse --absolute-git-dir --git-common-dir` must name the same two folders. The common dir has no `info/grafts`, because the copy carries each commit with its own parents. A partial clone's copy carries every object the repo has that its tips reach, and leaves the rest to its promisor remote ([below](#the-copy-into-a-clone-vm)). A worktree's copy sends its branch, that branch's upstream when the upstream is one ref, the repo's default branch, the remote-tracking branches and the tags, so the repo's other local branches stay on this machine. A `branch.<name>.merge` that's a pattern, such as `refs/heads/*`, would make the upstream every branch, so devvm then copies no upstream.
devvm finds the hook and filter names to turn off with one `git config` before each command, so a VM that keeps swapping the repo's config could show that `git config` one config and the command another. Every hook event is turned off by its name as well, which covers config hooks on git that has the event setting, so the gap is a filter that the swap hides, which `git status` could then run on a file whose stat changed. It needs a VM that writes the repo's `.git`, so on macOS, where `.git/config` is locked, it needs a repo devvm doesn't lock, such as a nested repo past the walk's bounds ([nested repos](#nested-repos)).
Two things a repo's config can still do, and neither runs code. An `include.path` can make devvm's `git config --get user.name` read your name and email from another file in git's config format, which then go into the VM as its git identity. A config file or included file that is a FIFO makes git, and so devvm, wait until you press Ctrl+C.
## The copy into a clone VM
devvm copies a repo into a `--clone` VM without `git push`, because `git receive-pack` in the VM refuses repos that users have: a shallow clone's push fails with `shallow update not allowed`, and a SHA-256 repo's push into a SHA-1 repo fails with `the receiving end does not support this repository's hash algorithm`. The copy is a snapshot instead, made by devvm's own git on this machine and applied by plain git in the VM, through the backend's command channel, which also carries the VM's agent. The structure test keeps git push out of devvm's code, so the copy can't drift back to a second transport ([where the code is](../contributing/structure.md#the-packages)).
The copy takes three commands in the VM:
1. **One script makes every repo** the clone has. For each repo, it gets the repo's path and the host repo's object format. A repo that's copied already is printed as landed and left alone. That's a repo whose `.git/devvm-seeded` says `done`, or one with no such file whose `HEAD` resolves, which an older devvm's push made. A repo that isn't there yet is made with `git init`, with `--object-format=sha256` only for a SHA-256 repo, because git before 2.29 doesn't know the option. One that's there, from a copy that didn't finish, isn't made again, because git 2.54's `git init` in a reftable repo drops its `extensions.refStorage` setting and breaks the repo. It takes `receive.denyCurrentBranch=updateInstead` and `receive.shallowUpdate=true`, for your own `git push devvm BRANCH` later, and `.git/devvm-seeded` says `pending`. A `git init` that fails for a SHA-256 repo prints the VM's `git --version`, and devvm stops before it sends anything (`clone_vm_git_old`), showing the version only when it reads as git prints one.
2. **A tar of small files** goes into `.git/devvm-seed` in the VM's repo, never `/tmp`, which is in memory on some systems. It holds the refs to set, each an object and its name, the symbolic refs, such as `refs/remotes/origin/HEAD`, each with the ref it points to, what to check out, a branch's name or, for a detached HEAD, its commit, and the host repo's `shallow` file, read from the repo's common dir as a regular file only, never through a link, so a link there can't send another file. It also holds the working tree ([the working tree](#the-working-tree-in-the-copy)): the repo's index, normalised, the paths to check out from it, and the working copies of the tracked files that differ from it. And it holds the repo's state ([the state in the copy](#the-state-in-the-copy)): an operation in progress, the stash, and the `info` files.
3. **The pack** of the objects those refs and a detached HEAD reach, with the index's blobs and the commits the state names, from `git pack-objects --revs --stdout`, goes straight into `git index-pack --stdin` in the VM, which checks every object it writes, so devvm doesn't run `git fsck` as well. `pack-objects --revs` walks with the repo's commit-graph and bitmaps when it has them, so a VM that once wrote this repo's `.git`, through a mount before `.git` protection, could have forged one to put objects in the pack that the refs don't reach, which are this repo's own objects, never another repo's or a file's. Neither end holds the whole pack in memory, and when the command in the VM ends early, devvm closes the pipe so `pack-objects` stops. The same command then copies the `shallow` file and sets the refs with `git update-ref --stdin`, and each symbolic ref with `git symbolic-ref`, unless a ref of that name is there already. It points `HEAD` at the branch, with `git symbolic-ref`, or detaches it at the commit, with `git update-ref --no-deref`, and puts the host's index in place, with the working copies sent where the VM has no file. It does that only when `HEAD` was unborn, is on the branch the copy just set, or is detached at the commit or at one an earlier try set, so a VM that checked out a branch of its own keeps it, and one that moved its detached `HEAD` keeps it too. A `HEAD` left where the VM put it, away from this machine's, is named (`clone_kept_head`), which covers a repo here switched between a branch and a detached `HEAD` since the copy that didn't finish. It checks out the listed paths with `git checkout-index -u -z --stdin`, or every path with `-a` when it kept the VM's `HEAD`, without `-f`, so it writes only the files that aren't there. It removes `.git/devvm-seed` and writes `done` to `.git/devvm-seeded` last.
The refs are those of `refs/heads`, `refs/tags`, `refs/notes`, `refs/replace` and `refs/remotes`, read in one `git for-each-ref`, less the remote-tracking branches of each remote any of whose URLs, as git resolves them (`git remote get-url --all`), reaches a devvm VM by its full name or its shorter one, in any URL form or case, and less a branch that's no commit, which git won't set. A linked worktree's copy takes the smaller set above, and its upstream and default branch pass the same rules, so neither can be another VM's remote-tracking branch or a ref outside the namespaces, such as `refs/stash` through `branch.<name>.remote=.`. A symbolic ref goes only when the ref it points to goes. Nothing outside those namespaces goes, such as `refs/original`, `refs/prefetch` or `refs/stash`. The pack carries what a push of the same refs would: the commits, trees, blobs and tags they reach, and nothing unreachable. devvm's git runs `pack-objects` with replace refs and grafts off, so each commit goes with its own parents, and a repo with a grafts file is refused before the VM is made (`clone_grafts`).
A partial clone, one whose config names a promisor remote (`remote.<name>.promisor`, or an older git's `extensions.partialClone`), lacks objects its remote has, and `pack-objects --revs` would want them in its walk, which fails with `GIT_NO_LAZY_FETCH=1`, missing trees and all. Its pack is made from a list instead: `git rev-list --objects --missing=allow-promisor --stdin` of the tips the repo has, which `git cat-file --batch-check` picks, as a sparse checkout's index can name blobs the repo never fetched, piped into `git pack-objects --stdout` through a pipe of their own, whose ends devvm closes once both have started, so when pack-objects ends early, rev-list's next write fails and it ends too. devvm holds back the pack's last 64 bytes, more than its trailing hash, until the pack ends, then waits for rev-list, and when rev-list failed, it ends the pack there, so the VM's `git index-pack` gets a pack cut short and refuses it, and the copy fails with rev-list's error, never with a pack that lacks objects and says nothing. The VM reads the pack with `git index-pack --promisor`, so it's a promisor pack, and the settings give the VM's clone the promisor remote, with its filter, and `promisor` as git reads it, so `yes`, `1` or no value at all goes as `true`. Its git then fetches a missing object from that remote when a command needs one. That fetch goes through the VM's own network policy, with no credential of this machine's, as the remote's URL has none, so a private remote needs the VM's own login.
devvm reads each ref's object type with `git cat-file --batch-check` after listing the refs, because `git for-each-ref`'s `%(objecttype)` fails on a ref whose object the repo lacks, such as a partial clone's tag of a blob it never fetched. Such a ref stays out of the copy, named (`clone_partial_refs_kept`), and in a repo that isn't partial, it fails the copy, as that repo is broken (`clone_ref_no_object`). devvm reads the promisor remotes as git here reads them, includes followed, each `remote.<name>.promisor` on its own, so one value git can't read as a boolean drops only its own remote, and a remote's last value wins. It names those whose settings don't go, as their URL is of a kind that stays or reaches a devvm VM (`clone_partial_promisor_kept`), and copies the repo anyway, as the VM's clone works with what it has. For each promisor remote that goes, in name order, it compares the remote's host and port with the VM's tier: on the none tier it names the host with how to reach it (`clone_partial_blocked_none`), on the allowlist tier one the allowlist doesn't allow (`clone_partial_blocked`), and on the internet tier one a deny rule blocks or an address that isn't public, which that tier never reaches (`clone_partial_denied`). A host it names on a port other than 80 or 443, such as an ssh remote's 22, is named as the rule that allows that port alone, such as `github.com:22`, which `devvm network allow` takes. When devvm can't read the VM's policies, it judges nothing against them, and names only the none tier's hosts and private addresses. A name that resolves to a private address isn't reached either, which devvm can't tell before the VM looks it up. It also names a remote on this machine, a `file://` URL or a path, which the VM can't reach (`clone_partial_unreachable`). A scp-like URL's host is read as git reads it, up to its first colon, past a bracketed one such as `[::1]`, and a URL whose port isn't a number names no host.
devvm's own fetch from the VM keeps `GIT_NO_LAZY_FETCH=1`, so a VM can't make this machine's git fetch anything, and the VM's `git upload-pack` fetches no missing object to send it, as git 2.45.1 and newer turn that off. So when the VM's work names an object its partial clone lacks, such as a blob restored from an old commit, the fetch fails, and devvm says to have git in the VM read the work's objects first, which fetches them, then fetch again (`clone_fetch_partial`). devvm doesn't turn lazy fetching on in the VM's upload-pack.
A copy that fails before its end leaves `pending`, so the next launch copies again in full. `git index-pack` of a pack the repo has, `git symbolic-ref` and the checkout are all safe to run again. The refs follow one rule, so a copy never moves a branch the VM moved: before it sets a ref, the script records its name and the commit in `.git/devvm-seeded-refs`, and it then sets a ref that's missing, at the host's commit already, or at a commit an earlier try recorded. It leaves any other as it is and prints it, and devvm names those branches (`clone_kept_branches`). After the checkout, `git update-index --refresh` and `git diff-files -z` list the files whose content isn't the index's. devvm leaves out the paths that the copy itself sent or deleted, adds the VM's own files at those paths, and names what's left as the files the VM wrote (`clone_kept_files`). What the VM prints is untrusted, so devvm reads at most 1 MiB of it, shows at most 20 names, each cut to 200 bytes and quoted, and acts on none of it. `devvm rm` and `devvm clone off` check a clone whose copy didn't finish as any other, so the VM's work there is offered for fetching too.
An older devvm made each VM's repo with plain `git init`, so with SHA-1 object names. In such a VM whose copy failed, a SHA-256 repo's empty repo has the wrong object format, which the script prints. devvm then asks whether to make that repo again (`clone_repo_format`). The repo has no commit, but it may hold the VM's own hooks or config, so only you can say, and no flag answers the question. Without a terminal devvm refuses, saying what to run (`clone_repo_format_kept`). On yes, the script deletes that `.git` only when it still has no `HEAD` and no ref, and makes it again.
### Submodules in the copy
Once a repo's copy is in, and before devvm records it as copied, each of its initialised submodules gets a clone of its own in the VM, nested ones after their parent, so a copy that didn't finish copies the rest on the next launch. devvm takes the list from this machine's repo alone, never from the VM or `.gitmodules`: a submodule is one whose name the repo's own config gives a URL (`submodule.<name>.url`, as `git submodule init` sets it), whose git dir is `modules/<name>` in the repo's common dir, whose `core.worktree` there leads to a folder below the repo where its index has a submodule (a gitlink), and which is its own repo there by [the checks above](#the-copy-into-a-clone-vm), at a path a terminal can show. An uninitialised submodule has no such git dir, so its folder stays as the parent's copy left it, empty, and so does one initialised after the copy, or in a VM made before devvm copied submodules. One that's initialised but fails a check stays on this machine, named (`clone_submodule_kept`), and so does each of a linked worktree's, whose submodules' git dirs are in the common dir, which devvm doesn't read for them. Each submodule's copy is a repo's, checked again just before, as a folder of repos' repo is: still its own repo's top, with no grafts and a `HEAD`, and no other VM mounting it. One that fails that, or any step of its copy, such as a VM that refuses it, is named (`clone_submodule_kept`), with its own submodules left out, and the repo's copy goes on without it and is recorded as done, so it's tried again only on a launch before that, when the repo's copy didn't finish. Its record is taken out only when nothing of it can be in the VM: it failed before this launch recorded it, with no record from an earlier launch. Otherwise its record stays, not copied, so whatever of it the VM has is still fetched from and checked by `devvm rm`, which checks a repo that wasn't copied when the VM has it, and `devvm clone fetch` adds its remote. Its remote is chosen as a repo's is, recorded with its path in the VM's state before its copy (`submodules`, in its repo's entry, nested ones in theirs). The submodule is then made in the VM, in the folder the parent's checkout left empty, as a repo with a `.git` folder of its own, which `git submodule status` reads as a submodule's, and copied, so its `HEAD` is detached at the commit the submodule has checked out here, with its refs, its changes, its state and its settings; then its remote added in its repo here, which is its git dir's config, and the copy recorded. The parent's settings give it `submodule.<name>.url` and `active` ([the settings in the copy](#the-settings-in-the-copy)), so git in the VM takes it for initialised.
`devvm clone fetch`, `devvm rm`'s and `devvm clone off`'s check and the remotes' removal go over each submodule the state records, each named by its path in the folder, as a folder of repos' repos are, so a submodule you remove or deinitialise here later isn't passed over: as one another VM mounts, it's named as one devvm can't check (`clone_submodule_unchecked`), and `devvm rm` and `devvm clone off` ask before the VM goes, while `devvm clone fetch` names it and leaves it. `devvm clone add` of a recorded submodule says it's the clone's already. An older devvm ignores the record, so its `devvm rm` wouldn't check a submodule, which matters only after a downgrade. A folder of repos' walk passes over a repo that's a submodule of a repo in the folder, among that repo's initialised submodules, which its clone has.
A submodule's own folder isn't a repo that `--clone` takes by itself: its `.git` file leads into the parent's `.git/modules`, or for a parent that's a linked worktree, into the main repo's `.git`, and a VM that mounts the folder of either could swap that git dir under host git, which the check for a VM mounting the repo, looking at the folder and a worktree's common dir, wouldn't see. So `devvm --clone` there, and a folder of repos' copy of one, refuses it as a `.git` that points into another repo (`clone_git_elsewhere`). Only as a submodule of a `--clone` repo is it copied, and every check of it as one, before its copy, before a fetch and in the clone check, takes that shape.
### Git LFS in the copy
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 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.
On the way back, once each fetch from the VM is in, `devvm clone fetch`'s and `devvm rm`'s and `devvm clone off`'s, devvm lists the objects that what it fetched (`FETCH_HEAD`) reaches past this repo's own refs, with `git rev-list --objects --missing=allow-promisor`, and reads the pointers among them as above. Its own refs are every ref but the `saved/` branches and the remote-tracking branches of a devvm VM's remote, so a commit that a plain `git fetch devvm` brought earlier, without its LFS objects, still has them looked for. Once that work is merged into a branch of this repo, though, its commits are past that branch, so devvm also has the script in the VM list the files in the clone's `lfs/objects`, by name and size, none followed through a link, and takes those this repo lacks whose pointer the history of what it fetched names since the copy. That walk stops at what the copy set the clone's refs to, which the VM keeps in `.git/devvm-seed-tips`, so an object the VM fetched for the history it was given isn't taken for its work, and a long history never has every blob read, or, for a clone an older devvm made, at this repo's own refs, as above. When the objects this repo lacks come to more than 2 GiB in all, a total that can't overflow, devvm asks first (`clone_lfs_large`), and refuses without a terminal. A script in the VM then writes all of them in one stream, its connection carrying no SSH agent: for each, a line with the oid and its size and then the clone's own `.git/lfs/objects/…/<oid>`, a regular file that isn't a link, or a line that says the clone lacks it or has it at another size. devvm reads exactly the pointer's size of each into a new file in this repo's `lfs/tmp` and moves it into `lfs/objects` only when its SHA-256 is the oid. One that the VM lacks, or that isn't what its pointer names, stays out, named (`clone_lfs_kept`), and its file is a pointer here until `git lfs pull` fetches it. A failure is named too (`clone_lfs_failed`), with its reason in the run log.
An object that the VM's clone has and that didn't come back, for a reason other than its content, such as a link in `.git/lfs` or a stream cut short, would go with the VM, so `devvm rm` and `devvm clone off` keep the VM then, as for a commit they couldn't fetch. Their check also looks for the objects that only the VM's clone has, of commits this repo has already: it lists them as above from the clone's refs, merged ones included, asks the script in the VM which it has, sizes only, stopping the script once it writes more than a line for each, or more than 64 MiB of the list, and names them (`clone_lfs_unfetched`), then asks before the VM goes, which `devvm clone fetch` answers by bringing them here.
### The working tree in the copy
The copy sends your uncommitted changes as git's own index and the working copies of the files that differ from it, so `git status` in the VM shows what it shows here. devvm reads the repo's index, at the path `git rev-parse --git-path index` gives, as a regular file only, never through a link, into a temporary file of its own, registered for removal before any git command runs, so it goes however the copy ends. The copy keeps the index's modification time, so git tells a file changed in the second the index was written from one that wasn't, as it would with the repo's own index. devvm's git then refreshes the copy, so a file whose stat changed but not its content isn't sent, without entering any submodule (`--ignore-submodules`), and rewrites it as version 3, even when it's that already (`--force-write-index`), with no split index, no sparse directories, no untracked cache, no fsmonitor data, no resolve-undo and a real trailing hash. The untracked cache names untracked files and the repo's path on this machine, so none of that goes, and any git since 1.7 reads the result. Resolve-undo, which `git checkout -m` uses to bring back a conflict you resolved, can name blobs that no ref reaches and that the pack doesn't carry, so the VM's repo would fail `git fsck` with it. What's staged is staged in the VM, conflicts, intent-to-add entries and skip-worktree bits included, and the pack carries every blob the index names, but no gitlink's commit, which isn't this repo's. An index with a path that git never checks out, one with a `.git` part in any case, as macOS and Windows also read one, or with an empty, `.` or `..` part, fails the copy.
`git ls-files -s -z` on the copy lists the paths, and `git diff-files --ignore-submodules=all --name-only -z` on it lists those whose working copy differs. Without `--ignore-submodules`, git diff-files runs `git status` in each submodule and embedded repo, where that repo's own config can name a filter that devvm's git hasn't turned off, so devvm runs diff-files only through the helper that adds it. Each path that differs is sorted out through a root opened at the repo, and each folder on the way to it is opened from its parent, refusing a symbolic link, so neither a link out of the repo nor one inside it, such as a tracked folder replaced by a link to an ignored folder or to `.git`, sends another file:
- A regular file or a symbolic link, where the index has one of those, goes as it is, under `changed/` in the tar, with its permissions and modification time, read without following a link. A file that's a link now goes as the link, so `git status` in the VM shows the same type change.
- A path that's gone, or whose folder is a symbolic link here, which git takes for a deletion, goes as gone: the VM doesn't check it out, so it's deleted there too.
- Anything else, such as a tracked file that's a folder now, goes as gone, and devvm names it (`clone_typechange_kept`), so nothing inside that folder goes.
- A gitlink, a submodule's or an embedded repo's, is checked out as git does, as an empty folder, without its `.git` or anything in it.
- A path that a `filter` attribute names a filter for, in the working tree's attributes or the index's, such as git-crypt's or Git LFS's, is checked out from the index, as git stores it, and named as one that may differ (`clone_filtered_kept`). devvm's git runs no filter, so it can't tell a real change from the filter's own. Such a file that's gone goes as gone.
In the VM, when the copy sets `HEAD`, it puts the index in place, notes which of the paths sent or gone it already has a file at, copies each working copy sent where the VM has no file, with `cp -P -p`, and checks out the other paths from the index, without `-f`, except a conflict's, which has no entry to check out, and a path with the skip-worktree bit that the working tree doesn't have, which a sparse checkout leaves out, in the VM as here. A skip-worktree path that the working tree has, marked by hand with `git update-index --skip-worktree` or left by a git older than 2.37 outside a sparse checkout, is checked out from the index, never sent as it is here, because git hides its edits, which are often local settings or secrets: the VM turns the bit off for those paths (`skip.list`), checks them out and turns it on again, and devvm names them (`clone_skip_worktree_kept`). An assume-unchanged file's edits are hidden from `git diff-files` too, so it goes as the index has it. The VM's files that the copy didn't write over are named (`clone_kept_files`): those at a path you changed or deleted here, and those elsewhere that differ from the index. When the copy keeps the VM's `HEAD`, the VM's index stays, nothing of the working tree is applied, because your changes would apply to something else, and devvm says so (`clone_uncommitted_kept`) instead of naming the files it would have left out.
### The state in the copy
The copy sends what git keeps beside the refs and the index that you'd miss in the VM. Every file is read from the repo's git dir, at the path `git rev-parse --git-path` gives, so a linked worktree's own are read, as a regular file only, never through a link, at most 16 MiB each and 64 MiB in all, and a folder is opened from its parent, refusing a link. `info/sparse-checkout` and `info/attributes` always go. `info/exclude` goes too, added below the VM's own, which holds the lines that keep a folder of repos' other repos out of each one's `git status`.
An operation's files go only while it's in progress, and an operation is never told by a file that a reftable repo keeps as a ref:
- A rebase, by its folder, `rebase-merge` or `rebase-apply`: the folder's files, the pseudo-refs `REBASE_HEAD` and `AUTO_MERGE`, and the refs below `refs/rewritten/`, with `ORIG_HEAD` only during `git am` (`rebase-apply/applying`), whose `--abort` needs it.
- A merge, by its `MERGE_HEAD` file: `MERGE_HEAD`, `MERGE_MSG`, `MERGE_MODE`, `MERGE_AUTOSTASH` and `SQUASH_MSG`, and the pseudo-ref `AUTO_MERGE`.
- A cherry-pick or a revert, by the pseudo-ref `CHERRY_PICK_HEAD` or `REVERT_HEAD`, or by the `sequencer` folder: `MERGE_MSG`, the folder's files, and the pseudo-refs `CHERRY_PICK_HEAD`, `REVERT_HEAD` and `AUTO_MERGE`.
- Bisect, by its `BISECT_START` file: the `BISECT_*` files, `BISECT_FIRST_PARENT` included, the pseudo-ref `BISECT_HEAD`, and the refs below `refs/bisect/`.
A pseudo-ref is read with `git rev-parse -q --verify`, and only when `--symbolic-full-name` gives its own name back, so a branch or tag named `CHERRY_PICK_HEAD` isn't taken for one. It's set in the VM with `git update-ref`, never copied as a file, so a reftable repo, which keeps `CHERRY_PICK_HEAD` and the rest as refs, works as a files one does. `ORIG_HEAD` never goes otherwise, not even while an operation is in progress, because a reset made meanwhile points it at what it took back, such as a commit that held a secret, and a stopped rebase or a `sequencer` folder left behind would carry it along.
The pack carries the commits the operation needs, and only those that its files hold as object ids: the first word of `rebase-merge`'s `onto`, `orig-head`, `stopped-sha`, `amend`, `autostash` and `squash-onto`, every id in its `update-refs`, the first two of each line of its `rewritten-list` and `rewritten-pending`, `rebase-apply`'s `onto`, `orig-head` and `abort-safety`, each line of `MERGE_HEAD`, `MERGE_AUTOSTASH`, `sequencer`'s `head` and `abort-safety`, `BISECT_EXPECTED_REV`, and the ids on `BISECT_LOG`'s lines that mark a commit good, bad, skipped, or with the terms `BISECT_TERMS` names. Each must be an object the repo has, which `git cat-file --batch-check` says. Free text never counts, so a commit that only a merge message or a revert's message names stays on this machine. A new state file that holds object ids needs its entry in that list. The commits the todo lists still have to pick, `rebase-merge/git-rebase-todo` and `sequencer/todo`, are never scanned into the pack: devvm resolves each and names those that the copy's refs and the ids above don't reach (`clone_todo_missing`), as that step will fail in the VM.
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.
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.
### The settings in the copy
The copy reads the repo's own config with `git config --local --no-includes --null --list`, and, when `extensions.worktreeConfig` is on, the worktree's `config.worktree` after it with `--worktree`, where `git sparse-checkout` writes its settings, so neither your global config nor an included file goes. It sends only the keys of an allowlist, each value checked, never the config as a file, and a key written with no value, which git reads as true, goes as `true`. The VM sets them with `git config --add`, each key unset first, then writes `.git/devvm-seeded-config`, so a copy that runs again sets nothing over what the VM changed since:
- `remote.<name>.url`, as `git remote get-url --all` gives them, with `insteadOf` applied, and `pushurl`, when `git remote get-url --push --all` gives other URLs, as it does with a push URL or a `pushInsteadOf`. Each URL is cleaned: an `http` or `https` URL without its user name, password, query or fragment, any of which can be a token; an `ssh://`, `git+ssh://` or `ssh+git://` URL without its password, query or fragment, its user kept, as `git@` is a name, not a secret; a scp-like `[user@]host:path` as it is; and a `file://` URL or a path as it is. git reads a scp-like URL's host up to its first colon, past a bracketed host such as `[::1]`, so its user, before an `@` there, holds no colon, and one whose path has an `@` and then a colon, as in `user:token@host:path`, which git reads as the host `user` and a path holding the token, stays. Any other kind, such as `git://` or a transport helper's `ext::`, stays, named (`clone_urls_kept`), and a remote with no URL that goes stays with the rest of its settings. A remote that reaches a devvm VM stays, as its refs do, and so does a push URL that reaches one. A remote whose push URLs all stay goes without them, so `git push` in the VM pushes to its URL, named (`clone_push_urls_kept`). A remote whose URLs `git remote get-url` can't give stays, named (`clone_urls_unread`).
- `remote.<name>.fetch`, `promisor`, `partialclonefilter` and `tagOpt`, for a remote that goes.
- `branch.<name>.remote`, `merge`, `rebase` and `pushRemote`, for a branch the copy sends, so the VM of a worktree learns no other branch's name, but an upstream on a remote that stays.
- `submodule.<name>.url`, resolved with `git ls-remote --get-url` and cleaned as a remote's, and its `active`, `branch` and `update`, but an `update` that runs a command (`!command`).
- `core.sparseCheckout`, `core.sparseCheckoutCone` and `index.sparse`.
- `core.hooksPath`, the last one, when it's a relative folder inside the repo, never through `..` or a `.git` part, and not one that git expands, as it does `~/` and `%(prefix)/`.
- `user.name` and `user.email`.
Nothing else goes, such as `credential.*`, `http.*` and its extra headers, `url.*.insteadOf`, which the URLs have applied already, `core.sshCommand`, `core.fsmonitor`, `filter.*`, `include*`, `alias.*`, or the keys that describe this machine's filesystem, `core.ignorecase`, `precomposeunicode`, `filemode` and `symlinks`.
The hooks go as they are, and only as git here runs them, from the common dir's `hooks` folder, which `git rev-parse --git-path hooks` can't give, as it gives `/dev/null` under devvm's own git's `core.hooksPath`. They go when the `core.hooksPath` git uses is none, `.git/hooks` or that folder. It's the last of the repo's own config and its worktree's, includes followed (`git config --includes --show-scope --get-all`, its `local` and `worktree` ones), so an include after the repo's own wins, as in git, else your global or system config's, read from the files that `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` name when they're set. In a linked worktree, whose `.git` is a file, a relative `.git/hooks` names no folder, so git there runs no hook, and none goes. A `core.hooksPath` elsewhere inside the repo goes as the setting alone: the hooks in it are files of the working tree, so the tracked ones reach the VM with the checkout, and the untracked ones, such as husky's `_` folder, stay, as every untracked file does. One outside the repo, or one an included file sets, stays, named (`clone_hooks_path_kept`), and no hook goes. The `hooks` folder is opened from the common dir, never through a link, and one that's missing, a link or unreadable is named (`clone_hooks_dir_kept`). Only files named as git's hooks go, the names devvm's own git turns off, each a regular file of at most 1 MiB and 16 MiB in all. A link, a folder or a bigger file stays, named (`clone_hooks_kept`). In the VM, a hook goes into the git dir's `hooks` folder only where the VM has no file of that name, with its executable bit.
The settings and hooks go in last, after the checkout, and the script's git runs with `core.hooksPath=/dev/null`, so neither a hook the copy brings nor one of the VM's own runs during the copy, and none can fail it or a copy that runs again.
### The record of what was copied
So that `devvm rm` and `devvm clone off` don't take your own uncommitted changes for the VM's work, the copy leaves a record of them in the VM's repo, `.git/devvm-seeded-tree`, written with the index. It covers each path that `git status` in the VM would list once the copy is in: those whose staged entry isn't `HEAD`'s, found with `git diff-index --cached` on the normalised index, and those whose working copy differs. For each path it holds what devvm put there: the blob of the working copy, which devvm hashes as it sends the file, with a mark for an executable file, `=` for one checked out from the index, `dir` for a gitlink's empty folder or `-` for none, and the path's index entries, each with its mode, blob and stage.
The clone check reads the record back in the VM. For each path, git in the VM hashes the working copy with `git hash-object --no-filters`, or the link's target for a symbolic link, or, for one checked out from the index, asks `git diff-files --quiet` after a refresh whether it's still the index's, so a file that `info/attributes` converts, such as with `eol=crlf`, matches as git checked it out, and it lists the index entries with `git ls-files --format`, and the VM prints the paths whose state matches the record. devvm leaves the `git status` lines that name only those paths out of what it counts and shows, so a path counts once the VM changes its content, its executable bit or what's staged for it. A deletion that's still deleted matches. Untracked files' lines always count, as the copy sends none.
The record is the VM's side of the copy, not a comparison with the repo here, so it stays right when your working copy changes after the copy, and it needs nothing in devvm's own state. The VM can write the record, and it can answer for it anything it likes, but all a forged record or answer can do is make the VM's own work look unchanged, so that `devvm rm` deletes it without asking, which hurts only the VM's work. A VM without the record, such as one an older devvm made, or whose git has no `ls-files --format` (before 2.38), counts every change as before.
+84 -46
View File
@@ -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 and says so (`image_build_waiting`) after 3 seconds, and once it gets the lock, it finds the image built. An image without a record is unfinished only when its lock is free, so devvm then deletes it and builds it again (`image_leftover`). While the lock is held, the image is `building`, and `devvm gc`, `devvm rebuild` and `devvm images rm` leave it alone (`image_building`). The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a crash never leaves an image looking like it's still being built. devvm deletes the lock file together with the image's folder.
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`) 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 of devvm's own scripts in a recipe 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, and a custom layer's script, which is yours, runs as you wrote it. 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.
@@ -37,6 +45,8 @@ Each key hashes its parent's, so a new key anywhere in the chain changes the key
```mermaid
flowchart TD
accTitle: Image keys in a chain
accDescr: Each image's key hashes its parent's key, as in base, then foo, then foo+bar. After foo.sh is edited, or devvm rebuild foo, base keeps its key and is reused, and foo and foo+bar get new keys and are built again.
subgraph next["after foo.sh is edited,<br>or devvm rebuild foo"]
b2["base<br>key 1a2b3c4d5e6f<br>reused"] -- "its key" --> f2["foo<br>key 9a0b1c2d3e4f<br>built again"]
f2 -- "its key" --> fb2["foo+bar<br>key 5a6b7c8d9e0f<br>built again"]
@@ -65,51 +75,65 @@ 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 of devvm's scripts that a build runs with bash: `assets/layers/base.sh` and `apt.sh`, the built-in layers and features, `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.
- `devvm_sha TOOL` prints TOOL's pinned SHA-256 for this VM, which is the script's own `TOOL_sha256_<arch>_musl` on musl when the script pins one, and its `TOOL_sha256_<arch>` otherwise. A script that pins none for this VM gets an error that names the pin.
A script that uses the prelude checks that it came first, with `: "${devvm_arch:?}"` for each variable it reads, so it stops at once when run without it. The key of each image and tool image whose build runs one of these scripts hashes the prelude with the script, so a change to the prelude rebuilds every image and every shared tool image. `bootify.sh`, which runs with the container image's own `sh`, and `kernel.sh` don't get it, and neither do your own layers and features.
The prelude goes in as one line, `eval $'…'`, which holds the whole file in bash's ANSI-C quoting, and that line takes the place of the script's `#!` line. Each of the script's lines then keeps its number in bash's errors and in `$LINENO`, and a script without a `#!` line gets the prelude's line before its first, so its lines are one further down. A build's exports for a company proxy and for your CAs go on that same first line, before the `eval`, so they don't move the script's lines either.
Each of devvm's scripts that uses the prelude checks that it came first, with `: "${devvm_arch:?}"` for each variable it reads, so it stops at once when run without it. The key of each image and tool image whose build runs one of these scripts hashes the prelude with the script, so a change to the prelude rebuilds every image and every shared tool image. `bootify.sh`, which runs with the container image's own `sh`, and `kernel.sh` don't get it.
Your own layer gets the prelude in the same way, so it can pin its downloads as devvm's scripts do and pick them with `devvm_sha`, which [Customizing's example](../using/customizing.md#example-mailpit) shows. The prelude runs first, so a name your script sets or defines afterwards, `devvm_arch` or `devvm_sha` included, is your script's from then on, and a script that never uses the prelude runs just as it would without it. Your layer's step in its image's recipe holds the prelude and your script together, so a change to either one rebuilds that image and the images above it.
## 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`). 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.
@@ -123,17 +147,19 @@ devvm fits base's CPUs and memory to the host with one rule that every backend u
A size you set with `--cpus`, `--memory` or `devvm size -g` replaces the fitted one. devvm checks that size against the same rule, so it refuses more memory than the host's whole GiB less 2, or half of them on a host of 4 GiB or less, and the fitted memory always passes ([size](../using/ports-size.md#size-and-ports)). The fitted size isn't in image keys, because the host's size doesn't change what an image holds.
base also drops the server extras that Ubuntu's cloud image comes with, which are snapd, multipath, ModemManager, udisks, firmware updates, crash reporting, tracing tools, kernel headers, and apt's background updates and upgrades. That saves 0.9 GB of disk and 100 MB of memory per VM, and the everyday tools stay ([base](../using/images.md#base)).
## 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.
@@ -145,18 +171,20 @@ 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)).
devvm then deletes the build VM and creates `base` from the disk, booting its kernel and initrd directly. One conversion runs at a time, because each holds a lock, `~/.local/share/devvm/oci-build.lock`, so another devvm's conversion waits for it and says so (`oci_waiting`) after 3 seconds. The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a devvm that crashed never keeps another from converting.
devvm then deletes the build VM and creates `base` from the disk, booting its kernel and initrd directly. One conversion runs at a time, because each holds a lock, `~/.local/share/devvm/oci-build.lock`, so another devvm's conversion waits for it under a status line (`oci_waiting`). The lock is an OS lock on an open file, which the system releases when its devvm ends, however it ends, so a devvm that crashed never keeps another from converting.
## Digests
`base` is keyed by the container image's digest, not its tag. When devvm builds, it asks the image's registry for the digest anonymously, with a `HEAD` request for the image's manifest, which doesn't count against Docker Hub's pull limit. When the registry asks for a token, devvm gets one from the registry's token service, at an `https` address only. The digest goes into `base`'s key, and devvm records it for each container image in its cache, `~/.local/share/devvm/cache/from-digests.json`, and in the record of each image it builds on that base. An existing VM's state records what its base was made from (`from`).
For a VM made with `--from`, devvm tells whether the VM is outdated from the container image's digest that it last recorded, without looking anything up. When devvm makes the VM again, the build looks up the digest as every build does, so a tag that has moved since gives the VM the container image's newer version too, and a pinned digest stays as it is ([outdated VMs](../using/images.md#outdated-vms)).
The cache may be deleted at any time. Without it, devvm takes the digest from the record of the newest base built from the same container image, so every key stays as it was, and images stay current until a lookup finds that the tag has moved. The next lookup writes the cache again.
devvm refuses a reference it can't read (`bad_from`). When it can't reach the registry, it uses the digest it recorded last, with a warning (`from_cached_unreachable`), and with none recorded, it fails (`from_unreachable`). [Tags and digests](../using/from.md#tags-and-digests) covers when a moved tag rebuilds base, how `@sha256:` pins an image, and how devvm reads a reference.
@@ -175,34 +203,38 @@ 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.
Before a build, devvm reads the record of the base it's about to clone and refuses to build in it unless it's the base the images are for (`tools_wrong_base`): `base` from Ubuntu's cloud image for glibc, and for musl a `--from` base with the digest that the images' keys hash. A tool's installer can run anything in its VM, as root too, so a VM and a folder for each tool are what keep one tool from writing into another tool's image, whose key doesn't hash it. A build VM gets its one tool and version, and it never sees the share. It writes into a folder of its own, `~/.local/share/devvm/tools-build.<random>`, which devvm deletes once that tool is done. Lima mounts that folder at boot and goes on when the mount fails, so the build script waits up to 60 seconds for the tools lock that devvm put in the folder, mounting the folder again while it isn't mounted. If the lock never appears, the build fails, naming the folder and the mount's last error. devvm then checks that each image is a plain file and not a link (`tool_bad_output`), moves it into the share and writes its record beside it, never through a name the VM could have planted.
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, saying so (`share_waiting`) after 3 seconds, 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.
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.
@@ -210,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
@@ -244,14 +276,20 @@ 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, and says so (`making_waiting`) after 200 ms. 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`.
gc also trims the [shared Nix cache](network.md#the-shared-nix-cache) to its cap, deleting its least recently used files under the lock that the VMs' proxies take, and with `--nix-cache`, it deletes all of the cache's files. `devvm images` ends with what the cache takes of its cap when it holds anything.
## Free space
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, 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.
+24 -7
View File
@@ -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.
@@ -25,6 +25,8 @@ At the end, when `~/.local/bin` is on `PATH`, the script looks up which devvm `P
```mermaid
flowchart TD
accTitle: How each install checks the release
accDescr: In the GitHub release, install.sh, with the public key, checks the signature on SHA256SUMS, signed in .minisig, and SHA256SUMS checks the archive for this machine. Homebrew's formula, in a repository of its own, checks the same archive against its own checksum.
subgraph release["the GitHub release"]
script["install.sh, with<br>the public key"] -- "checks the signature" --> sums["SHA256SUMS,<br>signed in .minisig"]
sums -- "checks the checksum" --> archive["the archive<br>for this machine"]
@@ -32,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.
@@ -70,7 +74,9 @@ It warns in these cases:
- another devvm comes first on your `PATH` ([one devvm](../using/upgrading.md#one-devvm)),
- 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 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 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.
@@ -82,7 +88,7 @@ Then it says devvm has everything it needs, or it fails. The warnings and tips n
- `backend` is the backend that doctor checked, `lima`, which every new VM gets.
- `problems` has what that backend is missing, each with its `key`, the `fix` command, and the `message` that `devvm doctor` prints for it. The `fix` is a command whose words are separated by spaces, without shell syntax, or `null` when there's none to run, for example when virtualization is turned off in the firmware.
- `warnings` has the messages of doctor's warnings, which have no keys, because there's nothing for a script to fix. They're about another devvm on `PATH`, low free space, a machine with less than 8 GiB of memory or fewer than 4 CPUs, and each line of `~/.config/devvm/policy`, `~/.config/devvm/layers/*.policy` and `~/.local/share/devvm/vms/*/policy` that isn't a rule (`policy_not_rule`).
- `warnings` has the messages of doctor's warnings, which have no keys, because there's nothing for a script to fix. They're about another devvm on `PATH`, low free space, a machine with less than 8 GiB of memory or fewer than 4 CPUs, each line of `~/.config/devvm/policy`, `~/.config/devvm/layers/*.policy` and `~/.local/share/devvm/vms/*/policy` that isn't a rule (`policy_not_rule`), and each running VM whose proxy runs without its sandbox (`proxy_unconfined` and the `proxy_unconfined_*` messages, one for each reason).
- `tips` has the messages of doctor's tips, which aren't problems: git's `safe.bareRepository` (`doctor_git_bare`).
- `docker` says whether Docker is installed, which only `--from` with an image that only Docker has needs.
- `features` has, for each backend, how it has each feature, as `native`, `emulated`, `unreviewed` or `none`. The example below shows two of Lima's features.
@@ -153,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.
@@ -175,3 +186,9 @@ A server, or someone in the way of one, can offer an older release that's still
Then devvm upgrade removes the other versions in `<prefix>/lib/devvm`, as the script does: it keeps the new version, the one that ran devvm upgrade, and any version that a running process's command line names, such as a VM's proxy, which it lists with `ps`. When `ps` fails, it keeps them all. An interrupted upgrade leaves a `.<version>.new.<pid>` folder at most. The next upgrade removes it once no process has that pid, so it never takes the folder of an upgrade that's still running, and the script's next install removes it too.
With Homebrew, devvm upgrade runs `brew upgrade devvm`, or `brew upgrade devvm-rc` for a `devvm-rc` keg, into the run log, after asking, and checks nothing of its own, because Homebrew checks the source against the formula's checksum.
## The release check
When you run devvm in a terminal, it checks at most once a day for a newer release ([the release check](../using/settings.md#the-release-check)). The check reads only where GitHub's latest devvm release is, over HTTPS, and sends nothing about you or your machine. The latest release is never a prerelease, so the check never announces one. The exception is a devvm that Homebrew's `devvm-rc` formula installed, which follows prereleases: its check reads GitHub's list of devvm's newest releases instead, as [devvm upgrade](#devvm-upgrade) describes, and it announces a newer prerelease or release, whichever is newest.
The check runs beside the launch, so it never makes devvm wait, and when you're offline it says nothing and tries again the next day. The line comes from what the last check found, so a release that came out since then shows up at the launch after the next check. devvm keeps what the check found in `~/.local/share/devvm/cache/release.json`, and `devvm doctor` shows it.
+24 -10
View File
@@ -25,25 +25,39 @@ 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, 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. devvm chooses the port when it makes the VM and records it, so no other VM's forwarded ports take it. The port changes only when another program on the host has it, on any address, while the VM is stopped, or when the VM lists it to forward.
- **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, 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`).
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`).
devvm leaves Lima's `mountInotify` off, so file watchers in the VM see only the changes made in the VM ([file watchers](../backends/lima.md#file-watchers)). With it on, Lima's hostagent watches the project folder on the host and, for each change there, changes the file's times in the guest as root, which raises an inotify event for the guest's watchers. The hostagent can't tell the VM's own writes from the host's, so it does this to every file the VM writes too, and on macOS the guest then sees such a file as root's for a moment. A command that writes a file and then changes its mode fails in that moment, and in a test on macOS, `git init` in the project folder failed 13 times in 30 with it on and never with it off. Lima also passes on no deletions, and it marks the setting as experimental.
## 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, 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
A VM on a confined tier, internet, allowlist or none, reaches nothing but its proxy on the host, which applies its tier's rules, and even root in the VM can't get around that. Direct connections, DNS, UDP and connections to the host's own services fail at once, while forwarded ports, mounts and ssh keep working.
A VM on a confined tier, internet, allowlist or none, reaches nothing but its proxy on the host, which applies its tier's rules, and even root in the VM can't get around that. Direct connections, DNS, UDP and connections to the host's own services fail at once, while forwarded ports, mounts and ssh keep working. [Processes](processes.md) has what the hostagent and the QEMU wrapper hold, write and wait for ([Lima's hostagent](processes.md#limas-hostagent), [the QEMU wrapper](processes.md#the-qemu-wrapper-and-its-keeper)).
On each host, the VM's traffic passes through one process that devvm confines:
```mermaid
flowchart TD
accTitle: The process that confines a VM's traffic
accDescr: On Linux, the VM's traffic goes through QEMU, with restrict=on, which reaches only its proxy at 192.168.5.4:3128. On macOS, it goes through its Lima hostagent, which is sandboxed, so it reaches only its ssh port, its proxy, its Lima sockets and its SSH agent, and everything else is denied.
subgraph linux["Linux"]
vm2["the VM"] --> q["QEMU,<br>restrict=on"]
end
@@ -57,23 +71,23 @@ flowchart TD
On macOS, devvm starts the VM's Lima process, its hostagent, under a macOS sandbox. That's `sandbox-exec` with a Seatbelt profile, `sandbox.sb` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`.
- 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 ssh agent the VM forwards, which is yours or devvm's own. 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 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, fails at once on macOS and on a Linux host alike. On a Linux host, where the VM lists only `127.0.0.1` as its DNS server, a few tools that resolve names their own way, such as workerd under `wrangler dev`, wait about 40 seconds for each lookup before they fail. 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. 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.
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.
An open VM isn't confined: on macOS its hostagent runs without a profile, and on Linux the wrapper runs QEMU with Lima's network as Lima gives it, without `restrict=on` and without the `guestfwd`, as it does for a build with the internet. Its guest reaches its proxy at `192.168.5.2` and the proxy's own port on both hosts, because Lima's user-mode network, vz's and QEMU's alike, reaches the host's loopback at that address. Its `NO_PROXY` adds `host.lima.internal` and `192.168.5.2`, which the proxy on the host couldn't resolve as the VM does, Lima's DNS stays on, so names resolve in the VM, and `propagateProxyEnv` is off, so the guest gets no proxy settings of the host's.
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)).
+181 -71
View File
@@ -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:
@@ -21,13 +21,17 @@ When devvm starts a VM on a confined tier, it takes these steps in order:
An open VM's start takes the same steps, but it starts the VM unconfined and runs [the open self-check](#the-self-check). Its proxy has the VM's CAs and its secrets as any VM's does, and applies no rules. Its setup installs both CAs in the VM, points the same tools at the proxy, and writes the same placeholders and copies of the agents' logins and settings, so an open VM holds no real secret either. The VM reaches its proxy directly, through the `HTTPS_PROXY` that names it ([Lima](lima.md#confinement)), and a request that goes around the proxy carries only the placeholder.
So an open VM runs on its backend's own network, and it reaches this machine and your LAN directly, as a VM without a proxy would. Its environment names its proxy all the same (`HTTP_PROXY`, `HTTPS_PROXY` and their lowercase forms), and the proxy reaches every host and address for it, this machine's `localhost` and your LAN included, so a tool behaves the same through the proxy as it does directly. Its `NO_PROXY` names the VM itself and this machine as the VM reaches it, `host.lima.internal`, so requests to those go directly. Every launch checks that an open VM's proxy is set in the VM and answers it, and when it doesn't, devvm warns you and opens the VM all the same. An open VM gets a placeholder for each secret it may use, as every VM does, and only its proxy puts the real value in, so a request that goes around the proxy, directly from the VM, carries only the placeholder, and the secret's host refuses it.
## VMs that can't be confined
A VM whose backend can't confine it to its proxy (`egress-proxy`) can only be open: devvm refuses to make it on any other tier, unasked, in one line that names the backend and `--network open` (`net_tier_backend`), and the registry's check refuses `devvm network` with a confined tier.
## The proxy
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 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)).
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, 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)).
@@ -35,19 +39,21 @@ 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. Anything else gets `400` before the policy or the log sees it.
- 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. 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, and a NAT64 address `64:ff9b::a.b.c.d` counts as its 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.
- It carries at most 1024 `CONNECT` tunnels at once for the VM, as described below.
- It carries at most 1024 `CONNECT` tunnels, holds at most 2048 connections of every kind and has at most 2048 requests to hosts under way at once for the VM, as described below.
- It logs every decision ([log files](#log-files)).
A `CONNECT` tunnel meets the proxy's checks in this order:
```mermaid
flowchart TD
accTitle: The proxy's checks on a CONNECT tunnel
accDescr: The proxy checks a CONNECT tunnel from the VM in order: the VM's password, else 407, a host name or an address, else 400, and fewer than 1024 tunnels open, else 503. transparent.devvm.proxy takes the host from its first bytes, TLS's SNI or each HTTP Host, and closes the tunnel when there's none, and devvm.proxy, its names and 198.18.0.1 get 403. One of the VM's links goes to the link's socket untouched, and a transparent connection to one is refused. Any other host must be on the allowlist and not denied, else 403, which a transparent TLS connection gets over the VM's CA, and it must be public and not this machine's or an address a rule names, and on port 443 when rules judge its requests, else 403. A bound host, on port 443, or one whose requests are judged, is intercepted with the VM's CA, where each request must name the host, else 421, and be allowed by the rules, else 403, before its placeholder is swapped for the real value. Any other tunnel passes untouched when its TLS SNI names the CONNECT host, or it isn't TLS.
conn["CONNECT host:port from the VM"] --> pw["the VM's password?<br>no: 407"]
pw --> name["a host name or an address?<br>no: 400"]
name --> room["fewer than 1024 tunnels open?<br>no: 503"]
@@ -57,7 +63,7 @@ flowchart TD
reserved -- "no" --> own["devvm.proxy or under it,<br>or 198.18.0.1?<br>yes: 403"]
own --> link{{"one of the VM's links?"}}
link -- "yes" --> linked["the link's socket,<br>tunneled untouched<br>(transparent: refused)"]
link -- "no" --> allow["on the allowlist, and not denied?<br>no: 403<br>(transparent TLS: 403 over the VM's CA)"]
link -- "no" --> allow["on the allowlist, and not denied?<br>no: 403<br>(transparent TLS: 403<br>over the VM's CA)"]
allow --> floor["public and not this machine's,<br>or an address a rule names?<br>no: 403"]
floor --> narrowed["rules by method and path<br>judge its requests:<br>on port 443?<br>no: 403"]
narrowed --> bound{{"a bound host, on port 443,<br>or its requests judged?"}}
@@ -71,7 +77,23 @@ 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. Plain HTTP requests in absolute form and idle kept-alive connections don't count toward the limit ([attack vectors](../safety/attack-vectors.md#rogue-agents)).
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](../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.
`proxy.log` says when the VM reaches either limit, once a minute at most ([attack vectors](../safety/attack-vectors.md#rogue-agents)).
Nothing bounds how long a request or a tunnel lasts, so a long download, a WebSocket, a model's slow stream and server-sent events go on for as long as they take. The proxy bounds what a connection makes it hold instead:
- 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, 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.
### Links through the proxy
@@ -81,7 +103,7 @@ A VM's `NO_PROXY` names only the VM itself, so an HTTP client that uses the VM's
The proxy checks a request's host against the list after the VM's password and before any rule, as it does for `devvm.proxy`. It lowercases the host and drops one trailing dot, and then a host and port match only an entry that names them exactly, so `DB.:5432` matches `db:5432`, while `db..:5432`, `db.devvm:5432` and `127.77.0.1:5432` don't. The request names a host and a port, never a socket. An entry counts only when its socket is the one that `devvm _links` names for this VM's link at that address and port, in the run folder of devvm's data folder, so the proxy never connects to another VM's link or to any other socket, whatever the list holds. Its address must also be in `127.77.0.0/16`. Any other name under `devvm.internal` is refused with `403` and logged as a refused block, whatever the rules allow, so the rules, the host's resolver and a company proxy never see one. A host and port on no entry are otherwise the policy's, as before.
For a match, the proxy connects to the link's socket, which is the same socket that the link's remote forward reaches, so `devvm _links` checks the connection as it checks every other ([each connection](ports.md#links-between-vms)), and the 256-connection cap counts both. A `CONNECT` is tunneled as it is, with no SNI check and no interception, and an absolute-form request, such as `GET http://db:5432/`, goes to the socket in origin form, without `Proxy-Authorization` or `Proxy-Connection`, over a new connection for each request, which ends when the client gives up the request. A kept-alive connection to the proxy that asks for a link and then for another host has each request handled on its own. HTTPS in absolute form gets `400`, because `CONNECT` carries it. The proxy puts no secret into a link's connection, even when a secret's hosts would match the link's name, and its rules don't apply, so `devvm network deny db` doesn't stop the link `db`.
For a match, the proxy's broker finds the host and port in its own read of the list again, connects to that link's socket and hands the connection to the child, so the child never reaches devvm's run folder, where every VM's link sockets are. It's the same socket that the link's remote forward reaches, so `devvm _links` checks the connection as it checks every other ([each connection](ports.md#links-between-vms)), and the 256-connection cap counts both. A `CONNECT` is tunneled as it is, with no SNI check and no interception, and an absolute-form request, such as `GET http://db:5432/`, goes to the socket in origin form, without `Proxy-Authorization` or `Proxy-Connection`, over a new connection for each request, which ends when the client gives up the request. A kept-alive connection to the proxy that asks for a link and then for another host has each request handled on its own. HTTPS in absolute form gets `400`, because `CONNECT` carries it. The proxy puts no secret into a link's connection, even when a secret's hosts would match the link's name, and its rules don't apply, so `devvm network deny db` doesn't stop the link `db`.
The proxy logs nothing for a link's connection that it passes on, because `devvm _links` logs it as `link`, once. When the socket doesn't answer, because the link was removed since the proxy read the list or `devvm _links` isn't running, the proxy answers `502` and logs `link_refused` with the reason `not carried`. A socket whose backlog is full refuses a connection, so the proxy tries again for under a second.
@@ -89,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`). Each of these checks is `settings.CompanyProxy.Upstream`.
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.
@@ -106,23 +128,77 @@ The proxy decides each request as it does without a company proxy, by the host n
- A plain HTTP request goes to `HTTP_PROXY`'s proxy in absolute form, with its `Proxy-Authorization` in place of the VM's. The company proxy's address in the request has no password, so no error the proxy logs holds one.
- Without `HTTPS_PROXY` or `HTTP_PROXY`, those requests go directly.
`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.
`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.
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, because a confined VM never runs on without its proxy. The next `devvm` starts both. 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. 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 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 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. 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. 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. 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` 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, 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 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 |
| --- | --- |
| `full seatbelt` | the profile confines the child, and its check held |
| `none seatbelt check-failed` | the child ran under the profile, but could open its broker's config |
| `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 |
| `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 |
| `partial seccomp no-landlock` | this kernel has no Landlock, or only ABI 1, so only the filter confines the child, which can read and write your files |
| `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. 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.
@@ -138,28 +214,36 @@ 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)). 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 (`policy.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.
Paths work like this. Servers don't all read a request's path alike, so a rule's path matches only a path that every server reads the same way: one with nothing percent-encoded, no `\` or `;`, no `.` or `..` part and no doubled slash. An allow matches exactly, its method and its path in their own case, and no path in any other form. A deny matches broadly instead. It matches in any case and every path that isn't in that plain form, a deny whose path ends with `/` also matches the path above it, a path's last segment matches with what follows its first `.` cut off too, as frameworks that take a format from a suffix route `/admin.json` to `/admin`, and every segment matches with its trailing dots dropped, as some servers drop them, so a deny of `/config.json` refuses `/config.json.`.
Judging a request costs the policy files' stat, which every connection already has, and a scan of the host's rules. Decrypting the tunnel costs a TLS handshake with a certificate from the VM's CA, which the proxy keeps for the 1024 hosts it used most recently, and another to the host, so the proxy decrypts only the hosts whose rules need it: a host that a whole allow covers, with no deny that narrows, stays a tunnel that the proxy doesn't read.
@@ -182,7 +266,7 @@ Each placeholder ends in a random value of the VM's own, its salt, which isn't i
On a confined VM, transparent mode sends a tool that ignores the proxy settings to the VM's proxy by the names it looks up ([what it covers](../safety/network.md#tools-that-ignore-the-proxy)). Nothing new runs or listens on the host, and the backends don't change: the VM reaches its proxy over the path its proxy settings use, and the proxy judges each connection as it judges `CONNECT host:port`. Every piece in the VM is a program that devvm configures, dnsmasq, nftables and socat, which base installs, and one script, `devvm-transparent`, which each launch sends. A tool that looks up `api.example.com` and connects to it goes this way:
1. Its lookup reaches dnsmasq in the VM. glibc asks systemd-resolved, which asks `127.0.0.1:53`, where Lima's DNS setting for a confined VM points, and musl on Alpine asks `127.0.0.1:53` itself. An nftables rule sends `127.0.0.1:53` to dnsmasq, which listens on the stand-in address, `198.18.0.1`, alone. That rule takes every connection to `127.0.0.1:53` in the VM, so a DNS server of the user's own there, or a forward of port 53 to it, gets nothing.
1. Its lookup reaches dnsmasq in the VM. glibc and musl both ask `127.0.0.1:53` themselves, which is where Lima's DNS setting for a confined VM points ([the VM's resolver](#the-vms-resolver)). An nftables rule sends `127.0.0.1:53` to dnsmasq, which listens on the stand-in address, `198.18.0.1`, alone. That rule takes every connection to `127.0.0.1:53` in the VM, so a DNS server of the user's own there, or a forward of port 53 to it, gets nothing.
2. dnsmasq answers the A query with `198.18.0.1`, with a time to live of 0, and every other type, AAAA and HTTPS included, with an empty answer, never `REFUSED`, which musl waits 5 seconds on. It has no upstream server, so no query leaves the VM, and it reads `/etc/hosts` first, so `localhost`, the VM's hostname, `host.lima.internal` and the [links](ports.md#links-between-vms)' names keep their own addresses. Names under `devvm.internal` that aren't a link's don't exist, and neither does a name without a dot, nor a name under the search domains that the VM's resolver appends to one, which Lima takes from this machine's network and dnsmasq reads from `/etc/resolv.conf` as it starts. So a single-label name that isn't in `/etc/hosts` doesn't resolve, rather than turning into a name of this machine's network. dnsmasq can't tell a name the resolver made that way from one a tool names whole, so every name under those domains gets no answer, such as `git.corp.example.com` under `corp.example.com`.
3. The tool connects to `198.18.0.1:443`. The address is on the VM's loopback interface, so the connection stays in the VM, and an nftables rule sends it to a socat listener on `198.18.0.1:61443`. Nothing binds port 443 or 80 itself, so your own servers keep them.
4. socat opens an ordinary `CONNECT transparent.devvm.proxy:443` to the VM's proxy, with the VM's password, which it reads from a file, never from its arguments. Each port has a listener of its own, so the port reaches the proxy in the target, and nothing the VM sends can change it.
@@ -197,11 +281,17 @@ 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
On a confined VM, Lima's DNS setting gives the guest one name server, its own `127.0.0.1`, and each launch's setup makes the system's resolver ask it directly. systemd-resolved's stub, `127.0.0.53`, would ask `127.0.0.1` in turn, and when nothing listens there, because transparent mode is off or stopped, the stub can keep retrying it over UDP and TCP without answering, so a lookup through glibc waits out its own timeout instead of failing. So the setup replaces `/etc/resolv.conf`, which on Ubuntu is a link to the stub's file, with a file of its own that names `127.0.0.1` alone, with the stub's search line and a timeout of one second, tried twice, which is plenty because dnsmasq answers in the VM itself. glibc then gets a refusal at once when nothing listens, and dnsmasq's answer through the nftables rule when transparent mode runs, as musl on Alpine does.
systemd-resolved still runs, so `resolvectl` and the programs that ask it over D-Bus still go through it. Docker reads `/etc/resolv.conf` and finds only a loopback server there, so on its default bridge it gives containers its fallback servers, and on a network of their own, such as Compose's, its embedded DNS server asks `127.0.0.1` from the VM's side. The nftables table sends both to dnsmasq. The setup writes its file only on a guest with systemd that has the stub's file and whose `/etc/resolv.conf` is the stub's link or the setup's own file, so a file or link of your own stays, and it copies the search line again at each launch. When it can't write the file, it says so in one line and the launch goes on. systemd-resolved reads a file that isn't its own link as servers and search domains of its own, so while the VM is confined it takes `127.0.0.1` from the setup's file, and a search line of `.` sends every name there. It keeps them after the file is a link again, until it restarts. So on an open VM, the setup puts the stub's link back and restarts systemd-resolved, which then asks Lima's DNS. Going back needs only the setup's own file, which it writes nowhere else, and when the stub's file is missing afterwards, the setup says that names may not resolve.
## 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.
@@ -209,7 +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 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. 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. 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`.
@@ -221,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
@@ -243,27 +335,29 @@ On macOS, devvm saves a secret in the Keychain, under the service `devvm` and th
A [secret of your own](../safety/network.md#your-own-secrets) keeps its value under `custom.<name>`, as its Keychain account or its file's name, which no known secret's name can be, so a known secret that devvm adds later never finds a value of yours. Its definition is in `~/.local/share/devvm/custom-secrets.json`: its name, an ID of 16 random bytes made as it's first saved, its hosts, header, variable, prefix, scheme, path, methods and whether it may be Basic's username, as one JSON object of `"version": 1`, written whole and mode 600, and never its value. A path that devvm writes there has `"path_pattern": true`, as `*` in it is a wildcard, and devvm refuses a saved path with a `*` but without it, which was saved as a prefix whose `*` was itself, rather than read it as wider than it was saved, so the commands that read the list fail and name the file, as for any entry they refuse. devvm changes the list only while it holds `custom-secrets.lock` beside it, so two runs of devvm secret set at once never lose one another's secret. It saves the value before the definition, and when a new secret's definition can't be written, it deletes the value again. devvm secret rm unbinds a secret's VMs and deletes it, and devvm secret use binds a VM to the definition that's there, each under the same lock, so neither can come between the other's check and its change. A value devvm can't save whole is refused before the one saved is touched: `security -i` reads its commands in lines of 4096 bytes, so a value has at most 3,800 bytes, and devvm checks the whole line before it runs `security`. Each value is printable ASCII alone, because a header carries nothing else and the Keychain gives what isn't back in hex.
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.
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. 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 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. 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 proxy makes one at a time, so two requests never refresh a login at once. The proxy caches values for 5 minutes, or 30 seconds for agents' logins, and never logs them. It caches each 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 `codex_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.
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.
**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.
@@ -271,7 +365,9 @@ A VM that runs past its next CA's end without a launch can't verify the proxy's
The CAs live as long as the VM's folder. A remake keeps the folder, so the VM keeps its CAs, and so does a change of tier. `devvm rm`, `devvm gc --orphans`, and devvm deleting a VM whose creation it interrupted or whose folder an earlier VM of the project left, delete the folder, and the CAs and their keys with it.
**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.
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.
**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
@@ -280,40 +376,48 @@ 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 a refresh token. 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 (`codex_refresh_failed`, `opencode_refresh_failed`, `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.
### Logins made in a VM
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 `POST` to the endpoint's path is captured, and the proxy compares the path once it's cleaned, without its path parameters and in any case, so a request for `/oauth//token`, `/OAuth/Token/` or `/oauth/token;x` is captured too. A captured request goes to the endpoint's own path, without a query, whatever the VM's spelling of it. 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. 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.
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 reads a captured request's body whole, up to 64 KiB, and refuses one that names a field twice, 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. The proxy reads at most 8 requests and replies to and from the host whole 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 proxy 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`. opencode runs on Bun, so a request whose `User-Agent` starts with `Bun/` or `opencode/` is opencode's, and any other is Codex's. 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 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 VM's bindings hold both logins' placeholders, the `claude` secret's and `claude-oauth`, each putting a value into `Authorization` for `api.anthropic.com`, 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. 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 (`claude_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. 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.
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. Neither does devvm guard Anthropic's other hosts: 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.
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.
**Unit tests:** `TestCaptureLogin`, `TestCapturePaths`, `TestCaptureEarlyHintsAnswerAndSaved`, `TestCaptureErrorPasses` and `TestCaptureRefuses` (`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` and `TestEndpointsAndPick` (`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 bindings get the login devvm keeps, 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. **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, the API gets the store's token for the VM's placeholders, and a login that's due makes the host refresh it at Claude's endpoint through the company proxy.
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: 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.
**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
@@ -323,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)).
@@ -331,7 +435,7 @@ On every tier, an HTTPS server's headers become bindings for its host, which mus
devvm also takes the keys out of the VM's copies of the agents' settings files, which are `~/.claude/settings.json`, `~/.codex/config.toml`, opencode's `.json`, `.jsonc` and `.toml` files and pi's `settings.json`, `models.json` and `mcp.json`. Those are JSON, JSONC or TOML, and devvm parses each file whole and writes the VM's copy from what it parsed, so a JSONC file's copy is JSON and a TOML file's copy has no comments. devvm replaces these with `devvm-redacted`, and names what it replaced (`config_redacted`):
- Every value under a key that looks like a secret's (`*key*`, `*token*`, `*secret*`, `*password*`, `Authorization`), and every string in a list or a table under such a key, but key bindings, such as opencode's `keybinds`.
- Every value under a key that looks like a secret's (`*key*`, `*token*`, `*secret*`, `*password*`, `Authorization`), and every string in a list or a table under such a key, but key bindings, such as opencode's `keybinds`. A name you choose isn't judged that way, so an MCP server, a plugin or a marketplace named `secret-scanner` or `token-saver` keeps its settings, while its own fields, such as its `env` or an `apiKey`, are judged as anywhere else. devvm knows the agents' tables of names from their docs, and reads every agent's settings files with all of them: Claude Code's `mcpServers`, `extraKnownMarketplaces`, `pluginConfigs`, `enabledPlugins` and `skillOverrides` among them, Codex's `mcp_servers`, `model_providers`, `marketplaces`, `plugins`, `projects` and `hooks.state`, opencode's `mcp`, `provider`, `agent` and `command`, with their 2.x names, and pi's `providers` and `mcpServers`. In most of those tables, only a table under a name escapes the check, so a string right under `mcpServers` with a secret-looking key is still replaced. In tables of settings, such as Claude Code's `enabledPlugins` and `skillOverrides`, a table and a setting's word, such as `off` or `name-only`, which has only lower-case letters and dashes, aren't judged by their name either, while any other value is. A name that's an env or headers table's key, such as a server named `env`, still gets its values replaced.
- Any string that starts like a known key or token, such as `sk-`, `ghp_` or `eyJ`, wherever it is.
- Every value in an env or headers table, whatever its name: `env`, `environment`, `headers`, `http_headers`, and Codex's `shell_environment_policy.set`. A number of up to five digits, `true` and `false` stay, because they're switches and ports. In Claude Code's own `env`, the top-level one of `settings.json`, its [configuration variables](https://code.claude.com/docs/en/env-vars) stay too: `ANTHROPIC_MODEL`, `ANTHROPIC_SMALL_FAST_MODEL`, the `ANTHROPIC_DEFAULT_*_MODEL` and `ANTHROPIC_CUSTOM_MODEL_OPTION` families, `CLAUDE_CODE_*`, `DISABLE_*`, `MAX_*` and `*_TIMEOUT_MS`. A variable whose name has `KEY`, `TOKEN` as a word, `SECRET`, `PASS`, `AUTH`, `CREDENTIAL`, `COOKIE` or `HEADER` in it is redacted all the same, such as `CLAUDE_CODE_OAUTH_TOKEN`, and so is its value when it's a URL.
- In a URL anywhere in the file, a string's whole value or a part of other text, its user info and its secret-looking query values and path segments.
@@ -351,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
@@ -369,6 +473,8 @@ This is the check, and what devvm does when it fails:
```mermaid
flowchart TD
accTitle: The self-check on every launch
accDescr: On every launch, devvm checks that the VM runs on the process devvm started and that a direct connection from it fails. If either isn't so, the check is unenforced. A VM started confined is then stopped, because it has another way out. Otherwise, without a terminal, devvm stops the VM without a shell, and the next devvm starts it confined. In a terminal, devvm offers to restart it confined, and warns and goes on if you say no, or stops it if the check still fails after the restart.
launch["every launch"] --> proc["on the process<br>devvm started?"]
proc -- "yes" --> direct["a direct connection<br>from the VM fails?"]
direct -- "yes" --> ok["check: ok"]
@@ -395,23 +501,25 @@ On Lima, "the process devvm started" is the VM's Lima process, which devvm start
The proxy writes every decision (`tunnel`, `intercept`, `forward`, `blocked`, or `nix-cache` for a request to the [shared Nix cache](#the-shared-nix-cache)) as a JSON line in `network.jsonl` in the VM's logs folder, `~/.local/share/devvm/vms/<hash>/logs/`. A line holds the time, the VM, the host and port, the method and path when the proxy sees them, the rule or the reason, and the names of the secrets it put in, never their values. A connection that [transparent mode](#tools-that-skip-the-proxy) sent to the proxy, and each request on it, has `"via": "dns"`, which `devvm network log` shows as `, without proxy settings`.
The proxy's own lines, such as what it loaded and what failed upstream, go to `proxy.log` next to it. An upstream error stays there, because it can name addresses that the VM shouldn't learn. So when a name doesn't resolve, or a tunnel can't connect, the VM's `403`, its `http://devvm.proxy/blocked` and the event log give only the reason `can't resolve it; see proxy.log on the host` or `connect failed; see proxy.log on the host`. The error itself, which can name this machine's DNS server or the company proxy's address and what it answered, goes to `proxy.log` alone. A name that resolves to an internal address gets the reason `it resolves to an internal address; allow the address itself to reach it`, which tells the VM that much and not the address ([attack vectors](../safety/attack-vectors.md#network)). Only you can read the VM's logs folder and its run folder, and devvm's run logs never hold a VM's password. The VM chose the hosts and paths, so `devvm network log` drops control characters in them.
The proxy's own lines, such as what it loaded and what failed upstream, go to `proxy.log` next to it. An upstream error stays there, because it can name addresses that the VM shouldn't learn. So when a name doesn't resolve, or a tunnel can't connect, the VM's `403`, its `http://devvm.proxy/blocked` and the event log give only the reason. For a name, that's `this machine's DNS has no address for it` when the DNS server says the name has none, with `and names resolve without its search domain; use the full name, such as jenkins.corp.example.com` after it for a name without a dot, `this machine's DNS didn't answer in time; see proxy.log on the host` when it doesn't answer, and `can't resolve it; see proxy.log on the host` for any other failure. A rule allows the name already, so each of these blocks is marked `refused`, and neither the `403`, nor `http://devvm.proxy/blocked/new`, nor `devvm network log --blocked` suggests a `devvm network allow` command for it. For a tunnel, it's `connect failed; see proxy.log on the host`. The error itself, which can name this machine's DNS server or the company proxy's address and what it answered, goes to `proxy.log` alone. After a timeout or another failure that may pass, the proxy asks the DNS server once more before it blocks the name. When the client goes away while its name is still resolving, nothing was refused, so the event log and `http://devvm.proxy/blocked` record no block. The lookup still went out, though, and a name can carry data, so `proxy.log` names the host and port with `the client went away while its name resolved`, for at most 20 such lookups a minute, and then says that it stops until the minute is up. The broker's own line for each of the child's lookups and connections that failed, such as one to an address that no rule names, is held the same way, to 20 a minute. A name that resolves to an internal address gets the reason `it resolves to an internal address; allow the address itself to reach it`, which tells the VM that much and not the address ([attack vectors](../safety/attack-vectors.md#network)). Only you can read the VM's logs folder and its run folder, and devvm's run logs never hold a VM's password. The VM chose the hosts and paths, so `devvm network log` drops control characters in them.
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 is the only program that writes `proxy.log`, and the event log has `devvm _links` as its only other writer. 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. Every log file and its `.1` file is readable only by you (mode 600).
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 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. Its flags take one dash or two, and its errors end in one line, `The VM's proxy failed: …` (`proxy_failed`).
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 |
| --- | --- |
@@ -426,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 proxy looks each binding's value up in its own process |
| `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 |
@@ -434,6 +542,8 @@ The config is one JSON file, `proxy.Config`, which a VM's proxy and a build's pr
| `nix_cache_max` | with `nix_cache`: the cache's cap, in bytes (none: 10 GiB) |
| `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 |
| `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)).
+35 -19
View File
@@ -12,6 +12,8 @@ When you run `devvm` in a folder that has no VM, devvm makes one in these steps:
```mermaid
flowchart TD
accTitle: How devvm makes a VM
accDescr: Until the first shell opens, devvm checks everything first, checks the shared tools for newer versions if due, builds the image if it isn't built, writes the VM's state, makes the VM from its image, locks .git unless --clone, starts its proxy and then the VM, runs the self-check, and sets the VM up, then the clone and devcontainer.json's commands. Then it opens the shell. If it's interrupted before then, devvm deletes the VM and what it made for it, and unlocks .git.
subgraph before["until the first shell opens"]
check["checks everything first:<br>image, size, ports,<br>network tier, SSH agent,<br>features, devcontainer.json"] --> tools["checks the shared tools<br>for newer versions, if due"]
tools --> build["builds the image,<br>if it isn't built"]
@@ -34,7 +36,7 @@ flowchart TD
6. Unless the VM is a `--clone` VM, devvm locks the folder's `.git` hooks and config ([`.git` protection](git-protection.md)). It warns when the repo's origin is an SSH remote and the VM has no SSH agent (`ssh_remote_hint`), and on Linux hosts it names the set-id files in the folder, including those an earlier VM of this folder made. When the VM forwards your SSH agent, devvm checks that the agent has keys.
7. devvm starts the VM's [proxy](network.md#the-proxy), then the VM, confined to the proxy on every tier but open.
8. The [self-check](network.md#the-self-check) runs, before the setup and the shell. Then, when you said yes to the export devvm offered, devvm warns when the tier that its `.folder` file records is less strict than the VM's, or when it records none (`history_import_less_strict`, `history_import_tier_unknown`), and streams it into the VM, whose own `tar` checks its paths and unpacks it as the VM's user ([importing history](../using/coding-agents.md#importing-history)), and a failed import only warns.
9. devvm sets the VM up ([the VM's setup](../using/coding-agents.md#the-vms-setup)) and makes it reachable [by name over SSH](../using/ssh.md). It makes a `--clone` VM's clone, or a workspace clone's repos, all in one command in the VM, then pushes each repo's branches and copies the folder's own files, and then runs the commands of the folder's [`devcontainer.json`](../using/devcontainer.md#commands).
9. devvm sets the VM up ([the VM's setup](../using/coding-agents.md#the-vms-setup)) and makes it reachable [by name over SSH](../using/ssh.md). It makes a `--clone` VM's clone, or a workspace clone's repos, all in one command in the VM, then copies each repo's branches into it ([the copy into a clone VM](git-protection.md#the-copy-into-a-clone-vm)) and copies the folder's own files, and then runs the commands of the folder's [`devcontainer.json`](../using/devcontainer.md#commands).
10. devvm opens a shell in the VM in its own place, so devvm ends when the shell does. Without a terminal, the shell reads its commands from devvm's input.
Until the first shell opens, nothing of yours is in the VM yet. If you interrupt devvm before then, it deletes the VM, stops its proxy, deletes its pinned host keys and its folder, with its state, its own rules and its run files, takes the locks off `.git`, and for a `--clone` VM removes the repo's remote for it.
@@ -45,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.
@@ -70,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.
@@ -95,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`. 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.
@@ -109,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
@@ -126,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. 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.
@@ -138,7 +140,7 @@ The VM's setup, which runs on every launch, moves Claude Code's history for the
## A VM whose folder is gone
A VM's folder is there, gone or not connected, which `devvm ls --json` gives as `folder_state`. It's there when something is at the path its state records as `dir` ([a VM's state](#a-vms-state)), so a folder made again at that path is there too, and [a folder made again](#a-folder-made-again) covers it, and so is a path devvm can't read for another reason, such as its permissions. When nothing is at the path, devvm walks up to the nearest folder above it that exists and compares that folder's device with the device in the `folder` identity the state records. The same device means the folder was deleted or moved from that filesystem, so it's gone. Another device means it was on a disk or share that isn't mounted, so it's not connected, and a folder moved to another disk and then deleted counts as not connected too, which is the safe mistake. A state with no `folder` identity, or a device devvm can't read, counts as gone. `devvm ls` and `devvm space` check every VM's path when they list it, and neither `devvm gc` nor retention treats such a VM as leftover state, because its backend still has it.
A VM's folder is there, gone or not connected, which `devvm ls --json` gives as `folder_state`. It's there when something is at the path its state records as `dir` ([a VM's state](#a-vms-state)), so a folder made again at that path is there too, and [a folder made again](#a-folder-made-again) covers it, and so is a path devvm can't read for another reason, such as its permissions. When nothing is at the path, devvm walks up to the nearest folder above it that exists and compares that folder's device with the device in the `folder` identity the state records, or, for a state that records the folder's volume (`folder_volume`), that folder's volume with it, so a disk that a restart numbered anew isn't taken for another ([one VM per folder](security.md#one-vm-per-folder)). The same device means the folder was deleted or moved from that filesystem, so it's gone. Another device means it was on a disk or share that isn't mounted, so it's not connected, and a folder moved to another disk and then deleted counts as not connected too, which is the safe mistake. A state with no `folder` identity, or a device devvm can't read, counts as gone. `devvm ls` and `devvm space` check every VM's path when they list it, and neither `devvm gc` nor retention treats such a VM as leftover state, because its backend still has it.
`devvm rm VM` finds the VM by the `name` or `alias` in each state file, and nothing else, so a folder's name never matches (`rm_unknown_vm`). A VM whose `dir` is the folder devvm runs in goes through `devvm rm` when it's that folder's own VM, the one the folder's lookup finds ([a VM's folder](#a-vms-folder)). A VM whose `dir` names a folder with another VM of its own, which only a state changed by hand can, is a VM whose folder is there, so `devvm rm VM` never sends the command to that folder's own VM. Otherwise devvm refuses a VM whose folder is there (`rm_vm_folder_there`), and one that its backend no longer has (`rm_vm_lost`). It then refuses a `--clone` VM unless `--no-clone-check` (`rm_gone_clone`), because there's no repo to fetch the clone's work into. When the VM has an agent and `--no-export` isn't given, it refuses a stopped VM that mounts its folder (`rm_gone_stopped`), because Lima makes a missing folder that a VM mounts as the VM starts, and the export would make the project folder again. It asks next (`delete_gone_folder_vm`), which `--force` answers, and where devvm can't ask it refuses unless `--force` (`no_input`). For a folder that isn't connected, it refuses where devvm can't ask, even with `--force` (`rm_vm_not_connected`), and otherwise it asks (`delete_not_connected_folder_vm`), which `--force` never answers. Once you answer, it reads the VM's state again and checks that the folder is still in the state it found, and the VM's status when it's to be exported, once more, because the folder may have come back while it asked, another devvm may have made the VM again, or stopped it: each of those keeps the VM, with the same refusals. Last, it exports the history from the running VM, or from a `--clone` VM it starts, and deletes the VM as `devvm rm` does ([deleting a VM](#deleting-a-vm)). A failed export keeps the VM (`export_failed_kept`).
@@ -176,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.
@@ -186,6 +188,16 @@ In the data folder, each VM has a folder of its own, `vms/<hash>/` ([a VM's fold
Each write replaces a file whole, so a file is never left half written. devvm makes its files readable only by you (mode 600), and the programs it keeps to run, such as its mise and QEMU wrapper, are mode 700, as are its folders. Before every command, devvm makes the data folder and `~/.config/devvm` when they're missing and sets both to mode 700, whatever mode they had. A wider mode on anything beneath them then opens nothing to others, and when devvm can't set a folder's mode, it warns and goes on. The folders that hold history, logs, keys or secrets (`exports/`, `logs/`, `logs/runs/`, `run/`, `secrets/`, and the `run/`, `run/ca/` and `logs/` folders in each VM's folder) are set to mode 700 again whenever devvm writes an export, a log, a key or a secret into them, whatever mode they had before. devvm refuses to use one of those folders when it's a symbolic link or not a folder at all, so it never sets the mode of whatever a link points to. The data folder and `~/.config/devvm` may be symbolic links, such as into a dotfiles repo, and devvm follows them. When a file can't be read, devvm names the file and the line, and you fix the line or delete the file.
### 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. 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. 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
Each VM's folder, `vms/<hash>/`, is named by the hash at the end of the VM's name, which is the hash of its project folder's physical path when devvm made the VM, and it holds every file that devvm keeps for the VM in the data folder:
@@ -195,8 +207,8 @@ Each VM's folder, `vms/<hash>/`, is named by the hash at the end of the VM's nam
| `vm.json` | the VM's state ([a VM's state](#a-vms-state)) |
| `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`, 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`), and on macOS the hostagent's [sandbox profile](lima.md#confinement) (`sandbox.sb`) |
| `logs/` | its proxy's decisions (`network.jsonl`) and its proxy'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`) |
| `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 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.
@@ -205,18 +217,18 @@ No VM's folder holds a socket, because a unix socket's path has fewer than 104 c
### A VM's state
A VM's state is `vm.json`, a JSON file that only devvm writes. It starts with the fields every VM has: the file's `version`, the VM's random `id`, its `name` and its ssh `alias`, the `image` the VM came from with its build `chain` and the `from` image its base started from, its project folder (`dir`) and that folder's identity (`folder`), its `backend` and where that backend kept it (`backend_at`), `created`, the time its backend finished making it, and `made_by`, the version of the devvm that made it, which later changes keep. A VM without `created` never starts, because its creation didn't finish. devvm takes the `alias` only when it's one devvm could have chosen for the VM, which is `devvm-<folder>` with the folder part of the VM's own name, or the full name. An alias edited to anything else never reaches the ssh config and names no VM, so the VM is reached by its full name. After those fields comes one section for each part of devvm that keeps something of the VM's:
A VM's state is `vm.json`, a JSON file that only devvm writes. It starts with the fields every VM has: the file's `version`, the VM's random `id`, its `name` and its ssh `alias`, the `image` the VM came from with its build `chain` and the `from` image its base started from, its project folder (`dir`) and that folder's identity (`folder`), the volume it's on (`folder_volume`, bound to the folder's inode and birth time, where devvm can tell it), `folder_unchecked` while that volume is still to check after a renumbering ([one VM per folder](security.md#one-vm-per-folder)), its `backend` and where that backend kept it (`backend_at`), `created`, the time its backend finished making it, and `made_by`, the version of the devvm that made it, which later changes keep. A VM without `created` never starts, because its creation didn't finish. devvm takes the `alias` only when it's one devvm could have chosen for the VM, which is `devvm-<folder>` with the folder part of the VM's own name, or the full name. An alias edited to anything else never reaches the ssh config and names no VM, so the VM is reached by its full name. After those fields comes one section for each part of devvm that keeps something of the VM's:
| Section | Kept by | Holds |
| --- | --- | --- |
| `net` | network tier | the VM's `tier`, and what devvm made for it: the proxy's password, the salt that ends its placeholders and the last [self-check](network.md#the-self-check)'s result |
| `git` | [.git protection](git-protection.md) | the mode, the mode chosen while the VM ran, and what locking found: `.git`'s identity, the git folders it locked besides `.git`, and a hash of what the locked files hand over to the project folder |
| `ports` | the port allocator | which ports the VM forwards, and the host ports devvm chose for its ssh, its proxy and its desktop |
| `agent` | SSH agent forwarding | the VM's choice, and the start devvm last started it with |
| `agent` | SSH agent forwarding | the VM's choice, the start devvm last started it with, and whether that start forwarded its proxy's [relay](processes.md#the-ssh-agents) of the agent |
| `tools` | the shared tools | the VM's shared tools by name, and their images and C library |
| `secrets` | secrets | the secrets bound to the VM |
| `size` | `devvm size` | the CPUs, memory and disk asked for |
| `clone` | `--clone` | whether the VM has its own clone, the repo's remote for it, and whether its branches were copied in |
| `clone` | `--clone` | whether the VM has its own clone, the repo's remote for it, and whether its branches were copied in; a folder of repos' repos, each with the same; and each repo's submodules the VM has a clone of (`submodules`), nested ones too, each with its path in its repo's folder, its remote and whether it was copied, so `devvm clone fetch` and `devvm rm`'s check go over each one the VM has, even when this machine's repo no longer has it. An older devvm ignores `submodules`, so its `devvm rm` wouldn't check them, which matters only after a downgrade |
| `devcontainer` | a devcontainer.json | the file the VM was made from, its variables and commands, which of them ran, and what of the VM came from the file and what from you ([reading it again](#reading-the-devcontainerjson-again)) |
| `desktop` | `devvm desktop` | the desktop's password |
| `links` | links and groups | the ports the VM publishes, its links and its group |
@@ -229,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. 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.
@@ -244,10 +256,14 @@ 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) |
+42 -5
View File
@@ -18,10 +18,25 @@ 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, the VM's own ssh port, and the ports other VMs list. 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)).
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.
### Ports other VMs forward
A host port that two VMs could forward belongs to the running VM that forwards it, never to a stopped one, so a stopped VM's listed ports are free to the others until it starts again. Each forwarder writes the ports it forwards to `ports.forwarded` in its VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, after each change, with its pid on the first line and the ports it forwards on the second. The next three lines hold the ports it tried and couldn't take, by why: those a program on this machine has, those past its limit of 256 forwards, and those this machine refused for another reason, such as a port below 1024 on Linux. It writes an empty record when it starts. A record counts only while that pid is the VM's running forwarder, as `ports.pid` and the process's arguments say, so the record of a VM that stopped or crashed, whose forwarder ended with it, holds nothing. devvm also removes the record under the VM's `ports.lock` each time it starts the VM's forwarder, so a pid used again never makes an old record count.
At each report from its VM, every forwarder reads the other VMs' states and records again, and it never takes these ports:
- a port that another VM's running forwarder forwards now
- a port that another VM lists while that VM has a claim on it, unless this VM lists it too. A VM has a claim while its forwarder runs, and while devvm holds its `ports.lock` to start the forwarder again, so no other VM takes its listed ports between the old forwarder's stop and the new one's start.
A VM that lists a port comes before one that forwards every port. Besides its VM's reports, every forwarder checks the ports it forwards against those rules every 10 seconds on its own clock and closes a forward whose port is now another VM's, so a VM that keeps its session open without reporting can't keep a port. Closing a forward also closes the connections it accepted that are still open, such as a browser's keep-alive connections, so none of them reaches the old VM afterwards. A VM that forwards every port therefore gives up a port within about 10 seconds of a running VM listing it.
A port the forwarder never takes for those reasons, and that its VM listens on, waits: the forwarder tries it again at each report, which comes at least every 10 seconds, and forwards it once it's free, even when an earlier try found it taken. A port the other VM gives up can therefore take up to about 20 seconds to reach this VM: up to 10 for the other forwarder's check and up to 10 for this one's next report. When a start or a change of ports finds that another VM forwards one of the VM's listed ports now, whether that VM lists it or forwards every port, devvm keeps the port in the VM's list and warns you (`ports_held`), and `devvm ports` warns again, with the other VM in its JSON's `held_by`. A port that another VM forwards isn't a program's, so it never gets `ports_taken`. A listed port of a running VM that its forwarder tried and couldn't take is only logged by the forwarder, and `devvm ports` warns about it, as [When it can't forward](#when-it-cant-forward) describes.
When two VMs that list the same port start at once, neither waits for the other, because neither forwards it yet. The first forwarder to bind the port on this machine's loopback has it, because the system lets one listener have it, and the other forwarder's try fails. That forwarder sees the winner's record at its next report and waits for the port from then on. No lock is needed for this, and no port is shared.
## How it reaches the VM
The forwarder reaches the VM over the VM's ssh, with a key and a host key that devvm pins, and it asks for no forwarding into this machine. Only a [link session](#the-link-session) asks a VM for a remote forward, on a connection of its own. Every connection starts on this machine, and the VM opens none to it. The VM sees each forwarded connection only as one to its own loopback, and on a confined tier the VM still reaches only its proxy.
@@ -30,6 +45,8 @@ A connection to a forwarded port, such as 5173, takes this path:
```mermaid
flowchart TD
accTitle: A connection to a forwarded port
accDescr: Your browser on this machine connects to localhost:5173, where devvm's forwarder, on this machine, takes it over ssh, with a key and a host key devvm pins, to the VM's sshd, which connects to your server on the VM's own loopback, 127.0.0.1:5173.
browser["your browser, on this machine,<br>where every connection starts"] -- "localhost:5173" --> fwd["devvm's forwarder,<br>on this machine"]
fwd -- "ssh, with a key and<br>a host key devvm pins" --> sshd["the VM's sshd"]
sshd -- "127.0.0.1:5173,<br>its own loopback" --> server["your server, in the VM"]
@@ -37,9 +54,13 @@ 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. 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)).
## Its process and files
The forwarder runs as a hidden devvm command, `devvm _ports`, one process for each VM. devvm starts it after each start of the VM, once the backend says the VM runs, and again with the new ports when you change a running VM's ports. `devvm stop`, `devvm rm` and `devvm gc --orphans` stop it, and a VM that stops some other way ends it, because the forwarder exits once the backend's process for the VM is gone. Which ports a VM forwards is in the VM's state, which devvm reads each time it starts the forwarder, so `devvm ports` changes the state and never the backend's config, and the backend never hears of them. The forwarder's log is `ports.log` in the VM's logs folder, `~/.local/share/devvm/vms/<hash>/logs/`, and its `ports.pid`, `ports.status` and `ports.lock` are in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, beside the VM's host keys for its current start, `known_hosts`, which the forwarder checks the VM against, as devvm's ssh config does ([ssh into VMs](security.md#ssh-into-vms)). Its control socket is `~/.local/share/devvm/run/port-<hash>.ctl`, named by a hash of the VM's name, outside the VM's folder, because a unix socket's path has fewer than 104 characters.
The forwarder runs as a hidden devvm command, `devvm _ports`, one process for each VM. devvm starts it after each start of the VM, once the backend says the VM runs, and again with the new ports when you change a running VM's ports. `devvm stop`, `devvm rm` and `devvm gc --orphans` stop it, and a VM that stops some other way ends it, because the forwarder exits once the backend's process for the VM is gone. Which ports a VM forwards is in the VM's state, which devvm reads each time it starts the forwarder, so `devvm ports` changes the state and never the backend's config, and the backend never hears of them. The forwarder's log is `ports.log` in the VM's logs folder, `~/.local/share/devvm/vms/<hash>/logs/`, and its `ports.pid`, `ports.status`, `ports.lock` and `ports.forwarded` are in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, beside the VM's host keys for its current start, `known_hosts`, which the forwarder checks the VM against, as devvm's ssh config does ([ssh into VMs](security.md#ssh-into-vms)). Its control socket is `~/.local/share/devvm/run/port-<hash>.ctl`, named by a hash of the VM's name, outside the VM's folder, because a unix socket's path has fewer than 104 characters. [Processes](processes.md#the-port-forwarder) has what the forwarder holds, what it reads from the VM and the bounds on its log, and [ssh masters and relays](processes.md#ssh-masters-and-relays) has its ssh processes.
devvm reads every list of ports the same way, whether it comes from `--ports`, `devvm ports` or the VM's state. Each entry is a port from 1 to 65535 or a range of them, such as `8000-8010`. When the VM's state holds a list that devvm can't read this way, such as a file edited by hand, the VM doesn't start and devvm names the value it couldn't read with `port_invalid`, so a bad entry never becomes a port the VM didn't ask for.
@@ -47,9 +68,21 @@ devvm reads every list of ports the same way, whether it comes from `--ports`, `
When a forwarder doesn't start, devvm warns you and names its log (`ports_forward_failed`), and the VM runs on without forwarded ports.
When a running forwarder tries a listed port and can't take it, it logs the port with the system's error and records why in `ports.forwarded`. `devvm ports` warns about each such port by why:
- `ports_taken`, when a program on this machine has the port, which the system reports as the address being in use. The forwarder tries the port again only once the VM's server on it stops and starts again.
- `ports_limit`, when the VM already forwards 256 ports, the most a forwarder forwards at once, so the forwarder didn't try it. The forwarder tries the port again at the VM's next report once it forwards fewer.
- `ports_refused`, when this machine denied the forwarder the port, such as Linux keeping ports below 1024 for root. The forwarder tries the port again only once the VM's server on it stops and starts again.
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 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
@@ -63,7 +96,7 @@ The addresses are internal to devvm. `devvm link` and its JSON never show them,
For each running client with links, devvm runs a hidden command, `devvm _links VM`, as one detached process on this machine. Its pid is in `links.pid` in the VM's run folder, `~/.local/share/devvm/vms/<hash>/run/`, and its log is `links.log` in the VM's logs folder, `~/.local/share/devvm/vms/<hash>/logs/`. It keeps an ssh connection of its own to the client, never the forwarder's, which starts with no forwards and asks for each link as a remote forward from `127.77.x.y:PORT` in the client to a unix socket on this machine. That's the only remote forward devvm asks a VM for. It reads the client's links again every second and adds or cancels one forward at a time as they change, and a cancel leaves the connections that are open. A link whose address and port a program in the client already holds fails alone, with `link_port_taken` in the session's log, which the next launch shows. Each line that the session's ssh processes print starts with `ssh:` in its log, so no line of theirs reads as one of the session's own, and devvm link add and the launch read only the session's own lines.
The process ends once the client no longer runs the start it was made for, or has no links left, and `devvm stop` stops it with the client, which ends its connections and removes its sockets.
The process ends once the client no longer runs the start it was made for, or has no links left, and `devvm stop` stops it with the client, which ends its connections and removes its sockets. [Processes](processes.md#the-link-session) has what the session holds, what it reads from the VMs and the bounds on its log.
Every VM's sshd allows remote forwards on `127.77.0.0/16` alone, with `AllowTcpForwarding all`, `GatewayPorts clientspecified` and `PermitListen 127.77.*:*`, written once into every image, so links never change or reload sshd. sshd matches the address a request names against that rule as text, so a remote forward on `localhost`, `127.0.0.1`, `0.0.0.0` or `::1` is refused. Root in the client can change sshd, so those settings protect only an honest VM. What keeps the VM from choosing where its connections go on this machine is the host's ssh client, which accepts a forwarded channel only for a forward it asked for and connects it only to that link's socket.
@@ -73,6 +106,8 @@ A program in the client that connects to `db:5432` takes this path:
```mermaid
flowchart TD
accTitle: A connection over a link
accDescr: Your program in the client connects to db:5432, which /etc/hosts names as 127.77.0.1. The client's sshd passes it over the link session's ssh, which this machine opened, to devvm _links on this machine, which connects over ssh, with the target's key and pinned host key, to the target's sshd, and so to the server on the target's own loopback, 127.0.0.1:5432.
app["your program, in the client"] -- "db:5432, which /etc/hosts<br>names as 127.77.0.1" --> csshd["the client's sshd"]
csshd -- "the link session's ssh,<br>which this machine opened" --> links["devvm _links,<br>on this machine"]
links -- "ssh, with the target's key<br>and pinned host key" --> tsshd["the target's sshd"]
@@ -91,8 +126,10 @@ At most 256 of a client's connections are carried at once, and the next one is r
`devvm link add` and `devvm link rm` record the change in the client's state on this machine, never in a VM. On a running client they send its setup again, which rewrites `/etc/hosts`, and they start `devvm _links` if it isn't running. `devvm _links` reads the links again every second and writes the list that the client's proxy reads, so the proxy reaches a new link as soon as its forward is in place. A stopped client gets the change when it next starts. Links change nothing else in the VM: no link name is in its `NO_PROXY` ([the VM's setup](network.md#the-vms-setup)), so no daemon restarts, and on Lima no link changes the VM's Lima config or its ssh host keys.
When a link goes, `devvm _links` stops listening for it and ends the connections that are open through it, with their ssh processes. Each connection's ssh process waits for the target's sshd to end its channel, so ending it is what keeps a target that never closes its end from holding that process, and one of the client's 256 connections, after the link has gone. When a target starts again, the connections still open through its old ssh connection end once the next connection to the target arrives, which makes a new ssh connection, or once the old one dies. A link whose name now leads to another target at the same address and port, because one link was removed and another added within the same second, ends the old target's connections the same way.
`devvm rm` of a target removes every link to it from every client's state and updates the running clients, and `devvm gc --orphans` removes links to VMs whose state is gone and the sockets that a killed link session left.
### 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.
+210
View File
@@ -0,0 +1,210 @@
---
title: Processes
explainer: What each of devvm's processes holds, reads, writes and is confined by
weight: 10
---
This page goes through every process that devvm runs on this machine for a VM, one section each: what it holds, such as secrets and keys, the input a VM controls that it reads, what it writes and how far that can grow, how it's confined, and who starts it and waits for it. Then it lists every listener on this machine whose bytes a VM controls, and why devvm is written in Go. The pages each section links to have the details, and the [security model](security.md) has what these processes protect.
Every process here runs as you. devvm runs its own long-running processes as itself, `devvm` with a hidden command, so their code is the binary you installed, and the other long-running programs it runs are OpenSSH's `ssh` and `ssh-agent`, Lima and, on Linux, QEMU.
| Process | Started by | Ends | Confinement |
| --- | --- | --- | --- |
| [devvm itself](#devvm-itself) | you | when its command ends | none |
| [A VM's proxy](#a-vms-proxy): its broker, `devvm _proxy` | each start of the VM | with the VM's hostagent, its child, or `devvm stop` | none |
| [A VM's proxy](#a-vms-proxy): its child, `devvm _proxy-child` | the broker | with its broker | a Seatbelt profile on macOS, and Landlock and a seccomp filter on Linux ([the child's sandbox](network.md#the-childs-sandbox)) |
| [A build's proxy](#a-builds-proxy), `devvm _proxy` and its child | a build behind a company proxy | with the build | its child's, as a VM's proxy's child's |
| [The port forwarder](#the-port-forwarder), `devvm _ports` | each start of a project VM, and each change of its ports | with the VM's hostagent, or `devvm stop` | none |
| [The link session](#the-link-session), `devvm _links` | a start or a change of links, for a client with links | when the client stops or has no links, or `devvm stop` | none |
| [ssh masters and relays](#ssh-masters-and-relays) | the forwarder, the link session and devvm | with the process that started them | none |
| [The QEMU wrapper](#the-qemu-wrapper-and-its-keeper), `devvm _qemu` | Lima, on Linux hosts | with QEMU | QEMU's restricted network, and a user namespace for a VM with `.git` pins |
| [The daily tools check](#the-daily-tools-check), `devvm _refresh-tools` | a launch of an existing VM, once a day | when the check is done | none |
| [The desktop relay](#the-desktop-relay) | `devvm desktop` | with `devvm desktop` | none |
| [The SSH agents](#the-ssh-agents) | you, or `devvm` for devvm's own | devvm's own: at logout or a reboot | none |
| [Lima's hostagent](#limas-hostagent) | `limactl start` | when the VM stops | a Seatbelt profile on macOS, for a confined VM or a build |
## 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 ([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. 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. 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 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. 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. 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. 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. 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 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 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](../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 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.
## The port forwarder
One forwarder runs for each running project VM that forwards ports, as `devvm _ports` ([its process and files](ports.md#its-process-and-files)).
- **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. 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.
- **Starts and ends:** devvm starts it once the backend says the VM runs, and again when the VM's ports change. It exits once the VM's hostagent is gone, which it checks every 2 seconds, and `devvm stop`, `devvm rm` and `devvm gc --orphans` stop it.
## The link session
One link session runs for each running client VM with [links](ports.md#links-between-vms), as `devvm _links VM` ([the link session](ports.md#the-link-session)).
- **Holds:** the login key and the pinned host keys of the client and of each target it connects to.
- **Reads from the VMs:** the bytes of each link's connection, both ways, and the messages of the client's sshd, such as its refusal of a forward, each cut at 512 bytes.
- **Writes:** `links.json` in the client's run folder, the client's event log, `network.jsonl`, with the proxy's own writer, so it rotates by the same rule, and its log, `links.log`, in the client's logs folder, which it writes, limits and rotates past 1 MiB as the forwarder does its own. Its warning that the client refused to listen for a link carries the client's sshd's words, and the client chooses how often it comes, so each warning takes its turn from the same limit as the log's lines.
- **Bounds:** at most 256 of the client's connections at once.
- **Listens:** on a unix socket for each link, mode 600, in `~/.local/share/devvm/run` (mode 700).
- **Confinement:** none.
- **Starts and ends:** a start of the client and a change of its links start it. It ends once the client no longer runs the start it was made for, which it checks every 5 seconds, or has no links left, and `devvm stop` stops it with the client.
## ssh masters and relays
The forwarder and the link session each reach a VM over one ssh connection of their own, its master. The forwarder's master runs the VM's report of its ports, and the link session keeps one master to the client, which asks for the links' remote forwards, and one to each target. Every master checks the VM's pinned host key, sets `ControlPersist=no`, and sends a keepalive every 10 seconds, giving up after 3 that get no answer.
Each connection that the forwarder or the link session carries gets an ssh process of its own, a relay, which runs `ssh -W`. A link's relay can only ride on its target's master. A forwarder's relay rides on the VM's master when it can, and it checks the same pinned host key either way, so it reaches only that VM.
- **Holds:** the login key, and no agent (`IdentityAgent=none`).
- **Reads from the VM:** the bytes of the connection it carries.
- **Writes:** nothing of its own. A master's messages go to its process's log.
- **Ends:** a relay ends when either side ends, when its forward or its link goes, and 30 seconds after the program on this machine closes its side if the VM sends nothing in that time ([how it reaches the VM](ports.md#how-it-reaches-the-vm)). Each process that starts a master or a relay waits for it, and kills it when it ends that connection.
`devvm desktop` and `devvm agent login` start relays of their own, one ssh process for each connection, which rides on no master (`ControlMaster=no`, `ControlPath=none`). A login's relay ends as the forwarder's do, and a login carries at most 16 connections at once, closing any past that, so whatever else on this machine connects to its port can't start ssh processes without end. A viewer's ssh process gets 2 seconds to end once its viewer leaves, and is then killed.
## The QEMU wrapper and its keeper
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, 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.
The keeper dies with `devvm _qemu exec`, and QEMU with the keeper. `devvm _qemu connect` ends when its connection ends, and its slot is free again.
## The daily tools check
`devvm _refresh-tools` asks for the shared tools' newest versions once a day, so a later launch can offer them ([shared tools](../using/toolchains.md)).
- **Holds:** the company proxy's password, when `config.toml` sets the proxy, in the environment of the mise it runs.
- **Reads:** nothing from a VM. It downloads devvm's pinned mise, checked by its SHA-256, mise reads the tools' versions from the internet, and the check fetches .NET's release data.
- **Writes:** the shared tools' lock, under its lock, the time of the check, and its output to `~/.local/share/devvm/logs/tools-check.log`, which each check starts empty.
- **Starts and ends:** a launch of an existing VM starts it when the shared tools have a lock file and a day has passed since the last check, and doesn't wait for it. `DEVVM_NO_TOOL_CHECK` turns it off.
## The desktop relay
`devvm desktop` runs the relay in its own process, for as long as it runs ([on this machine](desktop.md#on-this-machine)).
- **Holds:** the VM's desktop password, which never goes into the VM.
- **Reads from the VM:** the VM's side of VNC's handshake, which is a version, at most 255 security types and a result, within 15 seconds, and then the VM's screen, which it passes to the viewer as it is.
- **Writes:** lines to the run log when each viewer connects and disconnects, and for each connection it refuses, and each ssh process's messages.
- **Bounds:** at most 8 connections at once, counting those still in their handshake, one check of a password at a time, and a second's wait after a wrong one.
- **Listens:** on `127.0.0.1` alone, on the VM's desktop port ([listeners](#listeners-a-vm-reaches)). When accepting a connection fails but the port stays open, as when it runs out of open files, it tries again after 5 ms and then twice as long each time, up to a second, and logs only the first failure of a run.
- **Starts and ends:** it ends when you press Ctrl+C, or when the VM no longer runs, which it checks every 5 seconds, and it waits for each viewer's connection.
## The SSH agents
A VM whose [SSH agent](../using/ssh.md#agent-forwarding) choice is `on` gets your own agent, which devvm doesn't start, stop or confine. A VM whose choice is `devvm` gets devvm's own agent, which is OpenSSH's `ssh-agent`, run as `ssh-agent -a ~/.local/share/devvm/agent.sock`.
- **Holds:** only the keys you add with `devvm ssh-agent add`, each for 12 hours unless you chose another lifetime. devvm refuses a key in a folder that a VM mounts.
- **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.
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 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.
## Lima's hostagent
Each running VM has a hostagent, `limactl hostagent`, which `limactl start` runs and which runs the VM: on macOS it runs Apple's Virtualization framework in its own process, and on Linux it starts QEMU.
- **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. 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
These are the listeners on this machine that carry bytes a VM controls. Every one listens on this machine's loopback or on a unix socket, so other machines never reach them, but every program and every user on this machine can connect to a TCP port on its loopback.
| Listener | Process | Gate | What the VM controls |
| --- | --- | --- | --- |
| each forwarded port, on `127.0.0.1` and `::1` | the port forwarder | none: whatever connects reaches the VM's server, 256 connections at once | everything its server sends back |
| the VM's ssh port, on the loopback, one of the 17 ports every browser refuses ([why](lima.md#what-devvm-sets-on-a-vm)) | the hostagent on macOS, QEMU on Linux | the VM's sshd, which each of devvm's connections checks against the VM's pinned host key, and browsers' own refusal of the port | everything the VM's sshd sends, which root in the VM can make speak HTTP |
| Lima's DNS resolver, on loopback ports the system picks | the hostagent, for an open VM and every build, never for a VM confined to its proxy | none | its lookups |
| the unix sockets in the VM's Lima folder: the network socket on macOS, which carries the VM's network frames, and Lima's ssh control socket, `ssh.sock` | the hostagent, and Lima's ssh | the folder's mode | its network frames, and everything its sshd sends |
| the VM's proxy port, on `127.0.0.1` | the VM's proxy's child | the VM's password, before anything else | its requests |
| a build's proxy port, on `127.0.0.1` | the build's proxy's child | the build's password | its requests |
| the desktop port, on `127.0.0.1` | `devvm desktop` | the VM's desktop password, checked on this machine | its screen, once a viewer is in |
| `127.0.0.1:1455`, with `::1:1455` and port 1457 on both when they're free | `devvm agent login`, while Codex's or opencode's browser login to ChatGPT waits, but not with `--device-code` | none: whatever connects reaches the agent's login server in the VM, 16 connections at once | the login server's answers |
| each link's unix socket | the link session | the socket's mode, 600 in a folder of mode 700 | the client's bytes, through its sshd's remote forward or its proxy, and the target's answers |
| the ssh masters' control sockets, `run/port-<hash>.ctl` and `run/link-<hash>.ctl` in `~/.local/share/devvm` | the forwarder's and the link session's ssh masters | the folder's mode: any process of yours that connects gets a channel into the VM | everything the VM sends on that channel |
| the VM's agent socket, `run/agent-<hash>.sock` in `~/.local/share/devvm` | the VM's proxy's broker, for a VM that forwards an SSH agent | the socket's mode, 600 in a folder of mode 700 | the agent's requests, of which the proxy passes on only listing keys, signing and binding a session to a host |
A forwarded port and the login's port carry whatever connects to them into the VM, a browser's pages included, and that's what [attack vectors](../safety/attack-vectors.md#network) lists as left open.
## Why Go
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.
- **Secret leaks,** such as a proxy password in Lima's log, and a resolver's error in a VM's refusal reason.
- **Races between processes,** such as a proxy that had just started looking gone, and two runs choosing ports or making a folder's VM at once.
- **File-system trust,** such as a project folder replaced after devvm found it, a folder that a VM names as a git folder, a link under a folder's path, and a project folder mounted by its path rather than as the folder itself.
A port to Rust would cost what keeps devvm easy to keep:
- **One static binary,** built with `CGO_ENABLED=0` for every platform from one machine. Go's `crypto/tls` needs no C toolchain, while rustls's usual providers, aws-lc-rs and ring, have C in them.
- **A small dependency tree:** Go's standard library, Go's own `x` modules, Cobra and pflag, a TOML parser and go-i18n, with the few modules that cobra/doc brings in, where a Rust proxy on the usual async, HTTP and TLS crates brings in about a hundred.
- **One owner for each concern,** which depguard, forbidigo and the [structure test](../contributing/structure.md#the-structure-test) enforce, and which none of them could see across a language boundary.
The proxy is the only part that could be split off, and it's bound to the rest: its broker looks up secrets and refreshes agents' logins with devvm's own code, its config is a schema that every release's state keeps, and its child reads its built-in policies from devvm's binary.
The answer changes only for a requirement Go can't meet, such as intercepting QUIC. Even then, only that piece would move, as a process of its own.
+10 -5
View File
@@ -6,7 +6,7 @@ weight: 7
devvm treats everything in a VM as untrusted, including a coding agent with root, because the VM's user has passwordless sudo. This page explains how devvm keeps that code away from the rest of your machine. [Staying safe](../safety/_index.md) lists [what a VM can reach](../safety/_index.md#what-a-vm-can-reach) and the habits that [keep you safe](../safety/_index.md#the-habits), and [Attack vectors](../safety/attack-vectors.md) goes through common attacks one by one and lists what devvm leaves open.
All of it rests on the VM's boundary.
All of it rests on the VM's boundary. [Processes](processes.md) goes through each process on this machine that a VM's bytes reach, what it holds and how it's confined, and lists the listeners a VM reaches.
## What devvm protects, and how
@@ -19,11 +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.
`--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`). 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. 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.
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 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
@@ -55,11 +59,12 @@ The proxy applies the tier's rules, and it refuses the host's own addresses and
ssh and editors reach a running VM by name through the entries that devvm writes ([ssh access by name](../using/ssh.md#ssh-access-by-name)). Each entry is built so that ssh connects only to that VM and the connection gives the VM nothing else of this machine's:
- **Each entry checks the VM's own host keys,** which devvm keeps in the VM's folder, `~/.local/share/devvm/vms/<hash>/run/known_hosts`, as a record of the VM's current start. devvm reads them from the VM through its backend, instead of over the network, once each start, after the VM runs, and the record names the start it was read for, so the keys of an earlier start are read again rather than trusted, whoever started the VM. devvm also removes the record before each start of its own. A VM whose Lima config changed gets new host keys when it boots. A VM whose keys devvm can't read gets no entry, and ssh refuses a host key that doesn't match. devvm's port forwarder, the sessions of links between VMs and a `--clone` VM's git all check the VM against the same record.
- **Each entry checks the VM's own host keys,** which devvm keeps in the VM's folder, `~/.local/share/devvm/vms/<hash>/run/known_hosts`, as a record of the VM's current start. devvm reads them from the VM through its backend, instead of over the network, once each start, after the VM runs, whatever ports the VM forwards, and the record names the start it was read for, so the keys of an earlier start are read again rather than trusted, whoever started the VM. devvm also removes the record before each start of its own. A VM whose Lima config changed gets new host keys when it boots. A VM whose keys devvm can't read gets no entry, and ssh refuses a host key that doesn't match. devvm's port forwarder, the sessions of links between VMs and a `--clone` VM's git all check the VM against the same record.
- **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.
- **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 socket, which is yours, devvm's own or none, and gives it to the backend's start of that 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 or the checks of a `--clone` VM's clone. 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, 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.
+497
View File
@@ -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)).
+11
View File
@@ -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.
+15 -12
View File
@@ -29,15 +29,15 @@ config:
minNodeWidth: 0
---
flowchart TB
accTitle: What a VM can do with what's on this machine
accDescr: The VM reaches the project folder, read-write, or its own clone with --clone, and what its network tier allows, through the proxy. It gets the shared tools and devvm's agent store's folders read-only, and copies of its settings files, minus your secrets. Out of its reach are the rest of your home folder, the .git hooks and config, which are locked, your SSH agent, unless you turn it on, and your secrets, which stay on this machine.
%% Narrower nodes than other diagrams' and labels of at most 12 characters a line, so three
%% columns fit the page. Mermaid lays the columns out from right to left, so the last one comes first.
subgraph out["Out of reach"]
%% columns fit the page. The columns are laid out from left to right in the order they're written.
subgraph reach["The VM reaches"]
direction TB
home["the rest of<br>your home<br>folder"]
git[".git hooks<br>and config,<br>locked"]
agent["your SSH<br>agent,<br>unless you<br>turn it on"]
secrets["your secrets<br>stay on this<br>machine"]
home ~~~ git ~~~ agent ~~~ secrets
folder["the project<br>folder,<br>read-write,<br>or its own<br>clone with<br>--clone"]
hosts["what its<br>network tier<br>allows,<br>through the<br>proxy"]
folder ~~~ hosts
end
subgraph copied["Read-only or copied"]
direction TB
@@ -46,11 +46,13 @@ flowchart TB
files["copies of<br>its settings<br>files, minus<br>your secrets"]
tools ~~~ folders ~~~ files
end
subgraph reach["The VM reaches"]
subgraph out["Out of reach"]
direction TB
folder["the project<br>folder,<br>read-write,<br>or its own<br>clone with<br>--clone"]
hosts["what its<br>network tier<br>allows,<br>through the<br>proxy"]
folder ~~~ hosts
home["the rest of<br>your home<br>folder"]
git[".git hooks<br>and config,<br>locked"]
agent["your SSH<br>agent,<br>unless you<br>turn it on"]
secrets["your secrets<br>stay on this<br>machine"]
home ~~~ git ~~~ agent ~~~ secrets
end
```
@@ -62,7 +64,7 @@ flowchart TB
| The rest of your home folder, other projects | The VM doesn't mount them. |
| Your SSH keys | Only with `devvm ssh-agent on`, and only while you're connected. With `devvm ssh-agent devvm`, the VM can use only the keys you added to devvm's own agent ([details](../using/ssh.md#agent-forwarding)). |
| The network | On every tier but open, the VM reaches only its proxy on this machine, which lets it reach what [its tier](network.md#network-tiers) allows. On the open tier it reaches everything this machine reaches, including this machine's own services on `localhost` ([details](network.md#network-tiers)). |
| Your secrets | Your GitHub token, Claude Code's token, the coding agents' logins and API keys and Claude Code's MCP secrets stay on this machine on every network tier, and the proxy puts them into requests, so code in the VM can still use each secret the VM may use ([details](network.md#secrets)). opencode's and pi's keys that the proxy can't put in, such as a local model server's, stay on this machine too, unless you pass one to VMs in `config.toml` ([opencode logins](../using/coding-agents.md#codex-and-opencode-logins), [pi logins](../using/coding-agents.md#pi-logins)). |
| Your secrets | Your GitHub token, Claude Code's token, the coding agents' logins and API keys and the MCP secrets Claude Code gets from this machine stay on this machine on every network tier, and the proxy puts them into requests, so code in the VM can still use each secret the VM may use ([details](network.md#secrets)). opencode's and pi's keys that the proxy can't put in, such as a local model server's, stay on this machine too, unless you pass one to VMs in `config.toml` ([opencode logins](../using/coding-agents.md#codex-and-opencode-logins), [pi logins](../using/coding-agents.md#pi-logins)). |
> [!NOTE]
> Everything here rests on the VM's boundary: the VM runs its own kernel, apart from this machine's.
@@ -73,3 +75,4 @@ flowchart TB
- [.git protection](git-protection.md): what the lock stops, what still works and what it doesn't cover.
- [Attack vectors](attack-vectors.md): common attacks one by one, and what devvm does about each.
- [How it works › Security model](../internals/security.md): how devvm keeps each of these promises.
- [How it works › Processes](../internals/processes.md): what each of devvm's processes on this machine holds and how it's confined.
+33 -14
View File
@@ -27,19 +27,26 @@ Some protections hold only on some [network tiers](network.md#network-tiers) or
- **Cloud, cluster and registry logins.** Worms that steal credentials collect `~/.aws`, `~/.config/gcloud`, `~/.azure`, `~/.kube/config`, `~/.docker/config.json` and the npm publish token in `~/.npmrc`. A VM mounts none of them, so a package that goes looking finds nothing. Secrets you keep in the project folder are a different case, which [Left to you](#files-the-vm-writes) covers.
- **The Keychain, browsers and password managers.** Stealers read saved passwords, cookies and login sessions from browser profiles and the Keychain. The VM has no browser profile of yours, and it can't reach this machine's Keychain.
- **Your coding agents' history.** Agent transcripts hold what you pasted into them, such as secrets and code from other projects. Your history never goes into a VM, and each VM's own history stays in that VM ([coding agents](../using/coding-agents.md)).
- **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 Claude Code's MCP secrets work the same way, and devvm refreshes OAuth logins on this machine, so a VM never holds a refresh token.
- **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)).
### Git running code on this machine
- **Git hooks and config.** A VM can write the project folder, so without protection it could add a hook such as `.git/hooks/post-checkout`, or set a command in `.git/config`: `core.fsmonitor`, `core.hooksPath`, `core.sshCommand`, `core.pager`, `core.editor`, a `filter.*` or `diff.*.textconv` driver, a `credential.helper` or a `!` alias. Your next git command on this machine would run it. On macOS, devvm locks hooks and config with a flag that even root in the VM can't clear, and on Linux it makes them read-only in the VM's view of the folder ([.git protection](git-protection.md)). A Linux host whose kernel doesn't let devvm do that, which [Left to you](#the-platform) covers, has neither.
- **devvm's own git commands.** devvm runs git on this machine itself, for example to read your name and email for the VM, to check a `--clone` VM's repo for uncommitted changes, and to fetch from the VM. A VM can write a repo that git on this machine reads, such as the project folder's on Linux or a repo inside a folder it mounts, so devvm's git runs none of the programs a repo's config can name. It turns off the repo's fsmonitor, its hooks, including those its config defines, and its filters, it never enters a submodule for `git status`, and it uses no transport but ssh, so `git status`, a fetch or a push of devvm's runs nothing that the VM wrote into the repo. It ignores the git variables of the shell you run devvm in, such as `GIT_DIR` and `GIT_CONFIG_GLOBAL`, so it never works on another repo or config by mistake, and it never asks you anything (`GIT_TERMINAL_PROMPT=0`). Its fetches and pushes reach the VM with ssh in batch mode (`-o BatchMode=yes`), so the VM's ssh server can't ask you for a password. They always connect to that VM itself, whatever host the repo's config sends them to, accept only the host key devvm pinned for it, and forward neither your agent nor any port.
- **devvm's own git commands.** devvm runs git on this machine itself, for example to read your name and email for the VM, to check a `--clone` VM's repo for uncommitted changes, and to fetch from the VM. A VM can write a repo that git on this machine reads, such as the project folder's on Linux or a repo inside a folder it mounts, so devvm's git runs none of the programs a repo's config can name:
- It turns off the repo's fsmonitor, its hooks, including those its config defines, and its filters, it never enters a submodule for `git status`, and it uses no transport but ssh, so `git status` or a fetch of devvm's runs nothing that the VM wrote into the repo.
- It runs no program a repo's config names to check signatures, and it sees a repo's real history, whatever replace refs or a grafts file say.
- It ignores the git variables of the shell you run devvm in, such as `GIT_DIR` and `GIT_CONFIG_GLOBAL`, so it never works on another repo or config by mistake, and it never asks you anything (`GIT_TERMINAL_PROMPT=0`).
- Its fetches reach the VM with ssh in batch mode (`-o BatchMode=yes`), so the VM's ssh server can't ask you for a password. They always connect to that VM itself, whatever host the repo's config sends them to, accept only the host key devvm pinned for it, and forward neither your agent nor any port.
### Getting out over the network, on the allowlist and none tiers
- **Sending data to the attacker's server.** Most attacks end by sending what they stole to a server the attacker runs. A confined VM reaches only its proxy, and on the allowlist tier the proxy allows only the hosts on the VM's allowlist, and on the none tier only its agents' and secrets' hosts. On the internet tier, which a VM is on while it [learns the hosts it needs](network.md#learning-the-hosts-a-vm-needs), the proxy allows every public host, the attacker's included, so this holds only for this machine and your networks. devvm leaves storage and paste sites out of the default allowlist on purpose, because they're easy ways to send data out ([allowlists](network.md#allowlists)).
- **DNS tunnelling.** An attacker can encode data into names and look them up at a DNS server of their own. A VM sends no DNS queries out of it, because names resolve in the proxy on this machine. The names that tools look up in the VM are answered in the VM, by [transparent mode](network.md#tools-that-ignore-the-proxy)'s dnsmasq, which has no server to ask, and the proxy resolves a name only once the VM's rules allow it.
- **Services on this machine and your network.** Code in a VM could attack what developers leave open on `localhost`, such as databases, dev servers, Docker's API and other VMs' ports. It could also attack your router, a NAS, or a cloud provider's metadata service at `169.254.169.254`. The proxy refuses this machine's own addresses and internal ones, such as loopback, private, link-local and CGNAT ranges, unless a rule names the address ([the proxy](../internals/network.md#the-proxy)).
- **DNS rebinding and address tricks.** A name can resolve to a public address when it's checked and to an internal one when it's dialed, and an internal address can hide in an IPv6 or NAT64 form. The proxy dials only the address it checked, and it sees through NAT64 forms ([the proxy](../internals/network.md#the-proxy)).
- **DNS rebinding and address tricks.** A name can resolve to a public address when it's checked and to an internal one when it's dialed, and an internal address can hide in an IPv6, NAT64 or 6to4 form. The proxy dials only the address it checked, and it sees through NAT64 and 6to4 forms ([the proxy](../internals/network.md#the-proxy)).
- **Going around the proxy.** Root in a VM can change its routes and firewall, but devvm confines the VM from outside it, so nothing in the VM reaches anything but the proxy ([confinement](../internals/lima.md#confinement)). devvm catches a VM started outside devvm, or one given a second network, with [the self-check](../internals/network.md#the-self-check). It stops a VM that gets out through a second network, and it offers to restart one started outside devvm confined, or stops it when there's no terminal to ask in.
### Spreading beyond the VM
@@ -47,8 +54,8 @@ Some protections hold only on some [network tiers](network.md#network-tiers) or
- **Your agents' config.** A rogue agent could add a hook to `~/.claude/settings.json` or a skill to `~/.claude/skills`, so that it runs the next time you use the agent on this machine. devvm mounts the agents' config folders read-only, which this machine enforces, and copies their files in on every launch, so nothing the VM changes goes back ([mounts](../using/coding-agents.md#mounts)). Only `devvm agent save` copies a VM's settings into devvm's agent store, for every VM, and it shows what changed and asks first, so read its diff for hooks, MCP servers and plugins you didn't add ([saving a VM's settings](../using/coding-agents.md#saving-a-vms-settings)).
- **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 as well as its path, 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 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](../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
@@ -60,7 +67,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
- **npm, yarn, pnpm and bun lifecycle scripts.** A package's `preinstall`, `install`, `postinstall` and `prepare` scripts run any command when the package is installed, and most npm attacks use them. pnpm's build approvals (`pnpm approve-builds`) and `--ignore-scripts` narrow which packages run scripts, and they're still worth using, but a package you approved runs its scripts all the same, even one compromised after you approved it. In a VM, those scripts reach only what this section's introduction lists.
- **Python packages.** Installing a source distribution runs its `setup.py` or its build backend, and a `.pth` file in `site-packages` runs code every time Python starts.
- **Ruby gems.** A gem with a native extension runs its `extconf.rb` when it's installed, and Bundler can install gems straight from a git repo.
- **Rust build scripts and procedural macros.** `build.rs` and procedural macros run on `cargo build` and `cargo check`, and also when rust-analyzer opens the project, so opening the folder in an editor is enough to run them. With `devvm code`, VS Code's extensions, rust-analyzer among them, run in the VM ([devvm host and devvm code](../using/ssh.md#devvm-host-and-devvm-code)).
- **Rust build scripts and procedural macros.** `build.rs` and procedural macros run on `cargo build` and `cargo check`, and also when rust-analyzer opens the project, so opening the folder in an editor is enough to run them. With `devvm code` or `devvm cursor`, the editor's extensions, rust-analyzer among them, run in the VM ([devvm host, devvm code and devvm cursor](../using/ssh.md#devvm-host-devvm-code-and-devvm-cursor)).
- **Go modules.** Go has no install scripts, but cgo passes flags to the C compiler, `go generate` runs commands, a `toolchain` line in `go.mod` makes Go download another toolchain, and a module's `init` functions run in every test and program that imports it.
- **Makefiles, task runners and `curl | sh`.** A `Makefile`, a `justfile` or a project's install line from its README runs whatever its author wrote.
@@ -76,7 +83,7 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
- **Prompt injection.** Instructions hidden in a README, an issue, a code comment, a web page, a dependency's docs or an MCP tool's output can turn a coding agent against you. devvm can't tell an agent's own work from injected work, so it limits what the agent reaches instead. An attack like this needs private data, untrusted input and a way to send the data out. On the allowlist tier, the only way out is the hosts on the allowlist, which [Left to you](#the-network) covers.
- **Agents with their checks off.** An agent run with `claude --dangerously-skip-permissions` or `codex --dangerously-bypass-approvals-and-sandbox` acts without asking, and a mistaken `rm -rf ~` or `sudo` command reaches only the VM. The project folder is still the agent's to change, so commit often, or use [`--clone`](../using/clone.md) to keep the agent's work apart until you fetch it.
- **Malware that stays.** Anything the attacker leaves in the VM, such as a cron job, a changed shell startup file or a backdoored program, stays in that VM's disk and goes into no other VM's, unless you save an agent's settings that it changed with `devvm agent save`. What it wrote into the project folder stays there, though, and the folder's next VM gets it, such as a `devcontainer.json` command that runs as soon as devvm makes the VM, or a hook in the project's agent settings. devvm never deletes a VM on its own, because it may hold unsaved work, so save what you need and run `devvm rm`, then check the folder for what [the VM writes](#files-the-vm-writes), or use [`--clone`](../using/clone.md), before you make the VM again.
- **Mining and resource abuse.** A VM's CPUs, memory and disk are capped by its size, which `devvm size` shows and changes ([size](../using/ports-size.md#size)). The VM's proxy on this machine carries at most 1024 tunnels for it at once, but it doesn't count the VM's plain HTTP requests in absolute form or its idle kept-alive connections ([the proxy](../internals/network.md#the-proxy)).
- **Mining and resource abuse.** A VM's CPUs, memory and disk are capped by its size, which `devvm size` shows and changes ([size](../using/ports-size.md#size)). The VM's proxy on this machine carries at most 1024 tunnels and 2048 connections of every kind for it at once, and on a Linux host devvm carries at most 256 of its connections to the proxy at once, each a process on this machine, so a VM that opens connections without end can't fill this machine with them ([the proxy](../internals/network.md#the-proxy)).
## Narrowed, not closed
@@ -84,9 +91,11 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
- **Worms that use your GitHub token.** Shai-Hulud (2025) spread through npm install scripts. It collected npm, GitHub and cloud credentials, then used them to publish repos and new versions of packages. A VM holds no npm or cloud credentials, and its GitHub token is a placeholder. The proxy still puts the real GitHub token into every request to GitHub's hosts, so a worm in the VM can push, make repos and do whatever else the GitHub token's scope allows. Use a fine-grained GitHub token scoped to the repos the VM needs, or bind none ([saving and binding secrets](network.md#saving-and-binding-secrets)).
- **A host that sends your secret back.** The proxy puts a secret only into requests for its own hosts, but it passes their replies to the VM as they are. A host that echoes a request's headers, such as a debug endpoint, or an error page that quotes them, shows the VM the real value. This matters most for [your own secrets](network.md#your-own-secrets), whose hosts you choose, so give each one only hosts that you trust with it. A secret's hosts are on the allowlist of every VM that uses it, on every tier, so on a host where anyone can make an account, code in the VM can also send data to an account of its own there.
- **Minting credentials with a secret.** A VM that can use a secret can use it to make another credential that outlasts it. The proxy refuses GitHub REST calls that add an SSH key, a deploy key, a self-hosted runner or a webhook with `403`, but it can't refuse everything, such as GitHub's GraphQL API, an OAuth app grant or other services. 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.
- **Minting credentials with a secret.** A VM that can use a secret can use it to make another credential that outlasts it. The proxy refuses GitHub REST calls that add an SSH key, a deploy key, a self-hosted runner or a webhook with `403`, but it can't refuse everything, such as GitHub's GraphQL API, an OAuth app grant or other services.
- 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 or log in to servers, though it can't copy them. 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
@@ -101,19 +110,25 @@ The attacks in this section run the attacker's code, and devvm doesn't stop that
- **The first seconds of an open start.** A VM that was confined and is made open runs transparent mode from its next boot until that launch's setup takes it out, a few seconds later. In that window, its names resolve to the stand-in address and its connections reach its proxy, which is an open one by then, so they reach what the open tier allows, and nothing keeps those answers after.
- **Model providers that fetch for the VM.** The proxy allows a bound API key's provider hosts on port 443, and some providers' own tools fetch URLs that the request names, such as Google Gemini's URL context and Search grounding, xAI's live search, Groq's compound models and Mistral's agents with web search, as Anthropic's and OpenAI's web fetch and search tools do. Code in the VM can send data out through such a tool to a host that the allowlist doesn't have ([API keys the proxy puts in](../using/coding-agents.md#api-keys-the-proxy-puts-in)).
- **Ports the VM listens on.** devvm forwards the VM's TCP ports from 1024 up to this machine's `localhost`, unless you list the ports with [`--ports`](../using/ports-size.md#size-and-ports), so a VM could take a port that a program on this machine trusts while that port is free, and what the VM serves there reaches whatever connects to it. devvm's forwarder never takes a port that a program on this machine already has, or one that devvm records for a VM, but a program that binds a port on all addresses after devvm forwarded it gets its `localhost` connections sent to the VM. `devvm ports` limits what a VM forwards, and `devvm ports none` forwards nothing, though a project's `devcontainer.json` adds its `forwardPorts` to that list when devvm makes the VM or `devvm update` reads the file ([devcontainer.json](../using/devcontainer.md#security), [ports](../using/ports-size.md#ports), [port forwarding](../internals/ports.md)).
- **VS Code's relays.** Over Remote-SSH, which `devvm code` opens, VS Code forwards the ports that programs in the VM listen on, and it answers git's prompts with your GitHub sign-in. devvm turns both off in the VM's VS Code settings each time it sets the VM up, but the VM can turn them back on, so turn them off in your own VS Code settings as well ([VS Code](../using/ssh.md#vs-code)).
- **A browser login's port.** While `devvm agent login` waits for Codex's or opencode's browser login to ChatGPT, devvm forwards this machine's `localhost:1455`, and `localhost:1457` when it's free, to the agent's login server in the VM, so any program on this machine that connects in that window reaches the VM's server and gets what it answers. The forward ends with the login, and `--device-code` logs in without one ([logging in](../internals/agents.md#logging-in)).
- **VS Code's and Cursor's relays.** Over Remote-SSH, which `devvm code` and `devvm cursor` open, the editor forwards the ports that programs in the VM listen on, and it answers git's prompts with your GitHub sign-in. devvm turns both off in the VM's settings for each editor each time it sets the VM up, but the VM can turn them back on, and its settings take precedence over your own on this machine. The editor's extensions also run in the VM, its AI features among them, and they may get the editor's sign-ins there, such as Copilot's GitHub token or your Cursor login. Recent Cursor runs its Agent in the VM with your sign-in in memory ([Cursor's Agent](../using/ssh.md#cursors-agent)). So don't open a VM you don't trust with `devvm code` or `devvm cursor`, or sign out of the editor's AI features and its GitHub sign-in first ([VS Code and Cursor](../using/ssh.md#vs-code-and-cursor)).
- **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
- **A nested project replaced through its parent folder's VM.** A project with a VM of its own inside a folder with another VM is in both VMs, so code in the parent folder's VM can replace the nested project folder with a link, such as one to your home folder, which the nested VM would mount at its next start. devvm warns each time it makes or opens such a nested VM, naming the parent folder's VM. It checks the nested folder, by its path and by the folder itself, just before it starts the nested VM and again once the VM runs, and it refuses the start or stops the VM again when the folder was replaced. On macOS the VM mounts the folder itself rather than its path, so it never mounts what a link points to, even when the folder is put back before devvm checks again. On Linux the VM mounts the folder by its path, so code that replaces the folder for the moment the VM's backend mounts it and puts it back before devvm checks again stays unseen, and the VM keeps what the link pointed to until its next start. Keep a nested project that you don't want the parent folder's VM to reach out of the parent folder ([a nested project replaced](../using/vms.md#a-nested-project-replaced)).
- **A nested project replaced through its parent folder's VM.** A project with a VM of its own inside a folder with another VM is in both VMs, so code in the parent folder's VM can replace the nested project folder with a link, such as one to your home folder, which the nested VM would mount at its next start.
- devvm warns each time it makes or opens such a nested VM, naming the parent folder's VM. It checks the nested folder, by its path and by the folder itself, just before it starts the nested VM and again once the VM runs, and it refuses the start or stops the VM again when the folder was replaced.
- On macOS the VM mounts the folder itself rather than its path, so it never mounts what a link points to, even when the folder is put back before devvm checks again.
- On Linux the VM mounts the folder by its path, so code that replaces the folder for the moment the VM's backend mounts it and puts it back before devvm checks again stays unseen, and the VM keeps what the link pointed to until its next start. Keep a nested project that you don't want the parent folder's VM to reach out of the parent folder ([a nested project replaced](../using/vms.md#a-nested-project-replaced)).
- **Set-id files on Linux hosts.** Root in a VM can set the set-user-id bit on a file in the project folder, and on Linux hosts that bit reaches the host, so the file runs as its owner for whoever runs it. devvm names such files when it makes a VM and once a VM is stopped, but not at a launch into a running VM, and [Troubleshooting](../using/troubleshooting.md#devvm-names-set-id-files) says how to clear them. Don't run programs from the project folder outside the VM ([set-id files](../internals/security.md#set-id-files-on-linux-hosts)).
- **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. 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)).
- **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 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
@@ -127,14 +142,17 @@ The VM can write anything in the project folder, and devvm locks only `.git`. An
- **Project code and binaries.** `npm install`, `make`, a test run or `./bin/tool` on this machine runs whatever the VM wrote. Run them in the VM instead.
- **Symlinks out of the folder.** The VM can create a link in the project folder that points at a file of yours, such as `~/.ssh/id_ed25519`. A program on this machine that follows it, such as an upload, an archive or an agent reading files, reads your file instead. devvm itself never follows a link out of the folder.
- **Backdoors in code you merge.** Treat the VM's commits as an untrusted contributor's, and review them before you merge, deploy or publish them.
- **Secrets in the project folder.** A `.env` file, a project `.npmrc` or a cloud key in the folder is in the VM. On the allowlist tier it can reach only the hosts on the allowlist, on the internet tier any public host, and on the open tier anywhere. Keep secrets out of the project folder, or use `--clone`, which copies no untracked files into the VM. The same goes for your agents' config folders, which [keys devvm can't tell apart](#secrets-and-keys-the-vm-may-use) covers ([mounts](../using/coding-agents.md#mounts)).
- **Secrets in the project folder.** A `.env` file, a project `.npmrc` or a cloud key in the folder is in the VM. On the allowlist tier it can reach only the hosts on the allowlist, on the internet tier any public host, and on the open tier anywhere. Keep secrets out of the project folder, or use `--clone`, which copies no untracked files into the VM but those of a `git stash -u` entry, though it copies your repo's hooks as they are and a folder of repos' own files ([what's copied](../using/clone.md#whats-copied)). The same goes for your agents' config folders, which [keys devvm can't tell apart](#secrets-and-keys-the-vm-may-use) covers ([mounts](../using/coding-agents.md#mounts)).
- **What you paste in.** An image, a PDF or a file you send with `devvm paste` is a file in the VM, which anything in the VM can read, as it reads the project folder. devvm reads only an image, a PDF or a copied file's reference from your clipboard, never text, asks before sending a copied file, showing its path, refuses a link anywhere in a copied file's path but the system's own, and lets nothing the VM says onto your clipboard, so paste nothing you wouldn't put in the folder ([pasting images](../using/coding-agents.md#pasting-images)).
### The network
- **Allowed hosts.** Anything an allowed host accepts can carry data out. github.com accepts a push from anyone with an account, including an attacker with an account of their own, and the npm registry accepts packages the same way. Keep allowlists short, narrow a host to the methods and paths a VM needs ([rules by method and path](network.md#rules-by-method-and-path)), and check what a VM reached with `devvm network log`. A rule by method and path judges each request's method and path, not its body or its other headers, so what an allowed request sends still reaches the host. A deny of `git-receive-pack` on github.com, for example, blocks pushes over HTTPS alone: a push over ssh to `github.com:22`, if a rule allows it, and the commits that GitHub's Git Data API makes at `api.github.com` with a GitHub token go on.
- **What your secrets allow.** A VM can push with a GitHub token it may use and spend Claude quota. Use a fine-grained GitHub token, bind only the secrets a VM needs, and deny the methods a VM mustn't use, such as `devvm network deny api.github.com --method POST,PUT,PATCH,DELETE`.
- **Your claude.ai connectors.** With your Claude subscription's login, a VM with Claude Code can use every connector you added in claude.ai, as Claude Code on this machine can, so code in the VM can read what they reach, such as your mail or documents, and act through them. Disconnect the connectors you don't want VMs to use, or keep them from a VM with `devvm network deny mcp-proxy.anthropic.com`, or from every VM with `-g`, which works on every tier but open ([Claude Code login](../using/coding-agents.md#claude-code-login)).
- **Open VMs.** An open VM, because you chose open or passed `--network open`, reaches everything this machine can, including its services on `localhost`, such as other VMs' ports, dev servers and databases, and your local network, directly and through its proxy, which applies no rules for it. Its proxy still puts its secrets in, so it can spend them on their hosts as any VM can, but it holds only their placeholders, as every VM does. A VM started outside devvm, such as with `limactl start`, or one running since before `devvm network` gave it a confined tier, runs unconfined in the same way until devvm restarts it confined ([the self-check](../internals/network.md#the-self-check)).
- **Your browser.** Programs in a VM can open URLs in this machine's browser, and a page that a VM serves on a forwarded port runs in your browser like any other. From there it can reach the internet past the VM's tier, and your services on `localhost`. Browsers send a host's cookies to every port on it, so a server in the VM on a forwarded `localhost` port gets the cookies of the apps you use on `localhost`, such as a local dashboard you're signed in to.
- **A VM's ssh port in your browser.** Root in a VM can make its ssh port on this machine answer as a web server, so devvm puts every VM's ssh on one of the ports that every browser refuses, and a VM that forwards no ports gets no page from your browser that way. A browser you've told to allow those ports, such as with Chrome's `--explicitly-allowed-ports` or Firefox's `network.security.ports.banned.override`, reaches it again. Another user on this machine can also take all 17 of those ports, so none of your VMs starts until they let one go ([too many VMs at once](../using/troubleshooting.md#too-many-vms-at-once)).
- **Remote forwards you add.** A `RemoteForward` in your ssh config, or an `ssh -R` you type, makes this machine connect to whatever it names for the VM. devvm's ssh entries can't turn off a `RemoteForward` of yours without also refusing an `ssh -R` you type. The VM's ssh server refuses a remote forward on any address outside `127.77.0.0/16`, the range devvm keeps for links between VMs, so one on the VM's `localhost`, which `ssh -R` asks for by default, is refused. Root in the VM can change that setting, though, and the server allows a forward on an address in `127.77.0.0/16` for anyone it lets in. A forward you ask for by a host name that begins with `127.77.` binds whatever address that name resolves to in the VM. So keep remote forwards out of `Host *`, and don't forward into a VM you don't trust ([ssh into VMs](../internals/security.md#ssh-into-vms)).
- **A company CA you add.** A [company CA](../using/settings.md#a-companys-ca) that you put in `~/.config/devvm/ca` can read the TLS traffic of every VM, whatever its tier, as it can this machine's, and the proxy trusts it for its own connections. Only that folder adds CAs to the proxy, and nothing a VM sends can.
@@ -143,5 +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, 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).
+73 -12
View File
@@ -4,7 +4,13 @@ explainer: Keep code in the VM out of your .git
weight: 2
---
The project folder is read-write in the VM, so without protection anything in the VM could add a git hook, or set `core.fsmonitor`, `core.hooksPath` or `core.sshCommand` in `.git/config`, and your next git command on this machine would run it. On macOS, devvm locks the git hooks and config with a flag that even root in the VM can't clear, so nothing the VM does runs through them on this machine. On Linux, devvm makes them read-only in the VM's own view of the folder, which root in the VM can't change either ([Linux hosts](#linux-hosts)). It does the same for each git repo nested in the folder that it has found, such as the repos of a folder that holds several, but a repo or a submodule that the VM adds while it runs is git's to use before devvm finds it ([nested repos](#nested-repos), [not covered](#not-covered)). Only [`--clone`](../using/clone.md) keeps the VM's code away from git on this machine.
The project folder is read-write in the VM, so without protection anything in the VM could add a git hook, or set `core.fsmonitor`, `core.hooksPath` or `core.sshCommand` in `.git/config`, and your next git command on this machine would run it. devvm protects them:
- **On macOS,** devvm locks the git hooks and config with a flag that even root in the VM can't clear, so nothing the VM does runs through them on this machine.
- **On Linux,** devvm makes them read-only in the VM's own view of the folder, which root in the VM can't change either ([Linux hosts](#linux-hosts)).
- **Nested repos:** it does the same for each git repo nested in the folder that it has found, such as the repos of a folder that holds several, but a repo or a submodule that the VM adds while it runs is git's to use before devvm finds it ([nested repos](#nested-repos), [not covered](#not-covered)).
Only [`--clone`](../using/clone.md) keeps the VM's code away from git on this machine.
Every new VM gets `.git` protection. `--no-git-protect` creates a VM without it, and [`devvm git-protect`](#turning-it-on-or-off) changes it later. [How it works › .git protection](../internals/git-protection.md) lists what devvm locks and when it checks the locks again.
@@ -23,6 +29,12 @@ devvm git-protect on
## Turning it on or off
```sh
devvm git-protect # show this folder's VM's protection: on, off or clone
devvm git-protect off # take the locks off
devvm git-protect on # lock .git as it is now
```
`devvm git-protect` shows the VM's protection, which is `on`, `off`, or `clone` for a [`--clone`](../using/clone.md) VM, which mounts no `.git`. `devvm git-protect on` or `off` changes it at once when the VM is stopped. A running VM could race the locks, so for a running VM devvm saves your choice and asks in a terminal whether to restart the VM now, which stops anything running in it. If you answer no, or there's no terminal, or you pass `--no-input`, devvm says it saved the choice. It applies the choice the next time it finds the VM stopped: at the restart you agreed to, at `devvm stop`, at `devvm restart`, or, when the VM was stopped some other way, at the next launch, before the VM starts. Until then, `devvm git-protect` shows the protection the VM has, and a later choice replaces the saved one. Launches lock only a stopped VM for the same reason.
- `on` locks `.git` as it is now and takes it as yours, so a `.git` that was replaced since the last lock isn't reported, and the next launches compare with this one. It reports what [a lock can't stop](../internals/git-protection.md#what-a-lock-cant-stop) and what's [not covered](#not-covered), as devvm did when it made the VM. If the folder has no `.git` yet, devvm locks it on the first launch after one appears. The locks don't reach a submodule or a nested repo that the VM adds while it runs, so git on this machine runs what that repo's config and hooks say, such as its `core.fsmonitor`, until `devvm stop` or the next launch that finds the VM stopped names it and locks it ([not covered](#not-covered)).
@@ -43,15 +55,30 @@ On an existing VM, devvm ignores `--no-git-protect` and warns you. A `--clone` V
### VMs that were strict
In devvm 0.1.0 and 0.1.1-rc.1, `devvm git-protect strict` sets `diff.ignoreSubmodules = all` in the locked `.git/config`, so that `git status` and `git diff` on this machine skip the submodules the VM adds. That can't keep git on this machine out of them. A `.gitmodules` line that the VM writes, such as `ignore = none`, makes `git status` enter a submodule again, and `git add -A`, `git add -u`, `git describe --dirty`, `git diff-index`, `git diff-files`, `git fetch` and `git pull` enter one whatever the setting says, as does `--ignore-submodules` on the command line. So `devvm git-protect` takes only `on` and `off`, and `devvm git-protect strict` is a usage error that points to `devvm clone on`, which keeps the VM's code away from git on this machine.
`devvm git-protect` takes only `on` and `off`. `devvm git-protect strict` is a usage error that points to `devvm clone on`, which keeps the VM's code away from git on this machine.
An earlier devvm's `strict` set `diff.ignoreSubmodules = all` in the locked `.git/config`, so that `git status` and `git diff` on this machine skipped the submodules the VM adds. That couldn't keep git on this machine out of them. A `.gitmodules` line that the VM writes, such as `ignore = none`, makes `git status` enter a submodule again, and `git add -A`, `git add -u`, `git describe --dirty`, `git diff-index`, `git diff-files`, `git fetch` and `git pull` enter one whatever the setting says, as does `--ignore-submodules` on the command line.
A VM that was made strict shows as `on` at once, in `devvm ls`, `devvm git-protect` and its `--json`, and its locks stay as they are while it runs. The first time devvm finds it stopped, at a launch, at `devvm stop`, or at `devvm clone on`, or when devvm undoes a `devvm clone off` that didn't finish, devvm takes `diff.ignoreSubmodules = all` out of the `.git/config` of the folder's own repo and of each nested repo the VM protected, unlocking each file for the moment and locking it again. Then it records the VM as `on` and says so once, unless you chose `devvm git-protect off` while it ran, which it applies next. `devvm git-protect on` and `off` and `devvm rm` take the setting out the same way, without saying so.
strict doesn't record a value that the setting had before it sets its own, so devvm can't put one back. It takes out only the value `all`, so a value that you set since, such as `none` or `dirty`, stays. devvm leaves the setting alone in a repo whose `.git` isn't the one it recorded, because strict never set it there: a `.git` that the VM replaced, which devvm names, a nested repo that it finds for the first time at that check, and every repo of a VM it has no record of, such as one that `devvm adopt` moved. When such a config sets `all`, devvm names it once. If you didn't set it, run `devvm stop` and `devvm git-protect off`, then `git config --file .git/config --unset-all diff.ignoreSubmodules '^all$'` in that repo, and `devvm git-protect on`, which locks `.git` again as it is then. On a Linux host that watches `.git`, it also leaves a config that changed since the check read it, which the next check names.
devvm leaves the setting where it can't tell that it set it, and names what it leaves:
A `.git/config` that another VM's protection also keeps locked keeps the setting, because unlocking it would let that VM change the file if it runs, and devvm names the file and that VM at each launch that finds this VM stopped. devvm takes the setting out at such a check once the other VM no longer keeps the file locked. To take it out yourself, stop both VMs first, with `devvm stop` in this VM's folder and in the other VM's, because a running VM could change the file while it's unlocked, and a launch into a running VM locks nothing. Then, in that repo, run `chflags nouchg .git/config` on macOS, and `git config --file .git/config --unset-all diff.ignoreSubmodules '^all$'`. The next launch of either VM finds it stopped and locks the file again, and on Linux the other VM's watch names the change.
- strict doesn't record a value that the setting had before it sets its own, so devvm can't put one back. It takes out only the value `all`, so a value that you set since, such as `none` or `dirty`, stays.
- devvm leaves the setting alone in a repo whose `.git` isn't the one it recorded, because strict never set it there: a `.git` that the VM replaced, which devvm names, a nested repo that it finds for the first time at that check, and every repo of a VM it has no record of, such as one that `devvm adopt` moved. When such a config sets `all`, devvm names it once.
- On a Linux host that watches `.git`, it also leaves a config that changed since the check read it, which the next check names.
- If git can't change a config, devvm names it, and `git status` and `git diff` on this machine go on skipping that repo's submodules until you take the setting out yourself.
- A `.git/config` that another VM's protection also keeps locked keeps the setting, because unlocking it would let that VM change the file if it runs, and devvm names the file and that VM at each launch that finds this VM stopped. devvm takes the setting out at such a check once the other VM no longer keeps the file locked.
If git can't change a config, devvm names it, and `git status` and `git diff` on this machine go on skipping that repo's submodules until you take the setting out yourself: stop the VM, run `devvm git-protect off`, run `git config --file .git/config --unset-all diff.ignoreSubmodules '^all$'` in that repo, then run `devvm git-protect on`.
To take the setting out of a repo yourself, if you didn't set it:
```sh
devvm stop # in this VM's folder, and in the other VM's when another VM locks the file too
devvm git-protect off
git config --file .git/config --unset-all diff.ignoreSubmodules '^all$' # in that repo
devvm git-protect on # lock .git again as it is then
```
Stop both VMs when another VM keeps the file locked too, because a running VM could change the file while it's unlocked, and a launch into a running VM locks nothing. In that case, run `chflags nouchg .git/config` on macOS in place of `devvm git-protect off`, and the next launch of either VM finds it stopped and locks the file again, and on Linux the other VM's watch names the change.
## When devvm reports .git
@@ -69,13 +96,29 @@ Every launch of an existing VM, and `devvm stop`, check `.git` again, and devvm
## Nested repos
A folder can hold git repos of its own besides its submodules, such as `ws/repo-a` and `ws/repo-b` in a folder `ws`, whether `ws` is a repo itself or only a folder of repos. The VM can write all of them, and git on this machine runs what their `.git` holds when you run git there, so devvm protects each one it finds as it protects the folder's own `.git`: it locks them on macOS, makes them read-only in the VM on Linux, and watches them on a Linux host that can't lock. It finds them when it creates the VM, at each launch that finds the VM stopped and at `devvm stop`, by looking up to four folders below the project folder for anything named `.git` (on macOS, `.GIT` as well). It doesn't look in the folders that package managers and build tools fill, `node_modules`, `vendor`, `.venv`, `__pycache__` and `.terraform`, nor in a folder on another disk, and it protects the first 100 it finds and names the rest, at every check. A launch into a running VM doesn't look again, and it doesn't check the nested repos either, so they're checked at the next launch that finds the VM stopped, or at `devvm stop`.
A folder can hold git repos of its own besides its submodules, such as `ws/repo-a` and `ws/repo-b` in a folder `ws`, whether `ws` is a repo itself or only a folder of repos. The VM can write all of them, and git on this machine runs what their `.git` holds when you run git there, so devvm protects each one it finds as it protects the folder's own `.git`: it locks them on macOS, makes them read-only in the VM on Linux, and watches them on a Linux host that can't lock. It finds them this way:
- **When:** when it creates the VM, at each launch that finds the VM stopped and at `devvm stop`. A launch into a running VM doesn't look again, and it doesn't check the nested repos either, so they're checked at the next launch that finds the VM stopped, or at `devvm stop`.
- **Where:** up to four folders below the project folder, for anything named `.git` (on macOS, `.GIT` as well). It doesn't look in the folders that package managers and build tools fill, `node_modules`, `vendor`, `.venv`, `__pycache__` and `.terraform`, nor in a folder on another disk.
- **How many:** it protects the first 100 it finds and names the rest, at every check.
What [still works](#what-still-works) and what doesn't is the same in a nested repo as in the folder's own: `git config`, `git remote add` and hook installers fail there on macOS, so run them with protection off. devvm keeps protecting a nested repo for as long as anything is at its `.git`, even when that `.git` no longer looks like a repo's, because the VM can change it back at any time.
When you don't need the VM to write your working trees, `devvm --clone` in a folder of repos keeps the VM out of all of them instead. The VM gets a clone of each repo you choose, at the same path, and mounts nothing of this machine, so it can't reach any repo's working tree or `.git` here, and none of what this page describes applies to it ([folders of repos](../using/clone.md#folders-of-repos)). You get its work back with `devvm clone fetch`.
When you don't need the VM to write your working trees, `devvm --clone` in a folder of repos keeps the VM out of all of them instead:
devvm can't protect a repo before it has found it. A repo the VM makes in the folder while it runs, by cloning one or by making a `.git` in a folder of yours, is git's repo for that folder from the moment it's there: your `git status` in the folder, and the shell prompts and editors that run git as you open it, run what its config says. devvm names such a repo only at the next launch that finds the VM stopped, or at `devvm stop`, with the settings in its config and the hooks that run programs, and then locks it as it is, so check what it names before you run git there. A repo the VM makes more than four folders down, or in a folder devvm doesn't look in, is never named, only counted where devvm walks the folder for set-id files on Linux. On Linux the VM can also move a nested repo's folder aside and put another repo in its place while it runs, which devvm names only if it's still in place when the VM stops ([Linux hosts](#linux-hosts)). So when you run git in a folder of a VM's project while the VM runs, the protection holds only for the repos devvm has already found.
```sh
cd ws && devvm --clone # a VM with its own clone of each repo you choose, mounting none of them
devvm clone fetch # bring the VM's work back
```
The VM gets a clone of each repo you choose, at the same path, and mounts nothing of this machine, so it can't reach any repo's working tree or `.git` here, and none of what this page describes applies to it ([folders of repos](../using/clone.md#folders-of-repos)). You get its work back with `devvm clone fetch`.
devvm can't protect a repo before it has found it, so when you run git in a folder of a VM's project while the VM runs, the protection holds only for the repos devvm has already found:
- A repo the VM makes in the folder while it runs, by cloning one or by making a `.git` in a folder of yours, is git's repo for that folder from the moment it's there: your `git status` in the folder, and the shell prompts and editors that run git as you open it, run what its config says.
- devvm names such a repo only at the next launch that finds the VM stopped, or at `devvm stop`, with the settings in its config and the hooks that run programs, and then locks it as it is, so check what it names before you run git there.
- A repo the VM makes more than four folders down, or in a folder devvm doesn't look in, is never named, only counted where devvm walks the folder for set-id files on Linux.
- On Linux the VM can also move a nested repo's folder aside and put another repo in its place while it runs, which devvm names only if it's still in place when the VM stops ([Linux hosts](#linux-hosts)).
### Bare repos
@@ -105,15 +148,27 @@ The lock covers `.git`, and the VM can still put things elsewhere that git on th
## Linux hosts
On Linux, devvm runs each VM's QEMU in a user namespace of its own, without root, and there it makes the paths that macOS's flag would lock read-only: the hooks and config of `.git` and of its submodules, and the rest of [what's locked](../internals/git-protection.md#whats-locked). The VM reaches the project folder only through QEMU, so root in the VM gets `Read-only file system` when it writes one of them, and `Device or resource busy` when it renames or removes one, or renames `.git` itself. A [nested repo](#nested-repos)'s own folder isn't pinned, so the VM can still rename the folder, `.git` and all, and put another repo in its place, which devvm reports at the next check as a replaced `.git`. Nothing changes on this machine: your own git commands write `.git/config` as usual, and the read-only view ends when the VM stops. `devvm git-protect` works as it does on macOS, and a change to a running VM's protection applies at its next start.
On Linux, devvm runs each VM's QEMU in a user namespace of its own, without root, and there it makes the paths that macOS's flag would lock read-only: the hooks and config of `.git` and of its submodules, and the rest of [what's locked](../internals/git-protection.md#whats-locked). The VM reaches the project folder only through QEMU, so root in the VM gets `Read-only file system` when it writes one of them, and `Device or resource busy` when it renames or removes one, or renames `.git` itself.
Start VMs with devvm. A VM that `limactl start` starts runs without the read-only view, and so does one whose view went for another reason, so each launch of a running VM, and `devvm stop`, check that the VM still can't rename `.git` and still sees its hooks and config read-only, and name what it doesn't: run `devvm restart` then. If devvm's own process that runs the VM ends, the VM ends with it at once, as if you pulled its power, so it never runs without the view.
- A [nested repo](#nested-repos)'s own folder isn't pinned, so the VM can still rename the folder, `.git` and all, and put another repo in its place, which devvm reports at the next check as a replaced `.git`.
- Nothing changes on this machine: your own git commands write `.git/config` as usual, and the read-only view ends when the VM stops.
- `devvm git-protect` works as it does on macOS, and a change to a running VM's protection applies at its next start.
> [!WARNING]
> Start VMs with devvm. A VM that `limactl start` starts runs without the read-only view, and so does one whose view went for another reason, so each launch of a running VM, and `devvm stop`, check that the VM still can't rename `.git` and still sees its hooks and config read-only, and name what it doesn't: run `devvm restart` then. If devvm's own process that runs the VM ends, the VM ends with it at once, as if you pulled its power, so it never runs without the view.
Because a lock in the VM's view covers one name of a file, devvm also [watches](#when-devvm-names-a-change) `.git` as a Linux host without locks does, and names what changed at each launch that finds the VM stopped and at `devvm stop`. That includes your own changes, such as a `git remote add` or `git push -u`.
### When git on this machine replaces a locked file
The VM sees your changes, because its view is the same folder. A git command on this machine that writes `.git/config`, such as `git config`, `git remote add` or `git push -u`, writes a new file and renames it over the old one, and the new file isn't read-only in the VM until devvm locks it again. devvm watches the folders of what it locks, so it locks the new file within milliseconds, but until then the VM can change it, replace it with a file of its own, which devvm then locks as yours, or open it to write it later, which the lock doesn't stop. A VM running code that watches for that moment can use it, so this is a real gap whenever you change a locked file on this machine while the VM runs. devvm doesn't stop it, but it names it: at `devvm stop`, or at the next launch when the VM stopped another way, devvm names each file it locked again, once however often it happened, and the watch names each one whose contents changed. If devvm couldn't record whether its locks held while the VM ran, it says so then, and you should check `.git`'s hooks and config yourself. Check what it names before you run git in the folder, or stop the VM before you change its `.git` on this machine.
The VM sees your changes, because its view is the same folder. A git command on this machine that writes `.git/config`, such as `git config`, `git remote add` or `git push -u`, writes a new file and renames it over the old one, and the new file isn't read-only in the VM until devvm locks it again. devvm watches the folders of what it locks, so it locks the new file within milliseconds, but until then the VM can change it, replace it with a file of its own, which devvm then locks as yours, or open it to write it later, which the lock doesn't stop. A VM running code that watches for that moment can use it, so this is a real gap whenever you change a locked file on this machine while the VM runs.
devvm doesn't stop it, but it names it:
- At `devvm stop`, or at the next launch when the VM stopped another way, devvm names each file it locked again, once however often it happened, and the watch names each one whose contents changed.
- If devvm couldn't record whether its locks held while the VM ran, it says so then, and you should check `.git`'s hooks and config yourself.
Check what it names before you run git in the folder, or stop the VM before you change its `.git` on this machine.
### Hard links
@@ -145,7 +200,13 @@ On a Linux host that can't lock, each launch of a VM that mounts a folder with a
### When devvm names a change
On a Linux host that can't lock, devvm can't stop the VM from changing `.git`, and on one that locks, the VM can change a file that git on this machine [replaced](#when-git-on-this-machine-replaces-a-locked-file), but devvm notices the change afterwards on both. When devvm creates a VM, it records a hash of each path that a lock would cover on macOS, which are the hooks in `.git/hooks`, `.git/config` and the rest of [what's locked](../internals/git-protection.md#whats-locked), submodules' and [nested repos'](#nested-repos) included. It also hashes `.git/commondir`, whether it's there or not, and what the config hands over to the project folder: the files that an `include.path` leads to, and the hooks folder that `core.hooksPath` names, such as husky's `.husky`. Each launch that finds the VM stopped, and `devvm stop`, hash them again and name every path that changed since the last check, such as `.git/config` and `.git/hooks/pre-commit`. A warning names ten paths at most, and then how many more changed. The same checks report what a lock can't stop either, as they do on macOS: a `.git` that was replaced, a `commondir`, a repo or submodule that appeared, and includes, hook links and a `core.hooksPath` into the project folder ([not covered](#not-covered)). A launch of a VM that's already running checks nothing, so run `devvm stop` when you want the check. A VM that devvm has no hashes for yet, such as one that an older devvm made, records them at its first check and names nothing.
On a Linux host that can't lock, devvm can't stop the VM from changing `.git`, and on one that locks, the VM can change a file that git on this machine [replaced](#when-git-on-this-machine-replaces-a-locked-file), but devvm notices the change afterwards on both. When devvm creates a VM, it records a hash of each of these:
- each path that a lock would cover on macOS, which are the hooks in `.git/hooks`, `.git/config` and the rest of [what's locked](../internals/git-protection.md#whats-locked), submodules' and [nested repos'](#nested-repos) included
- `.git/commondir`, whether it's there or not
- what the config hands over to the project folder: the files that an `include.path` leads to, and the hooks folder that `core.hooksPath` names, such as husky's `.husky`
Each launch that finds the VM stopped, and `devvm stop`, hash them again and name every path that changed since the last check, such as `.git/config` and `.git/hooks/pre-commit`. A warning names ten paths at most, and then how many more changed. The same checks report what a lock can't stop either, as they do on macOS: a `.git` that was replaced, a `commondir`, a repo or submodule that appeared, and includes, hook links and a `core.hooksPath` into the project folder ([not covered](#not-covered)). A launch of a VM that's already running checks nothing, so run `devvm stop` when you want the check. A VM that devvm has no hashes for yet, such as one that an older devvm made, records them at its first check and names nothing.
devvm names a change only after it happened, so git on this machine may already have run a changed hook or read a changed config. devvm can't tell who made a change, so it also names your own, such as a `git remote add` or `git push -u` that you ran on this machine. When it names a path that you didn't change, check it before you run git in the folder:
Loaded 100 of 958 files, more files were not shown because too many files have changed in this diff. Show more