mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
main
8
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ecd266c7d3 |
test(cli): one wait for the scripts; the docs release job installs only what it builds with
The scripts waited with copies of the same loop: desktop.txtar's and nix_cache.txtar's waitfor files, and sh -c loops in link_life, fixture_v010_links, fixture_v010_small, ports and ports_stopped, each with its own interval and limit. They now use one testscript command, wait_until SCRIPT, which runs sh -c SCRIPT every 100 ms until it succeeds, for up to 90 s, and fails at once when every background command has ended, as wait_file does, or when SCRIPT exits 100 (waitGiveUp, a status no tool the scripts run gives), as the links check does when its session has ended. Contributing's tests page names it beside wait_file, whose limit it now says is 60 s. The docs workflow's release job installed every tool in the tag's mise.toml. It now installs only Go, Hugo by the name the tag gives it (hugo-extended before Hugo 0.170) and Node when the tag draws its diagrams, with --locked as mise-action did, picking them with mise's own reading of the tag's mise.toml (mise ls --current --json, the tag's file alone), and fails when the tag names no Hugo. MISE_AUTO_INSTALL is off for the job, so mise run docs:diagrams and the shims install nothing more, and a tool the pick missed fails the build. This job runs only at a release, so it hasn't run yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8e914b17c9 |
refactor(proxy): one typed, versioned config for every proxy, read as a private file
devvm _proxy runs with one argument, -config FILE: proxy.Config as JSON (version 1), which a VM's proxy (vms/<hash>/run/proxy.json, written by netpolicy.Proxy) and a build's (build-proxy/proxy.json, written by backend.ProxyStarter) both use. It holds what the flags and the run folder's sidecars held: the address, the VM, the password (proxy.auth), the built-in policies and the user's files (proxy.policy), the logs, the lifeline, the CA, the secrets, the user's CAs (proxy.cas), the company proxy (proxy.upstream, now proxy.Upstream), upstream_unresolved, the Nix cache and its cap, the links, and the SHA-256 of devvm's binary and CA (proxy.bin, proxy.ca), which the proxy doesn't read. devvm writes it whole, mode 600, before each start, and starts a running VM's proxy again when the config it would start it with has another Sum. ReadConfig reads it as the links' list is read (readPrivate): O_NOFOLLOW and O_NONBLOCK, fstat, a regular file owned by the proxy's user that nobody else may read or write, at most 1 MiB, of ConfigVersion, no unknown field, a password, a loopback listen address. The VM's proxy is found by _proxy -config with its own config's path. paths.VM names ProxyConfig, ProxyPID and ProxyStatus. Policy files are read only as regular files of at most 1 MiB (proxy.ReadRegular, PolicyMax), in the proxy, devvm network and doctor, so a FIFO or a link to /dev/zero can't hang them (ErrNotRegular, ErrTooLong; ErrNotPrivate for the config and the links' list); the proxy keeps a file's last rules and logs why once. hostOK refuses a name with an empty label (evil.test.., evil..test, .evil.test), so no form of a name gets past a deny the policy's own trim would miss. A build proxy that can't be spawned leaves no config behind. Tests: config round trip and Sum; ReadConfig refusing a link, a FIFO, a folder, group-readable and group-writable files, a long file, other versions, unknown fields, two configs, no password, non-loopback addresses, a CA without its key, a negative cap; ReadRegular and the policy readers on a FIFO, /dev/zero and a big file without hanging; the running proxy keeping its last rules; hostOK and requests with empty labels (failing on the code before); Prepare's config, restarts on a binary change, a missing config and one others may read; concurrent config writes; the build proxy's config and its removal; proxy.txtar, network.txtar, nix_cache.txtar and layout.txtar; e2e checks of the config's mode, password and the proxy's arguments. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
79b3ef94d4 |
refactor(cli): one backend: no --backend flag, no BACKEND column
devvm runs every VM on Lima, so the command line has no backend choice: - --backend is gone from devvm, build, rebuild, images, images rm, gc, space, doctor and setup (addBackendFlag, addBackendFilterFlag, setup's own, checkFlagValue's case, its completion); a removed flag now fails as an unknown flag (exit 2). - devvm setup no longer asks for or saves a default backend; config.toml and settings.json have no backend key (settings.KeyBackend, Values and Defaults' Backend, checkBackend, Value.With, Source.File, FromFlag). - Tables lose BACKEND: ls, images (both tables), space (both tables); doctor's FEATURE table is FEATURE and SUPPORT for Lima. space's images row is freed by images rm. - --json keeps every backend field (ls, images, tool records, space, doctor's backend, backend_source "built-in" and every backend's features). - The registry keeps Lookup, For and Default: For(d, vm) gives a VM its recorded backend and a new VM NewVMs, else Default; tests set NewVMs. vm.Env's lookups lose the flag parameter, found.flagIgnored and Options.Backend. - Messages removed: backend_unknown, backend_unknown_default, default_backend, backend_help, doctor_backend_from, backend_flag_ignored; backend_unknown_vm stays (a VM's recorded backend), linked to backends#a-vms-backend. - Docs: Backends' choosing section becomes "A VM's backend"; settings, setup, images, gc, space, doctor, commands and install pages lose --backend and BACKEND; Contributing gains "How a backend plugs in". - Tests: unit tests for For, settings, setup, doctor's table, the tables; CLI scripts check --backend as an unknown flag on devvm, build, restart, images, gc, space, doctor and setup, and a config.toml backend key as unknown; e2e's table checks lose the column. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
299ddb1476 |
refactor(state): image records in images/<key>/, rebuild counters per backend and --from, tool image records, cache/
- Image records are images/<key>/record.json (JSON, unknown fields ignored; name, chain, from, digest, libc, built). state.Images lists the folders; AnyImage needs a record.json; RemoveImage deletes the folder. Lima's cache cleaner reads records through state.Images. - Rebuild counters are images/rebuilds.json, keyed by (backend, from as given, name), changed under images/locks/rebuilds. image.Inputs takes them through an image.Rebuilds interface. A rebuild on one backend no longer outdates the others' images, and two --from references that wrote the same counter name (node:24, node-24) stay apart. paths.RebuildFile, RebuildName and unsafeName are gone. - Tool images: <file>.sha256, .target and .idle become one <file>.json (sha256, libc, format, backend, built, idle_since; state.ToolImage). BACKEND and LIBC read the record; the fallbacks (format matching, a VM's target, the current target) go, with toolTargets, vmToolTargets, formatBackend and gc's backendTools (toolsOn does it). Share.IdleFor owns reading idle_since. - cache/ (Dirs.Cache) holds mise/, nix-cache/ and from-digests.json. With the cache gone, from.Recorded takes the newest base record's digest for the reference, so no key changes. - Key check: the rebuild counter is the one input that moved and changes keys (deliberately: per backend and exact from). The --from digest moved to cache/ and stays an input, kept stable by the records' fallback. Records, mise and the Nix cache are outputs. - Tests: state's image, rebuild, digest and tool record tests; image key cases per backend and exact from; build.TestRebuildIsPerBackend; from.TestRecordedWithoutTheCache; cli.TestToolsOn; rebuild.txtar (Docker's and smolvm's rebuilds keep Lima's and the other --from's bases), gc_caches.txtar and from.txtar (a missing cache/); the testscript command json_set; e2e reads the JSON records. - Docs: space, images, settings (retention), internals images, overview, network, security, contributing (json_set). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ddbc377f8f |
test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN and CFG by default, and adds stub_reset, catg (the one file a glob matches), vm_name VAR NAME (the folder's VM) and project NAME [git]; script_cmds.txtar checks each. Every script is rewritten onto them, its assertions kept; TestCommandLines leaves the scripts' own commands out. mise run test runs scripts/test.sh: the tests as before, with the CLI tests' devvm built with -cover for every package (CLI_GOCOVERDIR), merged with the Go tests' counters by go tool covdata, then scripts/coverage.sh holds each package to testdata/coverage/<os>.txt. mise run coverage raises the baselines; coverage.txtar checks the comparison. The macOS baseline is recorded from this tree. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
16b4ad8771 |
feat(cli): --no-input, a flag or command for every question, and --force only skips a confirmation
A global --no-input (persistent on the root, with --help and -v): no question is asked or read. The ui's prompts (Ask, Confirm, Answer, Secret, Pick/PickOne in a terminal) show the question, then fail with no_input naming what answers it (msg.AnswerFor, by the question's ID), or no_input_terminal for a question only a terminal answers. ui.Flags and SetFlags carry -v and --no-input. Answers: --network-policy/--no-network-policy, --here, devvm size -g, devvm setup --features/--backend, devvm network -g, devvm ssh-agent add, devvm restart, --ssh-config (new, on devvm, host and code: the Include line without asking; sshconfig.Config.AddInclude, vm.Env.AddInclude), --stdin, and --force. --force (-f) only skips a confirmation, and destructive commands need it without a terminal (force_needed, a failure, not a usage error): rm (new rm_confirm), gc (it went ahead without a terminal), gc --caches (now allowed without a terminal with --force), images rm (images_rm_confirm), secret rm (secret_rm_confirm), adopt (adopt_vm), rebuild when images are built on the one rebuilt (build.Env.Force). rm --no-export skips the export; rm's parent-folder, earlier-folder and --clone confirmations are terminal-only and --force never answers them (vm.RmOptions). gc --tools --force splits: --recent (only with --tools, gc_recent_needs_tools) drops the hour's hold and keeps the refusal while a VM is being made (gc_recent_making); gc_tools_recent names devvm gc --tools --recent. gc_caches_need_terminal goes. Tests: TestNoInput, TestAnswers, TestConfirmed, TestRmConfirms, TestAdopt (--force), TestRebuild (force_needed, then Force); secret, rebuild, images, gc*, clone, subfolder, existing scripts. e2e: rm/gc/images rm/secret rm/rebuild with --force (and --no-export where rm -f skipped the export), and the clone section's rm with its checks. Docs: commands.md (Questions devvm asks, rm, flags), first-vm, clone, images (cleaning up, --recent), space, coding-agents, internals overview and images; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
18eefddc16 |
feat(cli): devvm retention, bare secret and ssh-agent, ssh-agent rm, and setup's network question
- devvm retention [KEY=VALUE...] shows every retention setting (off when
unset) and changes them; KEY=off turns one off, KEY= is refused and
nothing is written. devvm space only shows.
- devvm secret lists the secrets; devvm secret set claude saves the
Claude Code token. No auth or secret ls commands.
- Bare devvm ssh-agent shows the VM's forwarding, then devvm's own
agent's keys once one is added (it starts no agent without one).
devvm ssh-agent rm KEY_FILE takes a key out of devvm's agent, found by
its recorded fingerprint, and out of ~/.config/devvm/agent-keys; the
key file isn't touched, and a key not added is refused.
- devvm setup's flags are --backend and --features LIST|none ('' is
refused). In a terminal it also asks for new VMs' network policy (ask,
on, off), saved in ~/.config/devvm/network (Dirs.Network), which new
VMs read unless --network-policy or --no-network-policy is given.
Messages: features_empty, network_default, network_default_help,
network_default_ask/on/off, agent_key_not_recorded, agent_unload_failed,
agent_key_removed, retention_settings_failed; retention_unreadable,
agent_devvm_risk, no_claude_token and claude_token_invalid name the new
commands. paths: Dirs.Network (the structure test's Dirs limit is 42).
state: ReadNetwork, WriteNetwork, NetworkChoices, NetworkAsk/On/Off,
RetainOff. sshagent: Agent.Remove. Tests: TestNetwork, TestChooseNetSaved,
TestSetupNetworkStartsFromSaved, TestKeysNone, TestRemove, the real-agent
rm check; retention, setup, secret, ssh_agent and nix_cache scripts; e2e
checks for ssh-agent rm and retention.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
6f680a6f8b |
feat(proxy): a shared, read-only Nix cache that only the host fills
VMs with network policy and the nix layer share their downloads from cache.nixos.org: the proxy answers http://devvm.proxy/nix/ itself (a reserved endpoint, never forwarded), and the guest setup puts it before https://cache.nixos.org in Nix's substituters, trusted-public-keys left as Nix's own (cache.nixos.org-1). Each VM keeps its own store and daemon; only downloads are shared, and no VM can change what another gets. The proxy (internal/proxy/nixcache.go, -nix-cache DIR and -nix-cache-max BYTES): - takes only GET and HEAD, no query, nothing escaped, of nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no suffix or .xz, .zst or .bz2 (nixPath, FuzzNixPath); 400 otherwise; - makes up nix-cache-info (priority 30, before cache.nixos.org's 40); - fetches from https://cache.nixos.org alone, when the VM's policy allows cache.nixos.org:443, through the floor or the company proxy, with the system's roots and the user's CAs, following no redirect, sending nothing of the VM's request; - keeps a narinfo when its StorePath is the path asked for, its URL is of the pattern and named by its own NarHash or FileHash, and a Sig by the pinned cache.nixos.org-1 Ed25519 key verifies over 1;StorePath;NarHash;NarSize;References (parseNarinfo, against a real narinfo and NAR of cache.nixos.org's in testdata/nix/); - fetches a NAR only after a narinfo it checked names it, never for a HEAD, once however many ask and at most four at once (fetchOnce), and keeps it when its SHA-256 and size are the narinfo's FileHash and FileSize; a cached copy of another size is dropped; - answers 404 to anything that fails, keeping nothing, so Nix goes to cache.nixos.org itself; logs each request as a nix-cache event (hit, fetched, or why not), which devvm log shows as cache; - writes files whole and renames them in, 600 in folders of 700. The cap: the nix-cache.size retention setting, 10 GiB when off (state.NixCacheDefault, proxy.NixCacheDefault), with state.ParseSize (500M, 20G, 1T). Under a flock on .lock every proxy takes a file's room before writing it (reserve, in whole blocks), deleting the least recently used files (by mtime, which a hit sets) down to nine tenths of the cap; a NAR being fetched is made its full size at once and counts, so a fetch the in-flight files leave no room for is refused. devvm gc trims to the cap, devvm gc --nix-cache empties it, and the daily retention run trims it (proxy.TrimNixCache, NixCacheUsage). devvm space has a Nix cache row (GC: what's over the cap, FREED BY gc --nix-cache, RETAIN nix-cache.size), devvm images says what it takes of its cap. netpolicy passes -nix-cache and -nix-cache-max only for images with the nix layer (nixCacheArgs; a retention file it can't read warns and uses the default). The guest setup writes /etc/nix/devvm-cache.conf through !include in nix.conf only with the nix layer and policy on, removes it otherwise, and restarts nix-daemon when it changes. VMs without network policy get no shared cache: they fetch from cache.nixos.org directly, and nothing new runs or listens on the host for them. Review (security-audit skill, on nixcache.go, its callers and the setup): a NAR could be kept under another NAR's name, as the URL isn't signed (fixed: the URL must be named by the narinfo's own hashes, and a hit of another size is dropped); files being fetched didn't count against the cap and blocks weren't counted, so one VM's parallel requests could pass it (fixed: reserve, full-size temp files, block counts, fetchOnce); a HEAD downloaded a NAR (fixed). Ruled out: stored VM input, paths out of the folder, another upstream, parser differences, cross-VM visibility beyond timing, a VM's own nix.conf. Open, documented: timing tells a VM whether some VM fetched a public path, and a VM can fill the cache to its cap. Messages: gc_nix_cache_over, gc_nix_cache, deleted_nix_cache, images_nix_cache; retention_deleted gains nix_files. Paths: Dirs.NixCache (structure limit for Dirs to 40). Flags: devvm gc --nix-cache; the CLI reference regenerated. Tests: TestNixPath, TestNix32, TestParseNarinfo, TestNixCacheServes, TestNixCacheRefuses, TestNixCachePolicy, TestNixCacheFetches, TestTrimNixCache, TestNixCacheCap, FuzzNixPath, TestParseSize, TestRetention, TestNixCacheArgs, TestFormatEvent; nix_cache.txtar (the proxy's endpoint and refusals, space, images, gc, gc --nix-cache, retention); e2e nix: the VM's substituters and keys, hello through the cache, fetched by the host (600/700), a VM's writes and other requests refused and nothing kept, a second VM's hits fetching nothing, no cache after devvm network off. Docs: the design note (internals/design.md), internals/network.md's The shared Nix cache, the VM's setup, logs and flags, internals/security.md, internals/images.md, safety/network.md's Nix and Logs, using/toolchains.md's Nix projects, using/images.md, using/space.md, using/settings.md's Retention, internal/proxy/README.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> |