18 Commits
Author SHA1 Message Date
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 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 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 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 2151d1b959 feat(proxy): capture agents' logins at their token endpoints
A login that Codex or opencode makes inside a VM goes to devvm's agent
store, and the VM gets only placeholders. Every VM's proxy intercepts
OpenAI's token endpoint (auth.openai.com/oauth/token, listed in its
config's captures for Codex and opencode on every tier), and its host
joins the allowlist of a VM whose image has either agent. This is the
proxy's first response rewriting (ModifyResponse, stdlib only).

- proxy: Config.Captures, IO.Capture (Capturer: Request, Response),
  Exchange; a POST to the endpoint's path (cleaned, without ;params, any
  case) is read (64 KiB) and its 2xx reply (1 MiB) goes to IO.Capture,
  never to the VM; the VM gets IO.Capture's reply with only Content-Type,
  Cache-Control, Pragma and Date; a "login" event names the agent; what
  can't be read gets 502, logged as a refused block, values never logged.
- agentlogin: Endpoints, Pick (the User-Agent tells opencode, Bun's, from
  Codex), File.CaptureRequest and File.Capture under lockLogin: Codex's
  auth.json (tokens, account_id, last_refresh; the id_token->API-key
  exchange's key in OPENAI_API_KEY, the VM's id_token placeholder swapped
  for the store's on the way out), opencode's auth.json openai entry,
  Claude Code's .credentials.json (capturer only: no VM captures Claude
  yet). A code replaces the login, a refresh adds to it (newest refresh
  token kept). The VM's reply: the bindings' placeholders, refresh token
  devvm-proxy-managed, expiry 2099.
- secrets: Store.CaptureRequest, Store.Capture (folder private, out of
  backups), the token endpoints' hosts in secrets.policy.
- netpolicy: Capturer (devvm _proxy's IO.Capture: the VM's salt, its
  agent, the bindings written again at once); devvm network log shows
  login lines.
- e2e (network): a fake token endpoint behind a company proxy of the
  run's own, with the run's CA; the store gets the real tokens and key,
  the VM placeholders and no refresh token, no log holds a value, the
  next launch gets the login as placeholders.
- Docs: Logins made in a VM (internals/network.md), coding-agents.md,
  safety/network.md (the account swap), the proxy's README.

Security review (security-audit skill, plus an independent read):
- Fixed: a VM could spell the path another way (/oauth/token;x) and get
  real tokens uncaptured: path parameters dropped before matching.
- Fixed: another path on the host could hand the VM tokens: any 2xx from
  a token endpoint's host naming access_token, refresh_token or id_token
  is refused, whatever its type (web pages pass unread); 101 refused.
- Fixed: 1xx replies (103 with Set-Cookie) reached the VM before
  ModifyResponse: dropped on token endpoints' hosts.
- Fixed: Set-Cookie and other headers on a captured reply reached the
  VM: only four headers kept.
- Fixed: an error reply to the exchange could quote the real id_token:
  it reaches the VM as its OAuth error code alone.
- Fixed: a captured request went upstream under the VM's raw path and
  query: it goes to the endpoint's own path, no query.
- Fixed: repeated form or JSON fields, which devvm and the endpoint
  could read apart, are refused.
- Fixed: captures depended on the image's agents, so a self-installed
  Codex logged in uncaptured: every VM's proxy captures at the endpoint.
- Fixed: at most 8 bodies read whole at once.
- Fixed: the VM's refresh with its managed refresh token is answered
  from the store, so a VM's Codex isn't logged out after 8 days.
- Fixed: a login saved whose bindings write failed reached the VM as a
  502: it reaches the VM, the error is logged.
- Accepted, documented: any VM with the agent can replace the store's
  login (an account of its choosing); on the open tier a program can go
  around the proxy; Claude Code's own /login in a VM isn't captured.
- Unconfirmed: domain fronting through a sibling OpenAI host whose
  tunnel isn't intercepted (depends on the CDN routing on Host).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 17:22:55 -07:00
w3cjandClaude Opus 5.5 76f2021b65 docs: network tiers throughout, and the tools that ignore the proxy
Every page that spoke of network policy as on or off now speaks of the
four tiers: confined (internet, allowlist, none) or open. safety/network.md
is titled Network tiers, its company-proxy subsection is "Open VMs and
builds", and a new section lists tools that ignore HTTP(S)_PROXY on the
open tier (Node's fetch without NODE_USE_ENV_PROXY, aiohttp without
trust_env, Go programs with their own transport, Java, the Docker daemon).
internals/lima.md says how each tier reaches its proxy; design.md names
link_tier_mismatch and group_tier_mismatch; the help texts of stop,
network log, layer new, limactl and _proxy drop "network policy".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 17:06:49 -07:00
w3cjandClaude Opus 5.5 ca8a91305b fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what)
when it may not be a message (replacing fail and the direct Die calls in
cli), and a.env returns its failure. checkLayout returns its error from the
root's PersistentPreRunE. execute alone prints a failure (showFailure): a
backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces
DieLogged), a message as it is, else what failed or output_failed, with a
corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130.

Die is now the UI's own die, for where no command can return: a question
without an answer, a run log that can't be opened. Error prints nothing once
the run is interrupted.

After INT, TERM or HUP, Main waited only for the logged command and then ran
the cleanups while the command's own code still ran. It now also waits for
the command to return, up to returnGrace (2 s), when there are cleanups to
run; a run without cleanups ends at once, so the proxy and the other
background processes still stop as soon as they are told to. A start's
undoStart stays registered once interrupted (interruptCleanup), as the
cleanups now run after the start returned.

Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old
ordering), TestSignalsWaitForAStuckCommandAWhile,
TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure;
DieLogged's tests are ErrorLogged's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:42:20 -07:00
w3cjandClaude Opus 5.5 e132a29b5a refactor(cli): one per-run app holds the run's services
NewRoot makes one app for the run's UI and hands it to every command.
The app makes each service the first time a command asks for it and
keeps it, or its error, for the rest of the run: devvm's folders
(dirs), a test build's overrides, the secrets store, the backends'
registry, the shared tools, the VM environment (vmEnv) and the image
builder of the backend new VMs get (builder). The retention that runs
before a command and the command itself share them.

- paths.FromEnv: 23 of 24 calls go through a.dirs; partNames, which the
  parser's flag and word checks call before any command, keeps its own.
- The registry is made once (8 newRegistry calls and newEnv's).
- builder(u) (6 calls) and cli's newBuilder are gone: a.builder and the
  per-backend builders in images, space and gc are vm.Env.Builder,
  exported, the only builder. setup's feature choice takes a build.Env
  of its folders and prompts alone.
- The shared tools are made once (newTools and vm.NewEnv's), and the
  secrets store once (companyProxy's, newTools', vm.NewEnv's and
  _proxy's): vm.NewEnv takes the run's tools and store.
- withEnv (46 calls) is a.env; autoRetain, retainOrphans and gc
  --orphans use the run's VM environment.
- thisHost and readOverrides' other callers read the overrides once
  (a.host); space and gc --caches time out on the registry's host.

TestAppMakesEachServiceOnce checks that one run makes each service once
and that the VM environment and builder share the run's registry and
tools; TestAppKeepsAFailure that a failure is kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:53:51 -07:00
w3cjandClaude Opus 5.5 329e31be1d refactor(secrets): the proxy looks secrets up in-process, from one versioned bindings file
The proxy no longer runs devvm secret get for a value: proxy.IO.Secret,
which devvm _proxy sets to secrets.Store.Get, looks a binding's value up
in the proxy's own process (Keychain, devvm's secrets folder, or the
agent's login file), so internal/proxy stays standard library only.
Config.SecretCmd (secret_cmd) and the hidden devvm secret get command go,
with secret_to_terminal and secret_read_failed; Main refuses a config
with secrets and no IO.Secret.

One binding type, proxy.Binding, with kind secret|login and a login's
agent, in proxy.BindingList ({"version": 1, "bindings": [...]}), written
by secrets.Store (Encode) and read by the proxy and RefreshFiles with
proxy.ReadBindings (private regular file, no link, 1 MiB, version and
kinds checked; an unreadable file has no bindings). It replaces
proxy.binding, secrets.binding and agentlogin.Binding; the kind replaces
the name-prefix classifiers in proxy.ttlOf, secrets.loginOf and
RefreshFiles' Lookup check; proxy.InterceptLines replaces
agentlogin.Hosts and RefreshFiles' host loop.

agentlogin's user-actionable errors are typed (ErrCodexNoKey,
ErrCodexNoChatGPT, RefreshError) and secrets maps them to messages:
codex_no_key, codex_no_chatgpt, codex_refresh_failed,
opencode_refresh_failed, and login_read_failed for the rest.

Tests: proxy TestSecretValueLooksUpInProcess, TestReadBindings,
TestBindingsUnreadableHaveNone, ttlOf by kind, Main refusing secrets
without a lookup and -secret-cmd, config refusing secret_cmd; secrets
TestGet by kind, TestLoginFailed; agentlogin TestCodexBindings (kind and
agent checked on every binding), TestGetErrorsSayWhatToDo; secret.txtar
and network.txtar on the new file and without secret get; e2e's network
section keeps the fake token off argv and checks no command prints it.

Docs: the proxy README (Secrets section), internals/network.md,
safety/network.md, using/coding-agents.md, contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:35:25 -07:00
w3cjandClaude Opus 5.5 361087f95a refactor(proxy): host-only modes out of proxy.Main, into agentlogin and trust
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:

- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
  File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
  keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
  MCPSecrets and Redact. The salt is a parameter, not a global or
  DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
  hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
  through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
  1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
  netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
  redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.

Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 19:04:31 -07:00
w3cjandClaude Opus 5.5 8e914b17c9 refactor(proxy): one typed, versioned config for every proxy, read as a private file
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON
(version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by
netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by
backend.ProxyStarter) both use. It holds what the flags and the run
folder's sidecars held: the address, the VM, the password (proxy.auth),
the built-in policies and the user's files (proxy.policy), the logs, the
lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company
proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix
cache and its cap, the links, and the SHA-256 of devvm's binary and CA
(proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole,
mode 600, before each start, and starts a running VM's proxy again when
the config it would start it with has another Sum. ReadConfig reads it as
the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat,
a regular file owned by the proxy's user that nobody else may read or
write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a
loopback listen address. The VM's proxy is found by _proxy -config with
its own config's path. paths.VM names ProxyConfig, ProxyPID and
ProxyStatus.

Policy files are read only as regular files of at most 1 MiB
(proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so
a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong;
ErrNotPrivate for the config and the links' list); the proxy keeps a
file's last rules and logs why once.

hostOK refuses a name with an empty label (evil.test.., evil..test,
.evil.test), so no form of a name gets past a deny the policy's own trim
would miss.

A build proxy that can't be spawned leaves no config behind.

Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a
folder, group-readable and group-writable files, a long file, other
versions, unknown fields, two configs, no password, non-loopback
addresses, a CA without its key, a negative cap; ReadRegular and the
policy readers on a FIFO, /dev/zero and a big file without hanging; the
running proxy keeping its last rules; hostOK and requests with empty
labels (failing on the code before); Prepare's config, restarts on a
binary change, a missing config and one others may read; concurrent
config writes; the build proxy's config and its removal; proxy.txtar,
network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the
config's mode, password and the proxy's arguments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 17:51:45 -07:00
w3cjandClaude Opus 5.5 f71adb5a04 refactor: devvm's own files stay in the binary
assets.FS is the only copy of devvm's own files: nothing writes them to
~/.local/share/devvm/assets/<hash> any more, so an edit on disk can't
widen running proxies' allowlists or change a --from base its key
doesn't describe.

- Proxy: -builtin-policy NAME,... names policies in IO.FS (cli's _proxy
  passes assets.FS; proxy stays stdlib-only). Built-ins are parsed once
  at start (readBuiltins), ahead of -policy's files in the union, never
  re-read; a missing one, or one with a line that isn't a rule, refuses
  to start. -policy carries only the user's files.
- netpolicy: PolicyFiles(d, assets, vm, img) becomes Policies(d, vm, img)
  (builtin, files); Proxy.PolicyFiles and AssetsInUse go. .proxy.policy
  records both lists, a line each, for the restart check. ReadRules takes
  built-ins from an fs.FS; RuleFile.Builtin.
- devvm network: built-ins labelled "# devvm: layers/base.policy";
  --json entries carry "builtin": NAME or "file": PATH ("version": 1).
- Lima: createArgs ends in "-" and create() feeds base.yaml on stdin;
  convert writes oci/ and, with company CAs, guest/ca.sh into its own
  temp folder beside vm/ (writeScripts, state.WriteFile), mounted
  read-only and deleted by the existing cleanup. Lima.assets() goes.
- Deleted: internal/state/assets.go and its test (WriteAssets,
  StaleAssets, AssetsHash), paths.Dirs.Assets, gc's stale-assets plan
  and the gc_assets/deleted_assets messages, space's devvm's files row.
- Tests: proxy built-ins (order, not re-read, missing/invalid refuse,
  Main refuses before listening), Policies, the restart check on either
  list, ReadRules/WriteRules labels, JSON shape, createArgs and create's
  stdin, writeScripts' files and modes; CLI scripts check
  $XDG_DATA_HOME/devvm/assets never appears after up, build and --from,
  base.yaml on create's input (the limactl stub keeps it), the
  conversion's mounts and script paths in its temp folder.
- Docs: design (One binary), install, overview, space, images (gc),
  internals network, images and lima, safety/network, proxy README,
  the network command's Long and its CLI page; AGENTS.md rule.
- Coverage baselines (darwin) raised: cli 88.2, netpolicy 87.2,
  proxy 88.2, state 91.8. Dirs' method cap lowered to 41.

Image keys are unchanged: they already hash the embedded files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 17:29:06 -07:00
w3cjandClaude Opus 5.5 4bbd35a24b refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal
flags, run log, status line, cleanup stack and interrupt flag, and its
functions are methods. ui.Main makes the run's UI on devvm's own
streams, owns signals, recovers Die and runs the cleanups; ui.New makes
one on other streams. cmd/devvm passes it to cli.Execute, and every cli
command gets it through its constructor.

Only cmd/devvm and internal/cli import internal/ui (a depguard rule).
Each other package defines the small UI interface it needs, which its
constructor takes, filling fields tests set:
- gitprotect.New, secrets.NewStore, from.NewLookup: a warn func
- ubuntu.New: LoggedCmd, Note
- netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its
  log lines drop control characters themselves (oneLine)
- sshagent.New: Info, Note, Warn, LogWriter
- tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup
- lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run),
  WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too
- backends.Registry: lima's and smolvm's
- vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout,
  LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields
- build.Builder: Terminal and LogNote fields
- sshconfig.New: its caller sets what it prints and asks

ui's tests build their own UI over buffers and run in parallel; other
packages' tests use small fakes; cli's unit tests a UI over buffers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 16:23:51 -06:00
w3cjandClaude Opus 5.5 d73c010ec4 feat(msg): messages carry the error they report
msg.M.Because(err) returns the message carrying err, and Unwrap returns
it, so errors.Is and errors.As see through a message to its cause. The
text stays the message's own.

Messages made from an error carry it: proxy_failed (secrets and the
proxy command), login_copy_failed, run_log_failed and fail's fallback
message. TestBecause covers errors.Is and errors.As through a message,
through %w wrapping, and through a message in a message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:37:32 -06:00
w3cjandClaude Opus 5.5 86a1466cec refactor: print and prompt only from cli
Packages other than cli and ui take what they print and ask as fields,
set to ui's by their constructors or by cli:

- vm.Env: Info, Warn, Note, Say, Ask, Confirm, PickFeatures (cli sets
  PickFeatures); AgentMounts, UpdateAgentDirs, warnIgnored, applyAgent,
  applySize, applyPorts, removeRemote and saveFetched are Env methods
- build.Builder: Info, Warn, Say, Confirm, Pick (build.Feature); cli's
  newBuilder sets them, its pickFeatures asks through ui.Pick
- netpolicy.Proxy: Note, Warn, Ask, Confirm; Choose, SelfCheck and
  Unproxied are Proxy methods
- sshconfig.Config: Info, Warn, Say, Confirm
- secrets.Store: Warn; LoginKept takes the warn function

Tests set the fields and check messages through them. AGENTS.md: only
cli calls ui's messages and prompts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 15:12:36 -06:00
w3cjandClaude Opus 5.5 49d7205360 feat(sync): host settings, agent config and mounts for VMs
A new VM's setup now sends the whole of guest/sync.sh and its host
side, staged in memory: the hostname, timezone, UTF-8 locale and git
identity; the agents' config files (never their history), with their
folders mounted read-only at their host paths (one with a comma is left
out, with a warning); and the VM's tokens, as they are without network
policy (naming MCP servers whose secrets go too) or as its own
placeholders with it. With network policy it also sends devvm's CA, the
proxy's address (Backend.ProxyURL), the logins' copies with placeholders
and the agents' settings files with secret-looking values redacted (one
that can't be read that way isn't sent). UpdateAgentDirs keeps an
existing VM's agent mounts current through Backend.SetAgentDirs; its
caller comes with up for an existing VM. New docs page: coding agents.

Ported: sync_vm, agent_dirs, agent_files, agent_mounts,
update_agent_mounts, host_tz, claude_mcp_warn, the settings redaction;
guest/sync.sh copied whole (one comment edited).

Bats cases converted:
- project.bats: agent_mounts (one per line, names with spaces); the
  four update_agent_mounts cases (Go table tests, plus a running VM
  restarted once the user agrees)
- build.bats: sync_vm staging removed on failure, settings redacted
  with network policy (testscript sync.txtar)
- guest.bats: the prompt, blocked since the last prompt, MCP servers'
  merge (testscript guest.txtar)
- network.bats: claude_mcp_warn (sync.txtar, secrets Go test)
Deferred: guest.bats VS Code settings (ssh/code).

e2e: project gains agent folders and the VM's setup (mount read-only,
settings copied, history never, git identity, timezone, hostname, the
token without network policy); network becomes claude+codex and checks
the CA installed, the VM's own placeholder, the logins' copies and the
host's login files unchanged, with curl verifying TLS (no -k). Agent
folders on relaunch and restart wait for those commands.

Messages: agent_dir_comma, agent_dirs_added, agent_dirs_removed,
update_mounts, mounts_next_start, mounts_updated, no_claude_token,
claude_token_invalid, no_github_token, login_copy_failed,
config_redacted, config_not_copied, claude_mcp_secrets_copied;
sync_failed reworded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 11:20:03 -06:00
w3cjandClaude Opus 5.5 f4508dfb61 feat(proxy): the network policy proxy as devvm _proxy
The network policy proxy moves into the binary as internal/proxy
(standard library only), run by the hidden devvm _proxy with its own
flags. Main returns errors instead of exiting, writes only to the
streams devvm hands it (the event log and data on stdout, its log
lines on stderr), and returns when the VM's hostagent is gone. The
connect mode is gone: devvm _qemu connect does that. Logins copied
as they are are warned about through ui.

Its tests come along, with a short run, fuzz targets for policy rules,
request targets and ClientHellos, a testscript, and the network page
of the docs for the proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 10:12:26 -06:00