pi-microsandbox 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -57
- package/SECURITY.md +12 -8
- package/docs/commands.md +18 -14
- package/docs/configuration.md +49 -11
- package/docs/development.md +52 -10
- package/docs/getting-started.md +25 -8
- package/docs/images.md +18 -9
- package/docs/safety.md +43 -14
- package/docs/storage.md +63 -50
- package/docs/troubleshooting.md +54 -9
- package/extensions/pi-msb/command.ts +17 -189
- package/extensions/pi-msb/config.ts +191 -44
- package/extensions/pi-msb/control.ts +134 -302
- package/extensions/pi-msb/index.ts +2 -2
- package/extensions/pi-msb/labels.ts +46 -231
- package/extensions/pi-msb/locks.ts +4 -6
- package/extensions/pi-msb/prune.ts +16 -12
- package/extensions/pi-msb/sandbox-manager.ts +93 -143
- package/extensions/pi-msb/tools.ts +13 -26
- package/extensions/pi-msb/transport.ts +0 -18
- package/extensions/pi-msb/types.ts +42 -108
- package/extensions/pi-msb/workspace.ts +126 -0
- package/native/flock/prebuilds/darwin-arm64/flock.node +0 -0
- package/package.json +1 -1
- package/extensions/pi-msb/git.ts +0 -256
- package/extensions/pi-msb/storage.ts +0 -332
package/README.md
CHANGED
|
@@ -2,45 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
**Let your agents work. Stop babysitting every command.**
|
|
4
4
|
|
|
5
|
-
Give an agent a task and get on with your day.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
pi-microsandbox uses [Microsandbox](https://microsandbox.dev/) to run
|
|
5
|
+
Give an agent a task and get on with your day. pi-microsandbox uses
|
|
6
|
+
[Microsandbox](https://microsandbox.dev/) to run
|
|
9
7
|
[Pi](https://github.com/earendil-works/pi)'s file and shell tools in lightweight
|
|
10
8
|
microVMs. Microsandbox is an open-source, local-first runtime for isolating
|
|
11
9
|
untrusted workloads, with a separate Linux kernel for each sandbox.
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
boundaries. Set them up once, then let the agents get to work.
|
|
11
|
+
Each project can define its own environment and safety boundaries. Set them up
|
|
12
|
+
once, then let the agent get to work.
|
|
16
13
|
|
|
17
14
|
[Get started](#get-started) · [Documentation](#documentation) · [Releases](https://github.com/hcohe/pi-microsandbox/releases)
|
|
18
15
|
|
|
16
|
+
## Try it
|
|
17
|
+
|
|
18
|
+
Run Pi with pi-microsandbox for one session, without installing it:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
pi -e npm:pi-microsandbox
|
|
22
|
+
```
|
|
23
|
+
|
|
19
24
|
## Less supervision. More work getting done.
|
|
20
25
|
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
|
|
26
|
+
- Let routine file and shell work happen inside the sandbox. Host execution
|
|
27
|
+
stays an explicit escape, with approval required while the sandbox is active.
|
|
28
|
+
- Work at the same path inside and outside the VM. Sandboxed writes appear in
|
|
29
|
+
the host checkout immediately, with no export step.
|
|
30
|
+
- If the sandbox cannot start, routed tools stop by default. They do not quietly
|
|
31
|
+
run on your host instead.
|
|
25
32
|
|
|
26
|
-
You still review what the
|
|
27
|
-
on the results
|
|
33
|
+
You still review what the agent produces. The point is to spend your attention
|
|
34
|
+
on the results rather than supervise every step along the way.
|
|
35
|
+
|
|
36
|
+
## One workspace behavior
|
|
37
|
+
|
|
38
|
+
There are no workspace modes. If Pi starts inside a Git worktree,
|
|
39
|
+
pi-microsandbox mounts the whole worktree root read/write at the same lexical
|
|
40
|
+
path in the guest. If Pi starts outside Git, it mounts the current working
|
|
41
|
+
directory itself. Commands start in the original current working directory.
|
|
42
|
+
|
|
43
|
+
This is a VM boundary, not checkout isolation. The selected root is fully
|
|
44
|
+
visible, including `.git`, secrets such as `.env`, untracked files, and sibling
|
|
45
|
+
directories. Writes change the host immediately. Multiple sessions using the
|
|
46
|
+
same checkout share those files and can conflict; use separate host worktrees
|
|
47
|
+
or checkouts when you need independent changes. Containers started inside the
|
|
48
|
+
microVM can also reach the mounted workspace.
|
|
49
|
+
|
|
50
|
+
[Understand workspace storage and legacy-volume recovery →](docs/storage.md)
|
|
28
51
|
|
|
29
52
|
## Every project gets its own boundaries
|
|
30
53
|
|
|
31
|
-
Your frontend app and your internal service
|
|
54
|
+
Your frontend app and your internal service do not need the same sandbox.
|
|
32
55
|
Choose a [published variant or custom image](docs/images.md) with the tools a
|
|
33
56
|
project needs, allow only the network hosts it should reach, and configure its
|
|
34
|
-
file mounts and secrets. Another project can have a
|
|
57
|
+
extra file mounts and secrets. Another project can have a different setup,
|
|
35
58
|
including no network access.
|
|
36
59
|
|
|
37
|
-
Keep
|
|
60
|
+
Keep everyday defaults in global config and project-specific settings in
|
|
38
61
|
`.pi-msb.toml`. Trusted project config layers over those defaults; environment
|
|
39
|
-
variables and session overrides let you adjust a
|
|
40
|
-
|
|
62
|
+
variables and session overrides let you adjust a run without rewriting the
|
|
63
|
+
project setup.
|
|
41
64
|
|
|
42
|
-
The agent gets an environment built for the job.
|
|
43
|
-
|
|
65
|
+
The agent gets an environment built for the job. Image cohorts built from this
|
|
66
|
+
version include Docker Engine 29.8.0, Buildx 0.37.1, and Compose 5.5.1. The
|
|
67
|
+
daemon and its containers run inside the microVM; pi-microsandbox never connects
|
|
68
|
+
them to the host Docker socket. Nested containers can still access the mounted
|
|
69
|
+
workspace and remain subject to the outer network policy.
|
|
44
70
|
|
|
45
71
|
[Configure your project's sandbox →](docs/configuration.md)
|
|
46
72
|
|
|
@@ -50,67 +76,56 @@ You'll need Pi, **Node.js 22.19.0+**, and one of the supported host targets:
|
|
|
50
76
|
Apple Silicon macOS (`darwin-arm64`), GNU Linux x86_64
|
|
51
77
|
(`linux-x64-gnu`), or GNU Linux arm64 (`linux-arm64-gnu`). Live sandboxes also
|
|
52
78
|
need host virtualization support. The POSIX lock addon is bundled and installs
|
|
53
|
-
without lifecycle scripts or a compiler
|
|
54
|
-
for the Microsandbox platform package.
|
|
79
|
+
without lifecycle scripts or a compiler.
|
|
55
80
|
[Full requirements and installation help →](docs/getting-started.md)
|
|
56
81
|
|
|
57
|
-
Install
|
|
82
|
+
Install pi-microsandbox:
|
|
58
83
|
|
|
59
84
|
```sh
|
|
60
|
-
|
|
85
|
+
pi install npm:pi-microsandbox
|
|
61
86
|
```
|
|
62
87
|
|
|
63
|
-
|
|
64
|
-
runtime
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
That command also installs the pinned Microsandbox SDK, CLI, and matching
|
|
89
|
+
platform runtime. A separate Microsandbox installation is not required on a
|
|
90
|
+
supported host. Keep npm optional dependencies enabled so npm installs the
|
|
91
|
+
platform package.
|
|
67
92
|
|
|
68
|
-
|
|
93
|
+
If the platform package is unavailable, you can provide a standalone `msb`
|
|
94
|
+
binary with `MSB_PATH`. See the official
|
|
95
|
+
[Microsandbox documentation](https://docs.microsandbox.dev/) for standalone
|
|
96
|
+
installation and runtime troubleshooting. The documentation in this repository
|
|
97
|
+
covers the Pi integration.
|
|
69
98
|
|
|
70
|
-
|
|
71
|
-
pi install npm:pi-microsandbox
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
From a Git repository, start Pi with its own isolated workspace:
|
|
99
|
+
Start Pi from the directory where you want to work:
|
|
75
100
|
|
|
76
101
|
```sh
|
|
77
|
-
|
|
102
|
+
cd /path/to/project
|
|
103
|
+
pi
|
|
78
104
|
```
|
|
79
105
|
|
|
80
|
-
|
|
81
|
-
see first; untracked files such as `.env` and uncommitted edits stay out of the
|
|
82
|
-
initial copy. An existing retained workspace is reused for a matching session.
|
|
83
|
-
|
|
84
|
-
Once you're in Pi:
|
|
106
|
+
Once you're in Pi, inspect the selected workspace root:
|
|
85
107
|
|
|
86
108
|
```text
|
|
87
109
|
/msb status
|
|
88
110
|
```
|
|
89
111
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
workspace
|
|
93
|
-
|
|
94
|
-
When you're ready to review an agent's work, export a file to a new destination:
|
|
95
|
-
|
|
96
|
-
```text
|
|
97
|
-
/msb export src/example.ts --to ../sandbox-review
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Exports ask for confirmation and won't overwrite existing destinations.
|
|
101
|
-
See [storage and retained work](docs/storage.md) for the details.
|
|
112
|
+
> **Host execution is separate.** `/msb off` explicitly hands tools to the
|
|
113
|
+
> host. `fallback_mode = "host"` opts into automatic host execution after a
|
|
114
|
+
> sandbox failure. Neither control changes the workspace mount, and neither is
|
|
115
|
+
> sandboxed. The default fallback blocks tools when startup fails.
|
|
102
116
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
Upgrading from a release that used named Git volumes requires a manual recovery
|
|
118
|
+
check. Before upgrading, use the old `/msb volumes` and `/msb export` commands
|
|
119
|
+
to inventory and copy retained work. After upgrading, use Microsandbox's own
|
|
120
|
+
tooling to recover or remove legacy volumes; they are never deleted
|
|
121
|
+
automatically. See [workspace storage](docs/storage.md).
|
|
107
122
|
|
|
108
123
|
## Documentation
|
|
109
124
|
|
|
110
125
|
| When you want to… | Read |
|
|
111
126
|
| --- | --- |
|
|
112
127
|
| Install or check host support | [Getting started](docs/getting-started.md) |
|
|
113
|
-
|
|
|
128
|
+
| Understand the workspace mount or recover legacy volumes | [Storage](docs/storage.md) |
|
|
114
129
|
| Choose an image variant or build a custom image | [Images](docs/images.md) |
|
|
115
130
|
| Set up networking, secrets, mounts, or other options | [Configuration](docs/configuration.md) |
|
|
116
131
|
| Look up an `/msb` command | [Command reference](docs/commands.md) |
|
package/SECURITY.md
CHANGED
|
@@ -26,7 +26,7 @@ public channel.
|
|
|
26
26
|
A useful report includes the affected pi-microsandbox version or commit, Pi and
|
|
27
27
|
Node.js versions, host operating system and architecture, virtualization setup,
|
|
28
28
|
impact, and minimal reproduction steps. State whether the behavior requires a
|
|
29
|
-
particular
|
|
29
|
+
particular workspace layout, network policy, fallback setting, or host-execution
|
|
30
30
|
approval.
|
|
31
31
|
|
|
32
32
|
## Keep sensitive data out of reports
|
|
@@ -39,13 +39,17 @@ not include:
|
|
|
39
39
|
- resolved secret values from `$ENV:` or `$FILE:` references;
|
|
40
40
|
- complete sandbox logs, configuration dumps, session files, or command output
|
|
41
41
|
that may contain secrets;
|
|
42
|
-
-
|
|
43
|
-
data that is not essential to the report.
|
|
44
|
-
|
|
45
|
-
If a real secret may have been exposed, revoke or rotate it first.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
- workspace or legacy-volume contents, source code, `.env` files, or other
|
|
43
|
+
private user data that is not essential to the report.
|
|
44
|
+
|
|
45
|
+
If a real secret may have been exposed, revoke or rotate it first. The selected
|
|
46
|
+
workspace is mounted read/write: inside Git it includes the entire worktree,
|
|
47
|
+
including `.git`, secrets, untracked files, and sibling directories; outside
|
|
48
|
+
Git it is the current directory. Writes reach the host immediately, concurrent
|
|
49
|
+
sessions share the checkout, and nested containers can access the mount. Use
|
|
50
|
+
synthetic values in the reproduction and describe omitted material rather than
|
|
51
|
+
attaching it. Remember that GitHub advisory participants can read uploaded
|
|
52
|
+
artifacts, so a private report is not a reason to include unnecessary secrets.
|
|
49
53
|
|
|
50
54
|
## What happens next
|
|
51
55
|
|
package/docs/commands.md
CHANGED
|
@@ -8,9 +8,6 @@ The extension registers `/msb`:
|
|
|
8
8
|
/msb status
|
|
9
9
|
/msb on | off | reload
|
|
10
10
|
/msb prune
|
|
11
|
-
/msb volumes ls
|
|
12
|
-
/msb volumes rm <managed-name> [--yes]
|
|
13
|
-
/msb export <paths...> [--to dir] [--yes]
|
|
14
11
|
/msb logs [tail-lines]
|
|
15
12
|
/msb config
|
|
16
13
|
/msb set <key> <value>
|
|
@@ -23,16 +20,23 @@ The extension registers `/msb`:
|
|
|
23
20
|
/msb help
|
|
24
21
|
```
|
|
25
22
|
|
|
26
|
-
`/msb status` reports the full sandbox name,
|
|
27
|
-
and
|
|
28
|
-
display abbreviations only.
|
|
29
|
-
removed, kept, and error entries; **volumes are never pruned**.
|
|
23
|
+
`/msb status` reports the full sandbox name, mounted workspace root, image, PID,
|
|
24
|
+
age, and Docker mode, readiness, version, and storage driver. Six-character IDs
|
|
25
|
+
in UI text are display abbreviations only. There are no workspace modes.
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
without UI and the target has already been verified. Export rejects paths outside
|
|
35
|
-
the project and existing destinations; it also requires confirmation or
|
|
36
|
-
`--yes`.
|
|
27
|
+
`/msb prune` walks all SDK list pages and reports removed, kept, and error
|
|
28
|
+
entries. It can remove guarded stale sandboxes, including old-schema managed
|
|
29
|
+
sandboxes, but it never removes legacy named volumes.
|
|
37
30
|
|
|
38
|
-
|
|
31
|
+
`/msb off` explicitly switches to unsandboxed host execution. It is separate
|
|
32
|
+
from `fallback_mode = "host"`, which opts into automatic host execution after a
|
|
33
|
+
sandbox failure. With the default blocking fallback, startup failures fail
|
|
34
|
+
closed and routed tools do not silently run on the host.
|
|
35
|
+
|
|
36
|
+
The former `/msb volumes` and `/msb export` commands are not available. Files in
|
|
37
|
+
the current workspace already live on the host. Legacy named volumes from older
|
|
38
|
+
releases require manual inspection, recovery, and removal with Microsandbox's
|
|
39
|
+
own tooling; see [workspace storage](storage.md#upgrading-from-named-git-volumes).
|
|
40
|
+
|
|
41
|
+
For the narrow exceptions to sandboxed file reads, see
|
|
42
|
+
[host-read exceptions](safety.md#host-read-exceptions).
|
package/docs/configuration.md
CHANGED
|
@@ -7,17 +7,19 @@ CLI overrides. Global configuration is `$XDG_CONFIG_HOME/pi-msb/config.toml`
|
|
|
7
7
|
(or `~/.config/pi-msb/config.toml`) plus the optional `PI_MSB_CONFIG_FILE` in
|
|
8
8
|
the same layer. A trusted project may use the nearest `.pi-msb.toml` or
|
|
9
9
|
`<Pi CONFIG_DIR_NAME>/msb.toml`, stopping at the Git root. Untrusted project
|
|
10
|
-
configuration is ignored with a warning
|
|
10
|
+
configuration is ignored with a warning, except that removed workspace settings
|
|
11
|
+
still stop startup before any direct host write can occur.
|
|
11
12
|
|
|
12
13
|
TOML uses snake_case; environment variables use `PI_MSB_` with `__` for nesting.
|
|
13
14
|
The following is a small project example:
|
|
14
15
|
|
|
15
16
|
```toml
|
|
16
17
|
# .pi-msb.toml
|
|
17
|
-
|
|
18
|
-
image = "ghcr.io/hcohe/pi-microsandbox:1.0.0@sha256:00ea1e0911189815614e8a8eee36d1fd64f0f1edb39492e0bda9f273c834e59f"
|
|
18
|
+
image = "ghcr.io/hcohe/pi-microsandbox:1.1.0@sha256:ab4e99d4232f827b3f295ff3210437e01446dbb672ef0d0c78358566170ac86c"
|
|
19
19
|
pull_policy = "if-missing"
|
|
20
20
|
bootstrap_tools = "auto"
|
|
21
|
+
cpus = 4
|
|
22
|
+
memory_mib = 8192
|
|
21
23
|
idle_timeout_sec = 600
|
|
22
24
|
fallback_mode = "block"
|
|
23
25
|
show_footer = true # Default; set false to hide the MSB footer status.
|
|
@@ -26,6 +28,10 @@ show_footer = true # Default; set false to hide the MSB footer status.
|
|
|
26
28
|
mode = "default" # default | open | allowlist | deny
|
|
27
29
|
allow_dns = true
|
|
28
30
|
|
|
31
|
+
[docker]
|
|
32
|
+
mode = "auto" # auto | require | disabled
|
|
33
|
+
startup_timeout_ms = 15000
|
|
34
|
+
|
|
29
35
|
# Project secrets should use references, not literals.
|
|
30
36
|
[[secrets]]
|
|
31
37
|
env = "NPM_TOKEN"
|
|
@@ -35,32 +41,63 @@ allow_hosts = ["registry.npmjs.org"]
|
|
|
35
41
|
|
|
36
42
|
Important configuration behavior:
|
|
37
43
|
|
|
44
|
+
- There are no workspace modes or storage selection settings. Inside a Git
|
|
45
|
+
worktree, the whole worktree root is mounted read/write at the same lexical
|
|
46
|
+
guest path; elsewhere, the current directory is mounted. Commands retain the
|
|
47
|
+
original cwd, and writes reach the host immediately. The removed `mode`,
|
|
48
|
+
`clone_branch`, `clone_depth`, `shallow_archive`, and `volume_quota_mib`
|
|
49
|
+
settings, including `PI_MSB_MODE`, are startup errors rather than ignored
|
|
50
|
+
compatibility options.
|
|
38
51
|
- `show_footer = true` uses Pi's single custom-footer slot so the MSB status can
|
|
39
52
|
appear in the upper-right corner. It replaces Pi's built-in footer (or another
|
|
40
53
|
extension's custom footer), preserves the standard location, usage, model,
|
|
41
54
|
and shared status fields, but cannot show Pi-only indicators such as the
|
|
42
55
|
auto-compaction and experimental-feature markers.
|
|
43
|
-
- The default image is the complete Node.js, Python, Rust, and Go `1.
|
|
56
|
+
- The default image is the complete Node.js, Python, Rust, and Go `1.1.0`
|
|
44
57
|
variant, pinned to its immutable multi-platform digest. Image releases have
|
|
45
|
-
an independent version stream
|
|
46
|
-
|
|
58
|
+
an independent version stream from package releases. The default
|
|
59
|
+
`pull_policy = "if-missing"` pulls only when that exact reference is
|
|
47
60
|
absent from the Microsandbox cache. `"always"` and `"never"` are also
|
|
48
61
|
supported.
|
|
49
62
|
See [Images](images.md) for all published variants, exact tag patterns,
|
|
50
63
|
contents, custom image workflows, and the required guest commands.
|
|
51
64
|
`bootstrap_tools = "auto"` probes those commands and uses noninteractive
|
|
52
65
|
`apt-get` under the configured network policy when a custom image is missing
|
|
53
|
-
them. `false` blocks with the missing command list instead.
|
|
66
|
+
them. `false` blocks with the missing command list instead. New sandboxes use
|
|
67
|
+
4 CPUs and 8192 MiB by default; set `cpus` and `memory_mib` lower if the host
|
|
68
|
+
cannot support that allocation.
|
|
69
|
+
- `docker.mode = "auto"` starts the guest daemon when the image has Docker and
|
|
70
|
+
reports `missing` for older or custom images without it. `"require"` blocks
|
|
71
|
+
sandbox preparation if Docker is absent or cannot start. `"disabled"` leaves
|
|
72
|
+
the installed daemon stopped. `startup_timeout_ms` must be an integer from 1
|
|
73
|
+
through 300000. Readiness is pinned to the managed guest Unix socket and
|
|
74
|
+
ignores inherited Docker client endpoint settings. Docker state stays on the
|
|
75
|
+
disposable guest root filesystem. Small builds should have at least 1 GiB; larger Compose stacks usually need
|
|
76
|
+
2 GiB or more.
|
|
54
77
|
- `network.mode = "default"` leaves the SDK's default policy in place. `open`
|
|
55
78
|
allows all network traffic, including private/host access; `allowlist` is
|
|
56
79
|
default-deny with configured host/DNS rules; `deny` disables networking.
|
|
57
80
|
Published ports default to loopback unless a bind address is specified.
|
|
81
|
+
Nested containers remain subject to this outer policy. A Docker `-p` mapping
|
|
82
|
+
exposes a port only inside the microVM. Host access also needs a matching
|
|
83
|
+
`network.publish_ports` entry created with the sandbox, for example
|
|
84
|
+
`publish_ports = ["127.0.0.1:8080:8080"]` together with `docker run -p
|
|
85
|
+
0.0.0.0:8080:8080 ...`. Docker's random host-port form cannot create that
|
|
86
|
+
outer mapping.
|
|
58
87
|
- Secrets require a non-empty `allow_hosts` list. `$ENV:NAME` and `$FILE:path`
|
|
59
88
|
references are resolved only while constructing the SDK builder. Effective
|
|
60
|
-
config, warnings, errors, and `/msb config` redact literal values.
|
|
89
|
+
config, warnings, errors, and `/msb config` redact literal values. Process
|
|
90
|
+
control variables such as `DOCKER_HOST`, `DOCKER_CONTEXT`, `PATH`,
|
|
91
|
+
`BASH_ENV`, and `LD_PRELOAD` cannot be forwarded with `host_env` or injected
|
|
92
|
+
as secrets.
|
|
61
93
|
- Directory/file mounts have absolute guest paths. Project mounts outside the
|
|
62
|
-
|
|
63
|
-
write. Mounts may not overlap or shadow the project mount
|
|
94
|
+
selected workspace root must be read-only unless a global/session policy
|
|
95
|
+
authorizes the write. Mounts may not overlap or shadow the project mount,
|
|
96
|
+
reserved `/tmp`,
|
|
97
|
+
protected guest system trees such as `/usr`, `/bin`, `/proc`, and `/sys`, or
|
|
98
|
+
Docker runtime paths such as `/run`, `/var/run`, and `/var/lib/docker`.
|
|
99
|
+
Host mount sources are canonicalized before use; socket targets, including
|
|
100
|
+
Docker sockets reached through symlink aliases, are rejected.
|
|
64
101
|
- The legacy `host_ro_allowlist` is converted to canonical read-only mounts and
|
|
65
102
|
emits a deprecation warning.
|
|
66
103
|
|
|
@@ -68,9 +105,10 @@ Useful environment controls include:
|
|
|
68
105
|
|
|
69
106
|
```sh
|
|
70
107
|
PI_MSB_DISABLE=1 # explicit host/off mode
|
|
71
|
-
PI_MSB_MODE=none # nested scalar example
|
|
72
108
|
PI_MSB_PULL_POLICY=always # recheck mutable custom image tags on creation
|
|
73
109
|
PI_MSB_NETWORK__MODE=deny # nested environment key
|
|
110
|
+
PI_MSB_DOCKER__MODE=require # require a working guest Docker daemon
|
|
111
|
+
PI_MSB_DOCKER__STARTUP_TIMEOUT_MS=30000
|
|
74
112
|
PI_MSB_FALLBACK_MODE=host # opt into automatic host fallback
|
|
75
113
|
PI_MSB_SHOW_FOOTER=false # hide the MSB status from Pi's footer
|
|
76
114
|
PI_MSB_ROUTE_TOOLS='read,write' # POSIX delimiter for simple arrays
|
package/docs/development.md
CHANGED
|
@@ -23,6 +23,28 @@ npm audit --omit=dev
|
|
|
23
23
|
The smoke and unit tests do not require KVM, image pulls, or a live sandbox.
|
|
24
24
|
The boot-speed check and live matrix below are explicit VM tests.
|
|
25
25
|
|
|
26
|
+
To test the current extension and default image together, run:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
just dev
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`dev-flock` builds and smoke-tests the native owner-lock addon for the current
|
|
33
|
+
host. `dev-image` builds the current `default` variant as
|
|
34
|
+
`pi-microsandbox-dev:local` and imports it into Microsandbox's separate image
|
|
35
|
+
cache. `dev` runs both prerequisites, then starts Pi with this checkout's
|
|
36
|
+
extension explicitly loaded alongside your normal discovered extensions. It
|
|
37
|
+
forces the local image with `pull_policy = "never"`, requires Docker, and uses
|
|
38
|
+
4 CPUs and 8192 MiB. Docker caching keeps repeat builds short
|
|
39
|
+
when image inputs have not changed. Pass Pi arguments directly, for example:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
just dev --continue
|
|
43
|
+
just dev "Run docker info and report the storage driver"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Run `just dev-image` by itself when you only need to refresh the local image.
|
|
47
|
+
|
|
26
48
|
### Bundled flock addon
|
|
27
49
|
|
|
28
50
|
Consumers receive prebuilt lock addons and do not need native build tools. Only
|
|
@@ -81,9 +103,9 @@ just test-boot-speed
|
|
|
81
103
|
```
|
|
82
104
|
|
|
83
105
|
The tool performs one unmeasured warm-up, then three fresh boots using the
|
|
84
|
-
default prepared image. It
|
|
85
|
-
|
|
86
|
-
|
|
106
|
+
default prepared image. It disables guest networking and stale-resource
|
|
107
|
+
pruning, and sets `bootstrap_tools = false` so the result measures repeat boot
|
|
108
|
+
and readiness rather than an image pull or package install.
|
|
87
109
|
The p95 must be at most 2,000 ms. Every sandbox is shut down and removed. If
|
|
88
110
|
lifecycle cleanup fails, the test fails and retains its reported `.tmp` directory
|
|
89
111
|
for recovery instead of claiming success.
|
|
@@ -105,9 +127,9 @@ as the live matrix.
|
|
|
105
127
|
## Live test matrix
|
|
106
128
|
|
|
107
129
|
From a source checkout, the live matrix is opt-in because it can pull an image,
|
|
108
|
-
start VMs,
|
|
109
|
-
only from a trusted checkout on a disposable test host after
|
|
110
|
-
script:
|
|
130
|
+
start VMs, write through the host workspace mount, and use network and disk
|
|
131
|
+
capacity. Run it only from a trusted checkout on a disposable test host after
|
|
132
|
+
reviewing the script:
|
|
111
133
|
|
|
112
134
|
```sh
|
|
113
135
|
PI_MSB_LIVE_TEST=1 ./scripts/e2e-smoke.sh
|
|
@@ -117,14 +139,24 @@ Without that variable the script prints a `SKIP` line for every scenario and
|
|
|
117
139
|
exits successfully; this skip path does not validate virtualization. If
|
|
118
140
|
virtualization is unavailable, it prints the reason and skips the matrix rather
|
|
119
141
|
than reporting false failures. Set `PI_MSB_LIVE_IMAGE` to select the main live
|
|
120
|
-
test image; the default is `ghcr.io/hcohe/pi-microsandbox:latest`.
|
|
142
|
+
test image; the default is `ghcr.io/hcohe/pi-microsandbox:latest`. The main
|
|
143
|
+
scenarios use `pull_policy = "always"` by default. To test an image already
|
|
144
|
+
imported with `msb load`, set `PI_MSB_LIVE_PULL_POLICY=never`; do not use that
|
|
145
|
+
override as evidence for a published image.
|
|
121
146
|
The prepared-image scenario boots all six latest variant tags under
|
|
122
147
|
`network.mode = "deny"` with bootstrap disabled. Set
|
|
123
148
|
`PI_MSB_LIVE_PREPARED_IMAGES` to a comma-separated image cohort, or use the
|
|
124
149
|
legacy singular `PI_MSB_LIVE_PREPARED_IMAGE` to test one image. The live matrix
|
|
125
150
|
uses `pull_policy = "always"` intentionally so mutable development tags cannot
|
|
126
|
-
remain stale on the self-hosted runner. Review the output to confirm that
|
|
127
|
-
|
|
151
|
+
remain stale on the self-hosted runner. Review the output to confirm that every scenario reports `PASS`, not `SKIP`.
|
|
152
|
+
The workspace scenarios must show that a Git subdirectory mounts the whole
|
|
153
|
+
worktree, a non-Git cwd mounts itself, and routed writes appear immediately on
|
|
154
|
+
the host. They also cover off/on and reload, stale-sandbox pruning, fail-closed
|
|
155
|
+
boot errors, and approved host execution. Docker release validation must cover
|
|
156
|
+
daemon readiness, bridge DNS and HTTPS, user-defined networking, Buildx,
|
|
157
|
+
Compose, idle wake, double port publishing, nested-container access to the
|
|
158
|
+
workspace, and network enforcement for deny and allowlist policies. A skipped
|
|
159
|
+
scenario is not release evidence.
|
|
128
160
|
|
|
129
161
|
## Image development
|
|
130
162
|
|
|
@@ -135,7 +167,17 @@ variant's mutable latest tag and a commit-specific tag. Release builds pin the
|
|
|
135
167
|
Ubuntu image digest and one dated apt snapshot for all variants, while published
|
|
136
168
|
images restore normal apt sources for project use. See [Images](images.md#add-a-language-variant)
|
|
137
169
|
for the modular installer and verifier architecture, contribution rules, and
|
|
138
|
-
local validation commands.
|
|
170
|
+
local validation commands. Docker changes must also pass:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
node scripts/image-variants.mjs matrix
|
|
174
|
+
shellcheck -e SC1091 default-image/install/*.sh default-image/verify/*.sh
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The common image verifier checks Docker Engine 29.8.0, containerd 2.3.4, runc
|
|
178
|
+
1.5.1, Buildx 0.37.1, Compose 5.5.1, and Ubuntu's iptables-nft/nftables tools.
|
|
179
|
+
Docker daemon and nested-container behavior require the live microVM matrix;
|
|
180
|
+
they cannot be validated during a Dockerfile build.
|
|
139
181
|
|
|
140
182
|
## Releases
|
|
141
183
|
|
package/docs/getting-started.md
CHANGED
|
@@ -24,12 +24,12 @@ It is loaded lazily when an owner lock is first needed. Consumer installation
|
|
|
24
24
|
does not compile native code or require Python, a C/C++ toolchain, or npm
|
|
25
25
|
lifecycle scripts; installation with scripts disabled is supported.
|
|
26
26
|
|
|
27
|
-
Keep optional dependencies enabled. `microsandbox@0.6.16` supplies its
|
|
28
|
-
native addon and runtime binaries through an optional platform package. If that
|
|
27
|
+
Keep optional dependencies enabled. `microsandbox@0.6.16` supplies its CLI,
|
|
28
|
+
native addon, and runtime binaries through an optional platform package. If that
|
|
29
29
|
platform package is missing, reinstall with optional dependencies enabled,
|
|
30
30
|
install the matching Microsandbox platform package, or set `MSB_PATH` to a
|
|
31
|
-
working `msb` binary. These alternatives do not remove the host
|
|
32
|
-
requirement.
|
|
31
|
+
working standalone `msb` binary. These alternatives do not remove the host
|
|
32
|
+
virtualization requirement.
|
|
33
33
|
|
|
34
34
|
## Install
|
|
35
35
|
|
|
@@ -39,6 +39,11 @@ Install the package for the current user with Pi:
|
|
|
39
39
|
pi install npm:pi-microsandbox
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
This is the only package installation step on a supported host. The dependency
|
|
43
|
+
includes the Microsandbox SDK and CLI; its matching optional platform package
|
|
44
|
+
includes the host runtime. You do not need to run the standalone Microsandbox
|
|
45
|
+
installer first.
|
|
46
|
+
|
|
42
47
|
Before starting a sandbox, review [configuration](configuration.md) and choose a
|
|
43
48
|
[published variant or custom image](images.md) if the versioned default image
|
|
44
49
|
does not fit the project.
|
|
@@ -59,7 +64,19 @@ blocks routed tools rather than silently running them on the host. Keep that
|
|
|
59
64
|
default for a fail-closed setup. `fallback_mode = "host"` is an explicit,
|
|
60
65
|
visibly labelled opt-in to automatic unsandboxed execution.
|
|
61
66
|
|
|
62
|
-
The public package is named `pi-microsandbox`.
|
|
63
|
-
retain the shorter `msb` name
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
The public package is named `pi-microsandbox`. Current technical interfaces
|
|
68
|
+
retain the shorter `msb` name, including `/msb`, `PI_MSB_*`, `.pi-msb.toml`,
|
|
69
|
+
configuration directories, and managed-resource labels.
|
|
70
|
+
|
|
71
|
+
There are no workspace modes. Starting inside Git mounts the entire worktree
|
|
72
|
+
root read/write; starting elsewhere mounts the cwd. The mount uses the same
|
|
73
|
+
lexical guest path, commands retain their original cwd, and writes reach the
|
|
74
|
+
host immediately. This exposes `.git`, secrets, untracked files, and sibling
|
|
75
|
+
directories. Concurrent sessions share a checkout, and nested containers can
|
|
76
|
+
reach the mount.
|
|
77
|
+
|
|
78
|
+
Before upgrading from a release with named Git workspaces, use its `/msb
|
|
79
|
+
volumes` and `/msb export` commands to inventory and copy retained work. The new
|
|
80
|
+
release neither reconnects nor deletes legacy volumes. Recover or remove them
|
|
81
|
+
manually with Microsandbox tooling after confirming their contents. Removed
|
|
82
|
+
settings such as `mode` and `PI_MSB_MODE` are errors, not compatibility aliases.
|
package/docs/images.md
CHANGED
|
@@ -15,7 +15,7 @@ Push an exact `image-vVERSION` Git tag to publish a release cohort. Package
|
|
|
15
15
|
|
|
16
16
|
| Variant | Contents | Release tag | Latest tag |
|
|
17
17
|
| --- | --- | --- | --- |
|
|
18
|
-
| `base` | Required guest commands
|
|
18
|
+
| `base` | Required guest commands, CA certificates, Docker 29.8.0, Buildx 0.37.1, and Compose 5.5.1; no language toolchain | `base-VERSION` | `base-latest` |
|
|
19
19
|
| `node` | Base plus Node.js 24.21.0, npm, pnpm 12.3.4, Yarn 1.22.22, and native addon build support | `node-VERSION` | `node-latest` |
|
|
20
20
|
| `python` | Base plus Ubuntu Python 3, pip, uv/uvx 0.12.12, and native extension build support | `python-VERSION` | `python-latest` |
|
|
21
21
|
| `rust` | Base plus Rust 1.98.0, Cargo, rustup, and native dependency build support | `rust-VERSION` | `rust-latest` |
|
|
@@ -23,8 +23,12 @@ Push an exact `image-vVERSION` Git tag to publish a release cohort. Package
|
|
|
23
23
|
| `default` | Base plus the Node.js, Python, Rust, and Go modules above | `VERSION` | `latest` |
|
|
24
24
|
|
|
25
25
|
The base contract includes `bash`, `sh`, `git`, `rg`, `file`, `cat`, `mkdir`,
|
|
26
|
-
`rm`,
|
|
27
|
-
|
|
26
|
+
`rm`, Docker Engine and CLI 29.8.0, containerd 2.3.4, runc 1.5.1, Buildx
|
|
27
|
+
0.37.1, Compose 5.5.1, and the Ubuntu iptables-nft and nftables tools. CA
|
|
28
|
+
certificates support HTTPS Git operations. Docker is part of the common base
|
|
29
|
+
rather than a language toolchain, so all six variants built from this version
|
|
30
|
+
contain it. The extension's digest-pinned default changes only after that cohort
|
|
31
|
+
has been published and verified.
|
|
28
32
|
|
|
29
33
|
Select a variant in trusted project configuration:
|
|
30
34
|
|
|
@@ -46,10 +50,10 @@ an updated mutable tag, or `"never"` to require a cached local image.
|
|
|
46
50
|
[`default-image/variants.json`](../default-image/variants.json) is the single
|
|
47
51
|
source of variant composition and tag names. The workflow passes each entry's
|
|
48
52
|
toolchain list to one generic
|
|
49
|
-
[`default-image/Dockerfile`](../default-image/Dockerfile).
|
|
50
|
-
`default-image/install/<language>.sh`
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
[`default-image/Dockerfile`](../default-image/Dockerfile). The common Docker installer runs before the modular
|
|
54
|
+
`default-image/install/<language>.sh` scripts. The corresponding common
|
|
55
|
+
verifier checks Docker and its CLI plugins in every variant; language verifiers
|
|
56
|
+
then exercise each selected toolchain.
|
|
53
57
|
|
|
54
58
|
The `default` variant runs the same Node.js, Python, Rust, and Go modules as the
|
|
55
59
|
individual variants. It does not have a duplicate package list. This keeps an
|
|
@@ -62,8 +66,13 @@ can install current packages at runtime.
|
|
|
62
66
|
|
|
63
67
|
## Build a custom image
|
|
64
68
|
|
|
65
|
-
A custom image must provide `bash`, `sh`, `
|
|
66
|
-
|
|
69
|
+
A custom image must provide `bash`, `sh`, `rg`, `file`, `cat`, `mkdir`, and
|
|
70
|
+
`rm`. Git is a useful developer tool and remains in the published images, but
|
|
71
|
+
workspace setup no longer requires it inside the guest. Docker is optional for
|
|
72
|
+
custom images. The default `docker.mode = "auto"` records it as missing and
|
|
73
|
+
continues; use `docker.mode = "require"` when the image contract must include a
|
|
74
|
+
working daemon. pi-microsandbox does not install Docker during sandbox startup.
|
|
75
|
+
Install Git and CA certificates if guest commands need Git over HTTPS. With
|
|
67
76
|
`bootstrap_tools = "auto"`, pi-microsandbox can install missing required
|
|
68
77
|
commands through `apt-get` when the network policy permits it. A prepared image
|
|
69
78
|
is required when bootstrap is disabled or package repositories are unavailable.
|