mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
87
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]>
|
||
|
|
80923fc580 |
test(vm): a gone folder's VM restarted by its self-check is refused before its start
devvm rm VM, for a VM whose project folder is gone, goes on with the VM as it runs for its export, or with --no-export for the check of the agents' worktrees, and the network self-check of a confined VM started outside devvm offers to restart it confined. A yes stops the VM, and the restart goes through startOnce, which checks folderChanged before the backend's Start: the start is refused (project_folder_changed), the VM is kept, stopped, and its folder, which Lima would make again for its mount, isn't made. startOnce holds the only backend Start in internal/vm, so every start devvm makes (a launch, devvm restart, an export, rm's checks, a remake, the self-check's restart) is checked the same way. rm_gone_unenforced.txtar drives both rm paths with a yes to the restart: no limactl start, no export or worktree read, the VM kept, and once stopped refused as ever (rm_gone_stopped, rm_gone_stopped_trees) until the flags that skip what needs it running. The stub's limactl start makes no folder, so no limactl start is what shows the folder isn't made again. With startOnce's check before the backend's Start removed, it fails: the backend starts the VM, and only the check after the start stops it (project_folder_changed_stopped). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2de3e31a6c |
fix(vm): devvm ports shows a status line as it restarts a running VM's forwarder, and every lock's wait is tested for its label
Lock waits: - Tests record the label of each lock's wait that had none, the lock held as by another devvm and the wait ended by a cancel, a deadline failing one that shows nothing rather than hanging: git_lock_waiting (TestGitLockWaits; .git protection's Serial is gitSerial, so a test can reach it), packages_waiting and rebuilds_waiting (TestImageLocksWait), ubuntu_pin_waiting (TestPinOriginWaits), custom_secrets_waiting (TestYoursLockWaits) and forwarder_waiting (TestForwardsLockWaits). - A test build's locks panic on a nil platform.Waiting (platform.CheckWaiting, which the root's run calls in every test build beside state.CheckLockOrder), so the CLI tests and e2e catch a nil wait the structure test can't see, such as a zero agentlogin.File's; a msg.Waiting given a nil status shows nothing and stays review only. msg.Waiting with no status gives a wait that shows nothing, never nil; platform.NoWait is the Waiting of a lock that never waits (the build port's record, which passed nil), and the status-lines rule holds it to statusSites as it does nil (TestCheckWaiting, TestWaiting, the rule's NoWait case). - forbidigo refuses syscall.Flock and unix.Flock outside internal/platform, internal/proxy/rotate.go, the stubs and tests (testdata/lint, both). - TestLockFileWaiting runs in a synctest bubble and checks the wait shows while held, not before (its counters under a mutex, which the race detector needs, as only the file's lock orders them). Status lines: - TestCommandStatusLines runs the setters too: devvm ports LIST and ports add, size --cpus, network open, allowlist, transparent off and on, learn and allow, git-protect off and on, ssh-agent off. It found devvm ports on a running VM starting its forwarder again (ssh and a command in the VM) with no status line; that step now shows ports_restarting. The folder named twice: - vm_folder_unreadable's why was the open's error, the folder's path in it; folderUnreadable gives the system's reason alone when the error is about the folder itself (TestUnreadableFolder checks the whole message). - platform.OpenNoLinks and StatFolder return a link on the path as an fs.PathError about the folder too (ErrLinkOnPath still matches), so that case names it once as well (TestStatFolderUnique). Docs: Contributing's CLI page (status lines) and structure page, the codebase-standards guards; CHANGELOG (devvm ports' status line). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f80fd2df60 |
fix(vm): devvm agent save applies all or nothing under the login lock; a lock's wait and a walk end with their context; a link to the home folder counts unless only root can change it
All or nothing: - devvm agent save goes through devvm agent import's undo journal: each plan's files are written into a staging folder of the agent's store (saver.stage, newStage, the import's .devvm-import- name, swept by the next import or save), then put in place (applyPlan: each file renamed in, the one it replaces kept aside as a hard link, folders made, what a folder no longer has moved aside, seeds and kept entries left), and the .claude.json subset saved last with secrets.SaveLogins, which holds the login's lock. A failure after the first change puts every agent's store and the login back; an undo that fails too says so (agent_save_undo_failed) and keeps the staging folder. - applyStages (and stageSet) is what both commands apply through; importStage is now storeStage, pruneIn takes an fs.FS, and pruneFolder moves a folder's leftovers aside. pruneStore and applySettings go. - A file in the VM where the store has a folder, or the other way round, fails the save before anything changes (agent_save_store_folder, agent_save_store_file; sameKind), where the stage would have replaced it without the diff showing; storeFiles reads such a path as empty. Contexts: - platform.LockDir flocks a folder, polling until ctx ends as LockFile does (waitLock is their shared loop); agentlogin's lockLogin is it, so the lock is the one an older devvm's proxy takes. LockLogin, LockFolder, File.CaptureRequest, Capture, SetKey, Remove and secrets.Store.CaptureRequest take a ctx. A capture whose reply the endpoint has given is saved with agentlogin.AfterReply's context, the exchange's without its end and bounded by two minutes of its own, so the exchange's deadline never loses a rotated login while a refresh or a save holds the lock, and a stalled holder never holds it for ever (File.Capture, secrets.Store.Capture, its loginsDir included). - safefile.Walk takes a ctx and stops before each folder and batch once it ends; readSettings, followLinks and follower.copy pass theirs. - LockFolder's comment said its lock was another than a login file's in the same folder; it's the same (.claude.json's), and says so. Links while a state can't be read: - homeHops exempted every link on the way to the home folder, on the claim that no project folder can hold one, which --unsafe-folder breaks. rootOnly exempts a link only when every folder above it, up to /, is root's, has no group or other write bit and the system says you can't write it (platform.Writable, access(2), which counts ACLs and FUSE), and devvm doesn't run as root. The structure test lets internal/agentlogin import internal/platform and counts platform.LockDir in its status-lines rule. Tests that fail without their fix: TestAgentSaveApplyFailsWhole (a rename and the login failing), TestAgentSaveUndoFails, TestAgentSaveLoginLock (waits under agent_login_waiting; Ctrl-C leaves the stores as they were), TestAgentSaveKindChanged, TestAgentImportHomeBelowALink, TestCaptureOutlivesItsDeadline, TestClaudeCaptureOutlivesItsDeadline, TestWalkCancelled, TestLockLogin (synctest: a deadline and a cancel). New: TestLockDir (synctest, and a plain flock's lock), TestRootOnly, TestWritable, the status-lines rule's LockDir case. TestStoreOpsRefuseLinks checks openStoreDir in pruneStore's place. Docs: internals/agents.md (saving, the staging folder, links to the home folder), using/coding-agents.md, Contributing's CLI and structure pages; CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2b176c92b3 |
feat(ui): every slow step shows a status line, and messages and questions never land on it
Any work that can take noticeable time now runs under the UI's status line: a Reporter's Status with a label message, or a LoggedCmd step. The UI: - status lines are a stack: a Status or LoggedCmd inside another shows its own line, then the outer one is drawn again, where before it ended the outer one for good - a message (Info, Warn, Note, Say, data on Stdout/Stderr) clears the line, prints and draws it again below; an unended line holds it - a question (Ask, Confirm, Answer, Secret), the picker and ui.Terminal hold it until they're done - no status line starts once the run is interrupted, as nothing would clear it - the run log's path is read without the log's lock, as the status line reads it under outMu Covered, by site and label: - finder.target: finding_vm; Lima's limactl --version: checking_backend - bringUp's checks (seeds, instance, recordFolder, hostChecks, ssh, requirements) and a running VM's go-on (proxy, pins, mount check): checking_vm; startOnce after the agent: starting; the self-check's probes: checking_network; pinHostKeys: reading_host_keys - setUpVM (sync, ssh config, links, clone seed): setting_up_vm; each devcontainer command: running_script; makeMachine: creating; buildOnce: checking_image; paste's count and rm: reading_pasted - volumeOf's lookup (diskutil), for launch, adopt, move, ls and rm: looking_up_volume - vm.ListAll (devvm ls): reading_vms; devvm doctor's checks: doctor_checking - devvm agent import: agent_import_reading (walk, links, opencode), agent_store_saving (copy, marketplace git checks, tmutil); devvm agent save: agent_save_reading, agent_save_comparing, agent_store_saving - devvm stop (from its pins check on): checking_vm; a delete, an orphan's teardown and Lima's DeleteImage: deleting; devvm git-protect and clone on/off's .git work (leftBehind, mountFolder, unmountFolder): git_protecting; git-protect's re-read: finding_vm - devvm clone add: clone_reading, clone_adding; clone fetch: clone_fetching; planClone: clone_planning; the clone check before rm or a remake: clone_checking; history export and import: history_exporting, history_importing; a remake's home: saving_home, restoring_home - devvm upgrade's install: upgrade_installing; the shared tools' step back and .NET's downloads: resolving_tools; gc's caches: reading_space; the retention settings (daily and in gc): retaining Work that takes the terminal stays off: the shell, ssh-add's passphrase (checkAgent, Agent.Ensure, reloadAgent) and an agent's login. Tests and guard: - msg.Fake: OnStatus and Showing; its LoggedCmd shows its step - backendtest.Fake: OnCall - TestLaunchStatusLines: every backend call of a new, running and stopped VM's launch runs under a status line but the shell's and Running's (pid files) - TestSSHAddOffStatusLine: ssh-add, on the user's agent or devvm's, never runs under one; chflagsCalls fails a .git lock or unlock with none - the structure test's status-lines rule (statusSites, statusFree) - TestStatusLinesNest, TestMessagesClearTheStatusLine, TestQuestionsHoldTheStatusLine, TestSecretAndPickerHoldTheStatusLine, TestTerminalHoldsTheStatusLine, TestNoStatusLineOnceInterrupted, TestFakeStatus, TestAgentImportStatus, TestAgentSaveStatus, TestDoctorReport, TestProblems, TestList, TestListLooksUpVolumesOnce, TestVolumeOfCache, TestWithSDKDownloads, TestRetainStatus, TestSetCloneOn, TestTeardownLeavesNothing The rule is written in the cli skill (rule 14, checklist, review), the codebase-standards skill (Show what devvm waits for, its checklist line and rules.md's row), Contributing's CLI page (Status lines), its tests and structure pages, and the troubleshooting page. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c41ca82f6e |
fix(project): devvm's own folders are compared by identity; a launch warns of a project in an agent's folder
project.Unsafe's Holds and Inside compared a project folder with the home folder and devvm's config, data and Lima folders by name alone (paths.Within, paths.Below), so on a volume that ignores case, as a Mac's does by default, a project at ~/.Config/devvm/layers passed both and its VM got devvm's settings and layer scripts read-write. They now compare by identity too: paths.In, the vm package's isIn moved to its owner, finds the path or a folder above it to be the same folder as the other, by device and inode, and paths.Under is In for the path's folder. An empty folder holds nothing, so an unset one can't match the working folder. sshagent's mountedBy, which refuses a key in a folder a VM mounts, compared by name in the same way and uses paths.In now. Each launch (Launch.Up, beside warnMounted) warns once, in one line, when the project folder it mounts is inside an agent's folder in the home folder or holds one (project_agent_folder), naming every such folder from the agents' registry, with agent_import_project_inside's detection (overlapsAgent). A --clone VM mounts nothing and gets no warning. Tests: TestUnsafeIgnoresCase, TestInAndUnder, TestMountedKeyIgnoresCase, TestWarnAgentFolders; the case checks skip on a volume that tells names apart by case. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]>
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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]> |
||
|
|
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 (
|
||
|
|
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]> |
||
|
|
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]> |
||
|
|
2b49967b4e |
chore: CI time zones, test isolation from the repo, a flaky test and the agents page (#45)
Upkeep: CI, flaky tests, dead code and the coding agents page. - test: tests never run git on the repo they're run from. A git that runs the tests (a hook, git rebase --exec) sets GIT_DIR and friends, and the tests' plain git followed them into the real repo's config. Every test's git now runs through internal/stubtest (Git, GitEnv, NoGitRepo), the structure test enforces it, and the whole suite passes with GIT_DIR pointing at a decoy repo that stays untouched. - ci: two test jobs instead of three: Linux in America/Los_Angeles (DST) and macOS in UTC, with lint on both, since golangci-lint checks only the runner's OS's files. - test(e2e): accept Codex 0.167's wording for an API-key login. - test: internal/safefile's swap-after-look branch is tested on purpose through a seam, so its coverage no longer depends on a race (97.7% every run). - test(fetch): TestRetryUnanswered's "no answer" comes from a listener that keeps its port, so a parallel test's server can no longer take the freed port and answer in its place (Linux reuses ports at once). - refactor(proxy): the test-only policy.decide and policy.byRequest move to the tests; the proxy already judges a host from one read of the rules (rulesFor). - docs(agents): "Pasting images" moves down the coding agents page, before History, and its run of paragraphs becomes commands and lists, every fact and anchor kept. Gate and coverage pass on each commit; e2e `network` and `project` pass on Linux (251 passed, 4 macOS-only skips). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]> |
||
|
|
2f0cc97392 |
feat(paste): devvm paste and devvm paste rm (#38)
feat(paste): devvm paste, an image, PDF or copied file from the clipboard into the VM (#38) devvm paste reads the host's clipboard and streams what's on it into the running VM's paste folder over the backend's Exec, with no SSH agent and no new channel, then copies the file's path in the VM to the host clipboard for the agent's prompt. devvm paste rm empties the folder after a question, and a launch that starts a stopped VM offers to. What it reads: - an image (PNG, JPEG, GIF, WebP; TIFF is converted to PNG), checked by its bytes; browsers hand over a PNG, so an animated GIF arrives as one frame - PDF data, sent as it is, and preferred over a file reference beside it (Preview's page copies) - one copied file, after a question that shows its path on this machine; --send-file answers it only for a file inside the project folder reached without links, and never for a --clone VM - never text; several files are refused Security: - macOS reads file URLs only through NSPasteboard (FileURLsOnly): AppleScript's «class furl» coercion turned any text, such as a path a web page or the VM's OSC 52 put there, into a file to send - copied files are opened with openat and O_NOFOLLOW|O_NOCTTY|O_NONBLOCK, following a root-owned link only in a folder only root can change, and read through internal/safefile (Checked), capped at 64 MiB - osascript and pbcopy by absolute path, Linux's tools only from system folders, never PATH - time limits on every clipboard tool and on paste.sh in the VM; bounded reads of everything the VM prints - the path copied back is built on the host, keeping only the file's extension: nothing the VM says reaches the clipboard Also: the paste-dir setting (default /tmp/devvm-paste, made at each launch), --json with sent, the agents' guide line, messages with doc links, stubs, CLI tests, an e2e check in the project section, and docs on coding-agents, settings, design, security and attack-vectors. Co-authored-by: dustypolk <[email protected]> Co-authored-by: w3cj <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
20d2fe1db7 |
feat(clone): workspace clones of a folder of repos
devvm --clone in a folder of git repos gives one VM a clone of each repo the user chooses, each at the same path as on the host, so paths between them (file:../pkg, ../Lib/Lib.csproj) work in the VM, and a copy of the folder's own files outside the repos, made once. - Discovery by .git protection's walk (4 folders down, the same skipped folders, 100 repos); each repo checked as --clone checks one; a linked worktree of a repo in the folder isn't a repo of its own; a repo whose folder, or common dir, another VM mounts is refused, naming it, as is one whose name a terminal can't show. A picker in a terminal (every copyable repo ticked, the others shown with why); --repos all|none|LIST answers without one, and the question is refused naming it. A folder that's a repo keeps today's single clone unless --repos is given; one inside another repo's working tree is refused (workspace_inside_repo). The choice is recorded in the VM's state. - A single --clone, or devvm clone on, in a folder another VM mounts is refused too (clone_folder_mounted), at plan time and before the seed's push. - Each repo seeded with its current and default branch (origin/HEAD, else main, else master); a detached HEAD checks out the default. One VM command makes every repo, leaving one an earlier push reached as it is; each repo is checked again just before its push, and its remote chosen once the one before is added. The folder's own repo's clone excludes the other clones (escaped, anchored lines) and the host's info/exclude, at the seed and at devvm clone add. - The folder's own files: walked folder by folder beneath the folder (safefile.Root.OpenDir), no links followed, no hard-linked files, no bare repos, no set-id bits, bounded; refused folders (checkUnsafe) apply. - devvm clone fetch [--json]: every repo's branches into its remote's remote-tracking branches (--refmap=, one refspec), listed by branch name with their repos; nothing new is said only when a repo was fetched from. devvm clone add PATH: one more repo; one whose copy didn't finish is copied again. - rm, devvm clone off and the switch loop over the repos; rm's check reads every repo in one VM command (cloneState), parsed strictly and capped (8 MiB, 10,000 branches in all), counting only worktrees inside the folder, a VM-side folder never made read as every repo gone; a clone missing in the VM is asked about, an unfinished repo checked when it's there; a host repo that changed refuses the check, and one another VM mounts, a single clone's too, gets no host git and is asked about; each repo is checked again before rm's fetch. - The finder opens a workspace clone VM inside one of its repos; --here still makes the repo's own. --repos's dependencies go through needs(), which now takes a first argument too (devvm clone on). - State is additive: clone.workspace, clone.repos, clone.made.files; a 0.1.0 clone reads as one repo at ".". CHANGELOG: an Unreleased section. Messages: flag_needs_flag, repos_value, repos_not_workspace, workspace_repo_unknown, workspace_pick_help, workspace_pick_cannot, workspace_reason_*, workspace_inside_repo, workspace_repos_past, workspace_skipped, workspace_repo_dropped, workspace_detached, copying_repo, uncommitted_not_copied_repos, workspace_ready, workspace_files_failed, workspace_files_skipped, unfetched_commits_in, clone_repo_dirty, clone_repo_gone, clone_repo_changed, clone_repo_mounted, clone_repo_unchecked, clone_folder_mounted, clone_check_repo_changed, fetch_before_delete_repos, no_terminal_fetch_repos, clone_fetch_*, fetching_repo, clone_fetched_*, clone_add_*, clone_added. Tests: TestDefaultBranch, TestBranchPlan, TestIsWorkspace, TestChooseRepos, TestPickRepos, TestFindRepos, TestRepoExcludes, TestWorkspaceFiles, TestCloneChangesAcrossRepos, TestFetchedByBranch, TestCloneRepos, TestV010CloneReadsAsOneRepo, TestCoversRepo, TestParseCloneState, TestCloneStateScript, TestWorktreePathPins, TestOpenDir; the clone_workspace, clone_workspace_repo, subfolder and nested_replaced scripts; fixture_v010_clone (0.1.0's web clone fetched, checked by rm, made a workspace clone by devvm clone add, switched off; its scratch switched on); the e2e clone section's cloneWorkspace. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2865158e02 |
feat(network): learn the hosts a new VM needs, then lock it to them (#22)
--network learn runs a VM on the internet tier while it records the hosts it reaches beyond its allowlist, shown as internet (learning). devvm network lock picks which of them go into the VM's own rules, ticking only reviewed registries on 443 and listing risky hosts apart, then gives the VM the allowlist tier at once. learn is per VM only. The lock command names its docs page in its about. 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]> |
||
|
|
c171e205ec |
docs: the layout as it is, and the agents' guide on the VM's host folders
The in-VM guide says the project folder is the only host folder the VM can write to, with the agent store's folders and the shared tools mounted read-only. design.md names internal/vmssh/links_test.go and internal/proxy/testdata/nix/, and its devcontainer forwardPorts entry says the file's ports are added, as its Ports entry does. Contributing drops the old shared CA folder's paragraph; space.md says secrets/ is for hosts without a Keychain. Coverage baselines raised (netpolicy, settings, vm). 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]> |
||
|
|
2df3c6840c |
feat(agents): devvm agent login, an agent's login in the VM for every VM
devvm agent login codex|opencode logs the agent in from inside this
folder's VM, so this machine never needs Codex or opencode, and devvm's
agent store keeps the login for every VM with the agent. It sits under
devvm agent beside import and save: it fills the store, as they do, and
a bare devvm login would read as a verb on the VM itself.
- Browser login (the default): the agent's own login runs in the VM on
this terminal (codex -c cli_auth_credentials_store="file" login;
opencode auth login --provider openai --method "ChatGPT Pro/Plus
(browser)"), and devvm forwards this machine's localhost:1455, and
1457 (Codex's fallback) when free, on 127.0.0.1 and ::1, to the same
ports on the VM's loopback, only while the login runs: closed when it
ends, fails or is interrupted (AddCleanup), and an interrupt also ends
the agent's login in the VM (its pid kept in ~/.cache/devvm-login.pid),
so its server doesn't linger for the VM's port forwarder. Port 1455
taken on this machine: refused, naming --device-code.
- --device-code: codex login --device-auth, or opencode's headless
ChatGPT login; nothing forwarded.
- --api-key [--provider anthropic|openai|openrouter] [--stdin]: the key
is asked for on this machine (msg.Question answered by --stdin) and
saved in the store, never in the VM: Codex's auth.json becomes
{auth_mode: apikey, OPENAI_API_KEY}, opencode's gets the provider's
{type: api, key} beside the others; the running VM gets its copy with
a placeholder and its proxy the binding at once.
- The proxy's capture (agentlogin's capturers) saves ChatGPT logins;
devvm then confirms what the store saved, with the account's email,
and fails when the login saved nothing new.
- opencode 1.19.5 has no Anthropic OAuth in its core (no Anthropic
plugin among its built-ins), so there's no pasted-code capturer:
Anthropic is an API key. opencode's OpenAI login listens on 1455 only;
Codex 0.166 on 1455, falling back to 1457.
- vmssh: SSH.ForwardLoopback (LoopbackForward: listeners in devvm's own
process, each connection its own ssh -W to the VM's 127.0.0.1, no
master; ErrPortTaken).
- agentlogin: KeyProviders, File.SetKey, File.ChatGPT.
- secrets: Store.SaveKey, LoginSum, ChatGPT (loginsDir shared with
Capture).
- vm: AgentLogin (agentlogin.go), LoginAgents.
- cli: agentlogin.go (--device-code, --api-key, --provider, --stdin,
--here/--parent); usage errors before anything runs.
- assets/guest/sync.sh: cli_auth_credentials_store = "file" first in
the VM's ~/.codex/config.toml on every launch.
- Messages: agent_login_* and agent_key_*; codex_no_key,
codex_no_chatgpt, codex_refresh_failed and opencode_refresh_failed
point at devvm agent login.
- Tests: agent_login.txtar (usage errors, no VM, no agent, device code
argv, browser forward and its end, the agent failing, a login saved
while it runs, port taken, interrupt, API keys, the VM's copy failing,
no terminal, an empty key), unit tests for the forward, SetKey,
ChatGPT, SaveKey, the confirmation and the argv; coverage baselines
raised.
- e2e (network): the real Codex's login in the VM against the run's
fake token endpoint, its callback opened through the forward, the
store's tokens and key, placeholders in the VM, the forward gone; an
interrupted login takes its forward away.
- Docs: Logging in with devvm agent login (using/coding-agents.md),
the Commands page, the questions table, Contributing's e2e, the cli
skill's tree, AGENTS.md; the CLI reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
d17e62961e |
refactor(msg): one message for each kind of setting, flag and requirement
Messages that said the same thing for different settings are one message each, given what differs: - new_vm_flags_ignored and new_vm_flags_ignored_run (flags, vm, command) replace from_ignored, net_flag_ignored, git_protect_flag_ignored, size_flags_ignored, ports_flag_ignored, parts_flags_ignored, ssh_agent_flag_ignored and no_devcontainer_flag_ignored: one warning for each command that changes the same on the VM, naming only the flags given (ignoredFlags). - setting_already (command, vm) replaces net_already, agent_already, clone_on_already and clone_off_already. - setting_set (vm), for a stopped VM, replaces net_set_stopped, agent_set_stopped and links_next_start. - next_start (count, vm), for a running VM, replaces net_set_running, agent_set_running, size_next_start, agent_next_start, mounts_next_start, folder_next_start and net_off_next_start; a launch warns of each change with its next_start_* line, then next_start once. - program_missing, program_broken and program_old (+ _fix) replace lima_missing, lima_broken, lima_old, qemu_missing, macos_old and their _fix messages; the minimum versions are minLima and minMacOS in the lima backend, passed into program_old. - ports_list_needed replaces link_ports_invalid: devvm link publish and unpublish check their ports with ParsePortList, as devvm ports add does, and ParsePublish is gone. - no_vm replaces no_vm_link. - vm_unfinished says nothing of the user's is in the VM, as remake_unfinished does. Kept apart: git_protect_next_stop (it applies at the next stop, and devvm stop applies it), already_stopped and ports_all_already (not settings), group_already (joining again syncs the group's links), has_tools and has_layers (they name which of those given were there), docker_missing (Docker is optional, so it never says to install it). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
d58b24affe |
refactor(ui): prompts in one place: each question declares its answer
Every question is a msg.Question that declares what answers it where
devvm can't ask: AnsweredBy("--force") names a flag or command, which the
refusal names (no_input), and RefusedWith(msg.X(...)) gives a question no
flag answers its own refusal. msg.AnswerFor and its table go.
The Reporter's Ask, Confirm and Answer, and the UI's Secret, take a
Question and return a *msg.Refusal where they can't ask: with --no-input,
without a terminal, or at the end of the input, one refusal for all three
causes. Commands return it through the failure path (showFailure ->
UI.Refused: the question, then the refusal); nothing dies on an unanswered
question any more. Questions with a usual answer fall back on it instead:
network policy on, restart no, history import later, the Include line
warned, an unenforced VM stopped, the first run's size kept.
Gone: confirmed() in cli (4 callers), force_needed and no_input_terminal,
vm.Env.CanAsk and ui.CanAsk, vm's interactive, setup's terminal, the
Reporter's StdinIsTerminal/StdoutIsTerminal and the Fake's StdoutTerminal,
and every caller's terminal check (18 in vm, netpolicy, build and
sshconfig; 3 CanAsk; 1 interactive; 2 in cli). The picker's check
(CanPick) stays in the picker, which keeps its choices with --no-input
too; setup and the first run's agents and the new-VM summary still read
CanPick, because what they save or say depends on whether the picker
showed.
A Question's About context (the network policy's, a secret's howto, the
restart's changes, the size's host) is said only when it's asked.
devvm update asks before its tools change, so a refusal leaves the VM as
it is.
The CLI tests answer through a terminal (ttyin) or, explicitly, with a
test build's DEVVM_PIPED_ANSWERS=1, a line of input each.
Tests: ui's TestConfirm, TestAsk, TestAnswer, TestPromptsOnlyAtATerminal,
TestSecret, TestNoInput, TestNoTerminal, TestNoAnswer, TestPipedAnswers,
TestRefusedInterrupted, TestPickNoInput; msg's TestQuestionRefused,
TestQuestionAbout; cli's agreement test TestQuestionsDeclareAnswers (every
AnsweredBy names devvm's flags and commands, every RefusedWith a message,
no Question made otherwise) and TestCheckAnswer; vm's
TestSizeChoiceRefused; testscript prompts.txtar (each cause, a refusal of
its own, piped answers).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
7bdaf8e99e |
refactor: one Reporter for every package's messages and prompts
msg.Reporter is what every package below cli prints and asks through: Info, Say, Note, Warn, Status, Ask, Confirm, Answer, the terminal checks and CanPick, the run log (LogNote, LogWriter, LoggedCmd, WithSteps), Stdout, Stderr, AddCleanup and Interrupted, under the UI's signatures. *ui.UI implements it (a compile-time check in ui), and msg.Fake is the tests': quiet as its zero value, its On funcs and fields record and answer. The six UI interfaces (tools, netpolicy, lima, registry, sshagent, vm) are gone, and the copied output and prompt func fields of tools.Env, tools.Making, gitprotect.Protector, secrets.Store, netpolicy.Proxy, from.Lookup, backend.Review, lima.Lima, sshagent.Agent, vm.Env, vm.SizeChoice, vm.AgentsChoice, vm.LayersChoice, vm.NetworkChoice, vmssh.Forwards, build.Env and sshconfig.Config: each embeds the Reporter. Lima's and the shared tools' Warn, which says where the run log is too, is a method of their own over it; vm's interactive check is a function over it. The pickers (build.Env.Pick, vm.Env's PickFeatures and PickParts, the choices' Pick) and vm.Env.CanAsk stay fields: they carry types of their own or cli's answer. The test UIs of tools, netpolicy, lima, registry, build and vm become msg.Fake. Coverage baselines raised: internal/backend/lima, internal/msg, internal/tools. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bc8ed10156 |
fix(vm): devvm gc --orphans forgets a VM under its folder's creation lock
Leftovers.Forget takes the folder's creation lock (holdCreate) for its re-check and teardown, so a VM a devvm is making again, its state written before its backend has it, is refused (create_running) however old its state; gc --orphans and retention's orphans.age both go through it. TestForgetHoldsCreateLock failed first. TestMoveUnsafe covers a move's refusal of an unsafe folder, which no test did (fails without checkUnsafe in finder.move). Docs: the creation lock in internals/overview.md and space.md's leftovers; commands.md's moved folder says the agents' sessions keyed by the folder's path stay under the old one (claude --continue/--resume, codex resume --all). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e9ca7a4859 |
feat(vm): a moved or renamed project folder keeps its VM
A VM's files and machine are keyed by its name's hash, which stays; what moves is the state's dir. The finder finds a folder's VM by the state that records its path (finder.state: the path's hash first, then every state, recorded), so a VM moved there is found from the new path alone, and links by path (project.ForDir) match the recorded dir. When the folder has no VM, the finder looks through the states for one made for this folder at another path (moveHere, move.go; the match is here.movedFrom): the same folder identity (device, inode, birth time), the folder this user's, its identity unique (platform.UniqueFolderID: an ID with a birth time, and on macOS APFS or HFS+), another recorded path that's gone on the folder's device or only a symlink to here, its creation finished, not a --clone VM. One match is offered: in a terminal move_vm, [y/N]; without one vm_moved_here, naming devvm adopt; devvm adopt --force moves it without asking. Several matches warn (vms_moved_here) and move none. Never automatic. The move (finder.move) refuses a folder no new VM may have (checkUnsafe), holds the creation locks of the VM and of the folder's would-be new VM, checks again that no state records the folder and that the folder is still the one asked about (move_folder_changed), stops a running VM as devvm stop does, then records the path and identity under the VM's lock, refusing a state that changed meanwhile (create_running); vm_adopted says so. .git protection's record is kept: .git, its identity and its uchg locks move with the folder. The project folder's mount is now part of backend.Want (Want.Project, Instance.Project, Apply), so the next start mounts the folder where it is: Lima's wantEdits rebuilds .mounts in its one edit when the project mount or the agent folders differ (mount.project). A VM running with another path asks to restart (Y/n) and otherwise warns (next_start_folder, folder_next_start). A new VM at the old path can't use the moved VM's folder, so newName takes the first of the path's names whose VM folder holds no state (project.Nth: the hash of the path, then of the path and n). devvm adopt [VM]: with VM (by name or alias, as devvm rm VM), moves a VM whose folder is gone or not connected to this folder, for a copy on another disk (a new inode, never matched on its own): adopt_move_vm [y/N], --force, adopt_move_refused without either; refuses a --clone VM (adopt_clone), a lost machine (rm_vm_lost), an unfinished VM, a folder still there (adopt_folder_there) and a folder with a VM of its own (adopt_has_vm). It clears .git protection's record, as the copy's .git is another. rm_vm_state_mismatch is gone, as a dir needn't hash to the name any more: devvm rm VM acts as devvm rm only on the folder's own VM (finder.folderVM), and a VM whose state names a folder with another VM of its own is refused as one whose folder is there. macOS's FolderID has the folder's birth time too, as Linux's has. Security review (security-audit skill, focused, with an independent read): inode reuse needs a unique identity (birth time; APFS/HFS+ on macOS), the same device (in the ID) and the old folder gone; another user's folder never matches (its owner checked); a copy has a new inode and never matches; links and groups go by name and stay, and links by path take the recorded dir, a move refused when another VM records it; a symlinked cwd is resolved first, and a symlink at the old path counts only when it resolves here; .git protection's record stays for a move and is cleared for a copy; agents' mounts are unchanged (only the project mount changes); a VM can rename only folders inside its own mount, which it already writes. Fixed from the review: a folder swapped at the path while devvm asked was moved to (now move_folder_changed); macOS device:inode could collide with a later volume given the same device number (birth time added); a running VM kept the old path's share, which a new folder made there would reach (the move stops it first); a move to the home folder or into devvm's own folders (now checkUnsafe). FolderID's format change makes VMs and .git records made before it look like other folders (adopt them, or make them again). Tests: TestMovedFrom (table: gone/present, same/different device and inode, a non-unique ID, another user's, a clone, unfinished), TestMovedAway (gone, a folder, symlinks here/elsewhere/dangling), TestMoveHere (refused, no, yes, found by its dir, stopped, the new mount at start, a restart for a running old mount, a new VM at the old path by its next name), TestMoveFolderChanged, TestAdoptMoved, TestMoveHereSeveral, TestAdoptVM, TestUniqueFolderID, ForDir and Nth in project, wantEdits' moved project, the conformance start's moved project; move.txtar (refused, no, yes, found, Lima's mounts edit, a new VM at the old path, adopt VM of a copy); rm_vm.txtar's hand-edited dir; e2e project: mv, refused, a yes in a terminal (script), the home file kept, the new path mounted alone, moved back with adopt --force. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0d9154bd8a |
refactor(vm): one handle for the VM a command acts on, and Env's parts made once
The finder returns a target (target.go): the VM's folder, state, backend
and the instance its backend gave the finder, which each start
(starter.start, target.started, backend.Apply) and stop (target.stop)
then sets as the backend has it, without asking again. It runs what a
command does with that VM: exec, shell, shellDir, running, stop,
ensureRunning, ownSSH, sshHost and widen. Stop, network, ports, size and
ssh-agent read the finder's instance instead of asking again; git-protect
reads it again after its question (refresh), as before.
Env's parts are made once over it (wire, from NewEnv): the finder,
starter, linkRuns, syncer, remaking, clones, vmFolders, devcontainers,
creation, and the command types one reaches from another (launcher,
lifecycle, vmTools, groups, links, leftovers). The 110 conversions
between the package's struct{ *Env } types (finder(e), Launch(e),
starter{e}, creation{Launch(e)}...) are gone: none is left outside wire.
setUp and Groups.warnUnenforced went, their callers using setUpVM with
the target and Links.warnUnenforced; seedClone, gitSSH, fetchUnfetched
and setUpVM take the target. The fake backend applies a Want with
backend.Apply too.
TestTargetAfterStartAndStop: a target's instance after a start and a
stop is the backend's, a start reading it once and a stop not at all.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c1ca05bd94 |
refactor(vm): housekeeping and exports move out of cli
vm.Housekeeping owns what devvm keeps besides its VMs, and cli only renders what it returns: ListImages and ShareListing (the tool targets, worked out once in ToolTargets, for devvm images, gc, space and retention), LockGC, PlanGC (one inventory per run: the states, with --orphans the backends' lists too), GCPlan.Apply (returns GCDone, what it deleted in order, an image the backend refused among it) and Retain. gc runs on the run's one registry throughout, --caches included. vm.Exports owns an export's name (parsed without a regex), the list, the .folder file written and read, deletion and a folder's newest export; it replaces lifecycle.go's name, history.go's parse and retention's handling. One orphan definition: devvm space's leftover state is now what devvm gc --orphans would forget (Leftovers.FindIn, on space's own inventory), so a VM whose state changed in the last hour, one made in another Lima home and one being made again count as state, not leftover, and the row's retention uses the orphan's Changed time. space.txtar pins it against gc --orphans' list. gc's Short names old files and the Nix cache over its cap; the CLI reference is regenerated. using/space.md says what leftover state is. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
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]> |
||
|
|
1b9755a7df |
refactor(vm): one finder for the VM every command acts on
finder.target(ctx, need) finds the VM a command acts on: the folder's own, the nearest parent folder's (resolveFolder), or one named for devvm rm VM. Its need says what the command needs (has: any, the VM, its machine, made; own; folder; noVM), and need.check is the one place that refuses a missing VM, one made for an earlier folder at its path (found.other, from sameFolder), a pending remake and an unfinished one. It replaces Env's find, own, findExisting, existing (10 callers), folderVM (7 callers) and the linkVM, groupVM, portsVM and agentVM wrappers, Net's policyVM, up's and toRemake's checkFolder, and rm VM's inspect by name. devvm rm VM refuses a state whose folder doesn't hash to the VM's name (rm_vm_state_mismatch), so a changed vm.json never sends it to this folder's VM. The environment reads the folder devvm runs in lazily (finder.dir), so devvm build, rebuild, images, space and gc run from a deleted folder; NewEnv no longer fails. Guard: the structure test's callers rule, state.ReadHash and project.Parents called only in internal/vm/finder.go outside their package and tests. Tests: TestFinder (need x none, own, parent, nested repo, other folder, unfinished, remake pending with and without its machine), TestRmVMFolderOfAnother, callerCases, no_folder.txtar and rm_vm.txtar's mismatch case (its fixtures' hashes now match their dirs). Co-Authored-By: Claude Opus 5.5 <[email protected]> |