cosca 0.7.0

Unified cross-platform subprocess management: spawning, stdio, process trees, stable identity, and elevation.
Documentation
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# devvm guest: linux-x64 — for cgroup v2 lanes, cross-arch-emulated (TCG) on an Apple
# Silicon host, natively virtualized (KVM/HVF) on an x86-64 host.
#
# Not meant to be run directly with `vagrant up` in this directory — use
# `scripts/devvm.py up linux-x64`, which sets VAGRANT_DOTFILE_PATH and DEVVM_STAGE_DIR so
# all state lands under .tmp/devvm/ in the worktree, never in the box's own directory.
#
# Box: cloud-image/ubuntu-24.04 (community-published, not Canonical's), provider qemu, version and
# checksum pinned below. Ubuntu 24.04's systemd (255) defaults to the unified cgroup v2 hierarchy,
# and its polkit (124) reads JavaScript rules, which `.github/scripts/unattended-gui-elevation.py`
# needs (>= 0.106).

require_relative "../_shared/fix_macos_port_check"
require_relative "../_shared/fix_qemu_loopback_only"

STAGE_DIR = ENV.fetch("DEVVM_STAGE_DIR")

Vagrant.configure("2") do |config|
  config.vm.box = "cloud-image/ubuntu-24.04-20260926.0.0"
  # Pinned in box.json, the one place Vagrant checks a downloaded box against a checksum: a box named
  # from the catalog is checked only against the catalog's. sha512 of the box file, computed locally by
  # `curl -X GET` + `shasum -a 512` (TOFU).
  config.vm.box_url = "file://#{File.expand_path("box.json", __dir__)}"
  # Amd64-only box: without this, Vagrant's architecture auto-detection on an Apple Silicon
  # host silently excludes it from "usable providers" and `up` fails with a misleading "box
  # doesn't support requested provider" error, even though the box does publish a qemu
  # provider — it's just for the wrong (host) architecture unless told otherwise. Harmless
  # (a no-op match) on an actual x86-64 host.
  config.vm.box_architecture = "amd64"
  config.vm.hostname = "cosca-devvm-linux-x64"

  config.vm.provider "qemu" do |qe|
    qe.arch = "x86_64"
    qe.memory = "4096"
    qe.smp = "2"
    # This host may already have unrelated VMs (this tool's or not) holding the default
    # forwarded port; let Vagrant pick a free one instead of failing `up`.
    qe.ssh_auto_correct = true
  end

  # Vagrant's own default /vagrant synced folder would otherwise fall back to SMB on macOS,
  # which prompts for a one-time System Settings -> Sharing -> File Sharing toggle and a
  # password on every mount. Not used here; disable it outright.
  config.vm.synced_folder ".", "/vagrant", disabled: true

  # A one-shot rsync push, not a live mount: the guest cannot write back into the host's
  # source tree. Source is `devvm.py`'s staged, git-tracked-only copy (see stage_tree() in
  # scripts/devvm.py) rather than REPO_ROOT directly, so untracked files never leak into the
  # guest. Files land read-only (F444); directories stay writable (D755) so later
  # `devvm.py sync` runs can still add/remove/replace files.
  config.vm.synced_folder STAGE_DIR, "/home/vagrant/cosca",
    type: "rsync",
    rsync__args: ["--archive", "--delete", "--chmod=D755,F444"]

  config.vm.provision "shell", path: "../../provision/linux-rust.sh", privileged: false

  # Marks this machine as a devvm guest, which `.github/scripts/unattended-gui-elevation.py` requires before
  # it weakens a machine's security. It lives here, in the guest's own provisioner, not in the reusable
  # provisioning script, which could be run on a host.
  config.vm.provision "shell", privileged: true, inline: "echo 'devvm guest' > /etc/cosca-devvm-guest"
end