CI and upgrades¶
How to test code that uses fastsandbox in a CI, what to check before you run it on a machine of its own, and how to upgrade fastsandbox and Docker Sandboxes without breaking it.
Testing in CI¶
Most of what a program does with fastsandbox can be tested without Docker
Sandboxes: FakeDaemon serves the socket
API from memory, and fake_package() writes kit packages that need neither
sbx nor an image. Any runner can run those tests: no daemon, no microVM, no
virtualization, no secret. See Testing.
The fake daemon does not prove what only the real one does:
- commands do not run: what they print is what the test says;
- network rules are recorded, not enforced, and there is no proxy: no key is written into a request, none is withheld;
- sandboxes never stop by themselves, and a stopped one does not refuse commands;
- install commands do not run, and a creation never fails in the daemon;
- the events, the prompts, the activity log, the MCP gateway and SSH are not served.
Test those against a real daemon, on a machine where Docker Sandboxes runs. fastsandbox's own CI runs its tests against the fake daemon only, on Linux and macOS; it has never run a real sandbox on a hosted runner. Running Docker Sandboxes in CI needs a runner where it installs and its daemon runs for the CI user, with the virtualization its microVMs need: see the Docker documentation. Such a setup is possible as far as fastsandbox is concerned, and not tested by this project.
Before running it unattended¶
- Run the program as a user of its own: the daemon, its socket, its global policy and the credentials it holds are per user, and whoever can open the socket controls every sandbox of that user.
- Check the global policy of that user's daemon,
sbx policy ls, and pick its preset for the work: see the network model. - Give the program its keys in its environment, with the narrowest rights and a spending limit at their provider.
- Bound its runs with
max_concurrency, give its tasks atimeout, and remove what a crash leaves: see Failures and cleanup. - Go through the checklist of the security model.
Versions¶
| What | Supported | Where it is checked |
|---|---|---|
| The socket API of the daemon | The range of SUPPORTED_API of the installed release |
At each connection: connect() refuses a daemon outside it, unless told otherwise |
| Python | 3.12 and later | At installation |
| fastsandbox | Its own version: before 1.0, a minor version may break the API | The changelog |
The API of the daemon is private and changes with sbx releases. Pin
fastsandbox to a minor version, uv add "fastsandbox>=0.2,<0.3", and upgrade
it on purpose.
Upgrading¶
- Read the changelog of the new release of fastsandbox, its breaking changes above all.
- Upgrade
sbxor fastsandbox, then check that they fit:fastsandbox infoprints the API version of the daemon beside the supported range. - Run your tests, against the fake daemon and, where you can, a real one.
A daemon outside the range makes connect() and every task raise
UnsupportedVersionError.
To go on at your own risk while a release catches up, connect with
connect(version_policy="warn") and give that client to the application,
FastSandbox(client=...).
Kit packages kept in a directory suit the version of the crates that forged them and the API version they were forged for: after an upgrade of either, they are forged again on first use, which takes a little time once.
To roll back, install the previous release of fastsandbox,
uv add "fastsandbox==0.2.0" for instance. A release supports only the API
versions of its range: rolling sbx back is done with the means Docker
Sandboxes provides.
Next¶
- Testing: the fake daemon.
- Compatibility: platforms, Python, the API range.
- Security model.