Experiment Specification: Stock Apple Containers vs Direct Containerization for isolate
Current fork support: macOS 27+ Apple Silicon hosts only. Any lower macOS API/deployment floor in this design record is historical or component detail; Linux guests remain in scope.
Status: Run and concluded: results and decision in apple-sandbox-runtime.md; Track B’s checks live on as tests/integration-apple-sandbox.sh
Target product: macOS 27+ / Apple Silicon isolate fork
Objective: Determine whether stock Apple container containers can replace a fork of container machine; if not, determine whether a small purpose-built runtime on apple/containerization can satisfy the end-state architecture without forking the full Apple Container machine subsystem.
Date: 2026-09-25
Baseline versions
Primary baseline:
- macOS: 27.x, Apple Silicon
- Apple
container: 1.4.1, released 2026-09-09 apple/containerization: 0.45.0 (the version pinned bycontainer1.4.1)- isolate reference:
chr33s/isomain atdb5eb22850880db671d82b787b61d8394fe6f256
A second, non-decisive compatibility run MAY be made against current apple/container and apple/containerization main after the release-pinned experiment passes. Results from unreleased main MUST NOT be used to claim that the released runtime satisfies a requirement.
1. Question being answered
Can isolate use ordinary stock Apple containers as its persistent VM sandbox primitive while preserving the existing security model and the proposed OCI-first end state?
If not, can isolate satisfy the same requirements by using Apple Containerization directly through a small Swift runtime without adopting or forking the general-purpose container machine layer?
The experiment is not trying to prove that either approach is generally better. It is trying to identify the smallest runtime architecture that fully satisfies isolate’s requirements.
2. Competing architectures
Track A — stock Apple containers
iso experiment harness
|
| stock public CLI only
v
Apple `container` 1.4.1
|
v
container-apiserver / runtime helpers
|
v
one Linux VM per ordinary container
The intended sandbox is created with a stock container roughly equivalent to:
container network create <unique-network>
container create \
--name <sandbox> \
--network <unique-network> \
--cpus 4 \
--memory 8g \
--cap-add ALL \
--masked-path NONE \
--read-only-path NONE \
--entrypoint /sbin/init \
<iso-machine-image>
Notably absent:
--ssh
--mount
--volume
--publish
--publish-socket
No patched Apple runtime is allowed in Track A.
Track B — direct Containerization
Rust experiment driver
|
| small versioned protocol or direct test invocation
v
Swift sandbox runtime
|
v
apple/containerization 0.45.0
|
v
Virtualization.framework + vmnet
Track B uses the public Swift package directly and implements only the sandbox primitives isolate needs.
It does not fork or import container machine.
3. Hypotheses
H-A: stock containers are sufficient
An ordinary Apple container can behave as isolate’s persistent machine if the OCI workload uses systemd as its main process, receives the Linux capabilities needed for Docker, is attached to a unique custom network, and receives no host integration.
Expected advantages:
- no Apple runtime fork;
- standard OCI image lifecycle;
- stock update path;
- one VM per agent already provided;
- mounts, SSH-agent forwarding, and published ports are opt-in rather than automatic;
- machine security policy can be verified from
container inspect.
Primary uncertainty:
- whether normal container lifecycle exposes enough persistent-machine resource and disk management for the desired isolate end state.
H-B: direct Containerization is sufficient
If stock containers are lifecycle-incomplete, Containerization provides enough lower-level primitives to implement a small iso-specific sandbox runtime without reimplementing a general container platform.
Expected advantages:
- explicit rootfs and writable-layer sizing;
- direct control of network interfaces and VM configuration;
- direct OCI/ext4/VM primitives;
- no unwanted general-purpose machine defaults;
- secure sandbox shape can be encoded in the API.
Primary uncertainty:
- how much lifecycle, persistence, networking, recovery, and service management isolate must own itself.
4. Hard security invariants
Both tracks MUST satisfy every invariant below.
Failure of any invariant is a hard failure for that track unless the failure is clearly an experiment-harness bug.
S1 — one VM per sandbox
Each isolate sandbox MUST execute in a distinct Linux VM.
No shared Linux kernel between two isolate sandboxes.
S2 — dedicated network
Each sandbox MUST be attached to exactly one network unique to that sandbox.
The default/shared Apple network is forbidden.
S3 — peer isolation
A root-controlled guest A MUST NOT reach guest B by:
- IPv4 TCP;
- IPv4 UDP;
- IPv4 ICMP;
- IPv6 TCP;
- IPv6 UDP;
- IPv6 ICMP;
- forged on-link routes;
- source-address spoofing;
- ARP/NDP/neighbor manipulation;
- broadcast/multicast where applicable.
The test must be performed on real macOS 27 hardware.
Guest firewall rules do not count as isolation.
S4 — no host SSH agent
The guest MUST NOT receive:
SSH_AUTH_SOCK;- the host SSH agent Unix socket;
- an equivalent host signing proxy.
A root guest must not be able to discover or use one.
S5 — no host filesystem exposure
The guest MUST NOT receive:
$HOME;- the project directory;
- arbitrary host directories;
- arbitrary host files;
- host credential sockets.
Runtime-internal bootstrap files are allowed only when their source is runtime-owned and tightly scoped.
S6 — no runtime-published ports or sockets
The sandbox configuration MUST contain no host port publication and no host socket publication.
Later iso-managed SSH forwards are out of scope for the runtime primitive and are tested separately.
S7 — explicit ownership
The harness MUST be able to distinguish its own resources from unrelated Apple Container resources.
Deletion MUST operate only on experiment-owned resources.
Use random IDs plus labels where available.
S8 — pinned guest identity
The experiment MUST demonstrate a path to:
- enroll a per-instance SSH client public key without relying on unverified SSH;
- read the guest SSH Ed25519 host public key over a trusted native control path;
- pin the key on the host;
- reconnect with
StrictHostKeyChecking=yes; - fail on host-key replacement;
- never auto-reenroll.
For Track A, stock container exec may serve as the native enrollment/control path.
For Track B, LinuxProcess/guest RPC or an equivalent native control path may serve this role.
S9 — no secret leakage through runtime
A canary secret supplied only to the host test process MUST NOT appear in:
- runtime process argv;
- runtime child environment unless explicitly required by the test;
container inspect;- runtime logs;
- OCI image layers;
- sandbox filesystem before explicit credential bootstrap.
S10 — fail-closed effective inspection
Before the harness declares a sandbox safe, it MUST be able to read effective state sufficient to verify:
- sandbox identity;
- image identity;
- networks;
- mounts;
- SSH forwarding state or proof of absence;
- published ports;
- published sockets;
- CPU/memory configuration.
If effective state cannot be verified, the track fails the security contract.
5. Required product behavior
These requirements determine whether a security-valid runtime is actually useful for isolate.
P1 — OCI-native image
The reusable environment is a standard OCI image built from a Dockerfile/Containerfile.
The image MUST be usable by normal OCI tooling and identified by digest.
P2 — systemd guest
The sandbox MUST boot a normal distro userspace with systemd sufficient to manage:
- sshd;
- Docker daemon;
- supporting guest services.
systemctl is-system-running may report a degraded state if only known irrelevant units fail, but the experiment must record the exact state and failed units.
P3 — Docker inside guest
Inside the sandbox:
docker info
docker run --rm hello-world
or an equivalent deterministic local test MUST succeed.
A stronger nested workload test SHOULD run a multi-process image or Docker build.
P4 — persistent filesystem across stop/start
Write a random marker to:
/root or /var/lib/iso-experiment
and to Docker state.
Stop the sandbox using the runtime’s normal stop path.
Start the same sandbox again.
Both marker and expected Docker state MUST remain.
P5 — stable machine identity across normal restart
The guest’s generated:
- machine-id;
- SSH host key
MUST remain unchanged across normal stop/start.
A recreate from the same OCI image MUST produce new values.
P6 — CPU and memory configuration
The runtime MUST support setting CPU and memory at creation.
The guest MUST observe the expected values within documented runtime semantics.
P7 — CPU and memory mutation
Desired end state: change CPU/memory for a stopped sandbox without rebuilding the environment.
Test whether the track can:
- stop;
- alter values;
- restart;
- read back the new values;
- preserve guest disk identity.
If not possible, record as a lifecycle gap.
P8 — explicit disk size
Desired end state: create a sandbox with a requested root/writable capacity, e.g.:
8 GiB
32 GiB
64 GiB
The guest must observe a filesystem capacity consistent with the requested value.
Stock Track A must use only public stock surfaces. Hidden/private Apple APIs do not count.
P9 — disk growth
Desired end state: grow a stopped 8-GiB sandbox to 32 GiB without replacing its logical instance or losing data.
Read back and verify the resulting guest filesystem capacity.
Shrink is not required.
P10 — local checkpoint/restore
Desired end state:
- write state A;
- create checkpoint;
- mutate to state B;
- restore checkpoint;
- observe state A.
A raw filesystem export MAY be tested as an approximation, but it does not count as a successful checkpoint implementation unless it can restore the same logical instance with acceptable performance and identity semantics.
P11 — logs
The runtime must provide useful:
- workload/system logs;
- VM boot logs or equivalent diagnostics.
Logs must be streamable or incrementally readable.
P12 — crash recovery
The runtime must survive or cleanly reconcile:
- client process killed during create;
- client killed during boot;
- client killed during stop;
- client killed during delete;
- runtime service restart;
- VM process crash.
A retry must result in a known state.
P13 — concurrent sandboxes
Run at least:
1
4
8
sandboxes concurrently.
Validate:
- isolation still holds;
- unique networks/addresses;
- Docker works;
- no cross-resource deletion;
- startup remains bounded.
P14 — workspace copy workflow
Without host mounts:
- copy a git repo into
/workspace; - mutate files in guest;
- copy results back;
- verify checksums;
- ensure no runtime feature implicitly shares the host source directory.
This does not need the full isolate push/pull implementation; it proves the runtime primitive does not block it.
6. Experiment repository layout
Do not initially modify isolate lifecycle code.
Create an isolated experimental workspace, for example:
experiments/apple-sandbox/
├── README.md
├── results/
│ ├── environment.json
│ ├── track-a/
│ └── track-b/
├── image/
│ ├── Dockerfile
│ ├── machine-setup.sh
│ ├── sshd.conf
│ └── verify.sh
├── scripts/
│ ├── common.sh
│ ├── peer-isolation.sh
│ ├── host-exposure.sh
│ ├── persistence.sh
│ ├── docker.sh
│ ├── ssh-identity.sh
│ ├── crash-injection.sh
│ └── benchmark.sh
├── stock/
│ └── run-experiment.sh
└── direct/
├── Package.swift
├── Sources/
│ └── IsoSandboxExperiment/
└── Tests/
The harness should produce machine-readable JSON results plus raw logs.
7. Common OCI test image
Both tracks MUST consume functionally equivalent OCI image contents.
7.1 Base
Use:
ubuntu:24.04
linux/arm64
Pin the resolved base digest in results/environment.json.
7.2 Required packages
At minimum:
systemd
systemd-sysv
dbus
openssh-server
sudo
curl
ca-certificates
iproute2
iputils-ping
netcat-openbsd
socat
procps
jq
docker-ce
docker-ce-cli
containerd.io
docker-buildx-plugin
docker-compose-plugin
7.3 Guest setup
The image should:
- set
ENV container=container; - set systemd default target to
multi-user.target; - enable sshd and Docker;
- disable password SSH;
- disable root password login;
- disable SSH agent forwarding;
- generate no persistent host keys in the image;
- clear
/etc/machine-id; - generate host keys on first boot;
- include a fixed experiment user or use root only for the initial experiment.
Do not bake a host SSH public key into the image.
7.4 Entry point
For Track A, use:
/sbin/init
as the ordinary container’s entrypoint.
Do not use Apple’s --init flag as a replacement for systemd; the experiment is testing a persistent Linux machine userspace.
7.5 Container restriction overrides
Stock ordinary containers apply OCI-style masked/read-only paths by default.
The experiment MUST explicitly test whether Docker/systemd requires clearing them.
Initial Track A configuration should use:
--cap-add ALL
--masked-path NONE
--read-only-path NONE
If the environment works with a narrower set, record the minimum required configuration as a secondary hardening result.
8. Track A — stock Apple containers
A0 — environment capture
Record:
sw_vers
uname -a
container --version
container system status
Record hardware model/chip and host RAM.
Record existing container/network resources before the experiment.
A1 — build test image
Build with stock:
container build --platform linux/arm64 -t local/iso-exp:<id> image/
Capture:
- image digest;
- build log;
- elapsed time;
- resulting disk usage.
Verify the image contains no canary host secret.
A2 — create dedicated network
Create one network for sandbox A and a different network for sandbox B.
Example:
container network create iso-exp-a-<random>
container network create iso-exp-b-<random>
Capture network inspection/list output.
A3 — create stopped sandbox
Create without starting:
container create \
--name iso-exp-a-<random> \
--label iso.experiment=<run-id> \
--label iso.owner=<random-owner-id> \
--network iso-exp-a-<random> \
--cpus 4 \
--memory 8g \
--cap-add ALL \
--masked-path NONE \
--read-only-path NONE \
--entrypoint /sbin/init \
local/iso-exp:<id>
Absolutely do not pass:
--ssh
--mount
--volume
--publish
--publish-socket
--rm
Immediately inspect the stopped object.
A3 acceptance
container inspect must show:
- expected ID;
- expected image;
- zero external mounts;
- zero published ports;
- zero published sockets;
ssh == false;- exactly one configured dedicated network;
- expected CPU/memory;
- experiment ownership labels.
If any unsafe property is implicit and cannot be disabled, Track A hard-fails.
A4 — boot systemd
Start the sandbox.
Probe first through:
container exec <id> ...
Verify:
PID 1 identity
systemd state
sshd active
docker active
Capture failed systemd units.
A4 acceptance
/sbin/initor expected systemd process behaves as the sandbox’s workload init;- services stay alive after
container execexits; - Docker service reaches active state;
- sshd reaches active state.
If systemd cannot function robustly under the normal-container execution model, Track A fails product requirement P2.
A5 — Docker-in-guest
Run:
docker info
docker version
docker run --rm <small pinned test image> /bin/true
docker build <small deterministic build context>
Capture daemon logs if failure occurs.
A5 acceptance
All commands succeed without host Docker.
A6 — effective security inspection
While running, capture full container inspect.
Verify:
- one dedicated network only;
- no default network;
- zero host mounts;
ssh == false;- zero published ports/sockets;
- expected labels;
- expected resources.
Also inspect guest environment for:
SSH_AUTH_SOCK
and scan common socket locations.
A6 acceptance
All S-invariants observable through inspect pass.
A7 — peer isolation
Create sandbox B on its own network.
Run listeners in B for TCP and UDP.
From A, attempt:
- direct B IPv4;
- direct B IPv6;
- ICMP;
- TCP;
- UDP;
- route manipulation;
- neighbor manipulation;
- source spoofing where feasible;
- broadcast/multicast probes.
Run a positive control from the host or from a container on B’s network to prove the listener is actually reachable from an allowed peer.
Repeat after stop/start of both sandboxes.
A7 acceptance
No cross-network guest-to-guest connectivity.
If cross-network reachability is possible from a root guest, Track A hard-fails.
A8 — host exposure
From guest root:
- inspect mount table;
- inspect
/proc/self/mountinfo; - search for host-home paths;
- search for SSH-agent socket paths;
- test known host integration names/endpoints;
- enumerate reachable host gateway services;
- attempt to reach the runtime’s host control sockets indirectly.
Use a canary file in the host home that must never appear in guest-visible mounts.
A8 acceptance
No filesystem/SSH-agent exposure.
Network-reachable host services must be enumerated. Any unintended sensitive host service is a hard failure until a runtime/network policy can block it.
A9 — SSH enrollment and pinning
Using only native stock control:
- create a per-instance Ed25519 client key;
- use
container execas root to install the public key; - use
container execto read/etc/ssh/ssh_host_ed25519_key.pub; - record it in a temporary
known_hosts; - SSH directly to the container IP with strict checking;
- stop/start the container;
- repeat strict SSH and verify the host key is unchanged;
- deliberately regenerate host keys inside the guest;
- verify the next SSH attempt fails.
A9 acceptance
All steps work without ssh-keyscan and without disabling host-key checking.
A10 — persistence
Write:
/var/lib/iso-experiment/marker
Create Docker state:
- pull/create a pinned image;
- create a named Docker volume with a marker.
Stop then start.
Verify all persisted data.
Repeat 20 stop/start cycles.
A10 acceptance
No state loss and no host-key/machine-id churn.
A11 — CPU/memory lifecycle
At create time, verify guest-visible CPU/RAM.
Then determine whether stock public interfaces permit mutation while preserving the container filesystem.
Test only documented/public mechanisms.
Do not patch runtime state files manually.
A11 result classification
PASS: can mutate/read back while preserving instance disk.GAP: cannot mutate but creation-time configuration works.FAIL: resources are unreliable or incorrectly applied.
A GAP does not fail Track A security, but may force Track B for the desired end state.
A12 — disk lifecycle
Measure:
- guest filesystem capacity;
- host sparse-disk allocation;
- behavior when writing several GiB;
- capacity limit;
- behavior when full.
Determine whether stock public interfaces support:
- explicit initial disk capacity;
- disk growth while preserving instance state.
Do not edit Apple runtime files directly.
A12 classification
PASS: explicit size + growth supported.PARTIAL: sufficient automatic growth semantics with a well-defined upper bound acceptable to isolate.GAP: no way to meet requested disk sizing/growth.FAIL: persistence/corruption issue.
Because configurable disk capacity is part of the intended end state, a GAP triggers Track B.
A13 — checkpoint/restore
Test documented stock primitives:
container export;- image/container copy semantics if available;
- any released snapshot API exposed publicly.
Evaluate whether state A can be restored efficiently to the same logical sandbox semantics.
A13 classification
container export alone should normally be recorded as GAP, not PASS, unless the experiment demonstrates acceptable restoration behavior and preserves the desired identity/lifecycle semantics.
A checkpoint gap triggers Track B but does not invalidate Track A’s security result.
A14 — service/runtime recovery
Test:
- stop/start Apple container system service while sandbox stopped;
- restart service while sandbox running;
- kill the experiment client during create;
- kill client during start;
- kill client during stop;
- kill client during delete;
- kill backing VM/runtime process;
- inspect/recover/delete afterward.
Record exact states and orphan behavior.
A14 acceptance
The harness can deterministically discover and reconcile owned resources.
A result that can leave an uninspectable running VM after client/runtime failure is a hard concern.
A15 — concurrency and performance
Run 1/4/8 sandboxes.
Collect:
- create time;
- start-to-systemd-ready;
- start-to-SSH-ready;
- start-to-Docker-ready;
- host RSS;
- host allocated disk;
- stop latency;
- delete latency.
The experiment is not passed/failed on absolute performance unless it is operationally unusable.
9. Track A decision gate
After Track A, classify the result.
A-SUFFICIENT
Choose stock containers if:
- all S1-S10 pass;
- P1-P6 pass;
- P12-P14 pass;
- disk behavior meets the desired end state;
- checkpoint behavior is acceptable;
- no private Apple APIs or patched runtime are required.
In this case, do not run Track B except optionally as research.
A-SECURE-BUT-INCOMPLETE
Proceed to Track B if:
- all hard security invariants pass;
- systemd + Docker + persistence work;
- but one or more of these remain missing:
- resource mutation;
- explicit disk size;
- disk growth;
- checkpoint/restore;
- robust runtime reconciliation.
This is the expected fallback case.
A-UNSUITABLE
Proceed to Track B immediately if stock containers fail:
- systemd/Docker machine semantics;
- dedicated-network isolation;
- host exposure controls;
- effective inspectability;
- persistent filesystem semantics;
- pinned identity path.
10. Track B — direct Containerization
Track B should not begin by recreating Apple Container.
Implement the smallest runtime necessary to retest isolate’s requirements.
B0 — package baseline
Use:
apple/containerization 0.45.0
Swift 6.x toolchain required by the package
macOS 27 SDK
Pin the package revision/version in Package.swift.
Use a private experiment root such as:
~/Library/Application Support/iso-containerization-experiment/<run-id>/
Do not use the default Apple Container image store.
B1 — minimal runtime composition
Start from ContainerManager / LinuxContainer rather than from raw VZVirtualMachine.
Required primitives:
ImageStorefor OCI;ContainerManager;LinuxContainer;VmnetNetworkor a purpose-built network wrapper;- explicit rootfs sizing;
- optional writable overlay sizing;
- native guest process execution.
Use a dedicated state root per experiment run.
B2 — OCI image import/pull
Consume the same logical image used by Track A.
Record:
- resolved digest;
- unpack time;
- disk layout;
- rootfs capacity.
No host secret enters the image store.
B3 — explicit disk construction
Create sandboxes with:
8 GiB
32 GiB
64 GiB
using explicit rootfsSizeInBytes and/or writableLayerSizeInBytes.
Verify guest-visible capacity.
Test both models if useful:
Model 1 — mutable rootfs
OCI image unpacked into writable ext4 rootfs
Model 2 — immutable lower + writable overlay
read-only image rootfs
+
separate writable ext4 upper layer
Measure:
- startup;
- disk usage;
- persistence;
- feasibility of cheap checkpoints/clones.
The experiment should identify which model better matches isolate.
B4 — systemd and Docker
Configure the workload so the sandbox provides equivalent machine semantics to Track A.
Do not assume Containerization’s default vminitd workload model is sufficient.
Verify:
- systemd;
- sshd;
- Docker;
- nested Docker workload;
- persistence.
If a full systemd machine requires runc or additional configuration, record the exact architecture.
B5 — dedicated networking
The default VmnetNetwork alone is not automatically equivalent to “one isolated network per isolate VM.”
Construct the network topology so each sandbox receives an isolated peer domain.
Possible implementations to test:
- one
VmnetNetworkinstance per sandbox; - explicit vmnet network references/subnets per sandbox;
- a small network manager modeled after Apple’s network service.
Do not accept a design where all isolate guests are peers on one segment merely because IPs are unique.
Run the full S3 peer-isolation suite.
B6 — host reachability
Enumerate what a root guest can reach on the host through the chosen vmnet mode.
If direct Containerization gives more control than stock Apple Container, test whether isolate can reduce host reachability to the minimum required.
This is a comparison criterion, not just pass/fail.
B7 — no mounts / no agent
Create the VM with no host filesystem mounts except runtime-owned init/rootfs block devices.
Do not implement SSH-agent forwarding.
Inspect the guest mount table and host configuration.
Pass the same S4/S5 suite.
B8 — native enrollment/control path
Use Containerization’s guest process control over vsock to:
- install the SSH public key;
- read the guest SSH host key;
- perform readiness checks.
Then switch normal interactive/file operations to pinned SSH.
This validates the preferred end-state split between:
native control for enrollment/security
SSH for ordinary iso operations
B9 — persistence model
Direct LinuxContainer objects are runtime objects, not automatically a complete persistent-machine database.
Implement only enough metadata to prove restart across host process exit:
SandboxRecord {
id
OCI digest
rootfs/writable paths
CPU
memory
network allocation
SSH host key
}
Exit the Swift program entirely.
Relaunch it and reconstruct/start the same sandbox from persisted disks.
B9 acceptance
Guest filesystem, machine-id, and SSH host key persist.
No Apple container machine code is needed.
B10 — CPU/memory mutation
Stop sandbox.
Reconstruct with new CPU/memory settings using the same persistent guest disk.
Verify state and resources.
This is allowed because the product abstraction is “persistent sandbox”, not “same VZVirtualMachine object.”
B10 acceptance
Resource mutation succeeds without rebuilding/reprovisioning the rootfs.
B11 — disk growth
Starting from 8 GiB:
- stop;
- grow backing ext4/block image safely;
- restart;
- grow filesystem if required;
- verify 32 GiB capacity;
- verify old data and SSH identity.
If Containerization provides a direct helper, use it.
If a small filesystem utility is required, count that code/maintenance cost explicitly.
B12 — checkpoint/restore
Prototype the simplest robust local checkpoint mechanism.
Candidates:
- copy-on-write/clone of persistent writable disk;
- macOS 27 layered disk APIs if usable;
- filesystem snapshot/copy while stopped.
The checkpoint does not need to become OCI.
Evaluate:
- correctness;
- creation latency;
- restore latency;
- allocated bytes;
- crash consistency.
B13 — process/service crash recovery
Kill the Swift runtime process while VM is:
- booting;
- running;
- stopping.
Determine whether the VM dies with the owning process or persists.
Design the eventual service model accordingly.
For a persistent isolate runtime, test a LaunchAgent-style long-lived owner if necessary.
B14 — full security suite
Repeat S1-S10 without weakening any test because this is a lower-level API.
Direct control is only valuable if the resulting security contract is easier to prove.
B15 — concurrency/performance
Repeat the Track A 1/4/8 sandbox benchmarks.
Also record:
- OCI unpack cost;
- writable-layer creation cost;
- memory of the Swift runtime;
- amount of host state per sandbox.
11. Track B acceptance gate
Direct Containerization is considered a viable replacement if:
- all S1-S10 pass;
- P1-P14 can be implemented;
- the implementation does not need to fork broad parts of
apple/container; - the runtime-specific code remains a narrow sandbox service rather than a general-purpose container platform;
- lifecycle persistence and recovery can be made deterministic;
- network isolation is demonstrable on real hardware.
12. Comparative engineering-cost measurements
The experiment must record engineering cost, not just runtime behavior.
For each track record:
Runtime integration size
- source LOC written;
- number of Apple APIs/types depended on;
- number of subprocess commands parsed;
- number of persisted state types;
- number of lifecycle states handled.
Apple-upstream coupling
Classify dependencies:
public documented CLI
public Swift package API
package-internal behavior
forked upstream source
private framework/API
Lower is better.
Security state space
Count configurable dimensions relevant to isolation:
- networks;
- mounts;
- SSH;
- published ports;
- sockets;
- init mode;
- capabilities.
Prefer an API where unsafe states are impossible to express.
Recovery ownership
Document which layer owns:
- resource state;
- orphan cleanup;
- operation idempotency;
- VM process lifetime;
- network lifetime;
- image-store lifetime.
Upgrade burden
Perform one controlled dependency bump, if a newer patch exists by experiment time.
Measure:
- compile failures;
- protocol/schema changes;
- behavioral regression tests.
13. Decision framework
The final decision should use this order.
Rule 1 — security dominates
If only one track passes all S-invariants, choose it.
Rule 2 — prefer stock when complete
If stock containers pass security and all required lifecycle behavior through documented public surfaces, choose stock.
Do not build a private runtime merely for architectural elegance.
Rule 3 — prefer direct Containerization over a machine fork when stock is incomplete
If stock containers are secure but cannot satisfy disk/resource/checkpoint requirements, and direct Containerization closes those gaps with a reasonably small runtime, choose direct Containerization.
Rule 4 — do not silently create a hybrid based on private Apple APIs
A solution such as:
stock container CLI
+
undocumented edits to Apple's runtime state
+
internal XPC calls
is a failed Track A result.
At that point use Track B explicitly.
Rule 5 — machine fork is the comparison fallback, not the default
Only return to a container machine fork if both are true:
- stock containers are insufficient; and
- direct Containerization requires recreating so much persistence/network/runtime machinery that maintaining the smaller machine fork is demonstrably cheaper.
The experiment report must identify the exact missing primitive that makes the fork preferable.
14. Expected outcome table
Fill this with evidence.
| Requirement | Stock container | Direct Containerization | Evidence |
|---|---|---|---|
| Standard OCI | TBD | TBD | |
| One VM per sandbox | TBD | TBD | |
| systemd | TBD | TBD | |
| Docker inside guest | TBD | TBD | |
| Dedicated network | TBD | TBD | |
| Root-guest peer isolation | TBD | TBD | |
| No host mounts | TBD | TBD | |
| No SSH agent | TBD | TBD | |
| No published ports/sockets | TBD | TBD | |
| Effective inspection | TBD | TBD | |
| Native bootstrap channel | TBD | TBD | |
| Pinned SSH identity | TBD | TBD | |
| Stop/start persistence | TBD | TBD | |
| CPU/memory create | TBD | TBD | |
| CPU/memory resize | TBD | TBD | |
| Initial disk size | TBD | TBD | |
| Disk growth | TBD | TBD | |
| Checkpoint/restore | TBD | TBD | |
| Logs | TBD | TBD | |
| Crash reconciliation | TBD | TBD | |
| Concurrent instances | TBD | TBD | |
| Runtime implementation LOC | TBD | TBD | |
| Upgrade coupling | TBD | TBD |
Allowed cell values:
PASS
PARTIAL
GAP
FAIL
NOT TESTED
Every PASS must point to raw evidence.
15. Evidence collection
Each experiment action should generate:
results/<track>/<test-id>/
command.txt
stdout.log
stderr.log
before.json
after.json
guest.txt
timing.json
result.json
result.json:
{
"test": "A7-peer-isolation-ipv4-tcp",
"status": "PASS",
"runtime": "container 1.4.1",
"host": "macOS 27.x arm64",
"started_at": "...",
"duration_ms": 1234,
"notes": ""
}
Do not place secrets in evidence files.
16. Final experiment report
Produce:
experiments/apple-sandbox/results/REPORT.md
Required sections:
- Host/runtime versions.
- Exact OCI image digest.
- Track A result.
- Track A hard failures.
- Track A lifecycle gaps.
- Whether Track B was triggered and why.
- Track B result.
- Security comparison.
- Lifecycle comparison.
- Performance comparison.
- Engineering-maintenance comparison.
- Recommended runtime architecture.
- Required deviations from the proposed isolate end-state spec.
- Open risks.
The conclusion must be one of:
USE_STOCK_CONTAINER
USE_DIRECT_CONTAINERIZATION
KEEP_MACHINE_FORK
NO_ACCEPTABLE_RUNTIME_YET
17. Stop conditions
Stop Track A early and move to Track B when a result is clearly fundamental and repeatable:
- systemd cannot provide the required persistent service environment;
- Docker-in-guest cannot run under any acceptable stock configuration;
- dedicated networks do not isolate root-controlled guests;
- host mounts/SSH agent are unavoidable;
- effective security state cannot be inspected.
Do not stop Track A early merely because:
- disk resize is absent;
- checkpoint is absent;
- CPU/memory mutation is absent.
Those are specifically the lifecycle gaps Track B is intended to evaluate.
Stop Track B and retain the machine fork if direct Containerization requires a broad reimplementation of:
- OCI service infrastructure;
- networking service infrastructure;
- persistent runtime supervision;
- lifecycle recovery;
such that the resulting code is materially larger and harder to secure than the existing narrowly modified machine implementation.
18. High-value first-day spike
Before implementing the full harness, run this minimal sequence.
Stock
- Build Ubuntu systemd + Docker OCI image.
- Create two dedicated networks.
- Create one stock container per network with:
--cap-add ALL;--masked-path NONE;--read-only-path NONE;/sbin/init.
- Start both.
- Verify systemd.
- Verify Docker.
- Verify stop/start persistence.
- Verify inspect says:
- no mounts;
- ssh false;
- no published ports/sockets;
- one dedicated network.
- Verify A cannot ping/connect to B.
- Use
container execto enroll SSH and prove pinned SSH works.
If all ten succeed, the stock-container hypothesis is strong enough to justify the full Track A suite.
If systemd/Docker fails for fundamental runtime reasons, move quickly to Track B.
19. High-value Direct Containerization spike
If Track B is triggered, the first Swift spike should prove only:
- pull/open the same OCI image;
- create an explicit 16-GiB rootfs using
ContainerManager; - create an isolated vmnet interface;
- boot a
LinuxContainer; - run systemd or the proposed guest machine init;
- start Docker;
- exit the host client;
- reconstruct the sandbox from the same persisted block filesystem;
- verify its data persists.
Only after this works should the experiment add checkpoints, resize, and a long-lived service.
20. Why this experiment is structured this way
Stock ordinary Apple containers have an important property that container machine currently lacks for isolate: their dangerous host integrations are opt-in.
A stock container configuration can express:
mounts = []
publishedPorts = []
publishedSockets = []
ssh = false
networks = [dedicated]
and those fields are inspectable.
This makes stock containers worth proving before maintaining a runtime fork.
At the same time, the stock CLI does not currently expose every persistent-VM lifecycle primitive isolate wants. Direct Containerization is therefore evaluated not as a totally different product, but as the next lower layer when the stock product surface becomes the constraint.
The experiment deliberately keeps the same OCI image and security tests across both tracks so the decision is based on runtime behavior and maintenance burden rather than two unrelated prototypes.