9 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 cb7177b32c feat(ui): waits for another devvm's lock show a status line; a project folder devvm can't read says so
Lock waits:
- platform.LockFile and LockFileShared take a platform.Waiting, called
  once they find the lock held, never when it's free, whose end they call
  once the wait ends; LockFileWaiting, LockFileSharedWaiting and their
  delays (ShareNote, OCINote, WaitNote, groupsNote, makingNote) go.
- msg.Waiting makes one from a Reporter's Status and a label;
  msg.WithStatus and msg.StatusOf carry the run's Status in its context
  for the two packages that take no Reporter, internal/state and
  internal/trust, which cli's execute sets; forbidigo keeps StatusOf to
  them, and AGENTS.md says so.
- Every lock that waits shows its own label: vm_state_waiting (a VM's
  state, its deletion), claims_waiting, layout_waiting, git_lock_waiting,
  ca_waiting, packages_waiting, rebuilds_waiting, ubuntu_pin_waiting,
  custom_secrets_waiting, forwarder_waiting, agent_store_waiting, and the
  waits that printed a line after a delay, which now show theirs as a
  status line: share_waiting, oci_waiting, image_build_waiting,
  group_waiting, making_waiting.
- An agent's login file's lock (agentlogin's lockLogin, a folder's flock
  that a VM's proxy holds while it refreshes the login) tries first
  without waiting and shows agentlogin.File's Waiting
  (agent_login_waiting) while it waits; secrets fills it from its
  Reporter, for SaveLogins, Claude Code's logins folder and every File.
- The structure test's status-lines rule counts a LockFile or
  LockFileShared whose waiting is nil as slow work; the build port's
  record, a file just made that never waits, is listed in statusSites.
- Without a terminal, or with -v, a status line draws nothing, so the
  waits that printed an info line after a delay no longer print it there;
  the CHANGELOG and the troubleshooting page say so. from.txtar's check
  that a free conversion lock printed no wait goes, as TestLockOCI checks
  it.

The layout's migration runs under a status line (layout_migrating),
only when there are migrations to run.

Backend calls outside a launch: TestCommandStatusLines runs devvm ls,
ports, size, network, tools, git-protect, history export, stop and rm on
a running and a stopped VM and fails on a backend call with no status
line showing, with a control that each makes one.

A project folder devvm can't open and read (vm_folder_unreadable) was
taken for another folder's VM (vm_other_folder, which offers rm and
adopt, and adopt went on); the finder now keeps why (target.unread), and
every command on the folder's VM, from the folder or a subfolder of it,
names the folder and why; devvm rm VM run elsewhere goes by the VM's
name as before.

platform.UniqueFolderID had no caller but its test: FolderStat.Unique,
from the open folder, replaced it; it goes, and its test checks
StatFolder's Unique instead.

Tests: TestLockFileWaiting (rewritten: called only when held, its end
once got or given up, shared too), TestVMLockWaits, TestCheckLayoutWaits,
TestCheckLayout (migrations under layout_migrating, nothing shown
otherwise), TestLockGroups, TestLockShare, TestMaking, TestLockOCI and
the build lock's test (status lines, not info lines), TestLockLogin,
TestInitCACancelled (ca_waiting), the status-lines rule's lock cases,
TestCommandStatusLines, TestUnreadableFolder (a subfolder of it too),
TestStatFolderUnique.

Docs: Contributing's CLI page (Status lines) and structure page, the cli
and codebase-standards skills (the guards), AGENTS.md's Go conventions,
internals/images.md and design.md (the waits), using/troubleshooting.md,
using/vms.md (a folder devvm can't read); CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 15:10:22 -07:00
w3cjandClaude Opus 5.5 4ccdbf8125 fix(vm): folder identity's last checks: a renumbered folder keeps its volume
From the volume UUID commit's security review. A folder at its own
recorded path on a disk numbered anew (platform.SameFolder's renumbered
case) must now also be on the volume its state records, when both are
known (platform.KeepsVolume): the finder checks it (finder.sameFolder,
Env.keepsVolume, so a launch refuses with vm_other_folder) and so does
recordFolder under the state's lock, so a copy of the disk with a volume
ID of its own mounted at the folder's path is another folder. A volume
that can't be told leaves the device's rule, as for a state that
records none. mountedBy and mountsRepo keep the check without volumes
(madeFor), which errs towards warning.

hereOf reads the folder's identity, uniqueness, owner and volume from
one open folder (platform.StatFolder, now with Owner), so the folder
checked as the user's is the one matched and recorded. StatFolder is
one function for macOS and Linux (folderstat_unix.go) over each
system's openFolder, which SameFolder's renumbered case uses too, in
place of openFolderID and darwin's copy.

devvm ls and devvm space look volumes up through the run's Env
(Env.FolderOf, Inventory.List(ctx, e)), each mount once a run, in
place of diskutil for each VM; FolderOf, parentVolume and movedAway go.
FolderDevice is unexported (folderDevice), so only platform reads a
device; OnRecordedDisk takes a record without a device as on any disk.

The folder-ids rule tracks names assigned from such names, however
many steps on, and maps keyed by an identity, indexed or in a map's
literal, without counting a struct literal's field; its loop is
sitesWhereIn, shared with sitesWhere. The hdiutil e2e check makes sure
macOS gave the disk a new number, attaching up to three images first,
and is skipped when it never does. The design notes say who can forge
a volume ID and what it gets them.

Tests: TestKeepsVolume, OnRecordedDisk without a device,
TestRenumberedOnAnotherVolume (a launch and recordFolder),
TestListLooksUpVolumesOnce, StatFolder's Owner on both systems, the
folder-ids rule's new cases, and fixture_v010_renumbered.txtar (another
volume at its own path refused with nothing recorded; ls calls the
moved folder gone by its recorded volume, where it said not_connected).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-19 07:15:53 -07:00
w3cjandClaude Opus 5.5 2c0a894a1c fix(vm): a project folder's VM works after a boot renumbers its disk
macOS numbers its disks' devices in the order they appear at boot, so
after a restart an unchanged project folder's identity (dev:ino:btime)
can have another device. The finder then refused its VM as made for an
earlier folder (vm_other_folder), a stopped VM's start refused it as
replaced (project_folder_changed), and the next .git check called it
replaced (git_replaced).

platform.SameFolder is now the one comparison of two folder identities:
the same ID, or at the same path the same inode and birth time on
another device. On another device the ID must also be the one read from
the folder opened at the path with no link followed (OpenNoLinks, then
fstat and fstatfs on it: openFolderID), on a file system whose IDs are
their folder's alone, so a link swapped in while the caller read the ID
can't pass a copy's (a snapshot's, a cloned disk's) off as the folder's.
A folder at another path (moved) matches only exactly.
platform.Renumbered says when the record needs the folder's ID as it is
now.

The finder's sameFolder, here.movedFrom, gitprotect's protectRepo and
the strict conversion's checks use it. A start records the project
folder's identity as it is now under the VM's state lock (renumbered, in
bringUp) before the backend mounts it by Want.ProjectID, so vz's
/.vol/<dev>/<ino> mount names the current boot's device, in the one
limactl edit; folderChanged's checks after it then compare exactly. A
.git check that accepts a renumbered .git records its current identity.
The move's check stays exact, as both its IDs are read in one run.

The structure test's folder-ids rule fails on == or != on a field named
Folder or GitID, or a call of FolderID or folderID, outside
internal/platform and tests, unless exactFolderIDs lists the function
with why: the agents' and exports' Folder paths, recordMove's
unchanged-state check and folderChanged.

Tests: TestSameFolder (platform), TestRenumberedFolder (vm),
TestReportsRenumbered (gitprotect), a renumbered vz case in
TestProjectMountByInode (lima), existing.txtar's renumbered folder, and
fixture_v010_renumbered.txtar on the frozen v0.1.0 state, through the
new renumber script command and stubtest.Renumbered.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-18 10:12:14 -07:00
w3cjandClaude Opus 5.5 b2b12ee55d feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only
the folder's own: one walk (hostsafety.Walk, at most 4 folders down and
100 repos, no symlinks, one device) finds them, and each is locked on
macOS, pinned on Linux or watched where Linux can't pin, scanned within
its own top folder and the mount. A repo counts as covered only when a
scan locks its git dir; git dirs follow git's own rule, .git is matched
without case on macOS, and a recorded repo stays protected while
anything is at its .git. Repos the walk can't protect, that appear,
that leave or that look like bare repos are named, with the config keys
and hooks a VM-made repo would run. Existing VMs get a one-time notice
and opt in with devvm git-protect on. Ownership fails closed under one
host lock, so a VM never unlocks what another protects; one scan budget
covers every repo, and launches into a running VM check only the top
repo. devvm doctor gives a tip to set safe.bareRepository=explicit,
reading the user's GIT_CONFIG_GLOBAL when set.

Refs #3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 16:34:40 -07:00
w3cjandClaude Opus 5.5 2dfb0d2d50 fix(platform): Linux UniqueFolderID allows only file systems with stable inodes
UniqueFolderID on Linux reads the folder's statfs type and allows ext4,
XFS, Btrfs, tmpfs, OpenZFS, F2FS and bcachefs (uniqueFS), as macOS's
allows APFS and HFS+: FUSE, network shares, 9p, overlayfs and FAT may
make inode numbers up, so a moved folder on one is never offered its VM.
TestUniqueFS covers each type.

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 09:30:05 -07:00
w3cjandClaude Opus 5.5 d49163a85c refactor(gitprotect): gate locks on the host's immutable flag, not its OS name
platform.HasImmutableFlag says whether the host has a user-immutable flag
(true on macOS alone), and the Protector's CanLock field, set from it by
New, replaces its OS field: NewMode, NewVM, Set, Check, Unlock and
devvm git-protect's running-VM check (vm's settings) read it instead of
comparing an OS name with "darwin". Tests set CanLock; TestNewCanLock
checks New takes it from platform, and TestRealLocks skips on the same
constant.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:40:56 -07:00
w3cjandClaude Opus 5.5 f2aa210bf7 feat(up): existing VMs, restart, remove, update, adopt and rm
devvm opens a VM that exists instead of refusing it: unfinished VMs
(no state or no network choice) are refused before anything; --backend,
--network-policy, --no-git-protect, --cpus/--memory/--disk and --ports
are ignored with a warning each; an IMAGE naming what the VM lacks adds
it in place after asking (tools built and listed, a layer's script run
in the VM, new agents' folders mounted with a stop first); outdated
images and newer tools are warned about, the daily tools check runs,
agent folder mounts follow the host's, .git is checked per run, set-id
files are named on Linux, a stopped VM gets the size and ports its state
asks for (a running one is told they apply at its next start); then it
is started if stopped (a running VM with network policy keeps its
proxy), the self-check runs (a failure stops the VM), and it is set up
and its shell opened.

Commands: restart (stop, then open), update (newest shared tools, built
from base, then open), remove TOOLS (out of the image and tool list,
then open), adopt (a VM made for an earlier folder at this path, after
asking; .git protection restarts as appeared), rm [-f] (exports the
agents' history first unless -f, a failed export keeps the VM; a VM of
an earlier folder only after asking, without export; deletes the VM,
state, proxy, rules, run files, logs, .git locks, host keys and ssh
config entry, also when the delete failed but left no VM).

Inventory:
- vm: find/findExisting/existing, sameFolder, open, run, setUp,
  warnIgnored, checkSetID, applySize, applyPorts, addLayers,
  wantedImage, runScript, buildTools; Restart, Remove, Update, Adopt,
  Rm, export, delete; start refuses vm_unfinished and stops a leftover
  proxy for VMs without network policy
- gitprotect: Protector.Check (replaced, appeared, new submodules in
  the tree and .git/modules, unlocked hooks, commondir, delegations on
  change; locks only while stopped; unset protection set up as new),
  Locked field; platform.Immutable
- tools.Update takes a build func; build.Builder.LayerScript exported
- cli: restart, remove, update, adopt, rm; withEnv; root Long
- messages: vm_other_folder (reworded), vm_other_folder_rm/_adopt,
  delete_other_folder_vm, adopt_vm, vm_adopted, vm_already_here, no_vm,
  vm_unfinished, backend/net/git_protect/ports_flag_ignored,
  size_flags_ignored, size_next_start, ports_next_start, add_in_place,
  restart_for_mounts, no_terminal_confirm, keeping, adding,
  add_layer_failed, vm_is_now, exported, export_failed, deleted,
  rm_failed, adopt_failed, git_replaced, git_appeared,
  git_embedded_new, git_hooks_unlocked; net_unenforced_stop says devvm
  starts it again confined; vm_exists removed
- tests: testscript existing.txtar, existing_agents.txtar; Go tests for
  Check (five per-run reports, replaced/appeared, off/unset), open with
  network policy, addLayers, Rm, Adopt, remove/update/restart; limactl
  stub: delete-fails, Exec-fed scripts
- converted bats: delete (vm_unfinished, rm cleans up after a failed
  delete, rm deletes only this VM), project (folder made again, update
  twice, remove twice, five .git per-run reports), ports (applied once,
  restart warning), size (restart warning), cli (rm forgets host keys)
- e2e: project (stop and relaunch, running relaunch, restart with host
  keys, swapped .git, new submodule locked, rm unlocks; agent folder
  added/removed on restart, rm exports history without logins), tools
  (update, remove), network (relaunch confined, unenforced relaunch
  stops it, rm -f)
- docs: commands.md (existing VM, adding, deleting, a folder made
  again), coding-agents.md (mounts on launch, history), git-protection
  (on each launch), images, network, security; CLI reference

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 12:07:16 -06:00
w3cjandClaude Opus 5.5 53c37e4dee feat(up): create a project VM and open a shell
devvm [IMAGE] in a folder creates its VM: the folder checked (its path,
unsafe folders, a folder made again), its size and ports, the image
named or detected and built, cloned with only the folder mounted, its
state, .git hooks and config locked (macOS), started, then the backend's
shell in place of devvm. Network policy isn't there yet, so a VM is
created only with --no-network-policy; an existing VM is refused for
now. Ctrl+C before the first shell deletes the VM and unlocks .git.

Global flags: --backend, --network-policy/--no-network-policy, --cpus,
--memory, --disk, --ports; up's own --unsafe-folder, --no-git-protect.
tests/e2e.sh gains a project section, with Lima's Exec quoting checked
on a real VM. New docs: commands, security model, .git protection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 09:14:27 -06:00