# Review unfamiliar code in a disposable VM

`qemu-review-vm.py` builds an empty Ubuntu VM, then gives each repository its
own disposable copy with restricted networking. Your AI agent reads the code
and explains what it finds. The helper does not decide whether a repository is
safe.

Read the helper before you run it, or ask your agent to read it and explain
what it does. The optional skill, `qemu-review-vm-skill.zip`, gives your agent
the full procedure; install it the way your agent installs skills, then ask it
to use `qemu-review-vm` for the repository you want reviewed.

## Install the host tools once

On macOS with Homebrew:

```sh
brew install python qemu
```

On Ubuntu/Debian ARM64:

```sh
sudo apt-get update
sudo apt-get install --no-install-recommends python3 curl openssh-client qemu-system-arm qemu-utils qemu-efi-aarch64 genisoimage
```

On x86_64 Linux, use `qemu-system-x86` and `ovmf` instead of `qemu-system-arm`
and `qemu-efi-aarch64`. Linux also needs hardware virtualization and access to
`/dev/kvm`. Run the helper as your ordinary user, not root.

## 1. Set up the empty base

```sh
python3 qemu-review-vm.py setup
```

This downloads Ubuntu, verifies its checksum, installs updates and leaves an
empty, powered-off base in `~/review-vm`. It takes a while on a slow
connection.

## 2. Review a repository

```sh
python3 qemu-review-vm.py review https://github.com/OWNER/REPO
```

Replace the URL with the public GitHub repository you want reviewed. The helper
makes a disposable copy of the base, fetches the repository inside it, restarts
it with restricted networking, then checks out the code and opens a terminal in
the project as the unprivileged `review` user.

Have the agent inspect the code there. If you decide to run the project's
tests, run them in that terminal. Missing dependencies stay missing: don't
reconnect the VM after running project code.

Type `exit` when you're finished. The copy is shut down and deleted. Keep the
agent's findings: the commit, file/line evidence, test results and anything it
didn't review.

## 3. Remove the base when you no longer need it

```sh
python3 qemu-review-vm.py remove
```

This deletes the base, any leftover copies and their logs. To get a newer
Ubuntu later, remove the base and run setup again.

## Storage and resources

Everything lives in the state directory, `~/review-vm` by default: the base,
the disposable copy during a review, and small logs. Each virtual disk can grow
to 30 GiB, so leave room for the base plus one copy. A running VM uses 2 CPUs
and 4 GiB of RAM.

To use another directory, put `--state PATH` before the action, and use the
same path for setup, review and remove. Don't store personal files there. The
helper won't overwrite an existing base or touch VMs it didn't create.

## When something goes wrong

Errors name the log to look at. A review copy is discarded when the session
ends, even if it won't shut down. If QEMU itself doesn't exit, or the base
doesn't shut down during setup, the files are kept and the error shows where,
rather than deleting a disk that is still in use. Downloads fail only if they
stall for five minutes, so a slow connection is fine. The helper uses local port 2222 for SSH; if something else is using it,
stop that first.

## Tested on

macOS on Apple Silicon and Ubuntu 24.04 on ARM64. Intel Macs and x86_64 Linux
haven't been tested.
