7 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 00e5ea59f4 feat(cosign): the run, which makes and publishes each release CI hands over
devvm-cosign's run (Cosigner.Run), its command (cmd/devvm-cosign, Main)
and the maintainer's commands, devvm-cosign retry, ack and failed.

CI's token can only read the repo, so CI hands each build over as a
workflow artifact, and only the co-signer, and the maintainer by hand,
can make or publish a release. For each release CI handed over that it
hasn't published, oldest first, from the newest successful run of the
pinned release workflow for each tag, of this repo's own:

- its version is newer than the newest it signed, or one it signed, with
  the same SHA256SUMS; an older one is an alert, as a replay, until the
  maintainer acks it, unless it was published before the state began;
- CI's artifact is staged (stage/, which no build can reach) and
  checked: SHA256SUMS, CI's signature with CI's key and devvm-release
  <version>, and exactly the files it lists, each with its SHA-256; its
  files are deleted before the build and downloaded again after a match,
  so none of CI's bytes is on disk while a container could be live;
- a run builds once, so the podman service, which lives for the run,
  lives for one build, and anything that escaped a container is gone
  before the next build's host git and release.sh run; the next release
  or base waits for the next run;
- the build's finished files go in a folder of the state's src/, which
  release.sh copies to and the co-signer reads, where no container can
  swap a file or the folder;
- the tag's commit has to be the commit CI's run built, and the
  co-signer's own build has to match every file and SHA256SUMS; it
  renders the tap's formulas itself from the tag's template and the
  signed SHA256SUMS (formula.go, as release.sh's formula function does),
  and the build's own formulas have to be the same bytes, so neither
  builder's container decides what Homebrew installs. The formulas and
  the notes, the tag's CHANGELOG.md entry, are kept in kept/<v>/ with
  their SHA-256s in the state, and checked again before the tap;
- it signs, makes the draft itself, titled devvm <version> with the
  tag's notes, and uploads SHA256SUMS, both signatures and CI's files,
  each hashed as it's sent, keeping an asset only when its size and
  GitHub's digest are right and deleting any other;
- while the bridge lasts it waits for the old key's signature on the
  draft, failing each run so the maintainer hears of it, and downloading
  nothing again while it waits;
- it publishes only when the draft is exactly what it made, its tag,
  title and notes (but for line endings and the space at either end),
  and its assets by ID, size and digest, and the tag still names the tag
  object its rebuild checked; then checks the published release again,
  and finishes the tap.

Alerts and refusals:

- init records the highest release ID GitHub showed and the drafts there
  were then; IDs only go up, so any release published since that isn't a
  draft the co-signer made is an alert, whatever its tag or version, by
  <tag>#<ID>, so another release of an acked tag is alerted on again;
  each run also reads GitHub's latest release, wherever the list puts it.
- A published release that differs from what it checked, its own draft
  published without it seeing the answer that then doesn't check out,
  and a tap formula newer than any release it signed, by
  tap:<formula>@<version>, are alerts; the tap is updated only for a
  release it published and checked after.
- A rebuild that doesn't match is a refusal, which isn't downloaded or
  rebuilt again, even for CI's run again; devvm-cosign retry <tag> lets
  the next run rebuild it once more. Nothing retries on its own.
- Every run fails (exit 1) while an alert or refusal waits, until
  devvm-cosign ack or retry. A run records in last-failure.txt that it
  started, then what failed, or removes it when it succeeds; devvm-cosign failed, which the units' OnFailure=
  runs for any failure, a killed or timed-out run's or a config that
  won't load included, runs notify, the maintainer's command, with it on
  its stdin, a fixed environment and a minute of its own, whatever ended
  the run's context.

Bases go the same way, from the newest successful run of the base
workflow on main, made at the index's commit and never GitHub's latest.

Main makes the process non-dumpable (prctl PR_SET_DUMPABLE 0) before
anything else, so no process of its user can read its memory, where the
keys and token are, and reads the keys from systemd's credentials when
CREDENTIALS_DIRECTORY is set. A run empties the build folder's work/
and the state's stage/ and src/ in place, never making them again.

Tests, each fix reverted once to see it fail: TestPublishedBySomeoneElse
(a release published by someone else, whatever its tag or version, the
same tag again after an ack, a draft from before init published since,
and GitHub's latest past where the list stops; one from before the state
left alone), TestOneBuildPerRun (the build's files in the state, none of
CI's on disk during the build, and the next release left for the next
run), TestFormulas (a build's formula of
its own; a kept formula changed on disk), TestRenderFormula,
TestPrereleasePublished (a tap formula newer than any release signed),
TestDraftChangedBeforePublish (a swapped file, a retag, other notes),
TestTagMovedBeforePublish, TestAlertAfterPublish and
TestLostPublishChecked, TestMismatchSignsNothing (a failure every run,
and retry), TestReplayedOlderVersion (an alert, then acked),
TestNotify, TestLegacyBridge (a failure every run, with no download),
TestRunPagesReleases, TestInitPaged (init past ten pages of bases, which
fails with a page check that stops at its first unfinished entry),
TestRunsChecked, TestArtifactChecked, TestUploadChangedOnDisk,
TestBaseIndexChecked (a re-signed base on a 61-day snapshot),
TestBasePublishChecked, TestBasePublishedElsewhere (an expired base still
counts in checkBehind), TestWorkEmptiedInPlace, TestCommandLine (retry
and ack read no key file), and on Linux TestUndumpable.

A build that fails, rather than differs, is built again at the next
run, but the third failure in a row refuses it, with a report holding
the last failure (buildFailed), so a build that keeps failing no longer
takes every run's one build and holds up each newer release and base;
retry builds it again, and a build stopped with its run isn't counted.
Refusing rather than rotating past it keeps releases oldest first, as
versions only go up, and keeps the failure in front of the maintainer
through held and notify. buildRelease and buildBase are the build and
its comparison, apart from what's recorded. And GitHub's latest release
has to be the one init saw or one the co-signer published, not one of
its own older than another it published: anything else is an alert,
latest:<tag>#<ID> (staleLatest), as the install script's default
downloads it; so is the one init saw, once it's older than one the
co-signer published. The co-signer makes a release GitHub's latest only
when it's newer than every release it published, so publishing an older
release after a newer one, as when the old key signs the newer draft
first, never moves the latest back itself. And a release's run counts
only when a tag's push started it (PushEvent, which the structure
test's nameFree lets name "push"). Tests, each failing before its code:
TestFailingBuildRefused, TestBaseRefused's base that keeps failing,
TestLatestChecked, TestOlderReleaseNotLatest, TestRunsChecked's run by
hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 21:36:37 -07:00
w3cjandClaude Opus 5.5 8d44175601 refactor: the Go module is github.com/devvmhq/devvm
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-06 06:16:29 -07:00
w3cjandClaude Opus 5.5 ca8a91305b fix(ui): one failure path, and an interrupt's cleanups wait for the command
Commands fail by returning: RunE returns the error, as failed(err, what)
when it may not be a message (replacing fail and the direct Die calls in
cli), and a.env returns its failure. checkLayout returns its error from the
root's PersistentPreRunE. execute alone prints a failure (showFailure): a
backend.LoggedError with the run log's end (ui.ErrorLogged, which replaces
DieLogged), a message as it is, else what failed or output_failed, with a
corrupt file's message as names mode shows it. Exit codes stay 0, 1, 2, 130.

Die is now the UI's own die, for where no command can return: a question
without an answer, a run log that can't be opened. Error prints nothing once
the run is interrupted.

After INT, TERM or HUP, Main waited only for the logged command and then ran
the cleanups while the command's own code still ran. It now also waits for
the command to return, up to returnGrace (2 s), when there are cleanups to
run; a run without cleanups ends at once, so the proxy and the other
background processes still stop as soon as they are told to. A start's
undoStart stays registered once interrupted (interruptCleanup), as the
cleanups now run after the start returned.

Tests: TestSignalsWaitForTheCommandBeforeTheCleanups (failed on the old
ordering), TestSignalsWaitForAStuckCommandAWhile,
TestSignalsWithoutCleanupsEndAtOnce, TestExecuteShowsEachFailure;
DieLogged's tests are ErrorLogged's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 10:42:20 -07:00
w3cjandClaude Opus 5.5 866b9e0930 fix: the processes devvm starts don't inherit the files it was given
A terminal, an editor or a test harness can give devvm files past the
standard three without close-on-exec (testscript's ttyin puts a pty on
descriptor 3), and devvm's background processes then held them, keeping
that terminal or pipe open as long as they ran: on Linux a script hung
until its timeout. devvm now marks every file it was given from
descriptor 3 up close-on-exec as it starts (platform.CloseInheritedOnExec,
called first in main), which covers every process it starts, Lima's
included, and keeps them open itself.

TestCloseInheritedOnExec re-runs the test binary with an extra file on
descriptor 3, starts a detached process and checks it doesn't hold it
(/proc/<pid>/fd on Linux, lsof on macOS); layer_add.txtar now answers
yes in a terminal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:34:42 -07:00
w3cjandClaude Opus 5.5 4bbd35a24b refactor(ui): make the UI an instance only cli holds
internal/ui has no package state: ui.UI holds the streams, terminal
flags, run log, status line, cleanup stack and interrupt flag, and its
functions are methods. ui.Main makes the run's UI on devvm's own
streams, owns signals, recovers Die and runs the cleanups; ui.New makes
one on other streams. cmd/devvm passes it to cli.Execute, and every cli
command gets it through its constructor.

Only cmd/devvm and internal/cli import internal/ui (a depguard rule).
Each other package defines the small UI interface it needs, which its
constructor takes, filling fields tests set:
- gitprotect.New, secrets.NewStore, from.NewLookup: a warn func
- ubuntu.New: LoggedCmd, Note
- netpolicy.NewProxy: Note, Warn, Ask, Confirm, StdinIsTerminal; its
  log lines drop control characters themselves (oneLine)
- sshagent.New: Info, Note, Warn, LogWriter
- tools.New: Info, Warn, LogNote, Status, LoggedCmd, AddCleanup
- lima.New, smolvm.New: Info, Warn, LoggedCmd (their Runner's Run),
  WithSteps, AddCleanup, Interrupted; lima LogNote and ubuntu's too
- backends.Registry: lima's and smolvm's
- vm.NewEnv: all of the above, Say, Stdout, Stderr; Env has Stdout,
  LogNote, LogWriter, LoggedCmd, AddCleanup, Interrupted fields
- build.Builder: Terminal and LogNote fields
- sshconfig.New: its caller sets what it prints and asks

ui's tests build their own UI over buffers and run in parallel; other
packages' tests use small fakes; cli's unit tests a UI over buffers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 16:23:51 -06:00
w3cjandClaude Opus 5.5 e182e3787a feat(ui): output helpers, spinner, run logs and cleanups
internal/ui is now the only package that prints: the message helpers,
prompts, tty detection, the status line, the run log (Logged, step
counts, proxy keys redacted) and ui.Main, which recovers Die, runs the
cleanup stack and handles INT/TERM/HUP (exit 130). main runs devvm
through it, and Cobra's errors print as one-line devvm errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 02:27:59 -06:00
w3cjandClaude Opus 5.5 9271148b1e build: Go module and devvm entry point
A Cobra root command with no subcommands yet, a paths package that finds
devvm's files next to its binary (following links), Go pinned with mise,
the README, the license, and the security-audit skill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 01:10:51 -06:00