Linux build VMs' ssh ports were Lima's own pick, outside the claims
lock, so another VM's forwarder could take one before Lima bound it.
Lima's start now gets every build VM's port from ports.Allocator.Build
on macOS and Linux alike, and sets it with its one edit.
- start.go: the l.OS == "darwin" condition goes.
- build.go, tools.go: cloneEdits goes; a build VM's start always edits
its new ssh port, so the configure step is always counted.
- ports.Allocator.Build holds a file lock on run/build-ports/<name>
(platform.LockFile) until release, so the kernel lets go of it when
devvm ends, killed or not. free, under the claims lock, first deletes
(clearStale) the records no process holds that are over 15 minutes
old (staleAfter: longer than Lima's 10 minutes of waiting for ssh,
which a killed devvm's limactl start may still spend binding it).
Tests: TestBuild (a stale record kept while young, then cleared; a held
one kept however old), TestStartBuildSSHPort on darwin and linux,
TestStartConfined's Linux builds, TestBuildImageLayer, TestBuildTools;
TestCloneEdits goes. build.txtar checks the build's port edit and that
its record is gone; tools.txtar's steps are one count on both systems;
layout.txtar lists run/build-ports on Linux. The limactl stub needed no
change: it applies .ssh.localPort on every host, and the contract's
scenario already starts builds with a port.
Docs: internals/design (reserved ports; the build VM's ssh port lead is
now confirmed, fixed), internals/overview, using/space.
Co-Authored-By: Claude Opus 5.5 <[email protected]>