mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
bc00ebc088ae0aa9c05be3eb6b8dbb64373bd00a
358
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bc00ebc088 |
test(vm): housekeeping never deletes 0.1.0 state
fixture_v010_housekeeping.txtar runs today's housekeeping on 0.1.0's frozen state: a launch whose daily retention is due (0.1.0's retention.run made older than a day, and touched by the launch), then devvm gc --force, devvm gc --orphans --tool-images --retention --force, devvm space --json and devvm doctor. Every VM's vm.json and run folder stays, every shared tool image a state's tools.made.files names stays (the list read from the states before anything runs), no limactl delete names a project VM, devvm ls, devvm space and Lima still list all four, and nothing says unreadable or corrupt. A copy of a tool image under a name no state has goes, the control that gc could delete one. On Linux, 0.1.0's VMs' disks are modelled as it made them, qcow2 overlays of the image's disk (the fixture keeps no disks; the stub's qemu-img info reads the backing file), and gc keeps 0.1.0's base image with image_in_use; on macOS it deletes it, an older base than today's. Nothing found to fix. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
93322e9154 |
fix(vm): running 0.1.0 VMs are warned of and tested
A VM that devvm 0.1.0 started and that runs as you upgrade keeps what 0.1.0 gave it until its next start. Two of those went unsaid: - A launch into a running VM whose start forwarded an SSH agent itself (an older devvm's recorded start, without made.relayed) keeps that agent, which can add, remove or lock keys, and now warns, naming devvm restart, which gives it the relay (agent_raw_old). - devvm doctor said nothing of a running proxy without run/proxy.confined. One that another devvm binary started (its config's devvm_sha256) is an older devvm's single process without a sandbox, which it now names (proxy_old); one this binary started that hasn't written the file yet is still starting and gets none. doctor now passes devvm's own binary to the check. Tests, on 0.1.0's frozen state made running in the sandbox copy (hostagent pid file at 0.1.0's start's time from its known_hosts, run/ started, known_hosts and agent.made.started for that start, Lima listing it running, its ssh port listened on, and 0.1.0's one-process proxy): fixture_v010_running.txtar (doctor's proxy_old; a launch with no stop, start or edit, ports_ssh_old, the proxy started again as broker and child with proxy.confined, secrets.json and known_hosts unchanged, no relayed; then stop and launch: one .ssh.localPort edit, the new start's keys pinned) and fixture_v010_running_agent.txtar (devvm's agent forwarded raw: kept and warned, then devvm restart gives the relay and relayed, with only the ssh port's edit). The modelled hostagent is a live process of the test's, not 0.1.0's pid 54798, because a start counts as devvm's only while its hostagent runs. TestUnconfined: a proxy that hasn't said, by this binary, another, or an unreadable config. - msg: agent_raw_old, proxy_old. - Docs: ssh (agent forwarding), troubleshooting (the proxy runs without a sandbox), internals/install; CHANGELOG After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7cc0dd76ed |
fix(agents): a 0.1.0 store's plugin data stays out of the seed
devvm 0.1.0's agent import copied the whole of ~/.claude/plugins into the agent store, each plugin's data and installed_plugins.json included, and every VM with Claude Code mounts the store's plugins folder whole as its seed, so that data kept reaching every VM until agent import ran again. Every start (starter.bringUp) now takes out of each seed's folder in the store the entries a seed doesn't have (agents.MachineOwn), before the VM runs, and warns once, naming them (agent_seed_cleaned). The folder itself stays, so no VM's mounts or Lima config change. A running VM stops seeing them through its mount at once on macOS; on Linux, 9p's cache can keep what it read until its next start. The folder is reached from devvm's config folder as a root, each part of the path below it a folder: a link there (only a hand-made store has one, and the VM's mount would follow it, perhaps to the user's own ~/.claude/plugins) is refused (agent_seed_link), a link among the entries is removed, never followed, and the opened folder is checked to be the one checked. The temporary files a concurrent agent import or save writes known_marketplaces.json through, regular files, stay. A folder that can't be cleaned fails the start of a VM with that agent and warns for any other (agent_seed_clean_failed, naming what the folder should hold). - vm: Env.cleanSeeds, cleanSeed and seedTemp (agents.go), called first in bringUp with the VM's agents. - msg: agent_seed_cleaned, agent_seed_clean_failed, agent_seed_link. - Tests: TestCleanSeeds (0.1.0-style store, a link entry, a concurrent import's temporary file, no store, once only), TestCleanSeedsFails (a link at the store, .claude or plugins, for a VM with and without Claude Code; an entry that can't go); fixture_v010_plugins.txtar (0.1.0's app with the store's plugins as 0.1.0's import left them and their mount: the warning, no edit but the ssh port's, the seed's link to a folder without data/, nothing said again; then the store's plugins folder a link, and an entry that can't go, each refusing app's start with agent_seed_link or agent_seed_clean_failed). - Docs: coding-agents, internals/agents, the design note's threat check; CHANGELOG Breaking, After you upgrade (running VMs, Linux's cache, plugin logins) and #56's Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6965efcc0a |
fix(vm): devvm agent login claude --setup-token shows Claude Code's address (#57)
An agent's login in the VM ran with devvm's own writers as its output, so os/exec gave limactl shell pipes, Lima added no ssh -t, and claude setup-token, which draws full-screen, showed nothing and waited. When devvm's stdin and stdout are terminals and both output streams are files, the login now gets stdout and stderr as the files they are (ui.Terminal, set by cli as vm.Env.Terminal), so Lima gives it a terminal in the VM, as devvm's shell has. Without a terminal it keeps pipes, and --setup-token warns first (setup_token_no_terminal). Its output reaches devvm's output alone, never the run log, as before. On a terminal, Ctrl-C goes to the login in the VM, which ends, and devvm says the login ended or saved nothing. - internal/ui: Terminal, over Files, never a half pair; TestTerminal. - internal/vm: Env.Terminal; AgentLogin.loginOpts; the warning; why an interrupted login's cleanup stays as endLogin's backstop; endLogin's comment for a login on a terminal; TestAgentLoginTerminal (fails without the fix). - internal/backend: ExecOpts says a terminal's files pass on as they are; Lima's TestExecStreamsAsGiven. - internal/cli: vmEnv sets Terminal; agent_login.txtar checks the warning. - locales/en.toml, internal/msg: setup_token_no_terminal. - tests/e2e: OnTTY, out of TTYRun; network's check that devvm agent login claude --setup-token on a terminal shows the address, waiting for its devvm to end before the next login. - Docs: internals/network.md, using/coding-agents.md, contributing/extending.md and tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ea3037bc15 |
fix(vm): MCP servers' logins in a VM finish and survive launches (#62)
Each launch and each devvm agent login claude copied the store's VM copy of Claude Code's OAuth login (claudeAiOauth only) over the VM's ~/.claude/.credentials.json, where Claude Code also keeps its logins to MCP servers (mcpOAuth: their tokens and, mid-login, the PKCE verifier). So an MCP login failed when the VM was set up again before it finished, and a finished one was gone at the next launch. The setup now gets the copy as claude-credentials.json (claudeSyncName), and sync.sh's merge_claude_credentials merges it in the VM: the copy's claudeAiOauth replaces the VM's (or takes it out when the copy has none), every other key of the VM's file stays. It reads the VM's file with one jq call (--slurpfile, so two JSON values or a non-object are caught) and writes it whole, mode 600, through a mktemp file in ~/.cache, which no history export or remake carries, then mv; a failed cat or mv removes the temp file and fails the setup. A link, or a file that's empty, not JSON or not one object, is replaced by the copy and said (a link removed first, so mv never writes through it into a folder); a folder is left and said. With a Claude Code token (setup-token), devvm sends no copy, as before, so the VM's file stays as it is: Claude Code prefers the token in its environment, and a leftover login's placeholder gets the token at api.anthropic.com and nothing at the connectors' host. mcpOAuth stays in the VM: devvm agent save reads only settings and the .claude.json allowlist, history export excludes .credentials.json (HistoryExcludes) and import skips it, and a remake leaves login files out (homeSkips), all unchanged. Tests: TestStageClaudeOAuthMerged (the copy is staged to merge, never at home/.claude/.credentials.json); TestClaudeSyncNamesMerged (sync.sh merges each claudeSyncName name into its place); guest.txtar runs merge_claude_credentials (mcpOAuth and other keys kept, claudeAiOauth replaced or removed, a key with a \u escape, empty, not JSON, two values, an array, a link to a file or folder, a folder, a failed move, the warnings, mode 600, no temp left); agent_login.txtar reads the new name. Docs: Coding agents' MCP servers' logins (real tokens the VM's code can read, never leaving it) and its Copies, How it works' Claude Code's login and the network page's sentences, what a VM made again keeps, the sync.sh header, and the safety pages' claim that a VM never holds a refresh token, narrowed to the logins devvm keeps. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c1db911d1b |
fix(agentlogin): the Claude login reaches claude.ai's connectors (#61)
Claude Code lists a claude.ai account's connectors at api.anthropic.com/v1/mcp_servers and reaches each at mcp-proxy.anthropic.com/v1/mcp/<id>, with the login's access token. The OAuth login's binding named api.anthropic.com alone, so the connectors' requests carried the placeholder and were refused. ClaudeOAuthBindings gives the OAuth login a second binding, claude-connectors: the same placeholder, into Authorization for mcp-proxy.anthropic.com below /v1/mcp/ alone. It has a name of its own because the proxy looks a value up by its binding's name, and secrets.Store.Get gives claude-oauth a Claude Code token in the login's place but never gives one to claude-connectors, so a token, saved or in devvm's environment (whose scope isn't checked), still goes only to api.anthropic.com. The bindings file stays version 1. Tests: TestClaudeCapture and the claude-oauth golden check both bindings; TestClaudeBindings checks the connectors' binding gets the OAuth login and never a saved or environment token (with the claude-oauth control); network.txtar checks the VM's secrets.json and secrets.policy. e2e's network section adds the connectors' host to its fake upstream: with the claude secret, neither its placeholder nor the OAuth login's gets the token there (the API, the control, does), and after the host's refresh the connectors' host gets the refreshed access token. Docs: the Claude Code login, the attack vectors' new entry for connectors (deny mcp-proxy.anthropic.com to keep them from a VM), How it works' bindings and threat lines, the agents' table, and Contributing's e2e network section, whose refresh sentence was stale (the refresh succeeds). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e97db057fd |
fix(agents): Claude Code's plugins get a folder of each VM's own, the store's a read-only seed (#56)
A VM's ~/.claude/plugins was the agent store's plugins folder, mounted
read-only, so everything Claude Code writes there failed with EROFS: a
plugin's data (${CLAUDE_PLUGIN_DATA}), installs, marketplace refreshes,
mcpb/ and the rest. Making the store writable would let one VM change
what Claude Code runs in every other VM, so each VM's ~/.claude/plugins
is now its own folder on its disk (CLAUDE_CODE_PLUGIN_CACHE_DIR), and the
store's folder is linked at ~/.claude/plugins-seed and read as Claude
Code's own read-only seed (CLAUDE_CODE_PLUGIN_SEED_DIR). Checked on a
devvm VM first: a seed-cached plugin from a GitHub-style marketplace
loads with only enabledPlugins, its hook writes ${CLAUDE_PLUGIN_DATA} in
the VM's own folder, installs in the VM work, and seed marketplaces
refuse updates.
- agents: Def.Seeds (Rel, Link, Entries), Seeds, SeedOf, MachineOwn;
Env gains Home; Claude's Env sets both variables below $HOME.
- vm: the setup links a seed at its Link and stages own-dirs, which
sync.sh makes a folder in place of a link; agentEnv writes Home values
through homeValue (shared with toolchainEnv); a remake keeps the VM's
own folder and skips the seed's link.
- devvm agent import copies only a seed's entries (known_marketplaces.json,
marketplaces, cache), directly and through followed links, so the
host's plugins' data, mcpb, synced, .trash, store and
installed_plugins.json never reach the store.
- devvm agent save: the VM's script excludes a seed folder's other
entries by name, and readSent refuses any (listedPath); a seed folder
adds and changes, never removes or prunes; claudeRecords renames the
VM's plugins path to the store's and joins known_marketplaces.json by
key, leaving records Claude Code registered from the seed as the
store's, and the store's file as it is when nothing changed.
- History: an export leaves the VM's plugins folder out and an import
skips it and the seed's link: it's settings and plugin data (which can
hold a plugin's own logins), not history, and reaches other VMs only
through devvm agent save's reviewed diff.
- Review fixes (security-audit): historyImport refuses a name with a
., .. or empty part (GNU tar's anchored excludes missed
.claude/./plugins and .claude//plugins, which now reach a writable
folder) and deletes importSkips by path after the link sweep; the save
script never excludes a name with a wildcard's character (it's sent
and refused); only a marketplace record whose exact installLocation is
clean and in the store's marketplaces joins the store's.
- Tests: claude_test.go (TestClaudePluginsSeed, TestClaudePluginsHistory,
TestAgentImportClaudePlugins, TestAgentSaveScriptClaudePlugins,
TestReadSentClaudePlugins, TestAgentSaveClaudePlugins), TestSeeds,
TestListedPath cases, the agent, agent_save and sync CLI tests, goldens,
and e2e project checks of the seed, the VM's folder and a plugin's data.
- Docs: coding-agents (store table, Claude Code's plugins under Mounts,
the save's plugin example), internals/agents, a design note with its
threat check, extending.md, CHANGELOG Fixed and After you upgrade.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
2c0a894a1c |
fix(vm): a project folder's VM works after a boot renumbers its disk
macOS numbers its disks' devices in the order they appear at boot, so after a restart an unchanged project folder's identity (dev:ino:btime) can have another device. The finder then refused its VM as made for an earlier folder (vm_other_folder), a stopped VM's start refused it as replaced (project_folder_changed), and the next .git check called it replaced (git_replaced). platform.SameFolder is now the one comparison of two folder identities: the same ID, or at the same path the same inode and birth time on another device. On another device the ID must also be the one read from the folder opened at the path with no link followed (OpenNoLinks, then fstat and fstatfs on it: openFolderID), on a file system whose IDs are their folder's alone, so a link swapped in while the caller read the ID can't pass a copy's (a snapshot's, a cloned disk's) off as the folder's. A folder at another path (moved) matches only exactly. platform.Renumbered says when the record needs the folder's ID as it is now. The finder's sameFolder, here.movedFrom, gitprotect's protectRepo and the strict conversion's checks use it. A start records the project folder's identity as it is now under the VM's state lock (renumbered, in bringUp) before the backend mounts it by Want.ProjectID, so vz's /.vol/<dev>/<ino> mount names the current boot's device, in the one limactl edit; folderChanged's checks after it then compare exactly. A .git check that accepts a renumbered .git records its current identity. The move's check stays exact, as both its IDs are read in one run. The structure test's folder-ids rule fails on == or != on a field named Folder or GitID, or a call of FolderID or folderID, outside internal/platform and tests, unless exactFolderIDs lists the function with why: the agents' and exports' Folder paths, recordMove's unchanged-state check and folderChanged. Tests: TestSameFolder (platform), TestRenumberedFolder (vm), TestReportsRenumbered (gitprotect), a renumbered vz case in TestProjectMountByInode (lima), existing.txtar's renumbered folder, and fixture_v010_renumbered.txtar on the frozen v0.1.0 state, through the new renumber script command and stubtest.Renumbered. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ba5613e1ed |
fix(project): a folder name's run of separators becomes one dash in its VM's name
A folder named x--y, "foo (copy)" or "C++ stuff" failed to get a VM (#52): project.Slug turned each character other than a-z and 0-9 into its own dash, and Lima's instance-name grammar refuses separators in a row. Slug now writes one dash per run. - vmname: the project-VM grammar refuses dashes in a row ([a-z0-9]+(-[a-z0-9]+)*); HasRuns recognises the names releases up to 0.1.1-rc.3 made for such folders. - state: a vm.json whose name HasRuns and that has no created time is read as no state. Only a create that Lima refused leaves one (vm.json is written before limactl clone), so the folder's next VM, in the same hash folder, replaces it, rather than every read failing as corrupt. One with created set is still corrupt. - The limactl stub refuses names Lima refuses on create and clone; TestLimactlStubContract gains a refused clone, checked against real Lima. - Tests: TestNamesLimaTakes (Lima's regex as the oracle), TestHasRuns, TestVMWithRuns, TestLimactlRefusesNames, name_runs.txtar (a new VM for x--y, and an older release's leftover state replaced). - Docs: internals/backends.md's VM names; CHANGELOG Unreleased Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f9c02c1c5c |
build(lint): a file a VM can write is changed through what opened it
forbidigo refuses os.Chmod, os.Chtimes, os.Chown, os.Lchown and os.Truncate in internal/proxy, internal/vmlog and internal/vmssh, outside tests: a change by path follows a link a VM swapped in after the open. The two sites today, the proxy's SSH agent relay socket and the link session's sockets, chmod a unix socket devvm has just made in its own folder, which only its path can set; each says so in a nolint. The safefile rule widens to internal/vmlog, which has no open of its own, and to the proxy's rotate.go and nixcache.go, whose three opens to write or lock say why in their nolints. testdata/lint breaks the rule once for each function and keeps the descriptor's own methods. Named as the guard in codebase-standards' Treat what a VM can write as hostile and rules.md, and in the checks on owners. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0b85f5f557 |
fix(size): a size that isn't a number is refused, never read as 0
Size.Backend dropped strconv's errors, so a VM's size in vm.json that isn't a number, such as "cpus": "four" after an edit by hand, read as 0, the image's, and the VM started with the image's size without a word. Backend now reads each part with the check that took it (settings.CPUCount, settings.GiB, which ParseCPUs and ParseGiB now use), and returns an error naming the key and value. storedSize turns a stored one into size_stored_invalid, naming the VM. Every start (bringUp, before anything runs), a restart's stop (stopToStart, so a running VM keeps running, as a refused proxy start leaves it), devvm size and a remake's check refuse with it; devvm size --KEY sets it again. ParseCPUs and ParseGiB also refuse a number too big for an int or a float64, which for --disk reached Lima as +Inf. Lima's originOf read base's disk with ParseFloat and dropped its error: "NaN", "Inf" and "1e400" passed its check of a size above 0. Only devvm's own Origin writes that step (gibString of BaseDiskGiB), so no user, VM or limactl output reaches it; it now reads it with settings.GiB and fails naming the value. Every other discarded strconv error outside tests goes too: - hostgit.Bool reads a boolean as git does (yes, on, whole numbers) and says when a value isn't one; GIT_CONFIG_NOSYSTEM, which strconv.ParseBool read as false for "yes", uses it, as does the clone's copy of a repo's config (gitBool, which had its own copy). - image.GlibcOlder checks both versions itself and reports ok, so one that isn't a version is never read as 0. - leaktest and state's lock order panic on a goroutine number runtime.Stack doesn't print today, rather than reading it as 0. - cli's test-build overrides fail on a number that isn't one (a test build's panic), the stub limactl refuses a size it can't read, and opencodeMajor's fallback to 0 is explicit. Tests: TestSizeBackend, TestStoredSizeInvalid (a stopped VM and a running one's restart), TestSizeNumbers, new TestParseSizes and TestOriginOfRefuses cases, TestParseUnknownFormat, TestBool, TestUserFilesOf's git booleans, TestGlibc's invalid versions; each fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1a16b1bb73 |
build(nilaway): the baseline follows three triaged findings the harden stack reshaped
The agent relay's finder calls the VM state's Name directly, the links report is read through safefile.Read rather than os.ReadFile, and the rotation's Stat finding is gone with the broker's descriptor-based copy. The two that remain are the same false positives in new shapes: fst is set together with found, and from is reset when the data is shorter. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7bc886133d |
fix(proxy): the broker frees a request's slot as its reply goes; start tests wait out a loaded host
The proxy's start and broker tests failed on loaded hosts, most on the linux host under the race detector. The causes: - Start timeouts (TestAgentRelay, TestMainRuns, TestMainRefuses, TestStartChildSandbox, TestV010ProxyConfigsStart, TestHandshakeChildGone): a broker's start, timed from its own, hashes its executable (selfSum), and the in-process child's spawn hashed it again. Under -race with the package's other tests, each hash took 2-3.5 s on the linux host, so starts passed startWait's 4 s (a start frame's write timing out, a relay or a proxy not listening within the test's 2 s of retries). IO gets a startWait field, a test seam; inProcess sets it to testStartWait (30 s) and hashes the test binary once per inProcess, and the tests wait as long for the proxy (retryFor). devvm's own proxy still waits 4 s. - TestBrokerClientGivesUp's "busy": a real bug. The broker gave a request's slot back only after its reply was written, and the child gives its own back as the reply arrives, so a child that kept the caps and sent its next value at once could get busy. answer now frees the slot once the reply holds the socket's write lock, just before it's written (frameConn.sendThen), so a reply that waits for a child that doesn't read still holds its slot and the bound stays. TestServeChildFreesSlotsAsRepliesGo checks both, in a synctest bubble, and fails without the fix. The broker isn't released yet, so no CHANGELOG entry. - TestSpliceKeepsAnEarlyAnswer (1 in 20 on linux under -race): splice could put the whole 4 MiB answer into loopback's buffers and close before the test's delayed upload arrived, which then reset the connection and dropped the unread answer. The test's server now answers once the upload's first bytes reach it, as a 413 does. Coverage: internal/seatbelt has 53 statements, and the mini's unit and CLI runs cover 51 (96.2%) every time; 97.4% isn't k/53 for any k, so the baseline was measured on an earlier version of the package (37/38). The two misses were ProxyChild's branch for a profile that can't be made, now tested, and ChildProfile's template panic, which can't happen. darwin's baseline rises to 98.1. Docs: the design note says how the broker's caps never refuse a child that keeps them; Contributing's tests page covers testStartWait. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1793353dd9 |
feat(proxy): Linux confines the proxy's child with Landlock and seccomp
Before it reads a byte of the VM's, devvm _proxy-child confines every thread of itself through proxy.confineSelf on Linux: no_new_privs (syscall.AllThreadsSyscall), Landlock from ABI 2 (TSYNC from ABI 8) to its logs folder, the Nix cache and the resolver's files (never /, the home folder or one that holds it), binding no TCP port (ABI 4), scoping signals and abstract sockets (ABI 6, or ABI 6/7 with erratum 2), refusing named unix sockets (ABI 9) and UDP but to port 53 (ABI 10); then a hand-written classic BPF seccomp filter, installed with TSYNC, that refuses with EPERM AF_UNIX socket/socketpair, listen, io_uring, ptrace, process_vm_readv/writev, pidfd_getfd, a file's mode, owner, xattrs and times by its path (chmod, fchmodat, fchmodat2, chown, lchown, fchownat, the six xattr calls, utime, utimes, futimesat, utimensat with a path), truncate, the keyrings (add_key, request_key, keyctl), prlimit64 on any pid but 0, setpriority, ioprio_set, sched_setaffinity, sched_setscheduler, sched_setparam, sched_setattr, inotify_init, inotify_init1, inotify_add_watch, fanotify_init, fanotify_mark, execve, execveat, fork, vfork, unshare, setns, bpf, userfaultfd, perf_event_open, clone for anything but a thread or with a namespace's flag, and clone3 with ENOSYS; it kills a foreign architecture's call or an x32 number. fchmod, fchown, ftruncate and utimensat on a descriptor stay. It checks the confinement holds, then proxy.checkConfined, and that it still reads the host's addresses, within 2 seconds, or fails the start. A kernel without Landlock or seccomp leaves that part out; the child runs and says so. The broker sets itself undumpable (PR_SET_DUMPABLE 0). The Nix cache marks a file used through its descriptor. The broker's start, and its life with the child, take a reset of the socket (ECONNRESET, Linux's end of a socket closed with frames unread) as the child's end, as EOF is (socketEnded, TestHandshakeChildGone). Built on the Seatbelt item's shared owner, proxy.Confinement: - internal/landlock (new, stdlib only, Linux build tags): Self, Result, Floor, ABIPorts/ABISignals/ABIUnix, ErrUnsupported; landlock_linux.go (resolverFolders, refusedFolder, homeFolder), filter_linux.go (filter, asm, encode, archOf), seccomp_linux.go, self_linux.go (Self, check, refused). - internal/proxy: confineSelf on Linux calls landlock.Self; landlockConfinement words it (By landlock, seccomp; Why no-landlock-or-seccomp, no-landlock, no-seccomp, landlock-below-abi4, landlock-signals; full from ABI 6 with seccomp and scoped signals); confineChild takes the child's needs and returns an error, bounded by confineWait (within, confineWith); checkConfined only where Landlock or Seatbelt confines files; confineStarted; IO.confine required, set by ChildMain alone; hostAddrs.check; touch_linux.go and touch_other.go (touchFile, undumpable); IO.dumpable for tests. - devvm doctor: netpolicy.Unconfined's Linux warnings (proxy_unconfined_no_kernel, _no_landlock, _no_seccomp, _old_ports, _old_signals). - Tests: TestFilter and TestFilterBytes (an interpreter of the program's bytes, amd64 and arm64, and the assembler's refusals), TestSelf (a real confined child: outside file, ssh-like unix socket, listen, bind, signal, chmod, chown, setxattr, utimes, truncate, a keyring, unshare, exec, clone3, and new threads, fchmod, ftruncate and futimens kept), TestKernel, TestCheck, TestRights (refusedFolder), TestArchNumbers, TestLandlockConfinement, TestConfineWithin, TestCheckConfined, TestConfineStarted, TestRunChildOn, TestUnconfined; network.txtar; e2e network's Landlock, NoNewPrivs and Seccomp check. - CI: a nocgo job (CGO_ENABLED=0) for internal/landlock and internal/proxy. - Structure test, depguard, goroutineSites; docs: the child's sandbox, processes (and its why-Go note on unsafe), design (the network row's loopback follow-up on Linux, other processes and /proc without Landlock), doctor's checks, troubleshooting, attack vectors, Contributing, the proxy's README, AGENTS.md, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
941c63c696 |
feat(proxy): the proxy's child runs under Seatbelt on macOS
On macOS the broker starts devvm _proxy-child through /usr/bin/sandbox-exec -p PROFILE, by devvm's real path, with a deny-default profile, so the child is confined from its first instruction: devvm's binary to run and read, its folder's metadata, dyld-support.sb, /usr/lib and /System/Library, the time zone and resolver files, its logs folder and the shared Nix cache (regular files only, no hard links, no folder removed, no flags, ACL, owner, set-id or xattr changes), stat alone on the watched files and every link on the way, trustd and trustd.agent, mDNSResponder's socket, TCP and UDP out (loopback left to the floor: a rule for a loopback port applies at once, which a profile fixed at the start can't follow), sysctl but kern.proc, signals to itself. No home folder, no devvm folder but its own, no Keychain, no other unix socket, no bind, fork, exec, signal to or look at another process (process-info, the process list). - internal/seatbelt: the shared owner of Seatbelt (Exec, String, Path, Links, ChildProfile, Sandbox.ProxyChild); sbString, sbPath and sandboxExec move here from the Lima backend, which uses them. ChildProfile refuses a relative path and the root. - internal/proxy/confine.go: the confinement report every platform shares (Confinement, ParseConfinement, ReadConfined: one line of fixed words in run/proxy.confined, refused unless it parses, and unless it fits what the broker started the child with), the child's self-check (checkConfined: its broker's config must be refused), and the in-process hook (confineSelf, confineself_linux.go and confineself_other.go) for the Landlock follow-up. - internal/proxy/childstart.go: startChild, childSandbox, childNeeds; IO.Seatbelt, set by devvm _proxy on macOS. A missing sandbox-exec, or one that failed before devvm's code ran (exit 65 or 71, or SIGABRT or SIGKILL, before the child answered, decided before the broker's own stop), starts the child again unconfined within the broker's 4 seconds, with a warning in proxy.log; any other failure fails the start. The broker makes the Nix cache's folders first. start carries how the broker started the child (Spawned). - watched.get: a stat refused for want of permission reads through the broker each time (a watched link pointed elsewhere after the start). - daemon.Handle.ExitCode and ExitSignal. - devvm doctor warns for each running VM whose proxy's child isn't fully confined (netpolicy.Unconfined; proxy_unconfined, proxy_unconfined_unsupported, _no_sandbox, _sandbox_failed, _check_failed). - Tests: TestParseConfinement, TestCheckConfined, TestReadConfined, TestStartChildSandbox (an over-claiming ready, SIGTERM), TestSandboxFailed, TestChildNeeds, TestWatchedStatRefused, TestUnconfined, TestString, TestLinks, TestChildProfile, TestProxyChild, TestChildProfileConfines (the test binary run again under the profile on macOS: flags, rmdir, the process list), doctor's report, ExitCode and ExitSignal; e2e network checks run/proxy.confined is full seatbelt on macOS. - Docs: How it works' The child's sandbox, Processes, the design note's confinement and threat check (loopback as open work, other processes' details and kern.procargs2, the shared folders' flags, mDNSResponder's records, trustd.agent's trust settings, the fallback's signals, a ready that claims more), Troubleshooting's The proxy runs without a sandbox, Staying safe's escaping the VM, doctor's checks, Contributing's packages, the proxy's README, AGENTS.md, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
63bb1ff9a8 |
fix(network): a confined VM's programs ask 127.0.0.1 directly, so names fail at once
With transparent mode off or stopped, a confined VM's only name server, 127.0.0.1 (Lima's DNS setting), has nothing listening. glibc asked it through systemd-resolved's stub, which could keep retrying it over UDP and TCP without answering, so a lookup such as getent's waited out its timeout instead of failing at once (seen on a Linux host: e2e network's checks of DNS with transparent mode stopped and off). Each launch's setup now replaces /etc/resolv.conf, the stub's link, with devvm's own file on a confined VM: nameserver 127.0.0.1 alone, the stub's search line, timeout:1 attempts:2. glibc gets a refusal at once with nothing listening, and dnsmasq's answer through transparent mode's nftables rule when it runs, as musl on Alpine does. An open VM gets the stub's link back. Only systemd guests that have the stub's file and whose /etc/resolv.conf is its link or devvm's own are touched. Root cause, as far as it could be pinned down: with resolved's stub in the path, a lookup depended on resolved's retry loop over a server that refuses everything (24 attempts, flipping UDP and TCP feature levels), and on the linux host that loop sometimes never answered the stub within getent's 3 s. It didn't reproduce on demand (a base run on the linux host passed both checks, and bursts of 200 parallel lookups and stops mid-lookup all failed in under 2 s), so the fix takes resolved out of glibc's path rather than tuning it. Going back to open restarts systemd-resolved: it reads a /etc/resolv.conf that isn't its own link as global servers and search domains, so it had taken 127.0.0.1 and "~." from devvm's file, and kept them once the link was back, which left an open VM unable to resolve names (caught by e2e network's open checks on the linux host and ubuntu). Review folded in: no change of a foreign or dangling link when the stub's file is missing; two attempts; Docker's user-defined networks in the docs. Second review: devvm's file alone is enough to go back on an open VM (a warning when the stub's file is missing); a failed write says so in one line and the launch goes on; troubleshooting's "An open VM resolves no names after a downgrade"; tests for resolved's own resolv.conf link, an open VM without the stub, a non-systemd guest with devvm's file and a failed write. workerd under wrangler dev, checked by hand on fedora with transparent mode off: its fetch fails at once (Temporary failure in name resolution), so the "about 40 seconds for each lookup" sentence is gone from lima.md, safety/network.md and troubleshooting.md, and testing.md's manual check covers it. testdata/coverage/darwin.txt: internal/sshagent's baseline rose with mise run coverage (unrelated to this change). - backend.Confinement.Resolver: the one owner of a confined guest's name server; Lima's start sets .dns from it, sync.go sends it to the setup as DEVVM_RESOLVER; sync.go's setupInputs as mise run fmt writes it. - assets/guest/sync.sh: resolver_conf; its unit test runs the function (internal/vm/resolver_test.go). sync.sh runs at each launch and goes in no image, so no image key changes. - CLI tests: DEVVM_RESOLVER on confined (transparent on and off) and open VMs. e2e network: the stopped-transparent check also checks the file. - Docs: network.md's The VM's resolver, lima.md, design.md, tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aeea3135b2 |
feat(proxy): the proxy's broker and its child
A VM's proxy runs as two processes, as design.md's "The proxy's broker"
says: devvm _proxy, the broker, which keeps what only the host should
do, and devvm _proxy-child, which reads the VM's network and can be
confined by the follow-ups.
- wire.go: the protocol over one socketpair (close-on-exec from the
start: SOCK_CLOEXEC on Linux, ForkLock elsewhere), length-prefixed JSON
frames of at most 2 MiB, unknown fields refused, bytes as base64, one
descriptor on a frame's first bytes (SCM_RIGHTS, MSG_CTRUNC breaks the
rules), wire types for every secret (redact.Secret at once).
- broker.go: newBroker, the start (handshake: version 1 and each side's
executable's SHA-256, within 4 s), the answers (value through lookups,
kept 30 s or 5 min, a failure 5 s, dropped when the bindings change;
file by number; link connected by the broker and passed as a
descriptor; token exchanged by the broker), each by something in its
own config, with caps 1/8/4/256; live: the lifeline closes the socket
and kills the child 6 s later, SIGTERM stops it within a second, a
child that ends ends the broker, a rule broken stops the child.
- child.go: the start (startOf), the child's server (newChildServer),
the broker as hostSide over the socket (brokerClient), runChildOn;
ready only after it reads the host's addresses (kept: the last good
read), roots and time zone loaded first.
- process.go: Main(ctx, ...) and ChildMain; the child spawned with
/proc/self/exe on Linux, PR_SET_PDEATHSIG from a locked thread
(daemon.Cmd.DieWithThread), descriptors 3 and 4, and TZ, SSL_CERT_*
and GODEBUG with updatemaxprocs=0 alone; run/proxy-child.pid and
run/proxy.confined ("none" until the follow-ups); KeepLogs in the
broker. ChildMain refuses to start unless descriptors 3 and 4 are a
unix socket and an IP one (checkInherited): run by hand, without
them, those numbers can be the Go runtime's own, which closing
crashed it (signal_recv: inconsistent state).
- capture.go: a captured token request goes to the broker
(captureToken, exchanger), so a login's real tokens never enter the
child; an error reply passes up to 1 MiB, longer gets 502.
- watched.go: the child stats each changing file and asks the broker
for it once it changed, keeping the stamp of what the broker read.
- rotate.go: proxy.log rotated by both through its descriptor, under a
lock of a description of its own; OpenLog opens a log never through a
link, one link, yours, replacing what a child left in its place.
- nixcache.go: the trim and its count through a safefile.Root, nar/
only as a folder, links deleted as themselves; reads never through a
link; the lock tried for 5 s (ErrNixLocked, nix_cache_locked).
- daemon: Cmd.Err, Files, Env, DieWithThread; Handle.Kill, Exit;
WritePID.
- netpolicy: Proxy.Stop also stops a child that outlived its broker
(run/proxy-child.pid, _proxy-child -for); proxy.log opened with
OpenLog; a refused launch keeps a running VM only while both run.
devvm network log and lock read the event log through safefile.
- vm, vmssh, vmlog: links.log and ports.log opened with OpenLog, read
through safefile, trimmed only as a regular file with one link.
- backend: the build proxy's logs in a logs/ folder of their own.
- cli: _proxy-child; _proxy waits for its child on a signal
(StopsItsOwn); the child reads none of devvm's folders (no
makePrivate); ui.Files.
- Tests: FuzzBrokerFrames, the frames' rules, the handshake and the
pair's end in synctest bubbles, the caps, the broker naming its own
alone, the client over a real socketpair with a passed descriptor,
ChildMain, TestInheritedSocket and proxy.txtar's child run by hand,
the frozen 0.1.0 configs starting a broker and child,
two writers rotating once, planted links, FIFOs and hard links; the
testscript runner stops _proxy-child too; e2e: broker and child, their
arguments, descriptors and environment, stop, SIGKILL either, planted
files in the logs folder and the Nix cache, build proxies gone.
- Review fixes: the lifeline closes the socket and starts the kill's
timer before logging; every log lock (proxy.log's, the event log's
rotation) is tried without blocking for 200 ms (flockWithin, which the
Nix lock shares), then written without or the rotation skipped; a
copied log's rotation streams at most twice its limit from a line's
start (copyFrom, copyAtomic); a reply too long to send goes as
too_long; kept token headers capped at 1 KiB; the child gives up on a
request whose context ended, dropping its late reply and holding its
slot until then; a write deadline on the start frame; errors reach the
child as codes (not_found, refused, busy, too_long, failed), their
text in the broker's log; FuzzFrameStreams, and FuzzBrokerFrames
writes from a goroutine; nix_cache_locked links to How it works.
- Docs: processes, network, overview, design (with threat rows for the
logs' locks and a log made huge), troubleshooting, the proxy's
README, structure, testing; CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
9c74dac11e |
fix(logs): a VM's logs are held to their caps while it runs
internal/vmlog owns every log a VM can drive but the proxy's own: Limit (moved from vmssh's logLimit, with Allow for the link session's warnings), Capped and Trim for ports.log and links.log while they run, and KeepVM, which the VM's proxy (proxy.IO.KeepLogs, Config.VMLogs from backend.Run.Logs) and a Lima build run on the serial consoles' and the hostagent's logs: redacted as they grow (redact.FileFrom), so a reboot in place can't leave the proxy password there, and rotated past 10 MiB, counting what a log holds past the hole its writer left (platform.DataStart). The proxy's http.Server logs through its own limited log, and its copied log counts what reached it as stderr; the build proxy's log is held as a VM's proxy's is. git-pins.jsonl has a cap. Run logs take at most 256 MiB together, never the newest or a live run's. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4a4aabe9a8 |
fix(netpolicy): a refused launch leaves a running VM and its proxy as they were
With config.toml's proxy naming a user and no proxy secret saved, devvm in a running VM's folder refused (proxy_password_missing) but stopped the VM (net_proxy_down_stopped), and devvm restart stopped it before refusing. Every check that can refuse a proxy start already ran before Prepare stopped the old proxy; runningConfinement stopped the VM on any error. - netpolicy.Proxy.PrepareRunning: Prepare for a running VM. A refusal before its proxy is touched keeps the VM and proxy (net_proxy_kept, a new message) only while that proxy enforces the state's tier now (enforcesNow: built-in, files, denies, open, devvm binary); otherwise, or once its proxy was stopped or started, or with none running, the VM is stopped (unproxied, was Unproxied, which now stops a proxy left running too). - netpolicy.Proxy.Refusal (shared): the user's CAs and the company proxy, checked first in prepare, before a VM is made (up), before a running VM is stopped to start again (target.stopToStart: devvm restart, restartForNextStart), and before a running VM's tier changes between confined tiers (checkTier: devvm network, lock), so its state never names a tier its proxy doesn't enforce. - devvm network's change to a running VM's rules goes through PrepareRunning, so a proxy that can't start again stops the VM rather than leaving it running without one. - Proxy.Upstream removed (no callers); shared, prepare, unproxied and tierNow are functions of the proxy, keeping Proxy within 24 methods. Tests: company_proxy.txtar (launch and restart refused, VM and proxy untouched; devvm network allowlist refused, tier unchanged), TestPrepareRunningRefused (eight rows), e2e corpConfig checks the VM's status after the refused launch. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
90a64a44d1 |
fix(races): lock order checked, sandboxes' own ports, pins that meet a rename, daemons' groups stopped
- state: test builds and tests check the state locks' order (state.held, CheckLockOrder): a second VM's lock, a VM's lock under the claims lock, or a lock taken again panics before waiting. - platform: PinBeneath opens the path again when a rename takes the file away before move_mount (ENOENT), so the keeper no longer reports a false lost pin (TestPinsInNamespace's 'f lost / f pinned-again'); TestPinWhileRenamed. - daemon: Proc.Stop signals the process group (SignalGroup), so forwarders' and link sessions' ssh masters and relays end with them; ui.UI.StopsItsOwn makes _ports and _links wait for their ssh on an outside SIGTERM. - vm: gc --orphans and devvm space count forwarders' leftover control sockets (vmssh.ControlGlob). - CLI tests: each sandbox claims a block of ports below devvm's range and the ephemeral range (claimPortBlock, /tmp/devvm-test-ports); free_port, the fixtures' ports and DEVVM_SSH_PORTS come from it, and the sandbox's devvm chooses from its own range (DEVVM_PORT_RANGE override). Fixtures' forwarded ports and settings ports are rewritten too (FIXTURE_PORT_<port>). - netpolicy and vm tests: the fake proxy's stop waits for its reap, and fake daemons run until the test ends, not 30 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a7cc12521e |
test(fuzz): fuzz targets with properties, fuzzed nightly
Twenty-three new fuzz targets, built-in Go fuzzing, each checking a property rather than only that nothing panics: parsers of what a VM or the network sends fail closed and keep to their caps, a secret goes only where it's bound, and no planted secret survives a redaction. - internal/proxy: FuzzCursorFrames (passes only what came; no message over frameMax or holding a JWT's start, decompressed and unescaped), FuzzInject (a binding's value only to a host it names, judged apart from the matcher in NormHost's form, for its path and methods, in its own header, which held the exact placeholder once; other headers untouched), FuzzParseBindings, FuzzLinkList, FuzzParseUpstream (errors hold no more of the URL than its scheme), FuzzNoProxy, FuzzParseNarinfo (only cache.nixos.org-1's signed narinfo is taken). - internal/agentlogin: FuzzParseTokenRequest, FuzzRedact (secrets planted eight ways in JSON and TOML settings), FuzzCapture (the VM's reply holds none of the endpoint's tokens). - internal/redact: FuzzSplit (a password written in parts through Split, as the run log writes it, never survives). - internal/jsonc: FuzzStrip, differential against encoding/json. - internal/upgrade: FuzzParsePublicKey, FuzzVerify, FuzzEntryName, FuzzUnpack. - internal/vmssh: FuzzParseHostKeys, FuzzParsePorts. - internal/vm: FuzzParseCloneState, FuzzParseInit, FuzzParseKept, FuzzParseLFSPointer. - internal/desktop: FuzzHandshakeVM. What they found, each fixed with a regression test: - NO_PROXY: an entry with port 0 (git.test:0) was read as the host on every port, and git.test:080 or :+80 as port 80, which Go's clients match against nothing; an entry whose port no request has, or that isn't plain decimal, now matches nothing (TestNoProxy, testdata/fuzz/FuzzNoProxy). FuzzHostSites' NO_PROXY site allows this difference from its frozen copy, and the design note lists it. - A JSON token request with more after its object was judged by its first object; it's refused now (TestCaptureRefuses). The Fuzz workflow runs nightly rather than two minutes weekly: five minutes a target, eight at a time, each target's corpus restored from and saved to a cache of its own (a failing input added to it, so it fails nightly until fixed), new inputs minimized in at most 1,000 runs, and one issue, "Fuzzing found failing inputs", opened, commented on when the failing targets change and closed on a clean night, by a separate job with issues: write that runs no repo code, on main alone. Target names must be unique across packages. bump.sh moves an action in a folder of its repo (actions/cache/restore, /save) with its repo's releases. Docs: Contributing's Fuzzing (running a target, the nightly run, every target's property), Maintaining's Fuzzing failures and its actions bump, the proxy README, the NO_PROXY and token request facts in How it works' network page and the design note. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
19f9900b86 |
fix(sshagent): a VM reaches its SSH agent only through its proxy's relay
OpenSSH's ssh-agent answers every request a forwarded connection sends, so a VM that forwarded your agent or devvm's own (shared by every VM that uses it) could remove all its keys (ssh-add -D), lock it with a password of its own (ssh-add -x) or add keys without bound, denying the agent to you and to the other VMs. Checked with a throwaway sshd and ssh-agent: all three succeed over ssh -A. Each VM's proxy now relays the agent its start chose on a socket of the VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and the VM's backend, devvm's own connections and the ssh entries for editors name that socket. The relay passes on only SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the [email protected] extension (so destination-constrained keys keep their constraints), answers everything else with SSH_AGENT_FAILURE, reads messages whole up to OpenSSH's 256 KiB, carries at most 16 connections and closes one idle for 2 minutes. A filtering relay rather than an agent per VM: it covers your own agent too, needs no copy of a key or a passphrase per VM, and fronts hardware and app-held keys. - proxy: Config.Agent/AgentSocket (checked together, absolute), the relay in agent.go, listened before the proxy says it's ready; its accept loop backs off after an error that leaves the listener open (EMFILE), 5 ms doubling to 1 s, logging the first. - daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only package the proxy already imports, so the relay, the port forwarder, the link session and a login's forward share one owner. - netpolicy: Prepare takes a start's agent; a running VM's proxy keeps its start's agent from proxy.json (relayedAgent); Stop deletes the relay's socket. - structure: paths.Dirs may have 62 methods (AgentRelay); the relay's goroutines in goroutineSites. - sshagent: Made.Relayed, which RecordStart sets on every start of this devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK included, and ReachOf(st, start): a relayed start gets the relay (or none while it's down), a start devvm didn't record (one outside devvm) gets none, or its proxy's relay, and only an older devvm's recorded start keeps the raw agent until its next start (runningConfinement, finder.inspect, sshconfig). - vm: LeftoverSockets also finds a killed proxy's relay socket for devvm gc --orphans and devvm space. - Tests: relay filter, wiring through Main, bounds and idle close, real ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay, RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar, an outside start in ssh_agent.txtar, and e2e checks that the VM can't remove, lock or add to your agent, nor the VM or an editor's connection remove devvm's agent's keys. - Docs: processes (the SSH agents, listeners), ssh, attack-vectors, security, design, lima, overview, space, structure, proxy README, AGENTS.md, CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f37c70a5cd |
fix(bounds): bound what a VM can make the host hold
Five bounds, each with a test that failed first. Long downloads,
WebSockets, slow streams and SSE are never cut: every bound is on what a
connection holds, never on how long it lasts.
- _qemu connect (Linux): each guest connection to the proxy was a host
process with no cap. Connect now takes one of connectMax (256) slots,
lock files in the VM's run/proxy.slots (paths.VM.Proxy(".slots")),
each process about 7.7 MB, so about 2 GB per hostile VM. A connection
past them gets an HTTP 503 (connectsFullReply) and closes before it
dials; QEMU's stderr says qemu_connects_full at most once a minute,
decided under full.lock so refusals at once say it once. A VM started
before keeps the two-argument form, unbounded until its next start.
No idle timeout or byte bound: the proxy bounds what each carries.
TestConnectSlots.
- The VM proxy (limits.go):
- maxConns (2048, twice maxConnects so a CONNECT still gets its 503
first) counts a connection from its first request with the VM's
password (conns.admit, via httpServer's ConnContext); a request past
it gets 503 and the connection closes. Connections without the
password wait in a pool of maxWaiting (128) where a new one closes
the oldest, so holding connections can't take a VM's room (a host-speed flood still slows it
through the accept queue: listed in design.md).
- maxRequests (2048) requests upstream at once, plain HTTP's and
intercepted tunnels' (requests.take), 503 past it: per-tunnel
HTTP/2 streams alone allowed ~100,000 upstream connections.
- each limit logs once a minute at most (everyMinute).
- httpServer adds IdleTimeout (10 min); a 407 closes its connection;
handleHTTP's WithoutCancel is replaced by whileHeard, which ends a
plain HTTP request once its client has stopped sending and goneWait
(1 min) passes with nothing written, so half-closing clients still
get answers that keep coming; quiet WebSockets aren't cut.
- heardWriter.Unwrap: plain ws:// upgrades got 502 (pre-existing) and
get 101.
- No ResponseHeaderTimeout: non-streaming LLM requests wait minutes
for headers, and a waiting client is counted.
Tests: TestProxyLimitsSet, TestProxyConnectionBounds,
TestProxyConnectionLimit, TestProxyWaitingConnections,
TestUpstreamRequestLimit, TestUpstreamRequestLimitIntercepted,
TestPlainWebSocket,
TestPlainHTTPEndsWithClient.
- serveOne (intercepted tunnels, transparent HTTP, the 403 page) takes
maxHeaderBytes (64 KiB) always, not 1 MiB, and HTTP/2
MaxConcurrentStreams streamsMax (100, not 250). TestServeOneHeaderLimit,
TestServeOneStreamsLimit.
- Accept loops (forwarder, link session, login forward) retried nothing
or at a fixed 100 ms: vmssh.acceptRetry backs off from 5 ms to 1 s and
logs the first error of a run, ending only when the listener closes or
ctx ends. TestAcceptRetry, TestForwarderAcceptRetries,
TestLinksAcceptRetries.
- The login callback (LoopbackForward) carries at most
loopbackConnsMax (16) connections, an ssh each.
TestForwardLoopbackLimit.
Docs: processes, network, ports, lima, design (threat rows),
attack-vectors, the proxy README, CHANGELOG Fixed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
1b8fd8a639 |
test(lifecycles): synctest bubbles for the relays, the forwarder, the links, the proxy and the daemon's stop
Timeouts, graces and closes are tested in testing/synctest bubbles on the
bubble's fake clock, to the moment, instead of sleeping and polling on the
real one, with stand-ins in memory behind seams that are fields. Each kind
keeps one real-process test. No behaviour change: each seam's production
value is what the code did before.
Seams:
- vmssh: sshRelay{grace, start} carries a relay (pipeSSH's body, as
pipeSSHFor was); start is execSSH in production.
- vmssh: Links.Listen (listenSocket unless set), for the links' sockets.
- proxy: egress.connect, the dialer for allowed far ends (a net.Dialer
with its 15 s timeout, set in newServer).
- daemon: Proc.Alive (Alive unless set).
- proxy: httpServer, the proxy's http.Server as run serves it, which the
tests' memServe shares.
New test-only package internal/memnet (standard library only): Pipe, whose
connections half-close, buffer 64 KiB and have deadlines, and Network,
listeners by address with Listen, Dial, DialContext and SetDeadline. The
structure test keeps it for tests and a leaf, depguard keeps it standard
library only, and its AfterFuncs are in goroutineSites.
Bubble tests:
- relay: TestRelayGrace (silent and talking, closed and half closed),
TestRelayGraceSlowClient, TestRelayGraceWriteError,
TestRelayCancelEndsBlockedWrite, TestGraceTimer (exact grace).
- forwarder: TestForwarder, TestForwarderAliveOnEnd, TestForwarderOnly,
TestForwarderGap (reports exactly Gap apart), TestForwarderGivesUpSilently,
TestForwarderClosesConnections (now also its stuck relay's ssh and slot).
- links: TestLinks, TestLinksSessionLost, TestLinksCap,
TestLinksEndStuckRelays (memSSH; relays end at the next sync on removal,
master replacement and target change), TestLinksList.
- proxy: TestTunnelHelloDeadline (EOF at exactly helloTimeout),
TestTunnelHelloStall (and a hello whole a moment before the deadline),
TestTunnelAddressSplitHello, TestConnectLimit, TestCloseConns,
TestCloseConnsWaitsBounded (close gives up at exactly closeWait),
TestSpliceEnds, TestSpliceEndsWhenItsClientCloses.
- secrets: TestSecretLookupFailuresNeverCached (hung lookups cut at
lookupTimeout, cancelled, failed and empty ones never cached; a request's
end doesn't cancel a lookup; the TTL to the moment).
- daemon: TestProcStopWaitsForTheEnd, TestProcStopKillsOnlyItsOwn,
TestProcStopKillsAfterWait (fakeProc), TestFollowLifeline.
- TestCursorReplyScans uses httptest.NewTestServer.
Kept on real processes and the real clock: TestPipeSSHGrace,
TestPipeSSHGraceSlowClient, TestPipeSSHGraceWriteError,
TestForwarderEndsStuckRelay, TestLinksBurst, TestSpliceKeepsAnEarlyAnswer,
TestProcStop.
Docs: Contributing's Tests has Time and lifecycles; structure.md, _index.md
and AGENTS.md name memnet.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4d409589bb |
refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.
Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.
Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.
Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.
Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
e4ea123927 |
feat(ports): VMs' ssh on ports browsers refuse
Lima listens on a VM's ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as http://localhost:PORT reached a server the VM controls with the cookies of every app on localhost, even in a VM that forwards no ports. - Every VM's ssh port, and every build VM's, is one of the 17 ports every browser engine refuses (ports.SSHPorts): the Fetch standard's bad ports from 1024 up that Chromium's kRestrictedPorts blocks too, which leaves out 4190 and 6679 (headless Chrome 157 loads both). The one allocator chooses it (Allocator.SSH and Build, through freeSSH). A stopped VM keeps its port while it's on the list, free, not listed to forward and not held by another start or build; else it gets one no state records, or else a stopped VM's, which that VM gives up at its own next start. Another VM's listed ports are avoided only while that VM runs or starts. - The proxy and desktop ports never take one (free); one an older devvm chose moves at the VM's next start (Choose's keep path, proxyPort, the desktop's listener; Allocator.SSHOnly). - A forwarder never takes one unless its VM lists it (ports.Reserved), so a guest forwarding every port can't fill them; devvm ports and each launch warn when a VM's list names one, whatever set it (--ports, a devcontainer.json, config.toml's ports) (ports_ssh_listed, ports.SSHListed). - A start holds its port, kept or new, for a minute in the VM's own run/ports.ssh-hold (paths.VM.Forwarder; hold, held, projectHold), which other starts and builds avoid, so none takes it before Lima binds it; it goes with the VM's folder. - A build takes its clone's own port (was) only when no other is free. - Past 17: ports_ssh_limit names the VMs whose recorded ports are in use ("a or b" for a port two states record) with how many are taken otherwise, ports_ssh_limit_all when they have them all, and ports_ssh_limit_others when none of your VMs has one. - Older devvm's ports move at the VM's next start, in startSets' one limactl edit, and the start pins the new host keys (pinHostKeys); a running VM keeps its port until then, and each launch warns of running VMs still on an off-list port (ports_ssh_old, Allocator.OffList, confirmed with the backend's Running). - A test build's own list (DEVVM_SSH_PORTS, registry.Overrides.SSHPorts, the Allocator's and the Proxy's SSHList field), read only by readOverrides in a test build: each CLI test sandbox gets as many ports of its own from below the ephemeral range (sandboxPorts). Frozen 0.1.0 fixture: each launch now makes exactly one limactl edit, of .ssh.localPort alone, onto the sandbox's list, and vm.json changes only in .ports.host.ssh (and the start it records); the fixture's data is untouched. Messages: ports_ssh_limit, ports_ssh_limit_all, ports_ssh_limit_others, ports_ssh_listed, ports_ssh_old. Tests: TestSSHPorts (Fetch's list less Chromium's gaps, SSHListed, SSHOnly), TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild, TestReserved, TestForwardsHeld's reserved counts, TestStartBuildSSHPort, TestPrepareRestartsTheProxy, TestDesktopListener, TestOverrides (DEVVM_SSH_PORTS), ssh_ports.txtar, fixture_v010.txtar, layout.txtar; e2e project: the ssh port, first and after a move, is one browsers refuse. Docs: internals/lima (the ssh bullet, the hold's limit), processes (listener table), design (threat check), ports, overview, contributing/structure and testing (DEVVM_SSH_PORTS), using/ports-size, troubleshooting (Too many VMs at once), safety/attack-vectors (allowed ports, port squatting), CHANGELOG Breaking (17 VMs; forwarding every port leaves the 17 out) and After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cc94465400 |
test(leaktest): goroutine leak checks, and the leaks they found
A new internal/leaktest, standard library only, so the proxy's and the daemon's tests use it too (depguard's proxy rule allows it, and the structure test holds it to tests and to importing nothing of devvm's): - leaktest.Main(m), in TestMain: once the tests pass, every goroutine's stack (runtime.Stack), a settle of 5 s, then a failure naming those still running, but the standard library's own that outlive every test (allowed: signal.Notify's loop, an HTTP client's idle connections); then Go 1.27's goroutineleak profile, which fails on any goroutine blocked for good. - leaktest.Check(t), first in a test: its own goroutines, followed by parent through those still running, and by which ran before it, never by ID (each thread takes a batch of IDs). Main runs in proxy, vmssh, daemon, desktop, ui, vm, backend/lima, platform, cli and gitprotect (main_test.go, or the TestMain they had). Check runs in TestLinksEndStuckRelays (replacing its NumGoroutine count), TestForwarder, the desktop relay's serve helper, TestRunChild, TestPinWaits, and the proxy's new close tests. The structure test's goroutines rule (internal/structure/goroutines_test.go): goroutineSites lists every function outside tests that starts a goroutine, with a go statement, a wait group's Go, or time's or context's AfterFunc, function literals in package-level vars included, as "file: Func", with its waiter, or "detached: " and why nothing waits. A new one fails until listed, a listed one that starts none fails, and a package that starts one fails until its tests call leaktest.Main. Leaks it found, each fixed with a test: - The proxy's close left its connections running: http.Server's Close neither closes a connection a handler took (a CONNECT's tunnel, a WebSocket upgrade ReverseProxy takes) nor waits for a handler. conns (conns.go) holds every connection the listener accepted (track) and counts every handler (handle); serve calls closeConns once Serve returns, which closes them, closes any accepted after, and waits up to 5 s for the handlers. splice also ends when its client's connection can't be read (closed, reset), rather than half-closing the far end and waiting on it; a failed write to the server (one that answered early and closed) still lets its answer through. Tests: TestCloseConns (a tunnel and an upgrade), TestConnectAfterClose, TestSpliceEndsWhenItsClientCloses, TestSpliceKeepsAnEarlyAnswer; the tests' listen closes as the proxy does, and the fake upstream closes its target once its client's end comes. - platform's runChild left its signal-passing goroutine blocked on a channel signal.Stop never closes; it now closes it and waits (TestRunChild). - platform's WaitExit and WatchFolders blocked in poll(2) and read(2), which closing their fd from the stop doesn't wake on every kernel (Debian's didn't), and a retried call could land on a reused fd. They now wait in Go's poller (pollable), which the stop wakes (TestPinWaits, with a wait stopped before its process ends). Docs: Contributing's tests page (Goroutine leaks), the structure page (the goroutines rule, goroutineSites, the layers, the packages), the Go lint rules' depguard line, the proxy's shutdown in How it works' processes page and the proxy's README, and AGENTS.md. Coverage baselines: internal/leaktest's line on both systems, netpolicy's raise on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4e925492ca |
fix(proxy): every host is read in one form, proxy.NormHost, guarded by the structure test
Every check that judges or compares a host now reads it through proxy.NormHost (internal/proxy/host.go), which also holds HostOK, splitHostPort, hostASCII and asciiEqualFold: a host of printable ASCII is lowercased in ASCII alone and loses its one trailing dot; any other host stays as it is, so HostOK refuses it and no Unicode fold makes another name match. A host with two trailing dots or more, or a dot after a closing bracket, keeps them, so NormHost is idempotent and reading a host twice can't turn evil.test.. into evil.test. A proxy.Host is what the matchers take (rule.matchHost, noProxyRule.matches, local, sniMatches). Brackets are strict (hostAddr): HostOK, Host.Addr and splitHostPort take an address bare or an IPv6 address in one pair of brackets, never a stray bracket ([[::1]], 1.2.3.4]) or brackets around a name or an IPv4 address ([evil.com]:443, [1.2.3.4]:443), which get 400. Migrated: splitHostPort, sniMatches, sniHost, parseHostRule, the policy's rulesFor, quiet, byName and coversOn, secrets.forHost, parseNoProxy, route and local in internal/proxy; netpolicy.RiskOf, Tickable and sameRule (devvm network rm and the duplicate check, so a Kelvin sign never names the rule with a k); secrets.CheckHost; from.publicHost (a name HostOK refuses isn't public); agentlogin.claudeHost; vm.urlHostPort and privateHost. vm.urlHost (cloneseed.go) keeps its own reading: it's a remote's ssh host, which ssh lowercases and keeps the trailing dot of, to find a VM's alias. Differential fuzz targets keep a frozen copy of each reader as it was and allow only the decided differences: FuzzHostSites (proxy), FuzzRiskSites, FuzzCheckHostSite, FuzzPublicHostSite, FuzzClaudeHostSite and FuzzPromisorHostSite. A rule line is the same rule or no rule exactly as before, so a broken deny stays a broken deny. TestFixtureHosts reads the frozen v0.1.0 state's secrets.policy, secrets.json and links.json hosts and finds them unchanged. The structure test's new hosts check refuses, outside host.go and tests: Trim, TrimLeft or TrimRight with a cutset holding ".", TrimSuffix or CutSuffix with "."; ToLower, ToUpper, EqualFold and the TrimFunc family on an argument named for a host; and a conversion to proxy.Host of anything but a literal. Exceptions are by file and function, each with why (request.go:trimDots, cloneseed.go:urlHost, cloneworktree.go:safeIndexPath, cloneconfig.go:transportHelper, lima/start.go:machines.fillPassword). It doesn't see slicing, strings.Map or variables not named for a host. The owners doc, the proxy README, structure.md, design.md (One form of a host), network.md and safety/network.md say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
89f26c5771 |
docs(site): draw the diagrams at build time with pele, no Mermaid JS
The docs site's 18 mermaid blocks are now drawn as SVGs before Hugo
builds the site, by docs/render-diagrams.mjs with pele 1.13.0, and
inlined by a render hook, so no page loads Mermaid's 5.5 MB script.
- docs/render-diagrams.mjs: finds each mermaid block in docs/content,
draws it with pele in Departure Mono at 14px (a measurer from the
font's metrics), and writes <key>.svg and <key>.json (its size) to
the git-ignored docs/.build/diagrams. pele draws edge labels,
messages and notes at round(14 * 0.875) = 12px with no option, so the
measurer gives that text its 14px width and the script rewrites
font-size="12" to 14 on each small-text group (pele-edge-labels,
-notes, -boxes, -frames); a guard fails on any such group without
font-size="12", or small text outside them, and a self-check, run
whenever there's something to draw, renders an edge label, a message
and a note and fails unless pele measured them at 12 and wrote their
group with font-size="12". It also fails on a diagram without
accTitle and accDescr, or on an indented block. A newline after each
</text>, outside any text element, lets the search index see labels
as separate words; screenshots of all 18 are byte-identical with and
without it. (Newlines between a label's tspans would move centered
lines, so a label's own lines stay joined in the index.)
- Caching: a block's key is sha256(salt + "\n" + text)[:16], the salt
being sha256("pele <version>\n" + the script's text)[:16], written to
diagrams/salt. The script keeps every drawing already there, draws
only missing ones (written to .tmp and renamed), prunes files no key
names, and touches the folder. docs:diagrams has sources (the pages,
the script, package.json, the lock) and outputs (the folder), so mise
skips an unchanged run, and runs npm ci only when the lock's SHA-256
differs from docs/node_modules/.devvm-lock-sha256. An unchanged run:
0.45-0.75 s before, 0.02 s now (0.09 s forced); one diagram changed:
0.09 s. CI's check job caches ~/.npm keyed on the lock; the Docs
workflow, which publishes, keeps no cache.
- docs/package.json and package-lock.json pin pele 1.13.0
(sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==).
- docs/layouts/_markup/render-codeblock-mermaid.html: in place of
Hextra's hook, reads the salt, computes the key from it and .Inner,
inlines the SVG from assets/diagrams (hugo.yaml mounts .build/diagrams
there), sets the wrapper's contain-intrinsic-block-size to the
diagram's height and --devvm-diagram-width to its width, and errorf's
when a drawing or the salt is missing. layouts/_partials/scripts/
mermaid.html and params.mermaid go.
- custom.css: .devvm-diagram with content-visibility: auto, and pele's
--pele-* variables from the palette (subgraphs, lifelines and notes in
the border color). A diagram wider than the text reaches into the
article's right padding (1.5rem, 3rem from 768px) as far as it needs,
then into the left padding for the rest, so it never covers the table
of contents; wider than both, it scrolls. From about 1010px no diagram
scrolls, the four wide ones included (proxy checks 751px, agent store,
VM states, SSH agent); at 900px five scroll. With the table of
contents shown, the proxy checks take 48px on the right and 31px on
the left.
- mise.toml: docs:diagrams, which docs and lint:docs depend on.
docs.yml: the next and release jobs install node and draw the
diagrams; the release job only when the tag has the script, so older
tags still build.
- scripts/bump.sh: bump_pele, named only, replaces bump_mermaid: npm
install --save-exact --ignore-scripts in docs, then mise run
docs:diagrams, whose self-check catches a pele that changed how it
draws small text. TestBumpCoversPins finds docs/package.json's
dependencies (npm:NAME); bump.txtar tests --check and the install.
The header and hextra's note say the mermaid render hook replaces
Hextra's mermaid hook, so check it still has that name.
- Every diagram gets an accTitle and accDescr, which pele makes the
SVG's title and desc (aria-labelledby, aria-describedby). Staying
safe's columns are written in reading order, as pele lays subgraphs
out from left to right. The proxy checks' description names every
branch, and a hand-placed <br> keeps "CA)" off a line of its own.
- AGENTS.md: the one Node script; no other build script is JavaScript,
and no other npm package is installed outside mise's tools.
Contributing's docs, tools and
maintaining pages describe the drawing, the caching, the margin, the
task and the bump.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1ecd1faa73 |
build(nilaway): mise run nilaway against a triaged baseline, an advisory CI job, and two crashes it found
nilaway is pinned in mise.toml at its newest commit's pseudo-version (it has no releases); bump.sh's dev-tools moves it, and TestBumpCoversPins covers it through mise.toml:tool:*. mise run nilaway runs scripts/nilaway.sh: devvm's own packages, not the tests or their helpers (stubtest, backendtest), compared with testdata/nilaway-baseline.txt, the findings triaged as false positives, each with its group (checked, bounds, mapkey, nilsafe), keyed by file and trace without line numbers, one line for each finding, compared as multisets. It exits 3 on a new finding, a key found more often than the baseline has it included, and 1 when nilaway can't run, when a finding in its output can't be read, or when a baseline line is stale or malformed. TestNilawayBaseline checks each case with a stand-in nilaway. CI's nilaway job is continue-on-error: it warns on new findings and lists the new and stale ones, then every finding, in the run's summary, failing when the script exits 1. The first run reported 83 findings, 69 without the test helpers. Two were real: - agentlogin.Restore sliced above[1:] for a settings file that is one JSON string holding a placeholder, where above is empty, and devvm agent save panicked. - agentlogin's readJSON returned a nil map, with no error, for a file that is null, which the Codex and opencode captures then wrote to. It now refuses it as not a JSON object. The other 67 are the baseline. Both fixes get a CHANGELOG Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
02ba74e614 |
build(lint): stricter linters, and the fixes they need
golangci-lint now also runs govet's nilness, unusedwrite, hostport and waitgroup analyzers, nilnesserr, durationcheck, canonicalheader, errchkjson, forcetypeassert, contextcheck and gochecksumtype. - errchkjson checks each JSON encoding's error where the value could fail and drops it where errchkjson proves it can't, and reports structs without exported fields; tests may drop theirs. - forcetypeassert holds the code; tests are exempt. - gochecksumtype: agentlogin's format is a sum type (//sumtype:decl), and a switch on one names every case, default or not. - canonicalheader: WWW-Authenticate, X-Request-ID, X-Api-Key. - contextcheck: ctx threaded through carry, peekClientHello and sniOf, and through inject and value, whose cached lookup takes WithTimeout(WithoutCancel(ctx)), so two forbidigo nolints go; openTransparent takes its dialer's ctx. nolints stay where contextcheck can't follow: ReverseProxy's Rewrite, WithoutCancel alone, cobra's cmd.Context, e2e's runner window. - No-behaviour fixes: scrubList for redact's list, the loopback forward's ports kept with its listeners, upgradetest's Key keeps its public key, a CA's leaves read through leafOf. Contributing's Go lint rules lists each one and the sum-type convention. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c1cf96e4b6 |
fix(vm): every start pins the VM's host keys, whatever its ports
A start whose VM forwarded nothing, because other programs held every listed port or the VM was devvm ports none, never pinned its ssh host keys: only the port forwarder (Forwards.start, which returned before vmssh.Checked) and the ssh config pinned them, and a start that went no further than bringUp (devvm clone fetch, rm's fetch, the clone check) wrote no ssh config. devvm's own ssh (ownSSH, vmssh.ReadKeys) then found no record, and devvm clone fetch failed with clone_fetch_failed. bringUp now pins them last, once the start or the running VM has gone through the self-check (starter.pinHostKeys, vmssh.PinHostKeys), for a VM whose backend's ssh the review allows. A record of the current start is kept without reading the VM; ErrNoHostKeys is skipped, as the ssh config skips it, and other errors fail the command. A running VM without a record of its start, as this bug left one, gets it at its next command. Tests: TestFetchPinsHostKeys (forwarding none, every port taken, running without a record), and TestUp, TestUpNetworkPolicy and TestUpTools' calls with the pin after the self-check; testscript clone_hostkeys, its ports the script's own listeners. fixture_v010_clone passes with 3000 and 5173 held. CHANGELOG Fixed entry; design.md's host key and security.md's ssh into VMs say when the keys are read. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5225d5b43e |
fix(links): a relay's grace waits out a slow client; CI-proof timing in two tests
TestPipeSSHGrace failed on GitHub's macos-latest runner ("talking, half
closed: the relay ended while the VM talked") twice, and
TestLinkCheckBurst once.
The relay's grace restarted only when a read from the VM completed, and
io.Copy reads nothing while its write to the client waits, so a client
that half-closed and read slowly, holding back the VM's answer, was cut
after the grace though the VM kept sending. The grace is now time the VM
sends nothing, never time a slow client takes: graceTimer runs only once
armed (the client's side closed, or the copy to the client ended with a
failed write or the VM's EOF), stops while a write to the client waits,
and starts again after each write. A client that stops reading thus
holds its relay and ssh itself, so the owner's context now also closes
the connection when it ends (context.AfterFunc), which ends a write
waiting on such a client: a forward's close, a link's removal or
LoopbackForward.Close can't hang on it.
The CI failures themselves were the test's margins: a 200 ms grace
against a stand-in that spawns sleep between writes. The talking case
now has a 2 s grace, 40 times the stand-in's 50 ms, and reads for a
second past it; pidOf waits up to 10 s for the stand-in to start.
TestLinkCheckBurst wasn't the relay changes': its 256 checks ran on the
real clock, and a burst slower than linkRunFor (1 s) looked the target
up twice. vm.Links has a clock seam, Now (time.Now unset), which
linkCheck's targetRuns uses, and the burst runs through linkCheck on a
clock that stands still. With a targetRuns made for each call, it fails
(256 Inspects).
- vmssh: graceTimer (arm, write, restart, stop) replaces reset;
graceWriter replaces graceReader; pipeSSHFor closes the connection
when its context ends
- vm: Links.Now, used by linkCheck; env.go names Links' Env field
- tests: TestPipeSSHGraceSlowClient and TestPipeSSHCancelEndsBlockedWrite
(each failed on the old code); TestGraceTimer replaces
TestGraceTimerStopped (unarmed, armed, written to, stopped, armed
while a write waits many graces); TestPipeSSHGrace's per-case grace;
pidOf's wait; TestLinkCheckBurst through linkCheck on a still clock
- stress, with four cores of background load: TestLinkCheckBurst and the
relay tests under -race -count=50 -cpu 1,2 and GOMAXPROCS=1, then the
relay and link tests of vmssh and vm under -race -count=20 -cpu 1,2:
all pass
- coverage: internal/vmssh's baseline raised
- docs: internals/ports (how it reaches the VM), the design note (each
connection, the lead for relays held after their client closed)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
608ab43714 |
fix(ports): an IPv6 listen error fails the port as an IPv4 one would, and ::1 refused alone forwards on IPv4
The forwarder's open listened on 127.0.0.1, then ::1, and gave the port
up only for EADDRINUSE on ::1. Any other IPv6 error (EMFILE, ENOBUFS...)
was ignored, so the port was forwarded and recorded on IPv4 alone until
its VM's listener went and came back: a client that connects only over
IPv6 (http://[::1]:PORT, tools without fallback) didn't reach it, and
another program on this machine could take ::1 on the port.
Now any other ::1 error closes the IPv4 listener and is returned, so try
handles it as an IPv4 listen error (
|
||
|
|
c63f9a3340 |
fix(links): relays end with their link, their master or 30 s after their client closes
A relay's ssh (-W) ends only when the VM's sshd ends its channel, so a
VM that ignored EOF could keep a relay, its ssh process and one of its
owner's 256 slots:
- A link's removal closed only its listener, so its open connections
went on until the target's master or the session ended. The same held
for connections through a target master replaced when the target
started again, and for a link whose address and port named another
target at the next sync.
- While a forward or a link lasted, a relay whose client had closed its
side stayed for as long as the VM liked.
Each relay now gets its own context, which a link's removal, its
master's replacement or end, and its target's change cancel, as a
forward's close already did (
|
||
|
|
940f1e2d88 |
chore(scripts): bump.sh moves every pin in the repo, and a guard for new ones
scripts/bump.sh now covers every pinned version, so release prep is one command, grouped as --check prints them: - shared-tools: cursor (only when named), Cursor's CLI pinned in assets/shared-tools/mise.toml, checksums computed from the downloads - e2e: e2e-curl, tests/e2e/transparent_test.go's curlImage by digest - go: go (newest patch: go.mod, docs/go.mod, mise.toml, mise lock), go-minor (only when named), go-mods (direct modules, go get and go mod tidy; a next major's path only reported), deadcode (mise.toml's task) - dev-tools: mise.toml's tools but go, through mise lock - ci: ci-mise (jdx/mise-action's version follows base's mise), actions (uses: by tag commit from gh api, then actionlint and zizmor) - docs: hextra (go get and hugo mod tidy in docs/), mermaid (only when named) --check prints each pin's group and whether a bump is a patch, minor or major. With no tools named, bump.sh applies patches and minors only: never a major, a held pin or a named-only tool; naming an images or e2e tool still applies its major, and e2e-tools always does. Holds come from .github/dependabot.yml's ignore list (pflag < 1.1.0) and bump.sh's own (node on its major). The header lists every pin as "# pin KEY TOOL", or "-" and a reason, and says why the pins outside the scanned files are left (install.sh's Lima, the Homebrew formula, testdata, vendored files). TestBumpCoversPins in internal/structure scans assets/, mise.toml, both go.mod files, the workflows, tests/e2e-mise.lock, tests/e2e's consts and docs/hugo.yaml offline, and fails on an uncovered pin or a stale line. The Pins workflow gets mise and a token for the new checks, and its issue lists outdated pins under their groups. testdata/script/bump.txtar covers the new groups with stubbed upstreams, and caught newest_of failing on an empty list. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f76b2fa2a4 |
fix(ports): devvm ports says why a listed port isn't forwarded; a relay ends with its forward
The forwarder recorded every listed port it couldn't take on one line,
and devvm ports warned ports_taken ("in use on this machine") for all of
them, even a port past its limit of 256 forwards or one the host refused,
such as EACCES below 1024 on Linux. It now records why: in use
(EADDRINUSE), past its limit, or refused (EACCES, EPERM), each on a line
of its own in run/ports.forwarded (pid, forwarded, in use, limit,
refused). Any other listen error (EMFILE, ENOBUFS, EADDRNOTAVAIL...) says
nothing of the port: it's logged, not recorded, and tried again at the
next report, the log's limit capping the repeats. A port past the limit
is tried again at the next report once the forwarder is below it. An
older devvm's three-line record, whose third line held every failure,
is read as giving no reason, so it warns of none rather than call a
refused port in use; its forwarded ports still count.
A forward's close closed its accepted connections, but each relay's ssh
(-W) waited for the VM's sshd to end the channel, so a VM that ignored
EOF kept that ssh process and one of the forwarder's 256 relay slots
until the forwarder ended. Each relay now gets its own context, cancelled
by the forward's close under mu, so CommandContext kills its ssh; a relay
that ends by itself releases its context.
- vmssh: failure (in use, limit, refused) and failedPorts; failureOf's
ok for errors that are the port's; Forwarder.try; apply clears limit
failures below the limit; Note takes failedPorts;
Forwards.Unforwarded replaces Taken; record writes five lines
(recordLines); MaxForwards exported for ports_limit; forward.conns
holds each relay's cancel
- messages ports_limit (count, limit, ports, vm) and ports_refused
(count, ports, vm), linked to troubleshooting's listed-port section;
devvm ports warns each by why
- --json unchanged: it never listed failed ports
- tests: TestForwarderFailures (EACCES, EPERM and EADDRINUSE through
Listen, EMFILE tried again unrecorded, the limit and its retry once
below it), TestForwarderEndsStuckRelay (an ssh stand-in on PATH that
never exits: the relay ends, the process is gone, the slot is free),
TestForwardsHeld's record round trip, older and foreign records, and
ports.txtar's three warnings from a record and none from an older one
- docs: internals/ports (record lines, relays, when it can't forward and
what's retried), the design note (how many, each connection, the
below-1024 lead, the stuck relay as confirmed and fixed, channels a VM
never closes as listed), ports-size, troubleshooting, CHANGELOG Fixed
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
54cce97049 |
fix(ports): a stopped VM no longer keeps its listed ports from other VMs
Only a running VM holds a host port. Each VM's forwarder records the ports it forwards, and those it tried and couldn't take (run/ports.forwarded: its pid, then each list on a line; an empty one when it starts, and devvm removes it under ports.lock before each start). A forwarder reserves another VM's ports only while that VM has a claim: its forwarder runs, or devvm holds its ports.lock to start one again (the restart window). It never takes the ports such a VM forwards now, nor those it lists unless this VM lists them too. A stopped or crashed VM holds nothing. A reserved port the VM listens on waits and is forwarded once free, so a VM gets its port back within about 20 s of the other VM stopping. The host decides when a port is given up: every forwarder closes a forward whose port is now reserved every 10 s on its own clock (Forwarder.Recheck), so a VM that holds its session open and stops reporting can't keep another VM's listed port, and closing a forward closes the connections it accepted, so a browser's keep-alive connection never reaches the old VM afterwards. Two VMs starting at once are settled by the host's bind. The ports devvm chooses (ssh, proxy, desktop) still avoid every VM's listed ports, running or not. - ports: Used(d) for the allocator; Reserved, Holders and Live for the forwarders - vmssh: Forwarder.Recheck, Note and release; a forward tracks and closes its connections; Forwards.Reserved, Held, Taken, live, recorded and record; a start keeps a port another VM holds in -only and warns ports_held for any holder, listed or every-port; Main takes paths.Dirs - devvm ports warns ports_held and, for a running VM's listed port its forwarder recorded as a program's, ports_taken, reading the forwarder's record and binding nothing; --json adds held_by - backend.CountPorts; the stub's ssh master reports again when guest-ports changes - tests: TestReserved, TestForwarderWaits, TestForwarderGivesUpSilently, TestForwarderClosesConnections, TestForwardsHeld (restart window, every-port holder, no record, Taken from the record alone, another process's or no record), TestForwardsRecordFails, TestForwardsStart (old record removed), ports_stopped.txtar (CJ's case end to end, and an every-port VM leaving a running VM's listed port alone), layout.txtar - docs: ports-size's Two VMs and one port (the browser origin) and its JSON, internals' Ports other VMs forward, design.md's ports note and the listed ports' threat check; CHANGELOG Fixed Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6c36850251 |
feat(cursor): devvm cursor opens this folder's VM in the Cursor editor
devvm cursor is devvm code's twin for Cursor, the editor. It gets the folder's VM ready as devvm host does, then runs `cursor --remote ssh-remote+HOST DIR` in devvm's place, with the SSH agent devvm started with. Without `cursor` on PATH it fails with no_cursor_command, naming the host to connect to. Cursor's Agent and your sign-in (from CJ's manual check with a real login): recent Cursor runs Agent in the editor's server in the VM, which holds your Cursor sign-in in memory only (no token on disk, in any environment or command line) and calls Cursor from the VM. Cursor's `cursorAgentHost.remoteInferenceRoute` is application-scoped, so it's read only from the user settings on this machine; with it set to "always", Agent's own requests go through the Cursor app here, while the VM's server still talks to Cursor. - vm: Code and Cursor share openRemote; vm.CursorCommand names the editor's command, apart from the CLI agent's agents.Cursor. After LookPath finds `cursor`, devvm reads Cursor's user settings on this machine (platform.AppSettingsDir: Application Support on macOS, $XDG_CONFIG_HOME or ~/.config on Linux) through safefile.Read, 1 MiB at most, read-only, as JSON with comments, and warns with cursor_agent_in_vm unless the route is "always". It never fails on the file. - sync.sh: Cursor's ~/.cursor-server/data/Machine/settings.json gets VS Code's remote.autoForwardPorts, git.terminalAuthentication and github.gitAuthentication off, in one loop over both editors' files. devvm doesn't write the route there, since Cursor ignores it. - structure: nameFree lets a literal that is an agent's name stand in one file, with its reason, and fails when it frees nothing. - cli: cursor.go (--ssh-config, --here, --parent), registered beside code; cursor_failed, no_cursor_command, cursor_agent_in_vm and their doc links; ssh_host_info names Cursor too; the cli skill's judgment note: an editor's command is a bare verb named after the editor's. - Tests: host_code.txtar (cursor, its full-name host, the missing command, the warning and no warning once the route is set), guest.txtar, TestCursorAgentWarning (always, absent, other values, no file, broken JSON, too long, a FIFO, the XDG path; never written), e2e network: devvm cursor passes the editor only the host and folder, a fake editor sign-in on this machine reaches neither the VM's home, its processes' environments nor the proxy's logs, and a Cursor login in the store reaches the CLI's methods while the agent store's are refused. - Docs: SSH and editors (commands first; "Cursor's Agent": it runs in the VM with your sign-in, the user-settings line, what it doesn't cover, open only VMs you trust; if Tab doesn't work on the allowlist tier, devvm network allow api3.cursor.sh), the agents page's Cursor notes, Commands, attack vectors, design, the home page, CHANGELOG, generated CLI pages. Reviewed adversarially before the push: the settings read (size, FIFOs, links), the warning's wording and when it fires. Researched with PR #44's design as reference only. Co-authored-by: JB <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5d7f941678 |
feat(network): quiet hosts: documented telemetry stays blocked without a notice in the VM
A built-in policy's `quiet HOST[:PORT]` line, for one exact host name, marks a host devvm leaves out on purpose. A quiet host is blocked as any host no rule allows, and an allow of the user's still lifts it. A block is quiet only when its reason is "not on the allowlist" (notAllowed), it isn't refused, and no rule covers the host (an allow, a deny or one that narrows): then it's logged with "quiet": true but never counted in /blocked or /blocked/new, so neither the VM's prompt nor devvm-why shows it, its 403 page suggests no command, devvm network log --blocked shows it as a row of its own with "- (quiet)", and devvm network lock never offers it. - proxy: rule.quiet, parseQuiet (exact hosts only), PolicyLine.Quiet, policy.quiet, Allowlist.Quiet, Event.Quiet, server.blocked (proxy and transparent paths), notAllowed; loadPolicy skips and logs quiet lines in the user's files. - netpolicy: Judge.Quiet, Block.Quiet (its own row key), FormatEvent's ", quiet", RuleFile.Quiet, quietMark, policy_quiet_not_own in PolicyWarnings. - cli: quiet in network log --json, log --blocked --json and network --json; the agents' table leaves quiet lines out. - Quiet hosts, each with its source: api3.cursor.sh (the host Cursor documents for Tab requests; Cursor's CLI uses it for its metrics) and telemetry.go.dev (Go). Not marked: Claude Code's Datadog intakes (shared multi-tenant hosts projects may need), .NET's telemetry (no host in Microsoft's docs). - Tests: TestParseQuiet, TestQuietHosts, TestQuietOnlyWhenNoRuleAllows, learn/log/rules tests, network_rules.txtar, e2e network check for api3.cursor.sh. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
90694a414f |
feat(agent): devvm agent import follows links out of an agent's folder when allowed
A link out of an agent's folder, such as a dotfiles repo's link into ~/.claude, was always left out. Now it's copied when you allow it: config.toml's follow-links names folders whose links devvm follows without asking, and otherwise devvm names each link and its target and asks, a question --follow-links answers. Without a terminal and the flag, links out are left out with a warning naming --follow-links. - The store gets copies only: a linked file as a file, a linked folder as a folder of files; the next import replaces them, a folder that became a file included, and prunes them once the link is gone. - Each link is resolved one name at a time (linkHops), then read through its allowed folder as a safefile.Root opened one folder at a time from / (openPhysical); a link inside is read only to a file in that root. - Always refused: the home folder or a folder holding it, devvm's config, data and Lima folders, ~/.ssh, ~/.gnupg, ~/.aws, ~/Library/Keychains, ~/.config/devvm, ~/.netrc, ~/.config/gh, ~/.docker, ~/.kube, and every agent's logins and history, compared by name and identity (isIn); a follow-links folder in or holding one fails the import. - A target in a VM's project folder warns, naming the VM; a chain through a link in a VM's folder to a place outside it is refused. - Bounds: devvm agent save's, 20,000 entries, 128 MiB and 16 MiB a file, across one import. - A settings file must link to a file and a settings folder to a folder. Messages: agent_import_link_not_followed, agent_import_link_refused, agent_import_link_too_big, agent_import_follow, agent_import_link, agent_import_link_followed, agent_import_link_project, agent_import_link_via_vm, agent_import_root_refused, follow_links_invalid. Tests: TestAgentImportFollowsLinks, TestAgentImportNestedLinks, TestAgentImportRefusedPlaces, TestAgentImportRefusedRoots, TestAgentImportProjectFolderLinks, TestAgentImportLinkThroughProject, TestAgentImportRefusedOtherCase, TestAgentImportLinkBounds, TestLinkSourceGrown, TestAgentImportLinkKinds, TestAgentImportLinkPrune, TestAgentImportLinkedAgentFolder, TestLinkHops, TestOpenPhysical, TestFollowLinks; testscript agent_import_links; e2e project section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8da71a01bb |
refactor(from): --from's registries judged by proxy.Public
internal/from had its own copy of the internet-address judge (publicAddr, nonPublic) with a shorter table than the proxy's: no NAT64 or 6to4 decoding and none of IPv6's special ranges, so a registry at 64:ff9b::10.0.0.1 or fec0::1 passed it. - publicOnly and publicHost ask proxy.Public; publicAddr and nonPublic go. internal/proxy is the standard library only, so from may import it. - forbidigo refuses netip.Addr.IsPrivate outside internal/proxy, as a second judge would drift; testdata/lint breaks it once, and the owners' table in Contributing's structure page names proxy.Public. - TestPublicAddr checks publicHost and publicOnly, with NAT64, 6to4, site-local and documentation rows. - A CHANGELOG Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
99f57d4003 |
fix(proxy): 6to4 judged by its IPv4 address, and more special ranges internal
A 6to4 address (2002::/16) passed the floor as public even when the IPv4 address in it was private, and Teredo, IPv6's documentation, discard-only, benchmarking, ORCHID, SRv6 and IPv4-translated ranges, and IPv4's documentation ranges and 192.88.99.0/24, counted as the internet. - withIPv4 (was nat64): the IPv6 ranges that carry an IPv4 address, NAT64's and 6to4's, each with its site's prefix length (6to4's /48); embeddedIPv4 (was nat64IPv4) reads either. - hostAddrs.internal: the host's own address first, then the 6to4 site of any of its own addresses (its LAN's), then the embedded IPv4 address; hostAddrs.own, the address map, replaces has. - rule.matchAddr: a 6to4 address matches as its IPv4 address for a deny alone, as 6to4 goes through relays anyone may run; NAT64 still matches for both. - notPublic gains 2001::/32, 2001:db8::/32, 3fff::/20, 100::/64, 2001:2::/48, 2001:10::/28, 2001:20::/28, 5f00::/16, ::ffff:0:0:0/96, 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 and 192.88.99.0/24. - Tests: TestInternal's rows, TestInternalOwn6to4, TestSixToFourAllowsNot, TestResolveSixToFourName, a 6to4 deny in TestAddressDenyAppliesToNames; the learning tests' public address is 93.184.215.14 now, as 203.0.113.5 is documentation's. - The structure test's table name, the proxy's README, network.md's range list (with Teredo under a broad IPv6 allow), attack-vectors and safety/network, and a CHANGELOG Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d55476d3e2 |
feat(images): the prelude is one line, so build scripts keep their line numbers
Every script a build runs with bash, devvm's own and the user's layers, now gets the prelude as one line, eval $'…', in place of its #! line, so bash's errors and $LINENO give the script's own line numbers. A script without a #! line is one line further down. - shell.QuoteLine: ANSI-C quoting for bash, on one line of printable ASCII; every other byte as \xHH, so a multibyte locale's lead byte (Shift-JIS, GBK, GB18030, Big5) can't swallow the backslash escaping a quote, and a NUL panics as a caller's bug. image's layer rule allows internal/shell, a leaf. - image.WithPrelude, the one place the prelude and a script are joined (OwnScript calls it), used by base.sh, apt.sh, the built-in layers and features, the user's layers, shared-tools/build.sh and oci/build.sh. Every devvm script has a #! line. A leading UTF-8 BOM goes before the #! check. - A build's exports for a company proxy (lima's proxyExports) and the user's CAs (trust's exports) end in "; ", not a newline, so they share the first line and move no line either; backend.Trust.Env says so. - The stub logs a bash -s script's second line, which is the script's own second line with or without the prelude. - Keys: every build script's bytes change, so base, every image and every shared tool image are built again once; the CHANGELOG's After you upgrade says so with git-lfs, and what VMs say until devvm update, and Breaking has its own heading. - Tests: TestQuoteLine (every byte but NUL, a break-out word, in /bin/bash 3.2 and PATH's bash, in C and each of ja_JP.SJIS, zh_CN.GBK, zh_CN.GB18030 and zh_TW.Big5 that locale -a has), TestQuoteLineNUL, TestWithPrelude's shebang and BOM cases, TestWithPreludeRuns (the real prelude's line gives the prelude back; a layer under set -euo pipefail gets the names, keeps its function and its line numbers, with and without exports before it). - e2e nix: the layer copy no longer adds the prelude itself. - Docs: images.md's prelude section, Customizing's layer bullet, structure.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6ad4f6cb63 |
feat(images): your own layers get the scripts' prelude
devvm now puts assets/prelude.sh before a user's layer script, as it does for its own scripts, so a layer gets $devvm_arch, $devvm_libc and devvm_sha and can pin a download per architecture (and per C library on Alpine) the way devvm's scripts do. - image.WithPrelude puts the prelude before any script; OwnScript calls it. - build.(*Env).LayerData reads the user's layer and puts the prelude before it; a deleted layer is still fs.ErrNotExist (Missing). - The layer's step holds the prelude, so its key changes on its own: every image with a user's layer, and every image above one, is built again once. base and built-in-only images, and tool images, keep their keys; keyFormat is unchanged. The v0.1.0 fixtures have no user layers, so their keys don't move. - The prelude runs first, so a layer that sets its own devvm_ name keeps it. - layer new's starter mentions devvm_sha and $devvm_arch. - Tests: TestWithPrelude, TestUserLayerGetsThePrelude (LayerData, the key differing from a prelude-less build's, a deleted layer still missing); prelude.txtar runs a layer as a build does on gnu and musl, and one that overrides devvm_arch and devvm_sha. - e2e (images): the fixture layer prints $devvm_arch, $devvm_libc and devvm_sha of two fake pins, which the check compares with the VM's. - Docs: Customizing's Mailpit example uses $devvm_arch and devvm_sha; images.md's key table, recipe and prelude sections; structure.md; CHANGELOG (Breaking). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
b30229ca19 |
test(fixture): a fixture's host ports are ones free here
fixture_v010.txtar launched app, scratch and web on the host ports 0.1.0 recorded on the machine that made the fixture. When any of them was taken here, by a program or by another run of the same tests (two checkouts' gates on one machine), the launch rightly chose another port and edited the VM's Lima config, failing the script's check that a launch makes no limactl edit. fixture VERSION now maps each VM's ports.host to a port free here, wherever the number stands on its own (vm.json, the stub's state, lima.yaml's proxy URL, the proxy's config and status, the sandbox profile), never inside a hash. The other fixture_v010 scripts' own free_port and json_set of ports are no longer needed and go. - freePorts: free_port's helper, shared with fixture - fixtureRewrite: the paths' replacer plus the ports - TestFixtureRewritePorts Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4f99e40731 |
test(clone): don't depend on the machine's git-lfs or system git config
CI (run 43285988512, at
|
||
|
|
52bb0f467b |
feat(clone): a --clone VM gets the repo as it is here
A --clone VM's clone is now seeded with a snapshot, not git push, and gets everything a working copy has. devvm clone fetch brings it all back, and devvm rm and clone off check it before deleting. - Refs: every branch, tag and notes ref, and a detached HEAD. - Uncommitted changes: staged, unstaged and untracked files; files skip-worktree by hand get the index's version, named. - Operations in progress (merge, rebase, cherry-pick, revert, bisect) and the stash; a stash's untracked part goes as its own branch. - The repo's settings and hooks, sent as settings only where they live in the repo (husky); ORIG_HEAD never goes. - Partial clones, with their promisor remote, and messages per network tier when it can't be reached. - Initialised submodules, nested ones too, each with a clone of its own; a submodule's own folder is refused as a top-level --clone. vm.json gains an optional `submodules` field. - Git LFS both ways: objects hash-checked, written under os.Root with no link followed, a question past 2 GiB; the filter is set only in the clone's repos; git-lfs 3.8.1 in base, pinned by SHA-256. - rm and clone off keep the VM when anything the VM has didn't come back, and name it. - Every shell script embedded in Go is shellchecked. - clone.md is a guide that leads with commands; TestUserPageProse covers it and coding-agents.md. After you upgrade: base and every image on it build again once, for git-lfs. Fixes #40, reported by @Josuesp1620. Thanks to @dhruv1220 for #42, which found the cause (receive-pack refusing a shallow push); its receive.shallowUpdate setting stays in the VM's repos. Co-authored-by: Dhruv Arora <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d349868c31 |
feat(agents): one definition per coding agent, and Cursor's CLI
Every list of the coding agents now derives from internal/agents' registry, one Def each, and Cursor's CLI (cursor-agent) is a fifth agent. The registry: - each agent's login command, login formats and capture on its Def; one message for every agent where each had its own - the agents' table, the README's list and the docs' history lists are generated from the registry (cli.DocBlocks, TestDocBlocks); scripts and Go tests take their lists from it too - each agent's own code lives in a file named for it; the structure test lets only an agent's own files choose by its name, following constants named after an agent - a VM remade by clone on/off keeps no agent's login files (agents.LoginFiles from every Def.Logins; Claude Code's .claude.json stays, as it is also history) Cursor's CLI: - `devvm --agents cursor`, `devvm agent login cursor`, history import and export of ~/.cursor/chats - the proxy captures its login at a GET endpoint, guards a shared host by path, and puts the login in only where the CLI sends it, bound to the CLI's 57 methods - account changes and the agent store are refused in a VM; Cursor's headers and trailers are scanned for tokens - e2e: Cursor's CLI in the network section, its poll behind the fake company proxy Docs: the agents' pages lead with commands, with a How it works page for the agents. Co-authored-by: JB <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |