cosca 0.6.0

Unified cross-platform subprocess management: spawning, stdio, process trees, stable identity, and elevation.
Documentation
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# devvm guest: linux-arm64 — for cgroup v2 lanes, natively virtualized (HVF) on an Apple
# Silicon host, cross-arch-emulated (TCG) on an x86-64 host.
#
# Not meant to be run directly with `vagrant up` in this directory — use
# `scripts/devvm.py up linux-arm64`, 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: perk/ubuntu-24.04-arm64 (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 = "perk/ubuntu-24.04-arm64-20250704"
  # 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 from the Vagrant Cloud API.
  config.vm.box_url = "file://#{File.expand_path("box.json", __dir__)}"
  # Pin explicitly rather than rely on Vagrant's host-architecture auto-detection matching by
  # accident — see the box_architecture comment in the windows-x64/linux-x64 Vagrantfiles.
  config.vm.box_architecture = "arm64"
  config.vm.hostname = "cosca-devvm-linux-arm64"

  config.vm.provider "qemu" do |qe|
    qe.arch = "aarch64"
    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