How to develop from a Linux sandbox
This guide sets up the usual way of working on razorbill: the code is edited (by you or by Claude Code) in a Linux Docker sandbox (sbx), and everything that needs the Mac's GPU — building with Metal, the MLX tests, running models — is sent to the Mac through host-runner. It assumes Docker Sandboxes (sbx) is installed on the Mac.
1. Start the sandbox
On the Mac, from the repository root (where sbxenv.yaml is):
sbx env run --force
sbxenv.yaml describes the sandbox: the repository as workspace (mounted at the same path as on the Mac), the swift-toolchain-kit kit that brings the Swift toolchain for Linux, and the agent (Claude Code). --force skips the confirmation of the plan.
2. Start host-runner on the Mac
In a second terminal on the Mac, from the repository root:
python3 tools/host-runner/host_runner.py
It listens on 127.0.0.1:7777 and prints each command it runs. Leave it open while you work; Ctrl-C stops it. Restart it after pulling changes to tools/host-runner/.
If the sandbox later gets an HTTP 403 for host.docker.internal:7777, allow the port once, on the Mac:
sbx policy allow network localhost:7777
3. Check the connection from the sandbox
tools/host-runner/host.sh health
# ok /Users/…/razorbill
4. Work
In the sandbox:
scripts/test.sh # Linux: everything except MLX
swiftlint lint --quiet Sources Tests
tools/host-runner/host.sh build . razorbill # Mac: Release build with Metal
tools/host-runner/host.sh test . razorbill # Mac: the whole suite, MLX included
tools/host-runner/host.sh run . rzb models list
The script's exit code is the command's exit code on the Mac, so it can be chained like a local command. Files edited in the sandbox are the files the Mac builds: there is nothing to copy.
Limits
host.sh runhas no terminal, and waits for the command to end: do not use it forrzb serve. Killinghost.shin the sandbox does not stop the server on the Mac, and host-runner then answers 409 to everything until you stoprzb serveon the Mac. Start the server in a terminal on the Mac instead; the sandbox reaches it athttp://host.docker.internal:7920/v1(allow it once withsbx policy allow network localhost:7920).- host-runner runs one command at a time (a second request gets HTTP 409) and only knows
list,build,test,run,resolveandclean, on.orexperiments/<name>. - Models are downloaded into the Mac's Hugging Face cache; the sandbox cannot see it.
Variants
- Quality tools in the sandbox:
swiftlintandqltyare not part of the Swift toolchain kit. Install them as thequalityskill describes (section 0). What is installed outside$HOMEdisappears when the sandbox is recreated (--force); to keep them, add them to a kit listed underkits:insbxenv.yaml(for example a new version ofswift-toolchain-kit). - An experiment instead of the package:
tools/host-runner/host.sh build experiments/01-query-model query-model.
See also
- What host-runner allows and how it is secured: tools/host-runner/README.md.
- Running the tests: Run the tests.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|