emberpool 0.1.0a1__py3-none-any.whl

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.
emberpool/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """emberpool: warm-pool Firecracker microVM sandboxes for AI agents.
2
+
3
+ The public API is exactly what this module exports.
4
+ """
5
+
6
+ from emberpool._types import IsolationError, Result
7
+ from emberpool._settings import Settings
8
+ from emberpool.pool import Sandbox, SandboxPool
9
+
10
+ __all__ = ["SandboxPool", "Sandbox", "Result", "Settings", "IsolationError"]
@@ -0,0 +1,7 @@
1
+ """Files `emberpool setup` puts into the guest root filesystem.
2
+
3
+ ep-init guest PID 1: overlay on the scratch drive, then busybox init
4
+ inittab busybox init table: early setup, then the agent, respawned
5
+
6
+ The agent itself is emberpool/guest/agent.py with its vendored _protocol.py.
7
+ """
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ # emberpool guest init. As PID 1: put an overlay (upper layer on the scratch
3
+ # drive /dev/vdb) over the read-only root and hand over to busybox init.
4
+ # With --sysinit: early setup, run by busybox init from /etc/inittab.
5
+ PATH=/usr/sbin:/usr/bin:/sbin:/bin
6
+ export PATH
7
+
8
+ if [ "$1" = "--sysinit" ]; then
9
+ mount -t sysfs sysfs /sys 2>/dev/null
10
+ mkdir -p /dev/pts /dev/shm
11
+ mount -t devpts devpts /dev/pts 2>/dev/null
12
+ mount -t tmpfs -o nosuid,nodev,mode=1777 tmpfs /dev/shm 2>/dev/null
13
+ hostname -F /etc/hostname 2>/dev/null
14
+ ip link set lo up
15
+ # Quiet network: no IPv6 on eth0 (no autoconfiguration, router
16
+ # solicitations or MLD reports) and no multicast on it. Interfaces added
17
+ # later start without IPv6 too. lo keeps ::1. Noise reduction only; the
18
+ # host enforces the policy whatever the guest does.
19
+ echo 1 >/proc/sys/net/ipv6/conf/default/disable_ipv6 2>/dev/null
20
+ if [ -e /sys/class/net/eth0 ]; then
21
+ echo 1 >/proc/sys/net/ipv6/conf/eth0/disable_ipv6 2>/dev/null
22
+ ip link set eth0 multicast off
23
+ ip addr add 172.16.0.2/30 dev eth0 &&
24
+ ip link set eth0 up &&
25
+ ip route add default via 172.16.0.1
26
+ fi
27
+ exit 0
28
+ fi
29
+
30
+ fail() {
31
+ echo "ep-init: $*; powering off" >/dev/console
32
+ sync
33
+ reboot -f
34
+ exit 1
35
+ }
36
+
37
+ mount -t proc proc /proc || fail "cannot mount /proc"
38
+ mount -t devtmpfs devtmpfs /dev 2>/dev/null # may already be mounted by the kernel
39
+ [ -b /dev/vdb ] || fail "no scratch drive /dev/vdb"
40
+ mount -o remount,ro / 2>/dev/null
41
+ mount -t ext4 -o nosuid,nodev /dev/vdb /mnt/scratch || fail "cannot mount scratch drive"
42
+ mkdir -p /mnt/scratch/upper /mnt/scratch/work || fail "cannot prepare scratch drive"
43
+ mount --bind / /mnt/lower || fail "cannot bind the root filesystem"
44
+ mount -t overlay overlay \
45
+ -o lowerdir=/mnt/lower,upperdir=/mnt/scratch/upper,workdir=/mnt/scratch/work \
46
+ /mnt/root || fail "cannot mount the overlay"
47
+ mount --move /dev /mnt/root/dev || fail "cannot move /dev"
48
+ mount --move /proc /mnt/root/proc || fail "cannot move /proc"
49
+ cd /mnt/root || fail "cannot enter the overlay"
50
+ pivot_root . oldroot || fail "pivot_root failed"
51
+ exec chroot . /bin/sh -c 'umount -l /oldroot; exec /bin/busybox init' \
52
+ </dev/console >/dev/console 2>&1
@@ -0,0 +1,4 @@
1
+ ::sysinit:/sbin/ep-init --sysinit
2
+ ::respawn:/usr/bin/python3 -B /opt/emberpool/agent.py
3
+ ::ctrlaltdel:/sbin/reboot
4
+ ::shutdown:/bin/sync