6 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 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]>
2026-11-16 08:22:47 -07:00
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]>
2026-11-12 11:54:42 -07:00
CJandClaude Opus 5.5 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]>
2026-11-12 07:20:42 -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 9c34ad5c69 fix: host git reaches ssh alone, a queued git-protect mode is set after the check, and retention's lock is an OS file lock
A review of the recent fixes found three gaps, and an e2e cascade.

- hostgit: protocol.allow=never is only the default for protocols with no
  key of their own, so a repo's protocol.ext.allow=always and a url
  insteadOf for the VM's URL made a --clone VM's seed push and rm's fetch
  run a command the repo named on the host. Host git now runs with
  GIT_ALLOW_PROTOCOL=ssh, which git takes over every protocol setting.
  TestCommandSSHOnly (failed on the old code).
- git-protect: checkGit set a mode saved while the VM ran before it
  checked .git, so a .git the VM replaced meanwhile became the baseline
  without git_replaced. It checks under the mode the VM ran with first,
  then sets the new one. git_protect.txtar's replaced-.git step (failed
  on the old code).
- retention: its lock was a folder taken over after 10 minutes, so a
  long retention run could be joined by a second devvm and a crash left
  it held. It's platform.TryLockFile on retention.lock now, and
  retainLockAge is gone. TestRetainDueAndLock checks an hour-old held
  lock isn't taken over.
- e2e: when the group join's helper server didn't start, gp_refused ran
  devvm network on for a VM outside the group, which turned its policy
  on, so six later group and link checks failed too. gp_refused now
  checks the VM is a member first, and lk_start says which server didn't
  start.

Docs: internals/git-protection (GIT_ALLOW_PROTOCOL, the check's order),
using/space (retention.lock).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 07:31:24 -07:00
w3cjandClaude Opus 5.5 9c2511117b fix(hostgit): host git runs no program a repo names, nothing of devvm's environment, and ssh only to the VM
devvm ran git on the host bare: --clone's git status could run a repo's
core.fsmonitor or filters, its push, fetch, update-ref and remote remove
the repo's hooks, and git could ask on devvm's terminal or follow
GIT_DIR from devvm's environment. internal/hostgit is now the one runner
(Command, Output, Status), with its settings as GIT_CONFIG_COUNT pairs:
core.fsmonitor=false, core.hooksPath=/dev/null,
core.alternateRefsCommand=true, hook.EVENT.enabled=false for every
githooks(5) event, protocol.allow=never with protocol.ssh.allow=always;
and, for a command with -C DIR, hook.NAME.enabled=false and
filter.NAME's clean/smudge/process emptied with required=false for
each hook and filter driver DIR's config names. It drops every GIT_*
variable and relative PATH folders, and sets GIT_TERMINAL_PROMPT=0,
GIT_NO_LAZY_FETCH=1 (a repo that says it's a partial clone fetches
nothing, with its core.sshCommand or ssh), GIT_SSH_COMMAND=false (no ssh
but gitSSH's) and GIT_SSH_VARIANT=ssh; maintenance.auto=false and
gc.auto=0. Status adds --no-optional-locks and --ignore-submodules=all.

Callers: gitprotect (git, ignoreSubmodules), project.SSHRemote, vm/sync's
gitConfig, vm/clone (hostGit, gitSSH, saveFetched, the uncommitted-changes
status). gitSSH takes the VM: ssh with BatchMode, StrictHostKeyChecking,
devvm's known hosts only, HostKeyAlias=VM, ForwardAgent=no and
ClearAllForwardings=yes, so a url.*.insteadOf reaches only the VM with
its pinned key. The seed push adds --no-verify, --no-recurse-submodules
and --no-signed; rm's fetch --no-recurse-submodules.

Not neutralized: an include.path can make gitConfig read
user.name/email from another git-config file (sent to the VM as its
identity), and a FIFO as a config file hangs git until Ctrl+C; neither
runs code. A VM swapping the repo's config between repoOff's listing and the command
could hide a filter from it, and a --clone VM's root (its host key)
working with another VM that writes the repo could send the push to a
server of theirs; both documented in internals/git-protection.

Tests, each with plain git first running what the hardened one doesn't:
hostgit's TestCommandNoFsmonitor, TestCommandNoHooks (reference-
transaction, pre-push, from .git/hooks and a core.hooksPath; path,
file:// and ext:: pushes refused), TestCommandNoConfigHooks (hook.NAME.*),
TestCommandIgnoresGitEnv (GIT_DIR, GIT_WORK_TREE; environ),
TestCommandNoLazyFetch (a partial clone's core.sshCommand),
TestStatusNoFilters (clean, process, required, names with dots, = and
capitals), TestStatusNoSubmodules; vm's TestHostGitNoFsmonitor and
TestCloneRunsNoHooks (seed push and rm's fetch, update-ref and remote
remove); clone.txtar's push ssh options.

Docs: safety/attack-vectors (devvm's own git commands),
internals/git-protection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 19:13:43 -07:00