8 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 a8f0517579 feat(lima): devvm downloads Ubuntu's cloud image itself
Lima's download of the cloud image neither retries nor times out: one cut
in its 900 MB fails base's build, and a stall hangs it. devvm now
downloads the pinned image itself through fetch.Resumable
(ubuntu.Download), into images/ubuntu/<sha256>.img (Dirs.UbuntuImage),
resuming across cuts, stalls and runs, and gives Lima that file. Lima
2.3 checks a local file against the digest before it copies it.

- Before downloading, it takes the image from Lima's own download cache
  when that holds it with the pin's SHA-256: copied into a new file of
  devvm's own, mode 600, hashed as it's written, capped, stopped by the
  context, and kept only once it checks out. Lima's cache is never
  changed, and a base whose dated release Ubuntu may have removed still
  builds again.
- One devvm downloads at a time (images/locks/ubuntu-image), another
  waiting under ubuntu_image_waiting and looking again under the lock
  (TestUbuntuImageAfterWait, which fails without that second look).
- The download goes through the company proxy and trusts the user's CAs
  (Lima.Roots, from trust.Pool, which internal/cli passes through the
  registry), as do the Finder's lookups (TestNewTrustsRoots, and the
  registry's TestOverrides). An untrusted certificate is
  ubuntu_untrusted, naming the CAs' folder, one from a trusted CA
  that's for another host, out of date or not valid yet
  ubuntu_bad_certificate (check the clock and what answers for the
  host), and any other that fails to verify (a SHA-1 signature, a CA's
  name constraints, a key for clients alone) ubuntu_certificate_invalid,
  naming Go's reason, for the lookups (the listing, the checksums, their
  signature: TestLookupCertificates) and the download alike
  (TestLocalImageFailsFor), and a release Ubuntu removed (404, 410)
  ubuntu_release_gone, which names devvm rebuild base; none is retried.
  ubuntu_download_failed no longer starts with devvm.
- fetch.Untrusted, fetch.BadCertificate (an x509.HostnameError, or a
  CertificateInvalidError that's Expired) and fetch.Unverified (any
  failure to verify, with its reason, so every error the other two
  name), beside fetch.Gone, are the one
  place that tells a certificate's failures apart: Transient asks
  Unverified, the lookups and the download ask all three, host mise
  asks Untrusted, and a forbidigo rule keeps x509's and tls's
  verification errors in internal/fetch (TestCertificateClasses,
  TestTransient, testdata/lint, the owners doc's row).
- An https address, or a test build's file:// DEVVM_UBUNTU_URL, read
  from disk the same way; anything else is refused. The CLI tests'
  sandbox has a stand-in of this host's image in the store.
- Base's record keeps the image's address, and the key is as it was: it
  hashes the pin (release, file, digest), not the location.
- devvm gc --caches frees devvm's copies that no record names and that
  aren't pinned now, unchanged for an hour, a stopped .part and a killed
  import's .import included, and those of a kept image once its .img is
  there. A pin it can't read fails it.
- Of Lima's cache, it frees only an entry that devvm's own state shows a
  build of devvm's left: a base record names its address, devvm has its
  own copy of the image, and the installed Lima's own templates
  (share/lima/templates beside limactl, Lima.Templates) don't name it.
  An entry no record names may be the user's own Lima's, so it stays,
  and none is freed when the templates can't be read, with a line in
  the run log naming the folder and why. A test build's
  DEVVM_LIMA_TEMPLATES stands in for the templates folder.
- ubuntu.ParseImage reads a record's image as Image.String writes it,
  and ubuntu.IsSHA256 is the one check of a cloud image's SHA-256, in
  place of Lima's own regex.
- devvm space shows the copies as a cloud images row, freed by gc
  --caches, kept as state, as a release Ubuntu removed can't be
  downloaded again.

0.1.0's frozen state runs the new commands (fixture_v010_cloud_image):
devvm looks in Lima's cache under the SHA-256 of the address 0.1.0's
base record keeps and never changes the entry, base builds from devvm's
own copy, and gc --caches keeps that copy, frees Lima's entry the
record names and devvm's own stale copies, and keeps an older entry no
record names.

Docs: images.md (the download, its failures, the import, gc's rules),
space.md, backends/lima.md, settings.md (the lookups and the download
trust your CAs), troubleshooting.md, overview.md, testing.md,
tests.md, structure.md's internal/fetch row; the CHANGELOG's two Fixed
lines, which later commits make highlights, What to do 5 and 6, and the
release page's Ubuntu's cloud image in devvm's folder.

New messages: downloading_ubuntu, importing_ubuntu, ubuntu_image_waiting,
ubuntu_download_failed, ubuntu_release_gone, ubuntu_bad_certificate,
ubuntu_certificate_invalid, ubuntu_image_checksum, ubuntu_untrusted.
Lima.LocalImage is the seam, Lima.ImageClient the client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 22:53:34 -07:00
w3cjandClaude Opus 5.5 326660d748 feat(fetch): resumable downloads that survive cuts and stalls
fetch.Resumable downloads a large file into <path>.part and keeps it
across failures and runs: each retry asks only for the rest (Range, with
If-Range once the server named a strong ETag or Last-Modified, and
Accept-Encoding: identity, so no gzip changes what a range counts), a
try that reads nothing for Stall ends and is tried again, and Tries
tries in a row that bring nothing fail it, as do 100 tries in all, with
the wait doubling up to a minute. The file is kept at its path only once
its SHA-256 checks out; a part that doesn't is fetched again from
nothing, once. A server that ignores the range (200), has nothing past
it (416) or answers it from another byte starts the part again.

- A part that's already the whole file, as a run killed before its
  rename or a try that failed after its last byte leaves it, is kept
  without another request, where a range past its end would get a 416
  and start it again.
- A failure that trying again in this run won't mend (a 403, a proxy
  that refuses) keeps the part for the next run; only 404 and 410
  (fetch.Gone) and a file over Limit take it with them.
- A part that can't be written, or a whole file that can't be renamed
  into place, is ErrWrite, never tried again, and the part's hash and
  length count only what the file took, so a short write can't put them
  out of step.
- Content-Range is read strictly (parseContentRange, fuzzed), and a
  length over Limit fails as ErrTooLarge.
- The structure test's status-lines rule counts a
  fetch.Resumable{…}.Download as a request; structure.md says so, and
  its internal/fetch row names Resumable.

Tested in a synctest bubble on memnet against a server that cuts,
stalls, hangs, answers 403, 404 or 410, ignores the range or answers it
from byte 0, cuts after the last byte, behind a proxy that refuses, with
a part that can't be written, a whole part left by a killed run and a
file that can't be renamed into place (TestResumableWholePart,
TestResumableRenameFails).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-29 19:09:22 -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 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]>
2026-11-05 22:47:23 -07:00
w3cjandClaude Opus 5.5 760e602d18 fix(agents): host-side login refreshes trust the user's CAs
An agent's OAuth refresh (Claude Code, Codex, opencode) runs in the VM's
proxy on the host and goes through the company proxy, but trusted only the
system's roots, so a company proxy that inspects TLS made it fail. Each
secret lookup's context now carries the proxy's own roots, the system's
and upstream_cas (proxy.WithRoots, RootsOf), which the refresh's client
trusts through the new fetch.Client.Trust.

Tests: fetch TestTrust, agentlogin TestRefreshTrustsTheProxysRoots and
proxy TestLookupRoots, each against a TLS server signed by a test CA; the
e2e network section's Claude refresh check now expects success.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 21:17:04 -07:00
w3cjandClaude Opus 5.5 ed70aeae3b feat(netpolicy): config.toml's company proxy reaches devvm's own downloads and builds' checks, and VMs without policy warn
config.toml's [proxy] covers the places it missed:

- devvm's own requests on this machine (the download of its mise, Ubuntu's
  cloud image listing, --from's registries) go through it when the
  environment sets no proxy. settings.CompanyProxy.Route is their
  transport's proxy: at the first request it looks up the proxy secret,
  puts it in each URL that names a user, and routes each request as a VM's
  proxy does (proxy.Upstream.WithPassword, proxy.Upstream.Route, reusing
  the proxy's NO_PROXY matching). A missing password fails the request
  with fetch.ErrProxy, which isn't retried; HostMise shows its message.
- The mise devvm runs on this machine gets HTTPS_PROXY, HTTP_PROXY and
  NO_PROXY in its environment (settings.CompanyProxy.Env), with the
  password in the URL, as mise takes it nowhere else; never in its
  arguments or a file. With the environment's proxy it adds nothing.
- devvm build, rebuild, the remakes' builds and tool builds check the
  company proxy and its saved password before anything starts
  (build.Builds' checkProxy, tools.Share.Build), through the one check a
  new VM and a VM's proxy use: settings.CompanyProxy.Upstream, which
  netpolicy.Proxy.Upstream now calls. secrets.Store.ProxyPassword owns
  the proxy_password_missing mapping.
- A VM without network policy never gets config.toml's proxy, as the
  guest would need the password, which never leaves this machine; each
  start of one while config.toml is the only proxy warns
  (proxy_needs_policy), naming devvm network on or the shell's
  HTTPS_PROXY, with a doc link.

Wiring: tools.Env.Proxy (its Password set by cli and vm from devvm's
secrets), from.NewLookup/NewRegistry/NewPublicRegistry take the proxy,
lima.New and registry.New take a *settings.CompanyProxy for Ubuntu's
listing. internal/fetch stays standard library only.

- Tests: TestUpstreamWithPassword, TestUpstreamRoute,
  TestUpstreamRouteAuthorizes, TestCompanyProxy,
  TestCompanyProxyPasswordMissing, TestProxyPassword,
  TestHostMiseThroughCompanyProxy, TestMiseCmdCompanyProxy,
  TestBuildChecksCompanyProxy (tools and build), TestRegistryThroughProxy,
  TestUbuntuThroughCompanyProxy, TestTransient's ErrProxy, and
  company_proxy.txtar's build, rebuild and no-policy cases.
- Docs: network policy's Behind a company proxy and Without network
  policy, config.toml's [proxy], How it works' Through a company proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 01:42:37 -07:00
w3cjandClaude Opus 5.5 da93384f60 fix(lint): fetch.Client is its own type, and forbidigo bans http.Transport, os.Create and O_TRUNC
fetch.Client was an alias of http.Client, so &fetch.Client{} got past
NewClient's timeout and HTTPSOnly. It is now a struct only NewClient fills:
Do sends with the client's policy, Transport returns its own transport for
callers to change (ubuntu's file://, the public registry's dialer), and any
other Client fails every request with ErrNoClient, which isn't transient.
forbidigo's HTTP rule also bans http.Transport, and http.Client's Transport
field, outside fetch, the proxy and tests.

The os.WriteFile rule also bans os.Create and os.O_TRUNC, so a
truncate-in-place write outside state needs a nolint saying why. The four
left are not files written whole from memory, or are the standard library
only: tools' check log and a link session's log (a process writes them as
it runs), fetch.Download's file (streamed, removed on failure) and
daemon's pid and status files (one write, which readLine and readStatus
take as missing until its line ends). state's doc says so.

Tests: TestClientMadeByNewClient (nil and zero Clients send nothing and
aren't retried; NewClient's transport is its own); from's and build's
tests use the registry's own client trusting the TLS test server.
Fixture lines: http.Transport, os.Create, os.O_TRUNC.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 06:43:13 -07:00
w3cjandClaude Opus 5.5 b4402a74e8 refactor: every HTTP client through internal/fetch
internal/fetch (standard library only) owns how devvm reaches the web:
NewClient(timeout, HTTPSOnly|SameScheme) on a clone of net/http's
default transport, the Client alias other packages name, Retry and
Transient/TransientStatus (no answer, 408, 429, 5xx; never a refused
redirect, a bad request, a body over its cap or a SHA-256 mismatch),
ReadCapped, Open, Get, and Download, which keeps a file only when its
SHA-256 matches and leaves nothing on any failure.

- from: NewRegistry uses fetch.NewClient(HTTPSOnly); its own NewClient,
  httpsOnly, errRedirect and transient go; the token GET is fetch.Get;
  retry wraps fetch.Retry, keeping ErrNotFound and ErrUnreachable.
- ubuntu: NewClient is fetch.NewClient(SameScheme) with file://
  registered; sameScheme and errRedirect go; fetch is fetch.Retry over
  fetch.Get.
- tools: mise's client is fetch.NewClient(HTTPSOnly); its download is
  fetch.Download, which checks the pin before the file is kept.
- docker: devvm's Linux build is fetched with a client of its own
  (HTTPS-only redirects, a Client seam on linuxFinder) instead of
  http.DefaultClient, and retried twice on a failure that may pass or
  an archive cut short; an archive without a devvm (errArchive) isn't.

forbidigo bans http.Client, DefaultClient, DefaultTransport, Get, Head,
Post and PostForm outside internal/fetch, internal/proxy and tests; its
line in testdata/lint/forbidigo.go fires. internal/fetch is a leaf in
the structure test's layers.

Tests: fetch's TestRetry, TestRetryUnanswered, TestRetryCanceled,
TestTransient, TestRedirects, TestReadCapped, TestDownload; first,
characterising the callers, from's TestDigestRetries and tools'
TestHostMiseRedirect; docker's TestFetchLinuxRetries. Coverage
baselines: fetch 95.2 (new), from 87.1 to 91.3, ubuntu 88.7 to 92.5,
tools 87.9 to 88.6, docker 80.8 to 81.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 18:28:01 -07:00