mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
32
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
00e5ea59f4 |
feat(cosign): the run, which makes and publishes each release CI hands over
devvm-cosign's run (Cosigner.Run), its command (cmd/devvm-cosign, Main) and the maintainer's commands, devvm-cosign retry, ack and failed. CI's token can only read the repo, so CI hands each build over as a workflow artifact, and only the co-signer, and the maintainer by hand, can make or publish a release. For each release CI handed over that it hasn't published, oldest first, from the newest successful run of the pinned release workflow for each tag, of this repo's own: - its version is newer than the newest it signed, or one it signed, with the same SHA256SUMS; an older one is an alert, as a replay, until the maintainer acks it, unless it was published before the state began; - CI's artifact is staged (stage/, which no build can reach) and checked: SHA256SUMS, CI's signature with CI's key and devvm-release <version>, and exactly the files it lists, each with its SHA-256; its files are deleted before the build and downloaded again after a match, so none of CI's bytes is on disk while a container could be live; - a run builds once, so the podman service, which lives for the run, lives for one build, and anything that escaped a container is gone before the next build's host git and release.sh run; the next release or base waits for the next run; - the build's finished files go in a folder of the state's src/, which release.sh copies to and the co-signer reads, where no container can swap a file or the folder; - the tag's commit has to be the commit CI's run built, and the co-signer's own build has to match every file and SHA256SUMS; it renders the tap's formulas itself from the tag's template and the signed SHA256SUMS (formula.go, as release.sh's formula function does), and the build's own formulas have to be the same bytes, so neither builder's container decides what Homebrew installs. The formulas and the notes, the tag's CHANGELOG.md entry, are kept in kept/<v>/ with their SHA-256s in the state, and checked again before the tap; - it signs, makes the draft itself, titled devvm <version> with the tag's notes, and uploads SHA256SUMS, both signatures and CI's files, each hashed as it's sent, keeping an asset only when its size and GitHub's digest are right and deleting any other; - while the bridge lasts it waits for the old key's signature on the draft, failing each run so the maintainer hears of it, and downloading nothing again while it waits; - it publishes only when the draft is exactly what it made, its tag, title and notes (but for line endings and the space at either end), and its assets by ID, size and digest, and the tag still names the tag object its rebuild checked; then checks the published release again, and finishes the tap. Alerts and refusals: - init records the highest release ID GitHub showed and the drafts there were then; IDs only go up, so any release published since that isn't a draft the co-signer made is an alert, whatever its tag or version, by <tag>#<ID>, so another release of an acked tag is alerted on again; each run also reads GitHub's latest release, wherever the list puts it. - A published release that differs from what it checked, its own draft published without it seeing the answer that then doesn't check out, and a tap formula newer than any release it signed, by tap:<formula>@<version>, are alerts; the tap is updated only for a release it published and checked after. - A rebuild that doesn't match is a refusal, which isn't downloaded or rebuilt again, even for CI's run again; devvm-cosign retry <tag> lets the next run rebuild it once more. Nothing retries on its own. - Every run fails (exit 1) while an alert or refusal waits, until devvm-cosign ack or retry. A run records in last-failure.txt that it started, then what failed, or removes it when it succeeds; devvm-cosign failed, which the units' OnFailure= runs for any failure, a killed or timed-out run's or a config that won't load included, runs notify, the maintainer's command, with it on its stdin, a fixed environment and a minute of its own, whatever ended the run's context. Bases go the same way, from the newest successful run of the base workflow on main, made at the index's commit and never GitHub's latest. Main makes the process non-dumpable (prctl PR_SET_DUMPABLE 0) before anything else, so no process of its user can read its memory, where the keys and token are, and reads the keys from systemd's credentials when CREDENTIALS_DIRECTORY is set. A run empties the build folder's work/ and the state's stage/ and src/ in place, never making them again. Tests, each fix reverted once to see it fail: TestPublishedBySomeoneElse (a release published by someone else, whatever its tag or version, the same tag again after an ack, a draft from before init published since, and GitHub's latest past where the list stops; one from before the state left alone), TestOneBuildPerRun (the build's files in the state, none of CI's on disk during the build, and the next release left for the next run), TestFormulas (a build's formula of its own; a kept formula changed on disk), TestRenderFormula, TestPrereleasePublished (a tap formula newer than any release signed), TestDraftChangedBeforePublish (a swapped file, a retag, other notes), TestTagMovedBeforePublish, TestAlertAfterPublish and TestLostPublishChecked, TestMismatchSignsNothing (a failure every run, and retry), TestReplayedOlderVersion (an alert, then acked), TestNotify, TestLegacyBridge (a failure every run, with no download), TestRunPagesReleases, TestInitPaged (init past ten pages of bases, which fails with a page check that stops at its first unfinished entry), TestRunsChecked, TestArtifactChecked, TestUploadChangedOnDisk, TestBaseIndexChecked (a re-signed base on a 61-day snapshot), TestBasePublishChecked, TestBasePublishedElsewhere (an expired base still counts in checkBehind), TestWorkEmptiedInPlace, TestCommandLine (retry and ack read no key file), and on Linux TestUndumpable. A build that fails, rather than differs, is built again at the next run, but the third failure in a row refuses it, with a report holding the last failure (buildFailed), so a build that keeps failing no longer takes every run's one build and holds up each newer release and base; retry builds it again, and a build stopped with its run isn't counted. Refusing rather than rotating past it keeps releases oldest first, as versions only go up, and keeps the failure in front of the maintainer through held and notify. buildRelease and buildBase are the build and its comparison, apart from what's recorded. And GitHub's latest release has to be the one init saw or one the co-signer published, not one of its own older than another it published: anything else is an alert, latest:<tag>#<ID> (staleLatest), as the install script's default downloads it; so is the one init saw, once it's older than one the co-signer published. The co-signer makes a release GitHub's latest only when it's newer than every release it published, so publishing an older release after a newer one, as when the old key signs the newer draft first, never moves the latest back itself. And a release's run counts only when a tag's push started it (PushEvent, which the structure test's nameFree lets name "push"). Tests, each failing before its code: TestFailingBuildRefused, TestBaseRefused's base that keeps failing, TestLatestChecked, TestOlderReleaseNotLatest, TestRunsChecked's run by hand. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f3052e5a8e |
feat(upgrade): releases checked by two of three release keys, bridged from the old key
devvm upgrade and install.sh accept a release's SHA256SUMS when any two
of three release keys signed it (CI's, the co-signer's and an offline
recovery key's), each in SHA256SUMS.<role>.minisig, checked only against
its own role's key, with the trusted comment devvm-release <version>
compared exactly; one signer counts once. While releases bridge from it,
the old release key's single SHA256SUMS.minisig (devvm <version>) still
passes alone, so 0.1 and 0.2 keep upgrading and --to/--version can
install them; install.sh now checks that key's trusted comment too.
The keys themselves aren't made yet, so packaging/keys holds none and
install.sh's three key lines are empty: a devvm built so checks each
release with the old release key alone, and a release that only the
release keys signed is refused. Releases go out as before, signed with
the old key, until the keys are made and added, all three at once.
- internal/minisign: the one owner of signature checks (moved from
internal/upgrade): ParsePublicKey, PublicKey.Check (comment always
compared), Role (CI, Cosign, Recovery), Kind (Release, Base),
Kind.Comment, SigName, KeyFile, Keys/NewKeys/Keys.Check (two of three,
distinct keys and key IDs). minisigntest/ signs for tests. Stdlib and
blake2b only (depguard), a leaf; FuzzCheck, FuzzKeysCheck,
FuzzParsePublicKey.
- The structure test's signatures rule: outside internal/minisign no
code calls ed25519/rsa/ecdsa's Verify functions or imports blake2b,
but signatureFree's files (ubuntu/pgp.go, proxy/nixcache.go).
- internal/upgrade: Source.Keys, checkSums (signatures.go); the bridge
in legacy.go (checkLegacy, legacyKey, Source.Key); FuzzSumOf.
- packaging/keys/release-{ci,cosign,recovery}.pub, none yet;
packaging.Key ("" without one). TestReleaseKeys (checkReleaseKeys:
none, or three distinct minisign keys, none the old key),
TestCheckReleaseKeys (fixture keys from minisigntest),
TestInstallScriptKeys (checkInstallScriptKeys: one line per role,
empty without keys), TestReleaseRefusesPlaceholders (no key in keys/
marked PLACEHOLDER).
- scripts/release.sh (a tag, --check, --tag; never a snapshot) needs
none or all three of packaging/keys' release keys. With none,
install.sh's release_<role>_key lines are empty or missing; with all
three, each is a minisign key, distinct, not the old release key, not
marked PLACEHOLDER (placeholder), and equal to its install.sh line.
- install.sh checks with minisign -VHQm: prehashed signatures only.
- The structure guard also flags dot imports of the verifier packages
and calls of x509's CheckSignature* method names.
- install.sh: release_<role>_key lines, download_signatures (a role's
signature only when the script has its key), check_signature,
signed_by_two, check_legacy; plainer warning without minisign, with
the commands to check by hand.
- Tests: signatures_test.go (TestFetchWithoutReleaseKeys among them),
upgrade.txtar (-legacy, -keys, and the keys built in, none),
install.txtar (stub minisign with -Q; NO_KEYS), install_minisign.txtar
(real minisign), release.txtar (none, nolines, nokeyline, old, marked
and the rest); DEVVM_RELEASE_KEYS override.
- Docs: internals/install.md, using/upgrading.md, maintaining.md's
Release keys, structure, tests, testing, SECURITY.md, CHANGELOG,
releases/0.2.0.md.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
f5e6eebc55 |
refactor: one safe reader for files a VM can write
internal/safefile (standard library only) owns every read of a file a VM can write or swap: Read and Open never block on a FIFO, follow a final link only when asked, and check the opened file is regular, within its cap and, with OneLink, singly linked; OpenRoot opens beneath a folder. The proxy, secrets, agentlogin, devcontainer, detect, agent save and gitprotect read through it, fixing three hangs on a FIFO the VM leaves, and forbidigo holds those callers to it. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f51e79421 |
refactor(agents): one definition per coding agent (#29)
Each coding agent gets one definition, an agents.Def in a new stdlib-only leaf package, internal/agents, and everything else iterates over agents.Defs: agentlogin's format per login kind, secrets' login kinds, settings' [pass-keys], image.SharedTools, the vm package's store tables and scripts, and cli's help lists. The VM copies of every login file, their bindings, the store's layout, the scripts and the CLI reference stay the same byte for byte, as golden tests made before the refactor show. The agents' guest variables leave base.sh for /etc/devvm/agents.sh, written at every launch, so every image rebuilds once. Messages are merged per agent (login_kept, login_passed, login_withheld, login_oauth_withheld, agent_login_key_only). The structure test's new names rule fails on an agent's name or login kind as a literal outside internal/agents, and literals on one holding an agent's folder. Docs link the supported coding agents rather than listing them, and Contributing gains Adding a coding agent. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
5f7289e6f7 |
feat(cli): devvm upgrade, the newest release the way devvm was installed
devvm upgrade [--check] [--to VERSION] [-f/--force] [--json] installs devvm's newest release the way this devvm was installed, asking first (upgrade_confirm, answered by --force). upgrade is a top-level exception in the cli skill: it acts on devvm itself, not this folder's VM, and it's the name other tools give the verb. It skips the layout check, as a layout a newer devvm wrote is a reason to run it. - install.sh's (<prefix>/lib/devvm/<version>/devvm, which <prefix>/bin/devvm links to): SHA256SUMS and its .minisig over HTTPS, the signature checked against the key built in from packaging/minisign.pub (packaging/key.go embeds the folder; no file, no key, and upgrade_no_key), the archive's SHA-256, unpacked into lib/.<v>.new.<pid>, run (--version), renamed to lib/<v>, the link switched atomically (symlink beside, rename over), run again through the link, rolled back on any failure; then older versions pruned as install.sh does (kept: the one that ran, any a running process names, another upgrade's staging folder). - Homebrew's (a Cellar/devvm/ keg): brew upgrade devvm, asked first, through the run log; --to refused. - Anything else: says how it was installed (a checkout build, go install, a copy elsewhere) and fails. - Already latest says so; a newest release older than this devvm is refused even with --force (rollback); --to installs a named one, older asked about (upgrade_confirm_older). --check and --json install nothing. minisign verification is Go's: ed25519 over blake2b.Sum512 for the default prehashed ED signature (legacy Ed refused), the key ID, the global signature over signature||trusted comment, and the trusted comment "devvm <version>" as scripts/release.sh writes it. Verified against a signature minisign 0.12 made. golang.org/x/crypto v0.58.0 added for blake2b only (approved; depguard allows only golang.org/x/crypto/blake2b); MVS raised x/text to v0.43.0 and x/tools to v0.51.0. mise run vuln: no vulnerability reached; the module-level GO-2026-5932 is x/crypto/openpgp, which devvm doesn't import. New: internal/upgrade (Detect, Source: Latest, Check for the release notice to call, Fetch; ParsePublicKey/Verify; Valid/Compare; Upgrader), internal/upgrade/upgradetest (TLS release server, minisign signer; tests only, a structure layer), fetch.Resolve (where a HEAD's redirects end), fetch.Download's size cap (mise's 256 MiB too). Test-build overrides: DEVVM_REPO_URL, DEVVM_RELEASE_KEY, DEVVM_RELEASE_CA, DEVVM_TEST_VERSION; script command release_server [-badsig]. Security review (security-audit skill, guidance mode, a fresh reviewer): - Prerelease order compared suffixes as text (rc.10 < rc.9), which let an older signed prerelease past the rollback refusal: fixed, semver precedence, with table cases. - No cap on the archive download (a host could fill TMPDIR before the checksum failed): fixed, fetch.Download takes a limit. - Two upgrades at once: prune removed another's staging folder: fixed, .<v>.new/old.<pid> folders are kept while that pid runs. - A failed rollback of the link was silent: fixed, upgrade_rollback_failed names the link and the old devvm, and the new folder stays so the link isn't left dangling. - QEMU's guestfwd names devvm with commas doubled, which the in-use check missed: fixed. - Freeze (a host serving the current version as newest forever): no boundary crossed, inherent without signed expiring metadata; documented in internals/install.md. Checked sound: nothing untrusted runs or unpacks before the signature and SHA-256; versions from the redirect and --to pass Valid before any URL or path; tar takes only regular files in its one folder (no links, subfolders, ..), 512 MiB cap, fixed modes; test overrides are read only by test builds. Tests: minisign (real minisign fixture, tampering, legacy, other key), each install kind against the fake TLS server, bad signature, wrong trusted comment, replaced archive (wrong SHA), bad archives, a new devvm that fails before and after the switch, a failed switch (old kept), a failed rollback, downgrade refused and --to, pruning, Homebrew via a brew script, Check, Latest's failures, Compare; CLI test upgrade.txtar. Docs: getting-started/install.md (Upgrading: how, what it checks, an older release, --json), getting-started/commands.md (This machine row, Upgrading devvm, questions, output for scripts), internals/install.md (devvm upgrade), contributing (release_server), the CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e6f64dae31 |
refactor(vm): one VM inventory per run
vm.Inventory (internal/vm/inventory.go) holds each project VM's state, backend and Instance, read in one place: ReadStates for the states alone, ReadInventory (UsedBackends or AllBackends) for the backends' lists too, each within the host's list wait (30 s), with the backend's Check saying why a list failed. It replaces Env.mounts, recordedVMs, vm.List and vm.ToolsInUse, linkstate's clientStates listing, the secret list's, Leftovers.Find's (and backendVMs), cli/space.go's two (backendRows' list, vmFolders), images' state.Backends and sshconfig's running list: sshconfig.Write takes the inventory's Running VMs. state.ReadAll reads each VM folder on its own (only the inventory calls it, a structure-test callers rule); state.Backends and Registry.Used go. One failure policy: - a backend that can't list fails a listing (Inventory.Err) only when some VM's state names it: devvm ls and the ssh config fail, and the ssh config stays as it was rather than lose that backend's entries; space and gc --orphans name it and leave its VMs alone; - an unreadable vm.json is its own row: ls lists the VM with its name and status alone and warns (vm_state_unreadable); links, the secret list, rm VM and link targets leave it out; gc --orphans never takes it for an orphan; ToolsInUse and Mounts (images, gc, space, the SSH agent's mounted-key check) fail on it, naming the file; - FolderOf is bounded (5 s): a folder on a hung share is there. Mounts come from the states alone, stopped VMs and agents' folders included, so the mounted-key check asks no backend. ui.Table shows every cell through msg.OneLine, so ls's cells can't move the cursor or break a row. Docs: internals/overview's listing, troubleshooting's file devvm can't read, ssh's mounted keys, contributing's owners table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e132a29b5a |
refactor(cli): one per-run app holds the run's services
NewRoot makes one app for the run's UI and hands it to every command. The app makes each service the first time a command asks for it and keeps it, or its error, for the rest of the run: devvm's folders (dirs), a test build's overrides, the secrets store, the backends' registry, the shared tools, the VM environment (vmEnv) and the image builder of the backend new VMs get (builder). The retention that runs before a command and the command itself share them. - paths.FromEnv: 23 of 24 calls go through a.dirs; partNames, which the parser's flag and word checks call before any command, keeps its own. - The registry is made once (8 newRegistry calls and newEnv's). - builder(u) (6 calls) and cli's newBuilder are gone: a.builder and the per-backend builders in images, space and gc are vm.Env.Builder, exported, the only builder. setup's feature choice takes a build.Env of its folders and prompts alone. - The shared tools are made once (newTools and vm.NewEnv's), and the secrets store once (companyProxy's, newTools', vm.NewEnv's and _proxy's): vm.NewEnv takes the run's tools and store. - withEnv (46 calls) is a.env; autoRetain, retainOrphans and gc --orphans use the run's VM environment. - thisHost and readOverrides' other callers read the overrides once (a.host); space and gc --caches time out on the registry's host. TestAppMakesEachServiceOnce checks that one run makes each service once and that the VM environment and builder share the run's registry and tools; TestAppKeepsAFailure that a failure is kept. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
39c2ff4f4e |
test: one Go multi-call stub for every host command
The 18 shell stubs in testdata/stubs (about 600 lines, limactl 337 of them) are one Go binary, internal/stubtest/stub, which acts as the command it's run as (argv[0]): limactl, docker, security, ssh, ssh-add, ssh-agent, ssh-keygen, qemu-img, qemu-system-aarch64, qemu-system-x86_64, chflags, tmutil, sw_vers, uname, open, code and mise, and stub, scripts' commands on the stubs' state. stub-log is gone: each stub logs its call itself, in one write to $STUB_LOG, its arguments on no other process's command line. - internal/stubtest builds the binary once, into $TMPDIR/devvm-stubs-<hash> (its sources and Go's version) with a link per command, which every test process and later run reuses until the sources change; a day-old folder of another build is removed. stubtest.Bin, stubtest.Command (DEVVM_HOST_MISE's path), and Stubs' VM, Size, VMs, Keychain and SetKeychain on the state. - internal/stubtest/stubstate: the stubs' state, $STUB_DIR/state.json, typed JSON under a file lock (Lima's instances with their status, size and config, the Keychain, the SSH agent and its keys, Time Machine's exclusions, the tools build VM's folder). The instances file wasn't locked; TestCreatesAtOnce and TestUpdatesAtOnce make 20 and 50 changes at once. - guest.go is the VM behind limactl shell and ssh alike: a --clone VM's git on vmfs, a remake's home, a base build's packages, the setup's tar, the direct connection, host keys, a forwarder's ports, link forwards. - A link session's master listens with a backlog of one and never accepts, as the Perl one did, so a killed session's socket reads as stale once probed (link_life). TestScript's cleanup stops the sandbox's masters by their -M -S arguments. - Structure: the stubtest layers cover internal/stubtest/..., the binary and its state import nothing else of devvm's; execSites lists internal/stubtest/build.go and internal/stubtest/stub/process.go. Renamed switch: hostkeys-fail is hostkeys-fails. Moved into the state: instances, size-<vm>, config-<vm>, keychain/<account>, agent-up, agent-held, tm-excluded and tools-out; scripts use stub vm, vms, size, keychain, keychain-set, agent and agent-stop instead (build, existing, from, gc, gc_orphans, images, ls, net_interrupted, rebuild, rm_vm, secret, size, space, ssh, ssh_agent, up). Tests: stub_test.go (every stub in-process, TestShellWords), stubstate_test.go, TestBuild, TestCreatesAtOnce, TestState; the lima, platform, vm, tools and build tests use the state helpers and stubtest.Command. Coverage: internal/stubtest/stub and stubstate added, stubtest, build and tools raised (and lima, netpolicy on Linux). Docs: contributing (Stubs: the binary, logging, the state and the stub command, switches, the guest, adding a stub or a switch; Go test helpers; the layers), testing.md; AGENTS.md's stubtest and testdata rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
40d6f45296 |
fix: the phase review's findings in --clone, --from's output check and tool builds' CAs
- --clone refuses a symlink anywhere in objects or refs (a pack folder, a loose object's folder), not only at their top, which could copy another repo's objects into the VM. - A worktree's seed push sends its upstream only when it is one ref: a branch.<name>.merge pattern (refs/heads/*) pushed every branch. - The rm/clone off fetch passes --refmap=, so a remote the repo names after the clone's address can't update branches outside saved/devvm/*. - Undoing devvm clone off checks .git (gitprotect Check) before its locks come off, as leftBehind does: a clone VM's .git is never checked again. - --from's converted disk must have its first 1024 bytes zero before the ext4 superblock, so a qcow2 or VMDK header can't sit in front of one; the glibc file is checked a plain file before it is read (a link to a FIFO). - Tool builds get the CAs' variables from the backend (Trust.Env), as image builds' steps do; trust.CAs.Script, the caller-side copy, is gone. - image.isAgent unexported (used only in image). Tests: TestOwnRepo (pack folder, loose folder), TestSeedRefs (a pattern upstream), TestCloneRm (a remote named as the clone URL), TestSetCloneUndo (git_replaced on undo), TestCheckConverted (qcow2 before a superblock, a short disk, glibc a link to a FIFO), TestBuildToolsTrust. Docs: internals/git-protection, using/clone, internals/images, internals/design (the pin's name). Coverage baselines raised (darwin, linux). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7dba353351 |
fix(agentlogin): Redact parses settings files whole and scrubs what ~/.claude.json's servers lose
A VM with network policy got secrets from the agents' settings files that Redact couldn't read or didn't look for: TOML lines it couldn't parse (multi-line arrays, quoted dotted keys, spaces around dots) were copied as they were, and JSON's string lists, URLs and env values under names that don't look secret were never scrubbed. Redact now parses each file whole (JSON with UseNumber, TOML with BurntSushi/toml), refuses one that doesn't parse, and writes the copy from what it parsed, through one walk for both formats: values under secret-looking keys, and lists and tables under them (but key bindings); every value of env and headers tables (env, environment, headers, http_headers, shell_environment_policy.set), but references, paths, URLs (scrubbed, or whole under a credential's name: credName) and true, false and numbers up to five digits; scrubURL for every URL; scrubArgs for every list; known key shapes anywhere. scrubArgs also scrubs URLs in arguments and in --flag=URL, for ~/.claude.json too. Claude Code's own settings env (settings.json's top-level env) keeps its documented configuration variables (claudeEnv: ANTHROPIC_MODEL and the model families, CLAUDE_CODE_*, DISABLE_*, MAX_*, *_TIMEOUT_MS), unless the name says it's a credential (credName: KEY, TOKEN as a word, SECRET, PASS, AUTH, CREDENTIAL, COOKIE, HEADER), so Claude in the VM keeps its model and limits. MCP servers' env and headers keep no value. Tests: TestRedactTOMLLeavesNothingUnread, TestRedactJSONArraysURLsAndEnv, TestRedactClaudeEnv (failing before), TestRedactTOML and TestRedactRefuses updated; sync.txtar's unreadable config.toml is now one that doesn't parse. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4a782085b9 |
test: raise the linux coverage baselines, and network.txtar's proxy follows a hostagent that lasts
- linux.txt raised from Fedora's mise run coverage (backend, lima, build, cli, docgen, gitprotect, image, netpolicy, paths, ports, project, proxy, secrets, settings, sshconfig, state, trust, vmssh). - network.txtar's first network-policy launch makes the test's runner its hostagent, so the proxy that follows it is still running when the ps check looks under load: the stub's hostagent is devvm itself, gone at once, and the proxy ended within a lifeline tick. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8670db2df9 |
refactor(project): trim project to the folder, its VM's name and its unsafe folders
What a folder's files call for (detectFiles) moves to internal/vm's detect.go, beside the parts a new VM gets. The set-id check and SSHRemote move to internal/hostsafety, beside gitprotect. The set-id walk skips .git folders and runs only once the VM is stopped (devvm stop, or a launch that finds it stopped) and when a VM is made, never at a launch into a running VM: measured on APFS at about 5 us a file, 1.0-1.3 s for 220,000 files, 65 ms for a 20,000-object .git alone. internal/paths owns resolving and comparing host paths (resolve.go): Physical (every link, as far as the path exists), PhysicalParent (the folder's links, the last element as named) and, for a path that must exist, filepath.EvalSymlinks itself; Within (the folder or inside it) and Below (inside only). project's Unsafe and Parents, sshagent's mountedBy and recordedPath, Lima's Seatbelt paths and QEMU's PATH search, and the home copy's skips use them. Tests: TestPhysical, TestWithinAndBelow, TestSetIDOnStop (named at creation and stop, not at a launch into the running VM; not in .git), SetIDFiles' .git and missing-folder cases; detect's and hostsafety's tests moved with their code. Docs: when set-id files are named, on the user, safety and internals pages; the contributing page on the resolvers; AGENTS.md's layout rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
12d1a84149 |
fix(redact): proxy passwords stay out of Lima's hostagent log and guest commands' output
Lima's hostagent logs a proxy variable's value, password and all, as it starts a VM (Lima's cidata setupEnv: a loopback proxy pointed at the guest's gateway, an override of the system's value, or a value it can't parse), into <lima home>/<vm>/ha.stderr.log. For a VM without network policy that's the shell's HTTPS_PROXY. devvm's run log already redacted the copy limactl start prints; Lima's own file kept it. Start now redacts that file once limactl start ends, started or failed: each password becomes as many "*", in place. Lima creates the file with os.Create (no O_APPEND) and the hostagent keeps writing at its own offset, so the file keeps its length and every other byte, and Lima goes on where it was. Keeping the password out of the hostagent's environment would keep it out of the guest too (Lima writes the guest's /etc/environment from it), so apt and curl there couldn't use the company proxy. A file devvm can't change warns (lima_log_unredacted). Output written through UI.LogWriter() (guest commands: a VM's setup, the home folder's copy, devcontainer.json's commands) now goes through the run's one redacting writer, flushed at a logged command's start, at DieLogged and at the run's end. The patterns and both redactions have one owner, internal/redact (stdlib leaf): String, the run log's (moved from ui's redact), and File. - redact.String, redact.File; ui: LogWriter's redacting, flushLog; lima: redactLog; message lima_log_unredacted. - Tests: TestLogWriterRedacts (fails without the fix), TestStartRedactsTheHostagentLog, TestString, TestFile; e2e's network section restarts its VM without network policy behind the run's loopback company proxy, its fake password read from a file: the guest has and uses the proxy, the run logs hold <password> only and ha.stderr.log stars only. - Docs: troubleshooting's run log, network policy's Without network policy, Contributing's layers and e2e network section. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
866b9e0930 |
fix: the processes devvm starts don't inherit the files it was given
A terminal, an editor or a test harness can give devvm files past the standard three without close-on-exec (testscript's ttyin puts a pty on descriptor 3), and devvm's background processes then held them, keeping that terminal or pipe open as long as they ran: on Linux a script hung until its timeout. devvm now marks every file it was given from descriptor 3 up close-on-exec as it starts (platform.CloseInheritedOnExec, called first in main), which covers every process it starts, Lima's included, and keeps them open itself. TestCloseInheritedOnExec re-runs the test binary with an extra file on descriptor 3, starts a detached process and checks it doesn't hold it (/proc/<pid>/fd on Linux, lsof on macOS); layer_add.txtar now answers yes in a terminal. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2a23197372 |
test(backend): a conformance suite every backend runs, on the fake, the limactl stub and real Lima
backendtest.Conformance(t, factory) checks backend.Backend's documented contract, one subtest per check on a new backendtest.Subject (the backend holding one image, a folder of its own, Boots, Restart). Checks that need a running VM skip with the reason when Boots is false, and restart when Restart is nil. Checks: caps, problems, host (Host); images, delete-image, key-files, build-image (Images); create, create-refused, inspect-missing, stopped, start-shrink, proxy-url, rename, delete (Machines); start, confined, restart, reach, running-refused (running VMs); usage, strays, caches (Housekeeping); guard (the registry's guard refuses through Images and Machines alone). Runs: TestConformance and TestConformanceWithoutBooting on the fake; lima.TestConformance on the limactl stub (VMs start) and on real Lima's dummy instances (skips without limactl; running checks skipped, left to tests/e2e.sh). TestConformanceFinds checks ten broken fakes fail the check meant for them. Found and fixed in the fake: a start of a running VM gave it a new start and confinement; Restart kept a NetProxy start's Confined; a VM it made was confined while stopped or never started; CreateVM took a missing image, a name over NameLimit, and left its size unset (ImageVMSize); Rename took a name over NameLimit; SSH reached a stopped VM. Preset VMs keep their old Confined answer, which other packages' tests rely on. In the limactl stub: stop leaves ha.pid, and create and clone made no instance folder. Real Lima: nothing. Docs: contributing's How a backend plugs in. Coverage baselines raised: backendtest 46.5 to 74.4 (both), backend 97.0, lima 89.5 (darwin). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
329e31be1d |
refactor(secrets): the proxy looks secrets up in-process, from one versioned bindings file
The proxy no longer runs devvm secret get for a value: proxy.IO.Secret,
which devvm _proxy sets to secrets.Store.Get, looks a binding's value up
in the proxy's own process (Keychain, devvm's secrets folder, or the
agent's login file), so internal/proxy stays standard library only.
Config.SecretCmd (secret_cmd) and the hidden devvm secret get command go,
with secret_to_terminal and secret_read_failed; Main refuses a config
with secrets and no IO.Secret.
One binding type, proxy.Binding, with kind secret|login and a login's
agent, in proxy.BindingList ({"version": 1, "bindings": [...]}), written
by secrets.Store (Encode) and read by the proxy and RefreshFiles with
proxy.ReadBindings (private regular file, no link, 1 MiB, version and
kinds checked; an unreadable file has no bindings). It replaces
proxy.binding, secrets.binding and agentlogin.Binding; the kind replaces
the name-prefix classifiers in proxy.ttlOf, secrets.loginOf and
RefreshFiles' Lookup check; proxy.InterceptLines replaces
agentlogin.Hosts and RefreshFiles' host loop.
agentlogin's user-actionable errors are typed (ErrCodexNoKey,
ErrCodexNoChatGPT, RefreshError) and secrets maps them to messages:
codex_no_key, codex_no_chatgpt, codex_refresh_failed,
opencode_refresh_failed, and login_read_failed for the rest.
Tests: proxy TestSecretValueLooksUpInProcess, TestReadBindings,
TestBindingsUnreadableHaveNone, ttlOf by kind, Main refusing secrets
without a lookup and -secret-cmd, config refusing secret_cmd; secrets
TestGet by kind, TestLoginFailed; agentlogin TestCodexBindings (kind and
agent checked on every binding), TestGetErrorsSayWhatToDo; secret.txtar
and network.txtar on the new file and without secret get; e2e's network
section keeps the fake token off argv and checks no command prints it.
Docs: the proxy README (Secrets section), internals/network.md,
safety/network.md, using/coding-agents.md, contributing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
361087f95a |
refactor(proxy): host-only modes out of proxy.Main, into agentlogin and trust
devvm _proxy takes one flag, -config, and running the proxy is Main's only
mode. What only the host does runs in devvm itself, through typed functions:
- internal/agentlogin (new; imports only fetch, jsonc, proxy and state):
File{Kind, Path, Salt, TokenURL} with VMCopy (the VM's copy and what it
keeps as it is), Bindings, Get (refreshing OAuth tokens), plus Hosts,
MCPSecrets and Redact. The salt is a parameter, not a global or
DEVVM_LOGIN_SALT. Login files are read with proxy.ReadRegular (no FIFO
hang, 64 MiB cap) and written with state.WriteFile; the refresh goes
through fetch.NewClient (HTTPS-only redirects, 30 s, reply capped at
1 MiB) with context.WithoutCancel.
- trust.InitCA makes devvm's CA (state.WriteFileMode), replacing -init-ca;
netpolicy's InitCA field is it, and proxy_ca_failed carries the error.
- internal/jsonc: devcontainer's JSONC stripper, now redaction's too; the
redactor's own copy changed commas inside strings.
- proxy.HostOK is exported for agentlogin's MCP host check.
- secrets.Store loses its Login seam and LoginKept; IO loses Stdin and Kept.
Tests: proxy.txtar's login, redact and init-ca cases become unit tests in
agentlogin and trust; proxy.txtar and TestMainRefuses check the old flags
are refused. New: TestRefreshOutlivesItsCaller, TestRefreshFails,
TestGetRefuses, TestLoginFileNotRegular, TestHosts, TestRedactRefuses,
TestRedactJSONKeepsStrings, TestInitCA, TestInitCAFails, TestBundle.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
bdc95ef6ee |
refactor(ports): port forwarding out of the backends, one owner in vmssh
The port forwarder is devvm's on every backend. vmssh (moved out of internal/backend) holds it, the link sessions, and its one owner, vmssh.Forwards: the lock, stop and start of a VM's forwarder, which ports it forwards read from vm.json (ports.Forwarding) each time, the listed ports a host program has left out (ports_taken), the host key devvm pins, and the backend's new ForwardTarget (user, key, host loopback port) and Lifeline. One hidden command, devvm _ports (cli/forwarder.go, vmssh.Main), replaces _lima-ports. The backend no longer forwards: SetPorts, Want.Ports, Confinement.Free, Confinement.HostKey and Confinement.Forwarded go; Lima keeps its own forwards off and gives ForwardTarget (Lima's ssh port on 127.0.0.1, Lima's user, _config/user). Lima's Stop and Delete no longer touch the forwarder, and Lima's Forget goes with the backend/ folder: the forwarder's files are in the VM's run/ (ports.pid, .status, .lock, .known_hosts) and logs/ (ports.log), its control socket run/port-<hash>.ctl. vm starts the forwarder after each start and on devvm ports of a running VM; devvm stop, rm, gc --orphans and an interrupted start stop it. vm/ports.go's hand rollback goes: the state changes first, and a forwarder that can't start only warns. A structure-test layer keeps backends from importing vmssh. Tests: TestForwardsStart, TestForwardsRun, TestForwarderMain, TestSplitPorts (vmssh); TestForwardTarget (lima); TestForwarding (ports); TestStartPorts, TestSetPortsRunning (vm); testscripts up, ports, layout, gc_orphans updated. Docs: internals/ports.md, backends.md, lima.md, design.md (Ports on Lima), overview.md, using/space.md, contributing. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
628dc11c94 |
feat(state): a layout version for devvm's folders, made_by in its records, the golden listing and doctor's leftovers in vms/
The data and config folders each hold a version file (state.Layout, 1). state.CheckLayout runs before every command but help, completion, version and devvm's hidden commands, under version.lock: the same version goes on, a missing file gets this devvm's, an older one runs the migrations in order (migrations(), empty now), and a newer one in either folder refuses with layout_newer; a file that isn't a version fails with layout_unchecked. made_by, devvm's version, is in vm.json's core fields (set when the VM is made, kept by later changes), image records and tool image records. It's passed from cli's devvmVersion through vm.NewEnv, tools.New and build.Env.Version. testdata/script/layout.txtar makes two network-policy VMs with a forwarded port, a link and a secret, and compares every path under the data and config folders with checked-in listings (macOS and Linux). devvm doctor warns about entries in vms/ that aren't VM folders (vms_stray) and VM folders without vm.json (vm_folder_stateless), changing nothing. Tests: TestMigrations, TestCheckLayout, TestCheckLayoutMigrationFails, TestVMFolderProblems, TestSkipsLayout; made_by checks in TestVMRoundTrip, TestImage, TestToolImage, TestUp, the build and tools tests and scripts; doctor's unit test and script. Docs: internals/overview (the layout version, made_by), using/space, using/settings, using/troubleshooting, internals/images, Contributing (changing the state layout). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
9f6f62d28a |
refactor(state): vm.json, typed state in package sections, changed under the VM's lock
A VM's state is vms/<hash>/vm.json: core fields (version, id, name, alias, image, chain, from, dir, folder, backend, backend_at, created) and one section per package, each a json.RawMessage its owner decodes into its own type (state.Section, state.SetSection), what was asked for at its top level and what devvm made under "made": net (netpolicy), git (gitprotect), ports (the new internal/ports), agent (sshagent), tools (tools), secrets (secrets), and size, clone, devcontainer, desktop and links (vm, internal/vm/state.go). - state.VM.Update takes vms/<hash>/lock (platform.LockFile), reads the file again, applies a change and writes it once; a failed change, or write, writes nothing. VM.Set and its calls are gone; read-modify-write of lists (links, publish, secrets, tools, size, ports) happens inside Update. VM.Claim also holds run/claims.lock, after the VM's own; VM.Create writes a new VM's whole record once, its alias chosen (sshconfig.ChooseAlias) under the claims lock. Reads take no lock. - created replaces "net unset" as unfinished (VM.Finished). - internal/ports: the ports section (forward, host.ssh/proxy/desktop), ports.Used (was netpolicy.UsedPorts), and one Allocator for ssh, proxy and desktop ports under the claims lock (desktop allocated without one before; run/ports.lock and netpolicy's own ports key are gone). - gitprotect: mode recorded before the backend makes the VM (NewMode; clone for --clone, which ls and git-protect share as gitprotect.Mode); made.git_id (platform.FolderID), one git_dirs list for modules and embedded git dirs, delegations, protected; Unlock takes the union of recorded and current git dirs. - links' entries, git dirs, tools and devcontainer commands are JSON lists, not strings in values; the key=value parser is gone. - vm.checkState reads every section of the folder's VM as it's found. - registry.For drops its unused Dirs. - Tests: TestVMRoundTrip, TestVMOtherName, TestVMID, TestVMUpdate, TestVMUpdateTogether (two writers on one VM and on crossed VMs), TestVMClaim, TestVMFailures, TestVMCorrupt, TestChooseAliasTogether, TestUsed, TestSSH, TestChooseTogether, TestUnlockRecorded, TestCheckState, TestChangesTogether, TestChangesAtOnce; testscript's vm_state, json_set with dotted and := keys; e2e's vm_state/vm_set. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f4fd373439 |
refactor(backend): remove the smolvm backend
Lima is devvm's only backend. The backend architecture stays (Backend, Caps, Features, Review/Require, the registry, backendtest.Fake), so another backend is an addition. State from a smolvm VM reads as an unknown backend (backend_unknown_vm, gc_orphans_unknown); nothing migrates it. The image keys of layers/docker.sh, layers/nix.sh and features/desktop.sh change, so images rebuild once. Lima's port forwarder moves off smolvm's files first: newForwarderCmd and forwarderMain from internal/cli/smolvmports.go to limaports.go, and assets/container/ports.sh to assets/guest/ports.sh (sent by the forwarder at run time, so no image key changes). Removed: - internal/backend/smolvm (4,070 lines with tests), _smolvm-ports, its registry entry, registry.Experimental and backend_experimental. - The decider: backend.Decider/UsesDecider, Confinement.Decider and DeciderToken, internal/proxy/decider.go and its test, the proxy's -decider, -decider-to and -decider-token-file, netpolicy's KeyDeciderPort, KeyDeciderToken and deciderToken, the decider port in vm's forwarding and UsedPorts. - backend.AgentStarter/AgentUnchosen, vm's checkAgentStart and agent_unchosen_stop. - vmssh/key.go (EnsureKey, Public, HostKey, ServicesArgs, Capped). - paths.Smolvm/SmolvmImage and space's smolvm folders; paths.VM's Record, Key, KnownHosts and ProxyURL; project.Detect, which nothing called (a test helper now). - ubuntu.ContainerRepo/ContainerDigest/ContainerRef/ContainerOrigin and bump.sh's ubuntu_image, with its part of bump.txtar. - assets/smolvm/ and assets/container/; the no-init-system branches of layers/docker.sh, layers/nix.sh and guest/sync.sh, and the notes in features/desktop.sh and guest/ca.sh. - Messages: smolvm_* (14), vm_no_ssh, vm_no_sshd, ports_no_ssh, creating_from_image, packing_image, pack_failed, backend_experimental, agent_unchosen_stop; descriptions naming smolvm reworded. - Tests: smolvm.txtar, the smolvm stub, registry, decider, netpolicy and sshagent cases; gc_backend, gc_skipped, gc_orphans and space test a failing or hanging Lima listing instead (the limactl stub's list-fails and list-hangs); the --backend smolvm examples; e2e's --backend smolvm and its section (about 1,130 lines), the smol_* helpers and the link section's backend switch. - Coverage: internal/backend/smolvm's lines in both baselines. - Docs: backends/smolvm.md, internals/smolvm.md, design.md's smolvm notes (Ports on Lima now holds the forwarder's description), the backends table's smolvm column, every page naming smolvm, the README, the home page's backends art, and AGENTS.md's smolvm rows and gotchas (and the Docker bind-mount gotcha, which nothing refers to). Kept: the docker layer, on Lima; --from's local Docker; --backend, the BACKEND column and setup's backend choice, which the next commit removes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1917072228 |
refactor(backend): remove the Docker backend
devvm is about VMs, and Docker's containers aren't VMs: Lima is the default backend and smolvm stays experimental. The backend architecture (Backend, Caps, Require, the registry, backendtest.Fake) stays, so another backend is an addition. Removed: - internal/backend/docker, its registry entry and Names/Experimental's docker half; devvm _docker-connect and _docker-ports (internal/cli/dockerssh.go); assets/docker/unpack.sh. - Test-build overrides DEVVM_DOCKER_KIND, DEVVM_DOCKER_PROC_SYS, DEVVM_LINUX_BUILD_URL/_SHA256, the registry.linuxURL/linuxSHA256 ldflags vars and the CLI tests' Linux-build archive (linux_release). - Interfaces only Docker implemented, with their callers: backend.ProxySocket/ProxySocketOf (the proxy's -listen-unix), DiskUser (ls's and size's disk-over warning, size's disk_used and --json disk_used_gib), Reporter (doctor), LeftoverLister and Leftover (gc --orphans' volumes, networks, containers and images), DockerLayerVM and VMSpec.DockerLayer, SSHTarget.ProxyCommand and vmssh.SSH.Proxy, vmssh.SSH.SessionArgs, CacheEntry.Name. - The docker layer's runtime on a backend that makes VMs for it: vm/dockerlayer.go, KeyDockerLayer, chooseNet's refusal (chooseNet returns a bool now), the refusals at start and devvm network on, ls's "(sysbox)" and --json docker_layer, size_disk_default_unused. - The proxy's relay mode (relay.go, -relay, -relay-to, -listen-unix). - paths.Dirs.Docker and paths.VM.Lifeline. - assets/guest/tools.sh's linked-folder branch; services.sh's DEVVM_LOOP, DEVVM_DOCKERD and DEVVM_SSHD=inetd. - Messages: every docker_* the backend used, docker_layer_runtime, net_docker_layer, net_off_docker_layer, committing_image, pulling_image, unpacking_tools, disk_over, size_disk_default_unused, gc_orphan_volume/_network/_container/_image, docker_connect_failed; gc_orphan_elsewhere reworded. - Tests: docker.txtar, the docker stub's engine (its --from half stays), the ssh stub's login-shell branch; e2e's --backend docker, --engine, the docker host VM and Docker Desktop runs. - Release: one GoReleaser pass, no Linux-build pin in the macOS builds, no Linux devvm in the Homebrew formula's libexec. Linux builds stay. - Docs: backends/docker.md and internals/docker.md, design.md's Docker notes, the Docker column of the feature table, and every page's mentions of the Docker backend, Docker Desktop as one, and Sysbox. Kept: the docker layer in Lima VMs, devcontainer docker-in-docker, --from with images only a local Docker has, Docker Hub references. State written by a Docker VM before this reads as an unknown backend (backend_unknown_vm). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
dd3f0deb3f |
feat(state): config.toml and settings.json hold the defaults, and devvm's own files move to the data folder
~/.config/devvm/config.toml is the defaults you write by hand: backend,
network, ports, features, agents, [size] cpus/memory/disk and
[retention]'s six keys. devvm reads it and never writes it, strictly: an
unknown key (toml.MetaData.Undecoded, its line found by key) or a value
its check refuses (ParseCPUs, ParseGiB, ParsePorts, ask/on/off, a
backend's name, image.FeatureName, image.Agents, ParseDuration,
ParseSize, counts) fails naming the file and the line.
~/.local/share/devvm/settings.json holds what devvm setup, size -g,
ports -g, network -g and retention save (unknown fields ignored).
internal/settings owns both: Defaults (Value and List, each with its
Source: flag, config.toml, settings.json or built-in), Read, Save, which
refuses a key config.toml sets (set_in_config, with a doc link), and
the parsers and retention settings that moved from vm and state. A flag
wins over config.toml, config.toml over settings.json, settings.json
over the built-in default. Settings methods lose their files; setup
uses vm.NetworkChoice instead of its own copy; creation.plan reads one
snapshot (firstRun) after the first-run questions; the registry gets
the default backend through DefaultBackend; state's featureName copy
goes with base-features.
devvm size -g, ports -g, network -g and retention show each value's
source after a #, and in --json (source, sources); devvm doctor names
the file that sets its backend (doctor_backend_from) and adds
backend_source. devvm setup skips what config.toml answers
(setup_in_config) and refuses a flag that would change it.
ssh_config (and so the ~/.ssh/config Include line), known_hosts,
agent-keys.json and secrets/ move to the data folder. agent-keys.json is
{"keys": [{file, fingerprint, confirm, lifetime}]}, parsed once
(AddedKey); Keys formats KeyList.
Tests: settings' table tests (every key, unknown keys, bad values, an
empty file, precedence, Save's refusal and merge, settings.json's
fields), agent-keys.json, the registry's default backend, setup with
config.toml, SizeChoice with config.toml; CLI scripts for size -g,
ports -g, network -g, retention, setup and doctor's sources, each
refusal, a hand-edited config.toml with a typo, and ssh -G resolving
devvm-web through the Include line. Docs: settings.md's config.toml
section with a full example, linked from each command's page.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
2b25a0c7dd |
fix: the shared foundations' review: one Lima host address, a kill only for its own process, and the Linux baselines
The consolidation pass over the shared foundations: - Lima's host address on its user-mode network, 192.168.5.2, is one constant, limaHost, which the VM's proxy URL and the build proxy's both use (proxyHostDarwin and buildProxyHost went). - platform.LockFileShared had no caller: LockFileSharedWaiting with no waiting does its job, and its tests use that. image.ToolName had none either, and goes until the tools picker needs it. mise run deadcode lists only what AGENTS.md names. - tools' writeNew, a third whole-file writer, goes: the share's .sha256, .target and idle files are written through state.WriteFile. From the security audit of the phase: - daemon.Proc.Stop sends SIGKILL only to a process whose arguments still say it's this one. A process still ending, whose arguments can't be read, is waited for; so is another process given the pid since whose arguments can't be read either (a setuid one, on macOS), which would have been killed. TestProcStopKillsOnlyItsOwn fails without it. - forbidigo's signalling rule also bans os.Process's Kill and Signal outside daemon and platform; tests signal their own children, and devvm desktop's ssh child, not yet waited for, says why with a nolint. testdata/lint has a line for each. Contributing's checks table says so, and internals/network.md says which process SIGKILL goes to. testdata/coverage/linux.txt is measured again with mise run coverage on the x86_64 Linux host: it had no lines for fetch, shell and vmname, so mise run test failed on Linux, and daemon was set by hand. arm64 (the Linux host VM) agrees within a point. darwin.txt: daemon 97.8, tools 89.2. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2687eec488 |
refactor: one background-process helper, internal/daemon
internal/daemon (standard library only, so devvm _proxy uses it too) owns devvm's background processes: Detach and Spawn (own session, no input, reaped once they end, DEVVM_DAEMON_STATUS naming the process's own status file), Handle (signals through the process started), Proc (a pid file checked against the process's arguments, Stop: SIGTERM, a wait, SIGKILL, the pid file removed once stopped), readiness by status file (Ready, WriteStatus, WaitReady: the pid and data, written in one line-ended write, never another start's), Alive and Signal (no pid below 1), and one lifeline meaning (FollowLifeline, Lifeline.Holds and Wait: content equality, a bounded wait past what the file held first). It replaces netpolicy's proxy pid, stop and start wait, vmssh.Forwards' pid, stop and start wait, the build proxy's process and log-read port, links' link-session pid, stop and start, the proxy's watchLifeline and vmssh's lifeline reading, platform.StartDetached/StartDetachedProcess, and the alive copies (netpolicy alive/signal, lima alive, vmssh.ProcessRuns, smolvm runsOn's). The three log-scraping waits go: the proxy and the forwarder say they're ready in a status file, and the build proxy's port comes from its own. forbidigo bans os.FindProcess, syscall.Kill and unix.Kill outside internal/daemon and internal/platform, with its line in testdata/lint/forbidigo.go; the structure test lists DEVVM_DAEMON_STATUS and puts internal/daemon among the leaves; depguard holds it to the standard library. Tests: daemon's own (detach, handle stop, a reused pid, a stale pid file, groups refused, readiness, lifeline), characterisation tests first for the proxy's, the forwarders', the link sessions' and the build proxy's pid handling; coverage: internal/daemon 97.7%, lima 87.6 to 87.7. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
06bed70fc7 |
test: record the Linux coverage baseline, and fix two tests that failed on Linux
testdata/coverage/linux.txt is each package's coverage from mise run coverage on a Linux host (Ubuntu 24.04 arm64), so mise run test checks Linux runs too. Two tests failed there: - secret.txtar checked that --no-input saved nothing by asking whether the secrets file existed, but on Linux an earlier step had saved one. It now checks that github keeps the token saved earlier, on both systems. - smolvm's TestStartSSH looked for the proxy password "pw" in the arguments, which also held a random ssh public key whose base64 can contain "pw". The password now has a "!", which base64 never has. Co-Authored-By: Claude Opus 5.5 <[email protected]> |