Commit Graph
218 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 62cdd16dd4 feat(agents): devvm agent login claude, Claude Code's login captured in the VM for every VM
Claude Code logs in from inside a VM, so this machine never needs it, and
devvm keeps one Claude Code login on the host for every VM with Claude
Code: the subscription's OAuth login, or a Claude Code token from claude
setup-token. The newest replaces the other. The VM holds placeholders
alone, so claude /login in a VM no longer leaves real tokens there.

- Capture: every VM's proxy captures at platform.claude.com and
  console.anthropic.com /v1/oauth/token (agentlogin.Endpoints), only for
  a VM whose image has Claude Code (netpolicy.Capturer). setup-token's
  code grant (expires_in, agentlogin.SetupToken) gives the claude secret
  (agentlogin.ClaudeToken, secrets.Token's checks) and the VM the
  secret's placeholder. Any other code grant goes in the store's
  .claude/.credentials.json (a File of kind agentlogin.ClaudeOAuth:
  claudeAiOauth accessToken, refreshToken, expiresAt ms, scopes); the
  VM's reply holds sk-ant-oat01-devvm-proxy-managed-oauth-<salt> and a
  managed refresh token, and the VM's own refresh is answered from the
  store. Refused: a new login without user:inference (Console), any
  login or refresh with org:create_api_key, an access token that isn't
  sk-ant-oat01- shaped.
- One login: saving the claude secret (captured or devvm secret set
  claude) removes the OAuth login, and an OAuth capture deletes the saved
  token, both under the claude logins folder's lock
  (agentlogin.LockFolder); a token that can't be deleted is a warning.
  CLAUDE_CODE_OAUTH_TOKEN in devvm's environment wins, as in Claude Code
  (secrets.ClaudeOf(store).Login). A launch gives the VM either
  CLAUDE_CODE_OAUTH_TOKEN or ~/.claude/.credentials.json (placeholder,
  managed refresh token, expiry 2099), never both. Both bindings
  (claude, claude-oauth) go into Authorization for api.anthropic.com
  while either login exists, and Store.Get gives each the login devvm
  keeps now, so a running VM survives the switch.
- Refresh: the host refreshes the OAuth login when due, JSON to
  platform.claude.com with Claude Code's client ID and the login's
  scopes, through the company proxy (proxy.RouteOf), under the file's
  lock; claude_refresh_failed says to log in again.
- devvm agent login claude [--setup-token]: claude auth login --claudeai
  or claude setup-token in the VM without CLAUDE_CODE_OAUTH_TOKEN, the
  code pasted back on this terminal (no forward); the VM is set up again
  once the store has a new login of the kind asked for
  (secrets.ClaudeOf(store).Sums); claude_env_token_wins when the
  environment's token wins. --device-code, --api-key and --stdin are
  usage errors with claude, --setup-token without it.
- Confirmed in Claude Code 2.1.317's linux-arm64 bundle (sha256 checked):
  TOKEN_URL platform.claude.com/v1/oauth/token, client ID
  9d1c250a-e61b-44d9-88ed-5944d1962f5e, the JSON code and refresh
  bodies, setup-token's expires_in 31536000 and user:inference scope,
  the claudeAiOauth fields, the anthropic-beta oauth-2025-04-20 header
  Claude Code sends itself, claude auth login's pasted code#state on
  stdin. The real claude auth login logged in in e2e against the fake.
- Messages: agent_login_claude_paste, claude_login_saved,
  claude_setup_token_saved, claude_env_token_wins,
  agent_login_claude_flag, agent_login_setup_token_alone,
  claude_refresh_failed, claude_no_login; no_claude_token,
  claude_token_invalid, claude_token_howto and not_setup_token point at
  devvm agent login claude.
- Tests: TestClaudeCapture, TestClaudeSetupToken, TestClaudeOAuthGet,
  TestCaptureRefuses' Claude cases (agentlogin); TestOneClaudeLogin,
  TestClaudeBindings, TestClaudeOAuthVMCopy (secrets); TestCapturer's
  Claude cases (netpolicy); agent_login.txtar's Claude section;
  network.txtar's bindings.
- e2e (network): the fake company proxy fakes Claude's token endpoint
  and Anthropic's API too; setup-token's request makes the claude secret;
  devvm agent login claude runs the real claude auth login, the store
  keeps the login, the claude secret goes, the VM holds placeholders and
  no token, the API gets the store's token for the VM's placeholder; a
  due login makes the host refresh through the company proxy (which
  fails there, as the host doesn't trust the run's CA).
- Docs: Claude Code login (using/coding-agents.md), first VM, the home
  page, README, commands, settings, safety/network.md, internals
  network.md, the design note's risk that this path is unofficial,
  Contributing's e2e, the proxy README; the CLI reference.

Security review (security-audit skill, an independent read):
- Fixed: a login granting org:create_api_key would let a VM make an API
  key through the binding and get it unread: refused, on refresh too.
- Fixed: a refresh could install a Console login when the store had
  none: the scope check applies to every new login.
- Fixed: any VM, without Claude Code, could replace the login or delete
  the token with a refresh grant: only a VM with Claude Code captures.
- Fixed: two captures at once could leave neither login: one lock.
- Fixed: a saved token that couldn't be deleted gave the VM a 502 for a
  saved login: a warning instead.
- Fixed: captured and refreshed access tokens are shape-checked.
- Accepted, documented: the bound login reaches every api.anthropic.com
  path its scopes allow (profile, sessions); any VM with Claude Code can
  replace the login; a token Claude Code mints in a VM for another use
  (install-github-app) becomes devvm's login.
- Unconfirmed: whether another Anthropic host also answers
  /v1/oauth/token (it would pass unguarded).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 20:18:20 -07:00
w3cjandClaude Opus 5.5 2414d64bcc refactor(msg): one wording for questions only a terminal can answer
Refusals and help that need a person now say 'in a terminal without
--no-input', as no_terminal_fetch and no_terminal_delete did: each
message names the command to run, so the condition sits in it rather
than being added by UI.Refused. size_pending is for a stopped VM;
size_pending_running keeps the restart hint for a running one. setup's
size question goes through a Reporter the tests make (msg.Fake).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 20:13:35 -07:00
w3cjandClaude Opus 5.5 7a26d80a17 feat(settings): the network setting for new VMs is a tier, allowlist by default
The ask setting is gone: a new VM's summary shows its tier (--network,
else the saved tier, else allowlist) and customizing it asks for the
tier, with Enter keeping the one shown, so ask added nothing.

- settings.NetworkChoices is the tiers alone; settings.NetworkDefault
  (allowlist) replaces NetworkAsk, checked against netpolicy.TierDefault.
- chooseNet takes --network, then the saved tier; customize asks for the
  tier whenever --network didn't give it (netpolicy.Proxy.Choose takes
  the tier shown, and net_tier_unknown names it).
- devvm network -g ask and devvm setup's ask choice are gone; ask is a
  usage error (arg_not_choice). net_ask_global and network_default_ask
  removed.
- A saved "ask" in config.toml or settings.json is refused like any
  value that isn't a tier.
- Docs: safety/network, using/settings, using/images, getting-started
  commands and first-vm, the cli skill, devvm network's and up's help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:01:03 -07:00
w3cjandClaude Opus 5.5 2df3c6840c feat(agents): devvm agent login, an agent's login in the VM for every VM
devvm agent login codex|opencode logs the agent in from inside this
folder's VM, so this machine never needs Codex or opencode, and devvm's
agent store keeps the login for every VM with the agent. It sits under
devvm agent beside import and save: it fills the store, as they do, and
a bare devvm login would read as a verb on the VM itself.

- Browser login (the default): the agent's own login runs in the VM on
  this terminal (codex -c cli_auth_credentials_store="file" login;
  opencode auth login --provider openai --method "ChatGPT Pro/Plus
  (browser)"), and devvm forwards this machine's localhost:1455, and
  1457 (Codex's fallback) when free, on 127.0.0.1 and ::1, to the same
  ports on the VM's loopback, only while the login runs: closed when it
  ends, fails or is interrupted (AddCleanup), and an interrupt also ends
  the agent's login in the VM (its pid kept in ~/.cache/devvm-login.pid),
  so its server doesn't linger for the VM's port forwarder. Port 1455
  taken on this machine: refused, naming --device-code.
- --device-code: codex login --device-auth, or opencode's headless
  ChatGPT login; nothing forwarded.
- --api-key [--provider anthropic|openai|openrouter] [--stdin]: the key
  is asked for on this machine (msg.Question answered by --stdin) and
  saved in the store, never in the VM: Codex's auth.json becomes
  {auth_mode: apikey, OPENAI_API_KEY}, opencode's gets the provider's
  {type: api, key} beside the others; the running VM gets its copy with
  a placeholder and its proxy the binding at once.
- The proxy's capture (agentlogin's capturers) saves ChatGPT logins;
  devvm then confirms what the store saved, with the account's email,
  and fails when the login saved nothing new.
- opencode 1.19.5 has no Anthropic OAuth in its core (no Anthropic
  plugin among its built-ins), so there's no pasted-code capturer:
  Anthropic is an API key. opencode's OpenAI login listens on 1455 only;
  Codex 0.166 on 1455, falling back to 1457.

- vmssh: SSH.ForwardLoopback (LoopbackForward: listeners in devvm's own
  process, each connection its own ssh -W to the VM's 127.0.0.1, no
  master; ErrPortTaken).
- agentlogin: KeyProviders, File.SetKey, File.ChatGPT.
- secrets: Store.SaveKey, LoginSum, ChatGPT (loginsDir shared with
  Capture).
- vm: AgentLogin (agentlogin.go), LoginAgents.
- cli: agentlogin.go (--device-code, --api-key, --provider, --stdin,
  --here/--parent); usage errors before anything runs.
- assets/guest/sync.sh: cli_auth_credentials_store = "file" first in
  the VM's ~/.codex/config.toml on every launch.
- Messages: agent_login_* and agent_key_*; codex_no_key,
  codex_no_chatgpt, codex_refresh_failed and opencode_refresh_failed
  point at devvm agent login.
- Tests: agent_login.txtar (usage errors, no VM, no agent, device code
  argv, browser forward and its end, the agent failing, a login saved
  while it runs, port taken, interrupt, API keys, the VM's copy failing,
  no terminal, an empty key), unit tests for the forward, SetKey,
  ChatGPT, SaveKey, the confirmation and the argv; coverage baselines
  raised.
- e2e (network): the real Codex's login in the VM against the run's
  fake token endpoint, its callback opened through the forward, the
  store's tokens and key, placeholders in the VM, the forward gone; an
  interrupted login takes its forward away.
- Docs: Logging in with devvm agent login (using/coding-agents.md),
  the Commands page, the questions table, Contributing's e2e, the cli
  skill's tree, AGENTS.md; the CLI reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 19:07:06 -07:00
w3cjandClaude Opus 5.5 0a28f98f0a feat(agents): devvm agent save, a VM's agent settings into devvm's store
devvm agent save [AGENT...] reads the folder's VM's agents' settings,
shows what differs from devvm's agent store and, after a yes, saves them
there for every VM: import's other direction. It always asks, with no
flag that answers (RefusedWith), so without a terminal or with
--no-input it shows the diff and is refused; devvm starts a stopped VM
for it.

What it reads (a fixed list, the agents asked for only): agentFilesOf
(Claude Code's settings.json and CLAUDE.md, Codex's config.toml and
AGENTS.md), agentDirsOf (skills, agents, commands, output-styles,
plugins with marketplaces; prompts, skills), opencode's config folder's
entries but node_modules and lock files, and ~/.claude.json's subset
(claudeTopKeys, reduced by jq in the VM and again on the host, never its
per-project entries). Never a login (.credentials.json, auth.json) or
history. The guest script sends it as a tar stream; a folder that's the
store's own mount (the link to it) is no change.

Every byte from the VM is untrusted, checked on the host (readSent):
- the stream bounded: 128 MiB, the command cancelled past it; its
  stderr into the run log, at most 1 MiB
- at most 20,000 entries, a file at most 16 MiB (its header first)
- paths relative, clean, valid UTF-8, only characters a terminal shows
  (no control, format, bidi or zero-width), each once, only in the
  list, each inside a folder the stream has (nothing below a link):
  anything else saves nothing
- only files, folders and links; other kinds left out with a warning
- links never written: one inside its settings folder to a file there,
  by relative paths through real folders, at most 8 hops, becomes a
  copy; any other is left out, the store's copy kept
- modes normalized: 600, or 700 when executable; no set-id bits
- every file written with state.WriteFileMode; folders replaced in
  place (pruneStore through an os.Root), files the VM lacks kept
- every settings file parsed whole (Redact's decode), left out when it
  doesn't parse
- placeholders never saved: agentlogin.Restore puts the store's value
  back only where the VM's copy (the store's file redacted again, or
  for .claude.json the VM's salted claudeVM copy, as every VM gets)
  had the same placeholder at the same path and its table and the one
  above are unchanged; else the file is left out. A placeholder in any
  other file leaves it out; opencode's withheld files, which no VM
  gets, are left out.

The diff (data output): each file's lines against the store's, settings
files and .claude.json redacted on both sides so it never prints a
secret, a folder's A/M/D list then each added or changed file's diff, a
mode change line, every character a terminal wouldn't show as \u{HEX},
binary files named only, a file over 1 MiB or 10,000 lines and lines
past 20,000 as counts. Then agent_save_runs: every VM runs the hooks,
MCP servers' commands and plugins saved.

Security review (security-audit skill, guidance mode, an independent
read): nothing reaches outside the store, follows a link, or sends a
store secret to another host. Findings, all fixed here:
- folder files showed only as A/M/D names, so a changed hook or
  script went in unseen: their diffs are shown
- invisible Unicode (tag characters, zero-width) passed
  msg.Printable into the diff: shownLine escapes every non-graphic
  character
- names with bidi or format characters spoofed the diff's headers:
  refused in entryName, headers escaped too
- the diff could use GBs of memory on 16 MiB files of newlines: per
  file and total caps
- Restore's rewritten JSON/TOML hid a change among reformatted lines:
  both sides are diffed as rewritten
- the VM's stderr went into the run log without limit: 1 MiB
- quadratic work over many opencode folders: entries indexed by folder
- an execute-bit change showed no line: a mode line
Found in my own review: the diff printed the store's secrets in
context lines (now redacted), and a VM could replace opencode files
it never got, such as a .env (now left out). With captured logins,
HasPlaceholder also knows the JWT-shaped placeholders (fakeJWT's
devvm-placeholder signature, now jwtMark), so a captured token's
placeholder copied into a settings file is never saved; the save never
writes Codex's or opencode's auth.json or Claude Code's
.credentials.json, which the capture keeps in the logins store.

- agentlogin: Restore, PlaceholderError, HasPlaceholder, ClaudeSubset,
  ClaudeTopKeys; Redact and ClaudeCopy share decode/encode
- vm: AgentSave (agentsave.go), readSent, listedPath, resolve,
  agentSaveScript (agentsave_read.go), lineDiff, shownLine
  (linediff.go); opencodeFolder/opencodeFile from agentDirs/agentFiles
- cli: devvm agent save, with --here/--parent
- messages: agent_save_no_agent, agent_save_none, agent_save_nothing,
  agent_save_ask, agent_save_runs, agent_save_refused, nothing_saved,
  agent_settings_saved, agent_save_unsafe, agent_save_too_much,
  agent_save_link_left_out, agent_save_kind_left_out,
  agent_save_unparsed, agent_save_placeholder, agent_save_withheld,
  agent_save_not_read, agent_save_failed
- stub: agent-save.tar, the VM's stream
- tests: agentsave_test.go, linediff_test.go, restore_test.go,
  testdata/script/agent_save.txtar; e2e project (refused, then saved,
  never the login or a link out) and network (MCP header put back,
  refused once its URL changed)
- docs: coding agents (saving a VM's settings), commands, attack
  vectors, internals network (saving the copies back), contributing,
  the cli skill's tree, CLI reference

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:17:37 -07:00
w3cjandClaude Opus 5.5 3a2c290d3d refactor(msg): messages and comments say network tier and the VM's proxy, not network policy
Every VM runs a proxy and is on one of four tiers, so the proxy's messages
name the VM's proxy, the unenforced ones its network tier, and the
redaction ones say devvm keeps secrets on this machine on every tier.
Message IDs are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 17:16:40 -07:00
w3cjandClaude Opus 5.5 d94929523d feat(vm): a new VM shows a summary, then asks whether to customize it
Before devvm makes a new VM it shows a summary of what the VM gets:
each toolchain, coding agent and layer with why (the file that calls for
it, devvm setup, config.toml or the flag that gave it), its size, network
tier and ports, and the devcontainer.json it's made as. Where the picker
shows (CanPick) and something is left to choose, it asks
"Customize it? [y/N]": Enter makes the VM as shown; y opens the picker
(a part a flag gave greyed out), then the network tier question when no
tier is given or saved, then the VM's CPUs and memory (for this VM
alone). Without a terminal or with --no-input the summary ends with the
flags that choose others. The summary replaces new_vm_gets and
devcontainer_using. devvm's first run asks its size and agents first,
as before, then shows the summary.

A test build's DEVVM_PICK_ON_PIPE shows the picker with a terminal on
stdin alone, so testscript's ttyin reaches it (up_customize.txtar).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 16:48:53 -07:00
w3cjandClaude Opus 5.5 fcbab78670 refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its
tier, so even an open VM never holds a real secret: a request that goes
around its proxy carries only the placeholder.

- vm/sync.go: the open branches of stage go (the agents' logins copied
  as they are, the ClaudeCopy for unconfined VMs and its MCP warning,
  real values in ~/.config/devvm/env); stageNet is stageSecrets, run
  for every VM, and the salt is every VM's.
- netpolicy: Prepare readies the CAs, salt and secret files on every
  tier, and the proxy config carries the CAs and bindings on every tier;
  dropCA and its caller are gone, so a VM keeps its CAs as its tier
  changes.
- Removed without a caller left: the messages secret_unuse_copied,
  net_on_old_tokens and claude_mcp_secrets_copied;
  secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets,
  claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly.
- Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across
  tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for
  another host), TestStageSecretsEveryTier (every tier's setup sends
  the VM's CAs, the guard against a tier's own path); sync, ca, network
  and secret scripts for open VMs.
- e2e: network checks that an open VM holds no real secret (its proxy
  puts the token in over TLS the VM verifies, a direct request carries
  only the placeholder and gets a 401); project checks an open VM's
  placeholder, and its company-CA checks allow for the VM's own CAs in
  /etc/ssl/devvm.pem.
- Docs: safety/network (tiers, secrets), internals/network, the design
  note's tiers threat check, attack vectors, coding agents, first VM,
  staying safe, contributing; devvm secret's help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:55:21 -07:00
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00
w3cjandClaude Opus 5.5 c0f4b8fb5c feat(netpolicy): network tiers in state, confinement and the proxy
A VM's network is one of four tiers, open, internet, allowlist and none,
in its state's net section (netpolicy.Tier), in place of on/off. Every
VM has its proxy. Confined tiers start on NetProxy; open starts on the
backend's own network with its proxy set in the guest
(Confinement.GuestProxy): on Lima no Seatbelt profile and no QEMU
wrapper, the proxy at 192.168.5.2 on both hosts, propagateProxyEnv off.

The proxy: Config.Open (every host and address, no floor, no
policies), Config.DenyPolicies (files whose denies alone apply), the
rule port :* (any port), and ** matching address literals (the floor
still holds). Policies per tier (netpolicy.PolicySet): internet is
network/internet.policy (**:*) plus your denies; none is the agents'
built-in policies, the secrets' hosts and your denies; open none.

Links: a client links only to a target on its tier or a stricter one,
and a group's VMs are all on one tier. The self-check per tier: open
asks its proxy through the guest's settings and warns
(net_proxy_unreachable). devvm ls and devvm network show the tier. A
backend without egress-proxy offers open alone (net_tier_backend).
devvm network on/off and --network-policy/--no-network-policy map to
allowlist/open. Design note, threat check and docs; e2e in the network
and link sections.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 14:32:06 -07:00
w3cjandClaude Opus 5.5 317bd8f978 feat(agents): devvm's agent store, filled by devvm agent import
Every VM gets its agents' settings and logins from devvm's own store,
never from the agents' files in the home folder: settings in
~/.config/devvm/agents/<agent>/, logins in
~/.local/share/devvm/logins/<agent>/ (folders 700, files 600, each
agent's logins folder kept out of Time Machine), each laid out as in a
home folder. The store's settings folders are mounted read-only and
linked into the VM's home; its files and logins are copied in, with
network policy as placeholders the proxy fills from the store.

devvm agent import [AGENT...] [--force] copies the home folder's agent
settings and logins into the store once: only agentDirs, agentFiles and
secrets.LoginRel's paths, never history; .claude.json reduced to its
settings, account state and MCP servers; read through each agent's
folder as an os.Root, so no link out of it is followed (a link to a file
inside becomes a copy, any other is left out with a warning, and so is
a login file that's a link); Claude Code's plugin records renamed to the
store's folders. It asks before replacing what the store has (refused
without a terminal, naming --force), replaces in place, keeping the
mounted folders, and prunes what the home folder no longer has.

- paths: Dirs.AgentSettings, Dirs.AgentLogins
- secrets: LoginRel, LoginFile(Dirs, kind), SaveLogin, HasLogin,
  Store.ExcludeFromBackup; Logins, VMLogin, ClaudeCopy, MCPSecrets and
  the proxy's Get read the store
- vm: agentStore, agentMounts/homeSkips/Inventory.Mounts take Dirs,
  syncer.stageAgents, AgentImport; the guest's links file holds each
  folder's home path and its mount's (host_home is gone)
- structure: callers takes methods (pkg.Type.Name);
  Dirs.AgentSettings only in vm/agents.go, Dirs.AgentLogins only in
  secrets/secrets.go
- messages: agent_import_none, agent_import_nothing,
  agent_import_replace, nothing_imported, agent_settings_imported,
  agent_login_imported, agent_import_link_left_out,
  agent_login_read_failed, agent_import_failed; the login refresh
  messages point at devvm agent import
- tests: agentimport_test.go, testdata/script/agent.txtar, sync and
  network scripts through the store, e2e project and network sections
- docs: coding agents (devvm's agent store, importing from this
  machine), README, getting started, safety, internals, contributing

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 14:08:41 -07:00
w3cjandClaude Opus 5.5 14c4fe935a fix(ui): an answer after Ctrl+C is refused, and an interrupt doesn't wait at a question
A question's answer read once the run is interrupted is its refusal, so an
answer typed in the moment after Ctrl+C never lets a deleting command go
ahead. An interrupt no longer waits returnGrace for a command that waits
at a question: its read doesn't end at Ctrl+C (the UI counts the
questions waiting, asking).

One message for a failed export that keeps the VM: export_failed_kept
(command, vm) replaces remake_export_failed, rm_export_failed and
rm_vm_export_failed; devvm rm VM's case gets a CLI test.

no_terminal_delete and no_terminal_fetch no longer say there's no
terminal, as --no-input and the end of the input refuse them too;
no_input says to use its answer; --force's help names --no-input.

Tests: TestAnswerAfterInterrupt, TestSignalsDontWaitForAQuestion,
rm_vm.txtar's failed export.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 13:09:51 -07:00
w3cjandClaude Opus 5.5 0b82dc189f feat(vm): a moved folder's Claude Code history follows it
A folder move records the path the agents' state is under in the VM's
state (the moved section, set in recordMove under the VM's lock: the
first move's old path, kept through more moves, cleared by a move back).
The VM's next setup gets a moved file with both paths and their Claude
Code slugs (claudeMoved, claudeSlug), and guest/claude.sh's
claude_project_moved renames ~/.claude/projects/<old slug> to the new
one, or merges into it without replacing anything, and moves
~/.claude.json's projects entry (claude_json_project_move, kept on its
own for reuse). Once the setup succeeds, followed clears the section.

The slug is Claude Code's own rule (2.1.318's sanitizePath): every
UTF-16 unit but an ASCII letter or digit a dash; over 200, cut and
ended with "-" and abs(h*31+u, int32) in base 36.

Tests: TestClaudeSlug, TestClaudeMoved, TestClaudeProjectMoved,
TestMovedTo, TestFollowed, TestMoveHere's record and its clearing,
move.txtar, e2e project's moved checks. Docs: commands.md's moved
folder (Claude Code, Codex, opencode), internals overview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 12:39:55 -07:00
w3cjandClaude Opus 5.5 d17e62961e refactor(msg): one message for each kind of setting, flag and requirement
Messages that said the same thing for different settings are one message
each, given what differs:

- new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command)
  replace from_ignored, net_flag_ignored, git_protect_flag_ignored,
  size_flags_ignored, ports_flag_ignored, parts_flags_ignored,
  ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning
  for each command that changes the same on the VM, naming only the
  flags given (ignoredFlags).
- setting_already (command, vm) replaces net_already, agent_already,
  clone_on_already and clone_off_already.
- setting_set (vm), for a stopped VM, replaces net_set_stopped,
  agent_set_stopped and links_next_start.
- next_start (count, vm), for a running VM, replaces net_set_running,
  agent_set_running, size_next_start, agent_next_start,
  mounts_next_start, folder_next_start and net_off_next_start; a launch
  warns of each change with its next_start_* line, then next_start once.
- program_missing, program_broken and program_old (+ _fix) replace
  lima_missing, lima_broken, lima_old, qemu_missing, macos_old and
  their _fix messages; the minimum versions are minLima and minMacOS in
  the lima backend, passed into program_old.
- ports_list_needed replaces link_ports_invalid: devvm link publish and
  unpublish check their ports with ParsePortList, as devvm ports add
  does, and ParsePublish is gone.
- no_vm replaces no_vm_link.
- vm_unfinished says nothing of the user's is in the VM, as
  remake_unfinished does.

Kept apart: git_protect_next_stop (it applies at the next stop, and
devvm stop applies it), already_stopped and ports_all_already (not
settings), group_already (joining again syncs the group's links),
has_tools and has_layers (they name which of those given were there),
docker_missing (Docker is optional, so it never says to install it).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 12:10:45 -07:00
w3cjandClaude Opus 5.5 d58b24affe refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.

The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.

Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.

A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.

The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.

Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 11:49:57 -07:00
w3cjandClaude Opus 5.5 2a99183ea4 feat(vm): devvm update reads a changed devcontainer.json again
devvm update now makes the folder's VM again from its devcontainer.json
as it is now when the file changed, is gone or appeared since the VM was
made, as well as when its image is outdated. devcontainer_changed and
devcontainer_new name devvm update instead of devvm rm, then devvm. A
file's forwardPorts now join the VM's ports as devvm ports add adds them,
for a new VM and when devvm update reads the file again.

- vm.json's devcontainer section records what of the VM is the file's:
  image (the file's image, when the base starts from it), from_flag
  (--from won), parts (what its features mapped to), gave (those the VM
  got from the file alone, not from --tools/--layers, setup's layers,
  the folder's other files, nor unchecked), ports (its forwardPorts) and
  ports_gave (those it added to the VM's ports).
- devcontainer.Reread (pure) drops what the file gave that it no longer
  lists and adds what it lists anew that the VM lacks; the user's stay,
  and what the user took out stays out. It applies to parts
  (rereadParts) and to ports (filePorts, through AddPorts and
  RemovePorts, as devvm ports add and rm). devcontainers.reread
  re-pins a new image (or falls back to $DEVVM_FROM's), keeps --from's,
  and replaces variables and commands.
- The remake section carries reread (the new from, shared tools, ports
  and devcontainer section; tools built for the new base after the
  image) and was (what the VM had, kept when the new machine is made),
  which the undo gives back, for every remake.
- Messages: devcontainer_changed/new reworded, devcontainer_reread and
  devcontainer_gone added, devcontainer_ports_not_forwarded removed; the
  docs link points at the new "Updating a VM from the file" section.
- Tests: TestReread, TestRereadParts, TestFilePorts, TestFileParts,
  TestUpdateDevcontainer (undo and finish), TestUpDevcontainer and
  TestPlanDevcontainerFrom (the file's ports added), devcontainer.txtar
  (a new VM's ports, update after a change with the user's port added
  and the file's removed, --from winning, the file removed, a file that
  appeared), e2e's devcontainer section (the file's port reaches this
  machine; devvm update, the home kept, the new port in place of the
  old one).
- Docs: using/devcontainer (its ports, the security note), images,
  toolchains, commands, the internals overview's remake section and
  state table, the design note, the security model, attack vectors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:56:32 -07:00
w3cjandClaude Opus 5.5 e9ca7a4859 feat(vm): a moved or renamed project folder keeps its VM
A VM's files and machine are keyed by its name's hash, which stays; what
moves is the state's dir. The finder finds a folder's VM by the state
that records its path (finder.state: the path's hash first, then every
state, recorded), so a VM moved there is found from the new path alone,
and links by path (project.ForDir) match the recorded dir.

When the folder has no VM, the finder looks through the states for one
made for this folder at another path (moveHere, move.go; the match is
here.movedFrom): the same folder identity (device, inode, birth time),
the folder this user's, its identity unique (platform.UniqueFolderID:
an ID with a birth time, and on macOS APFS or HFS+), another recorded
path that's gone on the folder's device or only a symlink to here, its
creation finished, not a --clone VM. One match is offered: in a terminal
move_vm, [y/N]; without one vm_moved_here, naming devvm adopt; devvm
adopt --force moves it without asking. Several matches warn
(vms_moved_here) and move none. Never automatic.

The move (finder.move) refuses a folder no new VM may have
(checkUnsafe), holds the creation locks of the VM and of the folder's
would-be new VM, checks again that no state records the folder and
that the folder is still the one asked about (move_folder_changed),
stops a running VM as devvm stop does, then records the path and
identity under the VM's lock, refusing a state that changed meanwhile
(create_running); vm_adopted says so. .git protection's record is kept:
.git, its identity and its uchg locks move with the folder.

The project folder's mount is now part of backend.Want (Want.Project,
Instance.Project, Apply), so the next start mounts the folder where it
is: Lima's wantEdits rebuilds .mounts in its one edit when the project
mount or the agent folders differ (mount.project). A VM running with
another path asks to restart (Y/n) and otherwise warns
(next_start_folder, folder_next_start).

A new VM at the old path can't use the moved VM's folder, so newName
takes the first of the path's names whose VM folder holds no state
(project.Nth: the hash of the path, then of the path and n).

devvm adopt [VM]: with VM (by name or alias, as devvm rm VM), moves a
VM whose folder is gone or not connected to this folder, for a copy on
another disk (a new inode, never matched on its own): adopt_move_vm
[y/N], --force, adopt_move_refused without either; refuses a --clone VM
(adopt_clone), a lost machine (rm_vm_lost), an unfinished VM, a folder
still there (adopt_folder_there) and a folder with a VM of its own
(adopt_has_vm). It clears .git protection's record, as the copy's .git
is another.

rm_vm_state_mismatch is gone, as a dir needn't hash to the name any
more: devvm rm VM acts as devvm rm only on the folder's own VM
(finder.folderVM), and a VM whose state names a folder with another VM
of its own is refused as one whose folder is there.

macOS's FolderID has the folder's birth time too, as Linux's has.

Security review (security-audit skill, focused, with an independent
read): inode reuse needs a unique identity (birth time; APFS/HFS+ on
macOS), the same device (in the ID) and the old folder gone; another
user's folder never matches (its owner checked); a copy has a new inode
and never matches; links and groups go by name and stay, and links by
path take the recorded dir, a move refused when another VM records it;
a symlinked cwd is resolved first, and a symlink at the old path counts
only when it resolves here; .git protection's record stays for a move
and is cleared for a copy; agents' mounts are unchanged (only the
project mount changes); a VM can rename only folders inside its own
mount, which it already writes. Fixed from the review: a folder swapped
at the path while devvm asked was moved to (now move_folder_changed);
macOS device:inode could collide with a later volume given the same
device number (birth time added); a running VM kept the old path's
share, which a new folder made there would reach (the move stops it
first); a move to the home folder or into devvm's own folders (now
checkUnsafe). FolderID's format change makes VMs and .git records made
before it look like other folders (adopt them, or make them again).

Tests: TestMovedFrom (table: gone/present, same/different device and
inode, a non-unique ID, another user's, a clone, unfinished),
TestMovedAway (gone, a folder, symlinks here/elsewhere/dangling),
TestMoveHere (refused, no, yes, found by its dir, stopped, the new
mount at start, a restart for a running old mount, a new VM at the old
path by its next name), TestMoveFolderChanged, TestAdoptMoved,
TestMoveHereSeveral, TestAdoptVM, TestUniqueFolderID, ForDir and Nth in
project, wantEdits' moved project, the conformance start's moved
project; move.txtar (refused, no, yes, found, Lima's mounts edit, a new
VM at the old path, adopt VM of a copy); rm_vm.txtar's hand-edited
dir; e2e project: mv, refused, a yes in a terminal (script), the home
file kept, the new path mounted alone, moved back with adopt --force.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 09:30:05 -07:00
w3cjandClaude Opus 5.5 c98f91d8ad feat(history): devvm history import, and a new VM offers its folder's newest export
devvm history import [FILE] puts an export of agents' history into this
folder's VM: FILE, or the newest export devvm saved for the folder (by its
.folder file, through vm.Exports.Newest), never another folder's. The file
is streamed into the VM as it is, and the VM's GNU tar unpacks it there as
the VM's user, so the host never reads it. The VM lists the export's paths
as they are first and imports nothing when one is outside the agents'
history, absolute or has a .. part (history_import_unsafe). It unpacks into
a folder of its own without owners or modes and without the agents' logins,
~/.claude.json (the old VM's placeholders) and every agent's mounted folders
and copied files (importSkips), takes out symlinks pointing outside, then
copies the history paths into the home without replacing what the VM has.

A new VM with an agent offers the folder's newest export: in a terminal it
asks, [y/N] (history_import_ask); without one it says how to import later
(history_import_later). The import runs once the VM has started, before
its setup, and a failed one only warns.

Messages: imported, history_not_imported, history_import_unsafe,
history_no_export, import_failed, history_import_ask, history_import_later.
Tests: TestHistoryImportScript, TestHistoryImportRuns (GNU tar only),
history_import.txtar; the stub guest keeps an import as history-in.tgz and
takes a history-unsafe switch. e2e's project section: rm, a new VM in the
same folder naming the export, devvm history import, the history checked in
the VM, and a refused export with a .. path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 05:15:10 -07:00
w3cjandClaude Opus 5.5 84720ccfe3 feat(vm): opening a running VM with changes waiting asks once to restart it
When devvm opens a running VM that gets changes only at its next start
(its size, SSH agent forwarding, agent folder mounts, network policy
turned off while it ran confined), it names them in at most two lines
and asks restart_now once, in a terminal. It's yes by default ([Y/n])
when the agent folder mounts wait, as an agent just added needs them,
and no ([y/N]) otherwise. Yes stops the VM, so the launch starts it
with the changes and opens the shell; no, no terminal or --no-input
keep the next-start warnings and open the shell in the running VM.

- starter.restartForNextStart asks, on the launch path only (upOpts
  agentDirs); nextStartChanges is the one list both it and nextStart's
  warnings use; nextStartContext gives each change's line, or past two
  the first and how many more
- messages: next_start_size, next_start_agent, next_start_mounts,
  next_start_net_off, next_start_more (plural); restart_now is plural
  (count), one change or several
- Env.restartNow takes the question's form (Confirm or Ask), the count
  and its context lines
- updateAgentDirs no longer asks on its own: a running VM's new mounts
  join the launch's one question, so a launch asks at most once
- tests: TestOpenAsksToRestart (both defaults, yes, no, no terminal, one,
  two and four changes, nothing waits), TestUpdateAgentDirs updated;
  size.txtar opens a running VM with a size waiting without a terminal,
  then no and yes in one (yes ends at a failing setup, so its coverage
  is written)
- docs: commands.md's restarting section and answers table,
  ports-size, coding-agents, ssh, safety/network, internals/overview

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 04:30:10 -07:00
w3cjandClaude Opus 5.5 c1ca05bd94 refactor(vm): housekeeping and exports move out of cli
vm.Housekeeping owns what devvm keeps besides its VMs, and cli only
renders what it returns: ListImages and ShareListing (the tool targets,
worked out once in ToolTargets, for devvm images, gc, space and
retention), LockGC, PlanGC (one inventory per run: the states, with
--orphans the backends' lists too), GCPlan.Apply (returns GCDone, what
it deleted in order, an image the backend refused among it) and Retain.
gc runs on the run's one registry throughout, --caches included.

vm.Exports owns an export's name (parsed without a regex), the list,
the .folder file written and read, deletion and a folder's newest
export; it replaces lifecycle.go's name, history.go's parse and
retention's handling.

One orphan definition: devvm space's leftover state is now what
devvm gc --orphans would forget (Leftovers.FindIn, on space's own
inventory), so a VM whose state changed in the last hour, one made in
another Lima home and one being made again count as state, not
leftover, and the row's retention uses the orphan's Changed time.
space.txtar pins it against gc --orphans' list.

gc's Short names old files and the Nix cache over its cap; the CLI
reference is regenerated. using/space.md says what leftover state is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 03:29:38 -07:00
w3cjandClaude Opus 5.5 e6f64dae31 refactor(vm): one VM inventory per run
vm.Inventory (internal/vm/inventory.go) holds each project VM's state,
backend and Instance, read in one place: ReadStates for the states
alone, ReadInventory (UsedBackends or AllBackends) for the backends'
lists too, each within the host's list wait (30 s), with the backend's
Check saying why a list failed. It replaces Env.mounts, recordedVMs,
vm.List and vm.ToolsInUse, linkstate's clientStates listing, the
secret list's, Leftovers.Find's (and backendVMs), cli/space.go's two
(backendRows' list, vmFolders), images' state.Backends and sshconfig's
running list: sshconfig.Write takes the inventory's Running VMs.
state.ReadAll reads each VM folder on its own (only the inventory calls
it, a structure-test callers rule); state.Backends and Registry.Used go.

One failure policy:
- a backend that can't list fails a listing (Inventory.Err) only when
  some VM's state names it: devvm ls and the ssh config fail, and the
  ssh config stays as it was rather than lose that backend's entries;
  space and gc --orphans name it and leave its VMs alone;
- an unreadable vm.json is its own row: ls lists the VM with its name
  and status alone and warns (vm_state_unreadable); links, the secret
  list, rm VM and link targets leave it out; gc --orphans never takes it
  for an orphan; ToolsInUse and Mounts (images, gc, space, the SSH
  agent's mounted-key check) fail on it, naming the file;
- FolderOf is bounded (5 s): a folder on a hung share is there.

Mounts come from the states alone, stopped VMs and agents' folders
included, so the mounted-key check asks no backend. ui.Table shows every
cell through msg.OneLine, so ls's cells can't move the cursor or break
a row.

Docs: internals/overview's listing, troubleshooting's file devvm can't
read, ssh's mounted keys, contributing's owners table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 02:30:53 -07:00
w3cjandClaude Opus 5.5 1b9755a7df refactor(vm): one finder for the VM every command acts on
finder.target(ctx, need) finds the VM a command acts on: the folder's
own, the nearest parent folder's (resolveFolder), or one named for
devvm rm VM. Its need says what the command needs (has: any, the VM,
its machine, made; own; folder; noVM), and need.check is the one place
that refuses a missing VM, one made for an earlier folder at its path
(found.other, from sameFolder), a pending remake and an unfinished one.

It replaces Env's find, own, findExisting, existing (10 callers),
folderVM (7 callers) and the linkVM, groupVM, portsVM and agentVM
wrappers, Net's policyVM, up's and toRemake's checkFolder, and rm VM's
inspect by name. devvm rm VM refuses a state whose folder doesn't hash
to the VM's name (rm_vm_state_mismatch), so a changed vm.json never
sends it to this folder's VM.

The environment reads the folder devvm runs in lazily (finder.dir), so
devvm build, rebuild, images, space and gc run from a deleted folder;
NewEnv no longer fails.

Guard: the structure test's callers rule, state.ReadHash and
project.Parents called only in internal/vm/finder.go outside their
package and tests. Tests: TestFinder (need x none, own, parent, nested
repo, other folder, unfinished, remake pending with and without its
machine), TestRmVMFolderOfAnother, callerCases, no_folder.txtar and
rm_vm.txtar's mismatch case (its fixtures' hashes now match their dirs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 01:52:45 -07:00
w3cjandClaude Opus 5.5 e13839aa41 feat(cli): every command on the folder's VM takes --here and --parent, resolved in one place
The VM a folder uses is decided once, by vm's resolveFolder, from the
folder's own VM, the nearest parent folder's (with any repo of its own
in between) and the command's rule (vm.Env.Folder): by default the
folder's own, else the parent's unless a nested repo is in between,
else none (devvm makes the folder's own, other commands say no_vm).
--here takes only the folder's own; --parent takes the parent's across
a nested repo and past the folder's own, and refuses a folder inside
none with a VM (no_parent_vm). devvm asks nothing now, in a terminal
or not: use_parent_vm and use_parent_vm_repo are gone. The questions
before deleting, remaking or widening a parent's VM stay.

find resolves through it; own is the folder's own VM (adopt, --clone);
lookup and useParent are gone; Options.Here is the rule's.

cli: addFolderFlags (flags.go) adds --here and --parent into the run's
app, which vmEnv sets as the rule; the two are exclusive, and with -g
where a command has it; --clone and --parent are exclusive; devvm rm VM
takes neither (rm_vm_folder_flag). Commands: devvm, restart, stop,
update, rm, code, desktop, host, history export, tools (add, rm,
update), size, ports (add, rm), network (allow, deny, rm, log),
ssh-agent, git-protect, clone, secret use, secret unuse, layer add,
layer rm, group (join, leave), link (add, rm, publish, unpublish).

Tests: TestResolveFolder (own, parent, none, nested repo, --here,
--parent), TestFolderFlags (every folder command takes both, and no
other; refusals before anything runs; the rule each sets), the parent
tests and subfolder.txtar's cases updated for no questions and --parent.
Docs: the Commands page's subfolder section, first VM, --clone's
subfolders, the overview's subfolder VM; the CLI reference regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 01:21:41 -07:00
w3cjandClaude Opus 5.5 9f619bd2ca fix(lima): choose every build VM's ssh port under the claims lock, and clear stale build-port records
Linux build VMs' ssh ports were Lima's own pick, outside the claims
lock, so another VM's forwarder could take one before Lima bound it.
Lima's start now gets every build VM's port from ports.Allocator.Build
on macOS and Linux alike, and sets it with its one edit.

- start.go: the l.OS == "darwin" condition goes.
- build.go, tools.go: cloneEdits goes; a build VM's start always edits
  its new ssh port, so the configure step is always counted.
- ports.Allocator.Build holds a file lock on run/build-ports/<name>
  (platform.LockFile) until release, so the kernel lets go of it when
  devvm ends, killed or not. free, under the claims lock, first deletes
  (clearStale) the records no process holds that are over 15 minutes
  old (staleAfter: longer than Lima's 10 minutes of waiting for ssh,
  which a killed devvm's limactl start may still spend binding it).

Tests: TestBuild (a stale record kept while young, then cleared; a held
one kept however old), TestStartBuildSSHPort on darwin and linux,
TestStartConfined's Linux builds, TestBuildImageLayer, TestBuildTools;
TestCloneEdits goes. build.txtar checks the build's port edit and that
its record is gone; tools.txtar's steps are one count on both systems;
layout.txtar lists run/build-ports on Linux. The limactl stub needed no
change: it applies .ssh.localPort on every host, and the contract's
scenario already starts builds with a port.
Docs: internals/design (reserved ports; the build VM's ssh port lead is
now confirmed, fixed), internals/overview, using/space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:43:25 -07:00
w3cjandClaude Opus 5.5 39c2ff4f4e test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of
them) are one Go binary, internal/stubtest/stub, which acts as the command
it's run as (argv[0]): 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, and stub, scripts' commands
on the stubs' state. stub-log is gone: each stub logs its call itself, in
one write to $STUB_LOG, its arguments on no other process's command line.

- internal/stubtest builds the binary once, into
  $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link
  per command, which every test process and later run reuses until the
  sources change; a day-old folder of another build is removed.
  stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs'
  VM, Size, VMs, Keychain and SetKeychain on the state.
- internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json,
  typed JSON under a file lock (Lima's instances with their status, size
  and config, the Keychain, the SSH agent and its keys, Time Machine's
  exclusions, the tools build VM's folder). The instances file wasn't
  locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes
  at once.
- guest.go is the VM behind limactl shell and ssh alike: a --clone VM's
  git on vmfs, a remake's home, a base build's packages, the setup's tar,
  the direct connection, host keys, a forwarder's ports, link forwards.
- A link session's master listens with a backlog of one and never
  accepts, as the Perl one did, so a killed session's socket reads as
  stale once probed (link_life). TestScript's cleanup stops the sandbox's
  masters by their -M -S arguments.
- Structure: the stubtest layers cover internal/stubtest/..., the binary
  and its state import nothing else of devvm's; execSites lists
  internal/stubtest/build.go and internal/stubtest/stub/process.go.

Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state:
instances, size-<vm>, config-<vm>, keychain/<account>, agent-up,
agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size,
keychain, keychain-set, agent and agent-stop instead (build, existing,
from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm,
secret, size, space, ssh, ssh_agent, up).

Tests: stub_test.go (every stub in-process, TestShellWords),
stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima,
platform, vm, tools and build tests use the state helpers and
stubtest.Command. Coverage: internal/stubtest/stub and stubstate added,
stubtest, build and tools raised (and lima, netpolicy on Linux).
Docs: contributing (Stubs: the binary, logging, the state and the stub
command, switches, the guest, adding a stub or a switch; Go test
helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 00:00:12 -07:00
w3cjandClaude Opus 5.5 da5bae47f9 fix: tighten VM names, validate aliases, make written folders private and choose build VMs' ssh ports under the claims lock
- vmname.IsVM takes a name's folder part only as project.Slug makes it
  ([a-z0-9-], a letter or digit at each end), so a hand-edited name never
  carries spaces, slashes, newlines or ssh patterns. TestSlug checks that
  every name project.New makes is one.
- vmname.Short and vmname.IsAlias: a VM's alias is devvm-<folder> of its
  own name or the name itself. sshconfig.Host, ChooseAlias and
  project.Named ignore any other alias, so one edited into vm.json never
  reaches the ssh config's Host line or names a VM.
- state's writeFileMode makes a missing folder with PrivateDir (exactly
  700, whatever the umask, a link refused); a folder already there keeps
  its mode.
- ports.Allocator.Build chooses a build VM's ssh port on macOS under the
  claims lock (state.Claims, which VM.Claim now shares), records it in
  run/build-ports/<name> until limactl start returns, and ports.Used
  reads those records, so no VM or forwarder takes the port before Lima
  binds it. Lima's own freePort and platform.PortFree, its only user, go;
  Lima gets a Ports field (the allocator). paths.Dirs.BuildPorts is new,
  and Dirs' method limit goes to 54.

Tests: TestIsVM, TestIsAlias, TestSlug, TestChooseAlias, TestWrite,
TestTargets, TestWriteFileMakesPrivateDir, TestBuild,
TestStartBuildSSHPort; layout.txtar lists run/build-ports on macOS.
Docs: internals (backends, overview, design), contributing, using/space.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 23:21:52 -07:00
w3cjandClaude Opus 5.5 f4388d79ae fix(tools): each shared tool image builds in a VM of its own
A tools build ran every tool of a batch in one VM with a shared work
folder and output folder, and a tool image's key hashes only its own
tool's inputs, so one tool's installer (as root, through sudo) could
write into another tool's image: through the work folder, a process
left running until the next tool's mkfs.erofs, or by replacing mise or
mkfs.erofs. A fresh folder per tool and killing its processes wouldn't
stop root, so Share.Build now builds each tool in a throwaway VM and an
output folder of its own (buildOne, moveIn), one after another, and only
that tool's image and its .glibc are read from that folder.
shared-tools/build.sh takes exactly one TOOL VERSION FILE.

Measured on Fedora 43 (bare-metal x86_64, Lima with QEMU and KVM), node,
pnpm and bun: about 16 s in one VM, about 34 s in three (two runs each,
the same), so about 9 s for each extra tool, once per tool version.

Tests: TestBuildOneVMEach (node's build writes every tool's file in its
folder; each image holds its own tool's), TestBuild's one call per tool,
TestUpTools' calls, tools.txtar's VM per tool.

Docs: internals/images.md (building tools), internals/design.md's
shared tools (a VM for each tool, the cost).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 22:43:23 -07:00
w3cjandClaude Opus 5.5 d9d169e972 fix(tools): a --from base never builds tool images other VMs mount
gnu tool images, which any VM whose tools need their key mounts, always
build in a clone of devvm's own Ubuntu base on the VM's backend, never in
a --from image, whose code runs as root in its build. --from Debian and
Ubuntu VMs mount those images, and tool_needs_glibc still refuses a base
too old for one. When devvm's own 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.

musl tool images build in the VM's own --from base, and their keys hash
that base's digest (image.Tool.Base, tools.Target.Base, from the base's
record), so they're only ever another VM's on the same container image.
Their records keep it (base). devvm tools add, tools update and update
build a musl VM's base first, its digest looked up, so the keys they
work out are those of the base the images build in. Every gnu key hashes
devvm's own base, so no image built in a --from base under an earlier
key is mounted again.

Share.Build reads the record of the base it's about to clone and refuses
any but the one the images are for (buildsFor, tools_wrong_base): base
from Ubuntu's cloud image for gnu, a --from base with the target's
digest for musl.

Tests: TestBuildOnlyInItsBase (hostile --from gnu and musl bases, a
layer, no record), TestUpFromTools, TestToolsAddFrom, TestToolFile's musl
digest, TestToolFileRefuses, TestToolTarget's digest; from.txtar: the
clone of devvm's own base, a base record that says it came from a
container image refused (tools_wrong_base), and tools_need_own_base
before devvm's own base is built; e2e from checks where the Debian and
Alpine VMs' tool images built and the musl records' digest.

Docs: internals/images.md (building tools, keys, the share, listing),
using/from.md, using/images.md, using/space.md, internals/design.md,
internals/security.md, contributing's e2e list, AGENTS.md's tool-key
rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 22:22:16 -07:00
w3cjandClaude Opus 5.5 3649978bdb feat(build): base's features are devvm's own; your extras are layers
devvm reads base's features only from its own files (assets/features):
~/.config/devvm/features is no longer a folder devvm knows. An extra of
your own for every new VM is a layer of yours (devvm layer new), chosen
with devvm setup --layers, which each VM's list can uncheck.

- build: Features returns devvm's features alone; featureStep gives each
  its prelude; FeatureScript, the shadowing check and its
  feature_shadowed warning are gone. A chosen name devvm has no script
  for is skipped with unknown_feature, as before.
- paths: Dirs.Features is gone.
- Tests: TestFeatures, TestOwnFeatures, TestPickFeatures,
  TestSetFeatures, TestBuildRunsFeatures and the key tests use devvm's
  features only and check that a script in ~/.config/devvm/features is
  neither a feature nor in any key; features.txtar likewise.
- Docs: customizing's Extras of your own (a layer chosen in devvm
  setup), settings, install, space, overview, internals/images and the
  landing page drop the user features folder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 17:16:41 -07:00
w3cj cdac5e5012 refactor(image): typed image names, read once at the CLI boundary 2026-11-04 17:03:07 -07:00
w3cjandClaude Opus 5.5 9348a1e518 refactor(assets): one prelude for the build scripts' architecture, libc and pins
assets/prelude.sh gives each of devvm's scripts that a build runs with
bash $devvm_arch (arm64 or amd64), $devvm_libc (musl where apk is, else
gnu) and devvm_sha TOOL (the script's TOOL_sha256_<arch>_musl on musl
where it pins one, else TOOL_sha256_<arch>). It replaces the arch and sha
helpers in layers/base.sh, layers/nix.sh, features/cli-tools.sh,
shared-tools/build.sh and oci/build.sh, and the Alpine checks in
docker.sh, desktop.sh and fzf.sh. Each script that reads it checks it
came first (: "${devvm_arch:?}").

image.OwnScript reads devvm's own scripts with the prelude before them:
base.sh, apt.sh, built-in layers (LayerData) and features (featureStep),
shared-tools/build.sh (the tools build and ToolFile's key) and the
conversion's oci/build.sh (Lima's convertSteps, written into the
conversion's own temp folder). Users' layers and features get none.
keyHash.own goes, its one caller now hashing OwnScript's bytes.

Image keys change: every image and every shared tool image rebuilds.

Tests: testdata/script/prelude.txtar pins which pin devvm_sha picks from
each script on arm64 (aarch64 and arm64) and amd64, gnu and musl, and
refuses another architecture and a missing pin; oci.txtar sources the
prelude first and checks build.sh stops without it; TestOwnScript,
TestPreludeUsers (only scripts that get the prelude use it, each checks
its variables), key rows for the prelude in build and tool keys, and
recipe expectations with the prelude before devvm's scripts only.
e2e's nix copy as a user layer starts with the prelude.

Docs: internals/images.md (the scripts' prelude, keys), contributing
(owner, agreement test), maintaining, assets/oci/README.md, AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:57:21 -07:00
w3cjandClaude Opus 5.5 b4628d7bd1 refactor(gc): drop gc --recent and the one-hour rule for tool images
Every tool image build (tools.Share.Build) runs for a devvm that holds
the making lock shared from before it picks a VM's tools until the VM's
state lists them, and holds the share's lock while it builds and moves
images in. gc --tool-images takes the share's lock first, then tries the
making lock alone, so it waits for a build in progress and keeps every
current tool image no VM has while a VM is being made. The age rule
added nothing, so gc --tool-images now deletes current tool images no VM
lists however recently they were built.

- tools: Share.NoVM keeps only the state and record checks;
  NoVMRecent and builtRecent go.
- cli: gc loses --recent; gcPlan.making holds what it keeps while a VM
  is being made (showMaking).
- msg: gc_tools_recent, gc_recent_needs_tools and gc_recent_making go.
- tests: gc_tools.txtar checks a new tool image goes, and that gc waits
  for a tool build in progress and keeps every image while that VM is
  made (the limactl stub's shell-waits-on); gc.txtar checks gc's package
  cache cleanup (a stale set, its file, an unnamed file, an old
  .taken-* folder, a new one kept).
- docs: using/images.md, using/space.md, internals/images.md, the cli
  skill's judgment.md and the gc reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 16:12:26 -07:00
w3cjandClaude Opus 5.5 97672c4267 refactor(backend): base's size as Go constants, base's disk in Lima's origin
Base's size was read from assets/base.yaml four ways: vm.BaseDisk's
line scanner (a new VM's smallest disk), SizeChoice.Fitted's same scanner
for CPUs and memory (devvm size -g and setup's question), Lima's
buildSize regexes (base's build size), and limactl create reading disk:
from the template on its input. Now backend.BaseCPUs, BaseMemoryGiB and
BaseDiskGiB are the one source:

- vm checks new VMs' disks against backend.BaseDiskGiB, and Fitted fits
  BaseCPUs and BaseMemoryGiB; SizeChoice has no Assets any more.
- Lima's buildSize uses the constants; its Origin carries base's disk as
  a step of its own ("disk", its GiB), which originOf requires and
  createArgs passes as --disk=, so base's key still hashes it, and the
  --from conversion's VM gets it too.
- base.yaml sets no cpus, memory or disk, and is hashed only into Lima's
  key as Lima's settings.

Tests: TestBuildImageBaseSize (pinned on the old code: base created with
4 CPUs, 8 GiB and a 100 GiB disk, now all flags and none in base.yaml),
TestBaseSize, TestOriginOfRefuses' no disk and bad disk; the limactl stub
reads create's --disk=. Docs: internals/images.md, internals/lima.md,
contributing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:55:01 -07:00
w3cjandClaude Opus 5.5 1f2e4a0edc feat(tools): refuse a shared tool that needs a newer glibc than its --from base
Each shared tool is its project's prebuilt release, built against a
glibc it needs at least, so a --from gnu base older than that ran the
tool into a loader error. Now devvm measures both sides and refuses the
tool clearly.

- A tool image's build measures the newest GLIBC_ version its ELF
  programs and libraries need (shared-tools/build.sh's glibc_needs:
  readelf's version needs, testdata folders left out), writes it to
  FILE.glibc, and devvm keeps it in the image's record (glibc), taken
  only as a plain file holding one version (tool_bad_output).
- A --from conversion records the image's glibc version (getconf
  GNU_LIBC_VERSION in a chroot; oci/build.sh's glibc output, checked by
  checkConverted), in base's record and every image's on it
  (backend.Built.Glibc, state.Image.Glibc). Ubuntu's own base has none
  and isn't checked; musl needs none.
- tools.Target carries the base's glibc (not hashed: a gnu tool image is
  the same on every base); a VM's state records it (tools.made.glibc);
  Launch.buildTools checks every tool with tools.Share.Runs after
  building, for new VMs and devvm tools add/update and devvm update:
  tool_needs_glibc names the tool, its version and both glibc versions.
- image.ValidGlibc and image.GlibcOlder own the version's shape and
  order. build.Env.ToolTarget reads base's record once (BaseLibc gone).
- Measured minimums, current releases (arm64 / amd64): node 2.28/2.28,
  pnpm 2.18/2.18, bun 2.17/2.17, python 2.17/2.17, uv 2.28/2.17, rust
  2.17/2.17, go none (its 2.34 came from Go's own testdata), claude
  2.17/2.17, opencode 2.17/2.17, codex 2.28/2.28 (its voice helper).
- Tests: TestGlibc, TestBuildGlibc, TestBuildGlibcRefused, TestRuns,
  TestGlibcNeeds (build.sh's function against debug/elf, where readelf
  is), TestToolTargetGlibc, checkConverted's glibc cases; from.txtar: an
  old base refuses node at launch and at devvm tools add, keeps go, and
  records 2.24; e2e: the Debian base's record and VM state hold the VM's
  real glibc, no tool image needs a newer one, and Ubuntu's tool images
  record a glibc; the stubs write FILE.glibc and glibc.
- Docs: using/from.md (Shared tools and glibc), using/toolchains.md
  (Which bases they run on), internals/images.md, assets/oci/README.md.

Every tool image's key changes once (build.sh), so each is built again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:11:16 -07:00
w3cjandClaude Opus 5.5 de28721978 fix(build): check base's recorded packages on the host against Ubuntu's signed archive lists
A first build of base gave back each package it downloaded with apt's
entry for it, and the host took the build VM's word that each entry was
apt's: anything with root in that VM before apt.sh end could record a
package with a made-up entry, which every later build of the key
replayed. Now the build also hands back the InRelease files and package
lists apt used, and the host checks them itself before it keeps
anything:

- each InRelease is clearsigned by Ubuntu's archive key, pinned in
  assets/layers/ubuntu-archive.gpg ("Ubuntu Archive Automatic Signing
  Key (2018)", F6ECB3762474EDA9D21B7022871920D1991BC93C, from
  keyserver.ubuntu.com by fingerprint, checked against the Ubuntu
  security team's list), and one of 26.04's suites;
- each package list has the SHA-256 and size a verified InRelease gives
  one of its Packages lists;
- each recorded .deb's SHA-256 is in one of those lists, as the package,
  version, architecture and size apt's entry says, and the set keeps
  the archive's own entry.

- internal/ubuntu/pgp.go verifies clearsigned messages (RFC 4880's
  cleartext signatures: text signatures, dash-escaping, trailing
  whitespace, nothing before or after); archive.go's VerifyRelease and
  Release.Lists read a verified InRelease (ArchiveKeyring).
- assets/layers/apt.sh: record copies apt's *_InRelease and *_Packages
  lists to out/<n>.InRelease and out/<n>.Packages; base's build keeps
  lists uncompressed (Acquire::GzipIndexes "false").
- internal/build: take accepts the lists (an InRelease at most 4 MiB and
  all of them 32 MiB, a list 512 MiB with lines of 1 MiB and entries of
  4 MiB, all lists 2 GiB, no name twice), signedEntries and
  archiveEntry check them; cache carries devvm's own files for the key.
- Tests: Ubuntu's real resolute-updates InRelease verified, and refused
  when changed, framed differently or signed by another key; clearsigned
  parsing (dashes, CR LF, trailing whitespace, a binary signature
  refused); InRelease fields; a recording refused for a forged
  InRelease, a list no InRelease gives, a .deb no signed list has,
  another package's entry, missing lists, a list or an InRelease twice,
  a line over 1 MiB; a good set kept
  with the archive's entry (gpg-made fixtures in
  internal/build/testdata/archive); apt.sh's record giving back the
  lists.
- Docs: images.md's Base's packages, design.md's trust note (the
  recording VM's made-up packages closed), settings.md's mirror
  section, maintaining.md's archive key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:57:10 -07:00
w3cjandClaude Opus 5.5 2933b535a9 feat(clone): devvm clone on|off switches a VM to or from its own clone
devvm clone [on|off] is a setting: bare (and --json) it shows whether the
folder's VM has its own clone of the repo. on and off make the VM again
through the shared remake, keeping its home folder and settings, after
asking (--force, --no-export, --clean-home as devvm layer add).

- on: a mounted VM is made again with nothing of the folder mounted; its
  branches are seeded as a new --clone VM's, and once the old machine is
  deleted, .git is checked as a launch does and unlocked.
- off: the clone is checked as devvm rm does (unfetched branches offered
  for fetching into saved/<remote>/*, uncommitted changes asked about,
  terminal only; --no-clone-check skips it after a warning); the remote
  goes before the new machine's .git is locked, and is added back if the
  switch is undone.
- The remake records its clone mode (remake.clone), so a remake that
  didn't finish finishes in it, and undo restores the old mode.
- devvm --clone on a mounted VM and layer add/rm/update on a clone VM
  now name devvm clone on/off. rm's clone check messages name the
  command; --no-clone-check has one help text (addNoCloneCheckFlag).
- teardown removes a clone's remote and .git's locks independently.

Tests: TestSetCloneOn, TestSetCloneOff, TestSetCloneUndo,
TestSetCloneRefuses, clone_switch.txtar, e2e clone section checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 15:21:09 -07:00
w3cjandClaude Opus 5.5 389ac9f326 fix(vm): a VM without network policy gets only ~/.claude.json's settings, account state and MCP servers
Without network policy, the setup sent the host's whole ~/.claude.json:
primaryApiKey and customApiKeyResponses reached the VM's own
~/.claude.json, and the projects' history its setup's staging folder,
though sync.sh dropped it from the merge.

agentlogin.ClaudeCopy keeps only claudeTopKeys (claudeTop, which the
network policy copy uses too), with the MCP servers as they are, and the
setup sends it (Store.ClaudeCopy) for every VM without network policy. A
~/.claude.json devvm can't read stops the setup (login_copy_failed)
instead of reaching the VM unread. stage.has had no caller left.

Tests: sync.txtar's ~/.claude.json with an API key, its answers and a
project's history, none of which the copy holds (failing before), and
one that doesn't parse; TestClaudeCopy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:56:55 -07:00
w3cjandClaude Opus 5.5 aee099e52c fix(agentlogin): opencode OAuth logins devvm doesn't bind lose their tokens, and opencode's other files stay on the host
With network policy, an opencode OAuth login devvm doesn't bind (Copilot
Enterprise, a provider it doesn't know) reached the VM with its refresh
token, against network policy's promise that a VM never holds one, and
opencode's config folder's files that aren't settings, such as a .env,
were copied unredacted.

The VM's copy of opencode's auth.json now has devvm-redacted for such a
login's access and refresh tokens, and devvm warns
(opencode_login_withheld); API keys for providers devvm doesn't know stay
as they are, warned as before. File.VMCopy returns a VMFile (Data, Kept,
Withheld). With network policy, the VM doesn't get opencode's files that
are neither settings nor Markdown (withheld in sync.go), each named with
config_not_copied; AGENTS.md and other Markdown still go.

Tests: TestOpencodeUnboundOAuthWithheld (failing before), TestWithheld,
TestVMCopies's opencode_login_withheld, sync.txtar's opencode .env and
AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:53:53 -07:00
w3cjandClaude Opus 5.5 7dba353351 fix(agentlogin): Redact parses settings files whole and scrubs what ~/.claude.json's servers lose
A VM with network policy got secrets from the agents' settings files that
Redact couldn't read or didn't look for: TOML lines it couldn't parse
(multi-line arrays, quoted dotted keys, spaces around dots) were copied as
they were, and JSON's string lists, URLs and env values under names that
don't look secret were never scrubbed.

Redact now parses each file whole (JSON with UseNumber, TOML with
BurntSushi/toml), refuses one that doesn't parse, and writes the copy from
what it parsed, through one walk for both formats: values under
secret-looking keys, and lists and tables under them (but key bindings);
every value of env and headers tables (env, environment, headers,
http_headers, shell_environment_policy.set), but references, paths, URLs
(scrubbed, or whole under a credential's name: credName) and true, false
and numbers up to five digits; scrubURL for every URL; scrubArgs for every
list; known key shapes anywhere. scrubArgs also scrubs URLs in arguments
and in --flag=URL, for ~/.claude.json too.

Claude Code's own settings env (settings.json's top-level env) keeps its
documented configuration variables (claudeEnv: ANTHROPIC_MODEL and the
model families, CLAUDE_CODE_*, DISABLE_*, MAX_*, *_TIMEOUT_MS), unless the
name says it's a credential (credName: KEY, TOKEN as a word, SECRET, PASS,
AUTH, CREDENTIAL, COOKIE, HEADER), so Claude in the VM keeps its model and
limits. MCP servers' env and headers keep no value.

Tests: TestRedactTOMLLeavesNothingUnread, TestRedactJSONArraysURLsAndEnv,
TestRedactClaudeEnv (failing before), TestRedactTOML and TestRedactRefuses
updated; sync.txtar's unreadable config.toml is now one that doesn't parse.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:45:38 -07:00
w3cjandClaude Opus 5.5 4a782085b9 test: raise the linux coverage baselines, and network.txtar's proxy follows a hostagent that lasts
- linux.txt raised from Fedora's mise run coverage (backend, lima,
  build, cli, docgen, gitprotect, image, netpolicy, paths, ports,
  project, proxy, secrets, settings, sshconfig, state, trust, vmssh).
- network.txtar's first network-policy launch makes the test's runner
  its hostagent, so the proxy that follows it is still running when the
  ps check looks under load: the stub's hostagent is devvm itself,
  gone at once, and the proxy ended within a lifeline tick.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:15:12 -07:00
w3cjandClaude Opus 5.5 8d00c42e14 fix(netpolicy): a VM's CAs are readied under a lock and deleted once its policy is off, and the proxy refuses minting GitHub credentials in absolute form too
- trust.InitCA takes the caller's ctx and holds the CA folder's lock
  (paths.CA.Lock, vms/<hash>/run/ca/lock), so two launches of one VM at
  once never leave a key and a certificate of different runs
  (TestInitCATogether failed first, TestInitCACancelled, TestInitCAMismatched).
- netpolicy.Proxy.Unconfined: a VM's first start without network policy
  stops its proxy and then deletes its CA folder, keys and all, under
  that lock; a proxy that won't stop keeps them (TestUnconfined,
  network.txtar).
- The proxy's forwarder refuses GitHub calls that make a lasting
  credential for every HTTPS request, so absolute-form https:// requests
  get the 403 that intercepted tunnels got (TestForwarderRefusesMinting
  failed first); the minting paths also match /repositories/ID and
  /organizations/ID. Each forwarder's idle upstream connections close
  when its request or tunnel ends.
- e2e: the build proxy check expects the run log's devvm:<key>@ and no
  proxy key in the log.
- Docs: design.md's CA threat check, network.md, overview.md's locks,
  space.md, safety/network.md. Baselines raised (darwin).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 13:57:19 -07:00
w3cjandClaude Opus 5.5 0941219a76 feat(build): base's packages recorded per key, replayed from a host cache
base's apt packages are no longer pinned by a snapshot. A key's first
build of base records them: assets/layers/apt.sh (a recipe step, as
root, before base.sh and after the last feature) points the image's
sources at an apt mirror+file: list of config.toml's ubuntu-mirror and
then Ubuntu's own archive, so apt checks everything against the archive
key whichever server answers, and keeps what it downloads. At the end it
gives back each package with apt's entry for it. devvm checks what comes
back (regular files only, each named by its own SHA-256, each entry
matching a file's size and SHA-256, nothing left over, at most 20,000
entries and 16 GiB), keeps the files in
~/.local/share/devvm/packages/<sha256>.deb and the key's set in
packages/sets/<key>.json, before the image's record. Every later build of
that key replays the set from the cache, checked on the host first, with
apt given only those files: no network for base's packages, and a key's
packages never change. A --from base keeps its image's own sources,
unpinned. base keeps no package lists, so each layer's recipe starts
with apt.sh lists, which fetches them when there are none.

- backend.ImageSpec.Packages (Send before the steps, Take after) and
  backend.PackagesDir; Lima runs both over limactl shell as root.
- Fail fast: apt.sh turns apt's retries off and exits 75 when no source
  answers, which Lima reports as build_sources_unreachable.
- packages_missing refuses a replay whose cached file is gone or changed;
  packages_refused what a build gives back that isn't packages.
- config.toml's ubuntu-mirror (settings.UbuntuMirror), checked as an
  http(s) address without a user, query or spaces (ubuntu_mirror_invalid).
- devvm gc deletes the sets of keys neither current nor built, then,
  under the cache's lock, the files no set names at that moment, and
  builds' leftover folders over a day old (gc_packages,
  deleted_packages); devvm space lists the cache.
- The snapshot is gone from base.sh, guest/sync.sh and desktop.sh, and
  scripts/bump.sh's apt step with it.
- Tests: recording then replaying, a missing or changed cached file,
  every refusal of what comes back, gc's view of the cache and its race
  with a new set, the set record, the mirror setting, Lima's exchange and
  exit 75, apt.sh's mirrored and record functions, apt.sh in the keys;
  the limactl stub keeps what's sent and gives back
  $STUB_DIR/packages-out.tar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:58:23 -07:00
w3cjandClaude Opus 5.5 e93f29333a feat(ubuntu): pin the newest signed cloud image at base's first build
devvm's files keep only Ubuntu's release (26.04) and its cloud image key.
The first build of base on a machine pins the newest dated release whose
SHA256SUMS carry a valid signature from that key and list an image for the
host (state.UbuntuPin, images/ubuntu.json), and every later build uses the
pin without looking anything up. devvm rebuild base pins the newest again.
The pin is in base's recipe, so base's key hashes it.

The signature is checked in Go (internal/ubuntu/pgp.go: OpenPGP v4 RSA
signatures with SHA-256/384/512, the standard library's crypto), so no
gpgv is needed and a host without one is no longer unchecked.

- backend.Images gains PinOrigin (backend.Pin: PinFirst, PinNewest,
  PinOlder); internal/build pins before it keys a build, and says what it
  pinned (origin_pinned).
- Lima: Origin and createFromUbuntu read the pin; PinOrigin finds the
  newest with ubuntu.Finder (Newest, Release) under images/locks/ubuntu; a
  --from conversion pins only when nothing is.
- Messages: ubuntu_unreachable and no_ubuntu_release; ubuntu_unsigned and
  ubuntu_checksum_unpinned are gone.
- e2e pins its own release (DEVVM_UBUNTU_RELEASE, a test override;
  scripts/bump.sh e2e-ubuntu moves it); bump.sh's apt moves the package
  snapshot alone. The gpgv stub is gone.
- Tests: the verifier against Ubuntu's real signature and a test key
  (damaged keys and signatures, packet and subpacket lengths, armor),
  Newest/Release, PinOrigin, the pin record, and the key covering the pin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:27:25 -07:00
w3cjandClaude Opus 5.5 e148ca33ca fix(clone): the --clone push and fetch's ssh always connects to the VM itself
devvm's ssh for a --clone VM's seed push and rm's fetch read devvm's ssh
config, so a url.*.insteadOf, pushInsteadOf or remote URL in the repo's
config could send them to another host; only the pinned host key
(HostKeyAlias, BatchMode) stood in the way.

Their GIT_SSH_COMMAND (gitSSHCommand) is now a shell function that
ignores the host, port and options git passes, and runs ssh with
vmssh.SSH's new CommandArgs: no ssh config (-F none), the VM's loopback
port, user and key from vmssh.FromTarget, and the host keys pinned for
its current start (vmssh.KnownHostsFor) under HostKeyAlias, with
BatchMode and nothing forwarded. In the VM it runs only git-receive-pack
or git-upload-pack, whichever git's last argument asks for, on the
clone's own path; anything else fails without ssh. Links' linkSSH is now
Env's ownSSH, which both use.

Tests: TestUpCloneInsteadOf (failed on the previous code),
TestGitSSHCommand, TestForwarderSSH's command args, clone.txtar's push
past an insteadOf, and e2e's clone section (an insteadOf on the first
push, and a git worktree's clone with only its branch and upstream).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:56:37 -07:00
w3cjandClaude Opus 5.5 4477a1285d fix(clone): --clone takes only a repo of the folder's own or a verified git worktree
A project folder whose .git pointed into another repo on the host (a
gitdir file, a commondir, alternates) passed the --clone check, and the
seed push copied that other repo's branches into the VM.

gitprotect.OwnRepo now checks what git reads in the folder: a .git
folder without a commondir, or a linked worktree's .git file whose link
git made both ways (its gitdir is <repo>/.git/worktrees/<name>, that
entry's gitdir file names this .git back, and its commondir leads to
that <repo>/.git); no alternates, and no objects, packed-refs, reftable
or refs that are symlinks, in the git dir or the common dir. cloneSource
runs it before the VM is made and again before the push, and checks
that git's rev-parse --absolute-git-dir and --git-common-dir agree. A
worktree's push sends only its branch and that branch's upstream.

gitprotect's commondir and gitdir resolution are shared (commonOf,
resolvedDir) rather than copied. New messages: clone_git_elsewhere,
clone_alternates. Tests: TestCheckCloneRepoPointers (failed on the
previous code), TestSeedRefs, TestUpCloneWorktree, TestOwnRepo, and
clone.txtar's refusals.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 12:48:06 -07:00
w3cjandClaude Opus 5.5 866b9e0930 fix: the processes devvm starts don't inherit the files it was given
A terminal, an editor or a test harness can give devvm files past the
standard three without close-on-exec (testscript's ttyin puts a pty on
descriptor 3), and devvm's background processes then held them, keeping
that terminal or pipe open as long as they ran: on Linux a script hung
until its timeout. devvm now marks every file it was given from
descriptor 3 up close-on-exec as it starts (platform.CloseInheritedOnExec,
called first in main), which covers every process it starts, Lima's
included, and keeps them open itself.

TestCloseInheritedOnExec re-runs the test binary with an extra file on
descriptor 3, starts a detached process and checks it doesn't hold it
(/proc/<pid>/fd on Linux, lsof on macOS); layer_add.txtar now answers
yes in a terminal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:34:42 -07:00
w3cjandClaude Opus 5.5 c12fadd036 fix(ui): the run log keeps URL passwords out of commands' output
Lima's hostagent logs a proxy variable's value, password and all, when it
replaces a loopback proxy's address with the guest's gateway, overrides
the system's or lima.yaml's value, or can't parse it (Lima's
pkg/cidata setupEnv), and limactl start passes those lines on to its
stderr. For a VM without network policy, Start gives limactl the shell's
proxy variables, so a password in the shell's HTTPS_PROXY could land in
devvm's run log.

LoggedCmd's output now goes to the run log through a redacting writer:
whole lines (ended by \n or \r, or 64 KiB), each redacted, so a password
split across writes is still found, the rest written once the command
ends. redact, which the command's + line already took, also replaces the
password of any URL's user info with <password>, besides the proxy keys'
<key>. limactl.go's comment says when Lima logs the values.

- ui: urlPassword, redacting, redactLineMax.
- Tests: TestURLPasswordsStayOutOfTheLog (a Lima-like line, the URL in
  the command's environment, never its arguments), TestRedactingWriter;
  network.txtar and e2e's network check expect Lima's password stand-in
  as devvm:<password>@ in the run log.
- Docs: troubleshooting's run log, network policy's Without network
  policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 02:09:59 -07:00
w3cjandClaude Opus 5.5 ed70aeae3b feat(netpolicy): config.toml's company proxy reaches devvm's own downloads and builds' checks, and VMs without policy warn
config.toml's [proxy] covers the places it missed:

- devvm's own requests on this machine (the download of its mise, Ubuntu's
  cloud image listing, --from's registries) go through it when the
  environment sets no proxy. settings.CompanyProxy.Route is their
  transport's proxy: at the first request it looks up the proxy secret,
  puts it in each URL that names a user, and routes each request as a VM's
  proxy does (proxy.Upstream.WithPassword, proxy.Upstream.Route, reusing
  the proxy's NO_PROXY matching). A missing password fails the request
  with fetch.ErrProxy, which isn't retried; HostMise shows its message.
- The mise devvm runs on this machine gets HTTPS_PROXY, HTTP_PROXY and
  NO_PROXY in its environment (settings.CompanyProxy.Env), with the
  password in the URL, as mise takes it nowhere else; never in its
  arguments or a file. With the environment's proxy it adds nothing.
- devvm build, rebuild, the remakes' builds and tool builds check the
  company proxy and its saved password before anything starts
  (build.Builds' checkProxy, tools.Share.Build), through the one check a
  new VM and a VM's proxy use: settings.CompanyProxy.Upstream, which
  netpolicy.Proxy.Upstream now calls. secrets.Store.ProxyPassword owns
  the proxy_password_missing mapping.
- A VM without network policy never gets config.toml's proxy, as the
  guest would need the password, which never leaves this machine; each
  start of one while config.toml is the only proxy warns
  (proxy_needs_policy), naming devvm network on or the shell's
  HTTPS_PROXY, with a doc link.

Wiring: tools.Env.Proxy (its Password set by cli and vm from devvm's
secrets), from.NewLookup/NewRegistry/NewPublicRegistry take the proxy,
lima.New and registry.New take a *settings.CompanyProxy for Ubuntu's
listing. internal/fetch stays standard library only.

- Tests: TestUpstreamWithPassword, TestUpstreamRoute,
  TestUpstreamRouteAuthorizes, TestCompanyProxy,
  TestCompanyProxyPasswordMissing, TestProxyPassword,
  TestHostMiseThroughCompanyProxy, TestMiseCmdCompanyProxy,
  TestBuildChecksCompanyProxy (tools and build), TestRegistryThroughProxy,
  TestUbuntuThroughCompanyProxy, TestTransient's ErrProxy, and
  company_proxy.txtar's build, rebuild and no-policy cases.
- Docs: network policy's Behind a company proxy and Without network
  policy, config.toml's [proxy], How it works' Through a company proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 01:42:37 -07:00
w3cjandClaude Opus 5.5 50b0db2f7e refactor(vmssh): one host-key record per VM per start, which every ssh of devvm's checks
vmssh owns a VM's host keys: PinHostKeys reads them from the running VM through its backend (at most 64 KiB within 30 s) once for each start, into one record in the VM's folder, vms/<hash>/run/known_hosts (paths.VM.KnownHosts), whose first line names the start it was read for (backend.Run.ID). A record of another start is read again, keys read while the VM started again aren't recorded, and ErrNoHostKeys says none can be pinned. KnownHostsFor returns the record for the current start without reading, for links' sessions; ForgetHostKeys removes it before each start. ParseHostKeys is the one parser, for every key type: a line is kept only when its key decodes, names its own type and has more after it, and certificates, markers, patterns and anything else are dropped.

The ssh config's entries, the port forwarder (-known-hosts), links' sessions and a --clone VM's git all check the VM against that record. sshconfig's own parser, recordHostKeys, changeKnownHosts, HostKey and ForgetHostKeys go, with the shared known_hosts and its lock (Dirs.KnownHosts, Dirs.KnownHostsLock): a record per VM, each written whole, loses no other VM's keys. The forwarder's ports.known_hosts copy and Forwards.HostKey go, and teardown leaves the record to the VM's folder. paths.Dirs's method limit drops to 47.

Tests: TestParseHostKeys, TestPinHostKeys, TestPinHostKeysNone, TestPinHostKeysTogether (vmssh); TestForwardsStart and TestForwardsRun use the record; TestWrite reads keys again after a start, TestWriteUnreadableRecord (sshconfig); TestLinkConn refuses a target without a record and never reads one; up_test's call lists. The limactl stub shows a wire-format ed25519 key per VM. testscripts ssh (a launch keeps the record, a restart reads it again), up, existing, host_code, clone and layout updated; e2e's project and link checks read the VM's record. Docs: internals/security.md, design.md, overview.md, ports.md, lima.md, backends.md, git-protection.md, using/ssh.md and space.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 01:21:02 -07:00
w3cjandClaude Opus 5.5 2304f26bf0 feat(netpolicy): config.toml sets the company proxy, and a start warns when its proxy loses one
config.toml's [proxy] table (https, http, no-proxy) is the company proxy that
VMs' proxies and builds go through when devvm's environment sets neither
HTTPS_PROXY nor HTTP_PROXY; the environment's settings win whole, never mixed
with config.toml's. Each value is checked as config.toml is read
(backend.CheckProxyURL, backend.CheckNoProxy), and a URL holding a password is
refused (proxy_password_in_config): config.toml is copied between machines
and kept with dotfiles.

The password is the host-only secret proxy (devvm secret set proxy, in the
Keychain or devvm's secrets folder). A URL that names a user gets
upstream.secret in the proxy's config, and the proxy looks the value up
through IO.Secret as it starts (upstreamPassword), so no file of devvm's holds
it. No VM is ever bound to it: devvm secret use refuses (secret_host_only) and
secrets.Names drops it. A new VM and a VM's proxy refuse to start while it
isn't saved (proxy_password_missing, netpolicy.Proxy.Upstream).

A start whose VM's proxy last ran with an upstream and now has none warns
(upstream_proxy_gone), naming config.toml, with a doc link.

- settings.HostProxy: the environment's, else config.toml's; used by
  netpolicy, Lima's build proxy (buildUpstream) and devvm doctor's CA hint.
- proxy.Upstream.Secret, proxy.UpstreamSecret; secrets.Secret.HostOnly;
  secrets.Token keeps spaces inside the proxy password.
- Messages: proxy_password_in_config, proxy_password_missing,
  upstream_proxy_gone, secret_host_only, proxy_password_howto,
  password_prompt (answered by --stdin).
- Tests: TestHostProxy, TestUpstreamSecret, TestPrepareUpstreamConfig,
  TestBuildUpstreamConfig, config.toml refusals, the warning in
  TestPrepareUpstream, company_proxy.txtar, secret.txtar and ca.txtar cases.
- Docs: troubleshooting's Behind a company proxy, network policy's Behind a
  company proxy and secrets, config.toml's reference, How it works.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 01:10:36 -07:00