Quickly sandbox your AI agent.
Python
Fix release overlay indexes and Windows ARM64 runner availability
Tyler Payne2d9a00b13acf
diff --git a/.gitignore b/.gitignoreindex 179bc33..cf631b3 100644--- a/.gitignore+++ b/.gitignore@@ -34,6 +34,7 @@ htmlcov/# VM images (built during package build, not committed)manifest.json*.qcow2+*.qcow2.buildhash*.kernel*.initrddiff --git a/CHANGELOG.md b/CHANGELOG.mdindex e9ba338..a7484c5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,7 @@ Streaming command input, guest OS accounts, and more reliable mounted-file workf### Fixed- **quicksand-core:** Bundled SMB mounts use guest-local CIFS locks so `flock` and SQLite commits work. Native SMB retains server-side byte-range locking. Guest-local locks do not coordinate with host processes, other VMs, or separate mounts. (#44)- **quicksand-build-tools v0.6.0 / quicksand-qemu v0.5.12:** Linux wheel tags reflect the actual glibc requirements of bundled ELF binaries and libraries instead of always claiming manylinux 2.17 compatibility.+- **quicksand-image-tools / quicksand-agent / quicksand-cua:** Overlay Python installers honor configured host package indexes without putting index URLs in command arguments or persisting index settings in the image.### Released (dependency updates)- quicksand-agent v0.4.10, quicksand-cua v0.3.12, quicksand-alpine-desktop v0.9.10, quicksand-ubuntu-desktop v0.9.10, quicksand-base-scaffold v0.3.11, and quicksand-overlay-scaffold v0.3.11. Updated dependency ranges pick up the new core, image tooling, and base images.diff --git a/docs/contributor-guide/04-releasing.md b/docs/contributor-guide/04-releasing.mdindex 2b3ecbb..61a6249 100644--- a/docs/contributor-guide/04-releasing.md+++ b/docs/contributor-guide/04-releasing.md@@ -4,11 +4,14 @@ Releases are managed via the `/release` Claude Code skill.## Flow-1. **Dry run.** Run `uv run poe release:dry-run` to preview what will be built.-2. **Branch.** Create `release/v{version}` from main.-3. **Dispatch.** Run `gh workflow run release.yml --ref release/v{version}`.-4. **Monitor.** CI runs check, build, overlay build, test, and release.-5. **Post-release.** Verify per-package releases and test install.+1. **Prepare.** Use a non-main branch based on main. Run `uv run uvr status` to inspect changed packages and their baseline tags.+2. **Version.** Select feature/minor versions and dependency updates with `uv run uvr version`. Strip development suffixes from release targets with `--bump stable`, update the changelog, then commit and push.+3. **Preview.** Run `uv run uvr release --dry-run`. The worktree must be clean and local HEAD must match the remote branch.+4. **Dispatch.** Run `uv run uvr release`, supplying approved notes with `--release-notes PACKAGE @FILE`. The CLI generates the required workflow `plan` input.+5. **Verify and merge.** Monitor every build, license, release, PyPI publish, and next-development-version job. Verify published artifacts and installation, then fetch and merge the remote release branch tip back to main, including the CI-generated development-version commit.++The release workflow runs unit checks, but its VM integration job is currently+disabled. Run relevant VM checks separately before publishing.## Versioning@@ -21,24 +24,39 @@ Patch versions are set automatically by the previous release's dev bump.## Per-package releases-Each package gets its own GitHub release (`quicksand-core/v0.7.0`, `quicksand-qemu/v0.4.0`, etc.). Unchanged packages keep their existing releases. Change detection and internal dependency pinning are handled automatically by `quicksand-plan-release`.+Each package gets its own GitHub release (`quicksand-core/v0.13.0`, `quicksand-qemu/v0.5.12`, etc.). Unchanged packages keep their existing releases. `uvr` detects committed file changes; version commands update internal dependency ranges when required.++## Runners and package indexes++Runner assignments live in `[tool.uvr.runners]` in `pyproject.toml`. The Windows+ARM64 QEMU build uses GitHub's `windows-11-arm` runner. Linux and Windows x64+builds use the configured Azure VMs, and ARM64 image builds use the local macOS+runner. Set `AZURE_SUBSCRIPTION_ID` to the intended subscription before running+`uv run quicksand-runners start`; this command manages Azure VMs, not the macOS+runner.++Agent and CUA overlay Python installs inherit the host's `PIP_INDEX_URL`,+`PIP_EXTRA_INDEX_URL`, `UV_DEFAULT_INDEX`, `UV_INDEX_URL`, and+`UV_EXTRA_INDEX_URL` through `run_python_install()` in the image tools. The guest+requires Python 3 and a stdin-capable agent. Settings are passed over stdin,+apply only to the installer process, and are not saved in the image. This lets+release builds use the configured package mirror without changing users'+runtime package-index defaults.## Fixing CI failuresFix on the release branch, push, re-dispatch:```bash-git checkout release/v<VERSION># fix the issue-git push origin release/v<VERSION>-gh workflow run release.yml --ref release/v<VERSION>+git push+uv run uvr release --release-notes PACKAGE @FILE```-To reuse builds from a previous run:-```bash-gh workflow run release.yml --ref release/v<VERSION> \- -f plan="$(uv run quicksand-plan-release --reuse-base-build <RUN_ID> --reuse-overlay-build <RUN_ID>)"-```+For a late failure, `uvr release` supports `--reuse-run`, `--reuse-releases`,+`--skip`, and `--skip-to`. Reuse artifacts only when all required earlier builds+and checks succeeded for the intended source and versions. An early build+failure normally requires a fresh dispatch.## Changelogdiff --git a/docs/under-the-hood/01-installation.md b/docs/under-the-hood/01-installation.mdindex e049f14..0397fe9 100644--- a/docs/under-the-hood/01-installation.md+++ b/docs/under-the-hood/01-installation.md@@ -56,7 +56,7 @@ At runtime, `_find_bundled_runtime()` reads the native CPU architecture from the**Build pipeline:**1. The Windows x64 CI runner builds `win_amd64.whl` with x64 QEMU in `bin/`-2. The Windows ARM64 CI runner builds `win_arm64.whl` with ARM64 QEMU in `bin/`+2. The GitHub-hosted `windows-11-arm` runner builds `win_arm64.whl` with ARM64 QEMU in `bin/`3. A `pre_release` hook (runs after all builds, before publishing) opens the `win_amd64` wheel, moves its binaries to `bin/x86_64/`, extracts ARM64 binaries from the `win_arm64` wheel into `bin/arm64/`, and rewrites the wheel4. The `win_arm64` wheel ships unchanged (lean, single-arch) for the rare native ARM64 Python user@@ -74,7 +74,7 @@ quicksand-qemu is in `_SKIP` — never retagged. Each runner produces exactly on| `[linux, arm64]` | qemu-system-aarch64 (Linux) | `manylinux_<major>_<minor>_aarch64` | unchanged || `[macos, arm64]` | qemu-system-aarch64 (macOS) | `macosx_11_0_arm64` | unchanged || `[windows, x64]` | qemu-system-x86_64.exe | `win_amd64` | → **fat**: x64 in `bin/x86_64/`, arm64 in `bin/arm64/` |-| `[windows, arm64]` | qemu-system-aarch64.exe | `win_arm64` ¹ | unchanged (consumed by merge into fat wheel) |+| `windows-11-arm` | qemu-system-aarch64.exe | `win_arm64` ¹ | unchanged (consumed by merge into fat wheel) |Linux manylinux versions are derived from versioned symbols in the bundled ELFbinaries and libraries. They are not fixed at glibc 2.17; pip selects a wheel@@ -85,7 +85,7 @@ binary directory as `bin_dir` to `BinaryBundler.set_platform_wheel_tag()` andinclude auditwheel in their build dependencies. The QEMU hook supplies both;applications using `Sandbox` do not need to change their build configuration.-¹ **Windows ARM64 tag override:** The ARM64 runner runs x86_64 Python through transparent emulation, so `sysconfig.get_platform()` returns `win-amd64`. Without intervention, this runner would produce a **second** `win_amd64` wheel containing ARM64 binaries — colliding with the x64 runner's wheel and making the fat wheel merge impossible (no `win_arm64` to merge from). We override the wheel tag in `BinaryBundler.set_platform_wheel_tag()` (`quicksand-build-tools`, used by quicksand-qemu) and `set_platform_wheel_tag()` (`quicksand-image-tools`, used by image packages) by reading the native architecture from the Windows Registry (`HKLM\...\PROCESSOR_ARCHITECTURE`), which always reports `ARM64` regardless of process emulation.+¹ **Windows ARM64 tag override:** When an ARM64 runner uses x86_64 Python through transparent emulation, `sysconfig.get_platform()` returns `win-amd64`. Without intervention, it would produce a **second** `win_amd64` wheel containing ARM64 binaries, colliding with the x64 wheel. `BinaryBundler.set_platform_wheel_tag()` (`quicksand-build-tools`) and `set_platform_wheel_tag()` (`quicksand-image-tools`) detect the native architecture through the Windows Registry (`HKLM\...\PROCESSOR_ARCHITECTURE`) and apply `win_arm64`. Native ARM64 Python already reports the correct tag.#### Image wheels (ubuntu, alpine, etc.): build runners → retagdiff --git a/packages/contrib/quicksand-agent/hatch_build.py b/packages/contrib/quicksand-agent/hatch_build.pyindex b7f6e93..78bec08 100644--- a/packages/contrib/quicksand-agent/hatch_build.py+++ b/packages/contrib/quicksand-agent/hatch_build.py@@ -23,12 +23,15 @@ logger = logging.getLogger("quicksand-agent")async def _setup(shell: Callable[..., Coroutine[Any, Any, Any]]) -> None:"""Install steps for the agent sandbox."""+ from quicksand_image_tools.build_utils import run_python_install# ── Install uv ──────────────────────────────────────────────await shell("curl -LsSf https://astral.sh/uv/install.sh | sh", timeout=60)# ── Create Python 3.12 venv with pip at /opt/python ────────- await shell("/root/.local/bin/uv venv /opt/python --python 3.12 --seed", timeout=120)+ await run_python_install(+ shell, "/root/.local/bin/uv venv /opt/python --python 3.12 --seed", timeout=120+ )# ── Make venv discoverable on PATH ────────────────────────# Symlink venv binaries into /usr/local/bin (guest agent's PATH)@@ -65,7 +68,8 @@ PROFawait shell("apt-get install -y build-essential", timeout=600)# ── Install Python packages ─────────────────────────────────- await shell(+ await run_python_install(+ shell,"/opt/python/bin/pip install requests 'pyyaml>=6.0'"" 'ddgs>=9.11.2' 'markitdown[all]>=0.1.5'",timeout=600,diff --git a/packages/contrib/quicksand-cua/hatch_build.py b/packages/contrib/quicksand-cua/hatch_build.pyindex d0fdd81..a9fa9a5 100644--- a/packages/contrib/quicksand-cua/hatch_build.py+++ b/packages/contrib/quicksand-cua/hatch_build.py@@ -37,6 +37,8 @@ Shell = Callable[..., Coroutine[Any, Any, Any]]async def _setup(shell: Shell) -> None:+ from quicksand_image_tools.build_utils import run_python_install+# ── Install Xvfb, x11vnc, and Playwright system deps ────────await shell("apt-get update", timeout=120)await shell(@@ -49,7 +51,9 @@ async def _setup(shell: Shell) -> None:)# ── Install Playwright and Chromium via Playwright ───────────- await shell('/opt/python/bin/pip install playwright "flake8==7.1.1"', timeout=300)+ await run_python_install(+ shell, '/opt/python/bin/pip install playwright "flake8==7.1.1"', timeout=300+ )await shell("PLAYWRIGHT_BROWSERS_PATH=/opt/playwright"" /opt/python/bin/python3 -m playwright install --with-deps chromium",diff --git a/packages/dev/quicksand-image-tools/quicksand_image_tools/build_utils.py b/packages/dev/quicksand-image-tools/quicksand_image_tools/build_utils.pyindex 3d0c7a4..359db58 100644--- a/packages/dev/quicksand-image-tools/quicksand_image_tools/build_utils.py+++ b/packages/dev/quicksand-image-tools/quicksand_image_tools/build_utils.py@@ -6,12 +6,52 @@ previously duplicated across every ``hatch_build.py`` in the monorepo.from __future__ import annotations+import jsonimport os+import shleximport sysconfig+from collections.abc import Awaitable, Callable_X86_NAMES = {"x86_64", "amd64", "x64"}_ARM_NAMES = {"arm64", "aarch64"}+_PYTHON_INDEX_VARIABLES = (+ "PIP_INDEX_URL",+ "PIP_EXTRA_INDEX_URL",+ "UV_DEFAULT_INDEX",+ "UV_INDEX_URL",+ "UV_EXTRA_INDEX_URL",+)+++async def run_python_install(+ shell: Callable[..., Awaitable[None]],+ command: str,+ *,+ timeout: float = 300,+) -> None:+ """Run a Python installer in a Unix guest using the host's package indexes.++ The guest needs Python 3 and a stdin-capable agent. Index settings apply only+ to this command; they are not saved in the image or included in command logs.+ """+ index_env = {name: os.environ[name] for name in _PYTHON_INDEX_VARIABLES if name in os.environ}+ if not index_env:+ await shell(command, timeout=timeout)+ return++ # URLs can contain credentials: pass them through stdin, not command arguments.+ launcher = (+ "import json,os,sys;"+ "os.environ.update(json.load(sys.stdin));"+ "os.execl('/bin/sh','sh','-c',sys.argv[1])"+ )+ await shell(+ f"python3 -c {shlex.quote(launcher)} {shlex.quote(command)}",+ stdin=json.dumps(index_env).encode(),+ timeout=timeout,+ )+def get_image_arch() -> str:"""Return the image architecture string for the host (``"amd64"`` or ``"arm64"``).diff --git a/pyproject.toml b/pyproject.tomlindex 72b546b..10c8c0b 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -31,7 +31,7 @@ quicksand-base-scaffold = [["self-hosted", "linux", "x64"]]quicksand-core = [["self-hosted", "linux", "x64"]]quicksand-image-tools = [["self-hosted", "linux", "x64"]]quicksand-overlay-scaffold = [["self-hosted", "linux", "x64"]]-quicksand-qemu = [["self-hosted", "x64", "windows"], ["self-hosted", "linux", "x64"], ["self-hosted", "macos", "arm64"], ["self-hosted", "linux", "arm64"], ["self-hosted", "windows", "arm64"]]+quicksand-qemu = [["self-hosted", "x64", "windows"], ["self-hosted", "linux", "x64"], ["self-hosted", "macos", "arm64"], ["self-hosted", "linux", "arm64"], ["windows-11-arm"]]quicksand-smb = [["self-hosted", "linux", "x64"]]quicksand-ubuntu = [["self-hosted", "linux", "x64"], ["self-hosted", "macos", "arm64"]]quicksand-ubuntu-desktop = [["self-hosted", "linux", "x64"], ["self-hosted", "macos", "arm64"]]diff --git a/tests/unit/test_overlay_python_indexes.py b/tests/unit/test_overlay_python_indexes.pynew file mode 100644index 0000000..30f444b--- /dev/null+++ b/tests/unit/test_overlay_python_indexes.py@@ -0,0 +1,112 @@+"""Python package indexes used by overlay build commands."""++from __future__ import annotations++import json+import os+import runpy+import shlex+import subprocess+import sys+from pathlib import Path+from unittest.mock import AsyncMock++import pytest+from quicksand_image_tools.build_utils import run_python_install++_INDEX_VARIABLES = (+ "PIP_INDEX_URL",+ "PIP_EXTRA_INDEX_URL",+ "UV_DEFAULT_INDEX",+ "UV_INDEX_URL",+ "UV_EXTRA_INDEX_URL",+)++[email protected](autouse=True)+def clear_indexes(monkeypatch):+ for name in _INDEX_VARIABLES:+ monkeypatch.delenv(name, raising=False)+++async def test_python_install_preserves_default_behavior_without_indexes():+ shell = AsyncMock()+ await run_python_install(shell, "pip install example", timeout=20)+ shell.assert_awaited_once_with("pip install example", timeout=20)+++async def test_python_install_passes_only_index_settings_without_logging_urls(monkeypatch):+ indexes = {+ "PIP_INDEX_URL": "https://example-user:[email protected]/simple/",+ "PIP_EXTRA_INDEX_URL": "https://extra.invalid/simple/",+ "UV_DEFAULT_INDEX": "https://uv.invalid/simple/",+ "UV_INDEX_URL": "https://legacy.invalid/simple/",+ "UV_EXTRA_INDEX_URL": "https://uv-extra.invalid/simple/",+ }+ for name, value in indexes.items():+ monkeypatch.setenv(name, value)+ monkeypatch.setenv("UNRELATED_SECRET", "not-for-the-guest")+ shell = AsyncMock()++ await run_python_install(shell, "uv venv /opt/python --seed", timeout=120)++ call = shell.await_args+ assert call is not None+ assert json.loads(call.kwargs["stdin"]) == indexes+ assert call.kwargs["timeout"] == 120+ assert all(value not in call.args[0] for value in indexes.values())+ assert b"UNRELATED_SECRET" not in call.kwargs["stdin"]++[email protected](os.name == "nt", reason="The launcher executes inside a Unix guest")+async def test_python_index_launcher_applies_settings_only_to_installer(monkeypatch):+ index = "https://mirror.invalid/simple/?value='quoted'&more=value"+ monkeypatch.setenv("PIP_INDEX_URL", index)+ shell = AsyncMock()+ command = f"{shlex.quote(sys.executable)} -c " + shlex.quote(+ "import os; print(os.environ['PIP_INDEX_URL'])"+ )+ await run_python_install(shell, command)++ call = shell.await_args+ assert call is not None+ env = os.environ.copy()+ env.pop("PIP_INDEX_URL")+ result = subprocess.run(+ shlex.split(call.args[0]),+ input=call.kwargs["stdin"],+ env=env,+ capture_output=True,+ check=True,+ )+ assert result.stdout.decode().strip() == index+ assert "PIP_INDEX_URL" not in env+++ ("package", "install_count"), [("quicksand-agent", 2), ("quicksand-cua", 1)]+)+async def test_overlay_installer_commands_use_configured_indexes(+ monkeypatch, package, install_count+):+ index = "https://mirror.invalid/simple/"+ monkeypatch.setenv("PIP_INDEX_URL", index)+ hook_path = Path(__file__).parents[2] / "packages" / "contrib" / package / "hatch_build.py"+ hook = runpy.run_path(str(hook_path))+ shell = AsyncMock()++ await hook["_setup"](shell)++ installs = [+ call+ for call in shell.await_args_list+ if "uv venv" in call.args[0] or "pip install" in call.args[0]+ ]+ assert len(installs) == install_count+ for call in installs:+ assert json.loads(call.kwargs["stdin"]) == {"PIP_INDEX_URL": index}+ assert index not in call.args[0]