Documentation
¶
Overview ¶
Package assets holds the image build assets embedded into the cs-sandbox binary. It is not this module's entry point: cs-sandbox is a command-line tool rather than a library, and the program is cmd/cs-sandbox.
go install github.com/codesweep-ai/sandbox/cmd/cs-sandbox@latest
The package sits at the module root only because a //go:embed directive cannot reach a parent directory and the tree it embeds, image/, is there. Everything the tool actually does lives under internal/.
What it embeds — the Containerfile, the guest rootfs skeleton, and the guest init — is what lets a single downloaded binary build the sandbox image and boot microVMs with no source checkout. When run from a checkout the on-disk image/ tree is preferred (see internal/paths.AssetDir); this embedded copy is the fallback that makes the binary self-contained.
Index ¶
- func GuestInitPath(assetDir, cacheDir string) string
- func GuestInitramfsSrcPath(assetDir, cacheDir string) string
- func HostHelpers(assetDir string) (fs.FS, error)
- func ImageDir(assetDir string) (dir string, cleanup func(), err error)
- func TierPins(assetDir string) (map[string]string, error)
- func ToolPins(assetDir string) (map[string]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GuestInitPath ¶
GuestInitPath returns a host path to the guest init (image/guest/init): the on-disk checkout copy when available, otherwise the embedded copy materialized once into cacheDir (a stable path so its content hash — the base-rootfs stamp key — is identical to the on-disk copy). Returns "" (no error) if neither the checkout nor cacheDir is usable.
func GuestInitramfsSrcPath ¶
GuestInitramfsSrcPath returns a host path to the initramfs init source (image/guest/initramfs-init.c), materializing the embedded copy into cacheDir when there is no checkout — the same pattern as GuestInitPath, and for the same reason: its content hash keys the cached initrd.img, so the path must resolve identically whether the assets came from a checkout or the binary. Returns "" (no error) if neither source is usable; the boot-artifact build then fails with an actionable error rather than booting something stale.
func HostHelpers ¶
HostHelpers returns the guest ~/.local/bin tools (cs-claude/cs-codex families + docs) as an fs.FS, from the checkout when available else embedded — for the `install-agent-tools` command. Same source dir the guest home skeleton seeds into ~/.local/bin, so host and sandbox get the identical tools in the same path.
func ImageDir ¶
ImageDir returns a temp directory holding Containerfile + rootfs/ + guest/ ready for `podman build`. It always extracts (from the checkout or the embedded copy) with normalized modes + a fixed mtime, so the same image id results regardless of where the assets came from. cleanup removes the temp dir; call it when the build finishes.
func TierPins ¶
TierPins reads image/tiers.env — the tier images the leaf Containerfile is built ON, and the one place a bump happens.
Two entries, one per family: AGENTS_REF for the shipped image and SLIM_AGENTS_REF for the CI one. Both are pinned here rather than as ARG defaults in the Containerfiles because the slim Containerfiles are DERIVED (see image/ci-slim.sh) and a derived file cannot carry a pin of its own.
Same fallback as everything else here: the checkout's copy when there is one, the embedded copy otherwise, so a downloaded binary can still build.
func ToolPins ¶
ToolPins reports the versions this module pins for the sibling cs- tools the image ships, as module path -> version. It prefers the checkout's go.mod over the embedded copy, the same preference sourceFS applies to the image tree, so a checkout that has moved a pin builds an image carrying it.
The manifest is scanned rather than parsed: a require line is "path version" once trimmed, which is all this needs. A module the manifest does not mention is simply absent, and the caller decides whether that is fatal.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
cs-sandbox
command
Command cs-sandbox manages named dev sandboxes (user/agent types) as rootless Firecracker microVMs or podman containers.
|
Command cs-sandbox manages named dev sandboxes (user/agent types) as rootless Firecracker microVMs or podman containers. |
|
internal
|
|
|
cli
Package cli wires the cobra command tree over the internal packages (cli depends on engine/state/run; main only maps exit codes).
|
Package cli wires the cobra command tree over the internal packages (cli depends on engine/state/run; main only maps exit codes). |
|
covemit
Package covemit emits behavioral-coverage run-records from this repo's tests, for consumption by a downstream harness that tracks a coverage matrix whose cells are filled only by executed proofs.
|
Package covemit emits behavioral-coverage run-records from this repo's tests, for consumption by a downstream harness that tracks a coverage matrix whose cells are filled only by executed proofs. |
|
doctor
Package doctor checks host prerequisites, structured so each check is a typed result the CLI renders (and the package-name mapping is unit-testable).
|
Package doctor checks host prerequisites, structured so each check is a typed result the CLI renders (and the package-name mapping is unit-testable). |
|
engine
Package engine is the ports-and-adapters boundary between the CLI and the two sandbox backends.
|
Package engine is the ports-and-adapters boundary between the CLI and the two sandbox backends. |
|
fcconfig
Package fcconfig builds a Firecracker microVM configuration file (run.json) from a typed spec.
|
Package fcconfig builds a Firecracker microVM configuration file (run.json) from a typed spec. |
|
fcdisk
Package fcdisk builds the on-disk artifacts a firecracker microVM boots from: the cached kernel/initrd/base-rootfs, the per-instance reflink rootfs copy, and the seed.ext4 disk (the cs-sandbox.conf + trust seed + share manifests, packed with `fakeroot mke2fs -d`), per SPEC.md §12.3.
|
Package fcdisk builds the on-disk artifacts a firecracker microVM boots from: the cached kernel/initrd/base-rootfs, the per-instance reflink rootfs copy, and the seed.ext4 disk (the cs-sandbox.conf + trust seed + share manifests, packed with `fakeroot mke2fs -d`), per SPEC.md §12.3. |
|
fcnet
Package fcnet is the firecracker network fabric: the shared L2 network that microVMs and podman containers both live on (see SPEC.md §12.6).
|
Package fcnet is the firecracker network fabric: the shared L2 network that microVMs and podman containers both live on (see SPEC.md §12.6). |
|
forward
Package forward manages host<->sandbox port forwards as tracked, detached `ssh -N -L/-D` processes over the published SSH port (engine-agnostic).
|
Package forward manages host<->sandbox port forwards as tracked, detached `ssh -N -L/-D` processes over the published SSH port (engine-agnostic). |
|
hostcfg
Package hostcfg generates the host-side SSH material: the reusable ssh option set for reaching a sandbox (keyed by HostKeyAlias, so two sandboxes of the same name in different groups key two entries), and the managed ~/.ssh/config.d include that makes `ssh <name>` work.
|
Package hostcfg generates the host-side SSH material: the reusable ssh option set for reaching a sandbox (keyed by HostKeyAlias, so two sandboxes of the same name in different groups key two entries), and the managed ~/.ssh/config.d include that makes `ssh <name>` work. |
|
hostenv
Package hostenv captures the host user's identity and SSH material — the "H" key set from the trust model.
|
Package hostenv captures the host user's identity and SSH material — the "H" key set from the trust model. |
|
hostroute
Package hostroute implements the optional, Linux-only `host-route` feature: direct host->sandbox reachability by name (any protocol) under a DNS suffix, via a veth from the host root netns into podman's rootless netns plus a systemd-resolved per-link resolver pointed at the fabric dnsmasq.
|
Package hostroute implements the optional, Linux-only `host-route` feature: direct host->sandbox reachability by name (any protocol) under a DNS suffix, via a veth from the host root netns into podman's rootless netns plus a systemd-resolved per-link resolver pointed at the fabric dnsmasq. |
|
lend
Package lend is the credential lender: a host-side proxy that lets a sandbox call an LLM API without ever holding the credential that pays for it.
|
Package lend is the credential lender: a host-side proxy that lets a sandbox call an LLM API without ever holding the credential that pays for it. |
|
lock
Package lock provides the host-wide create lock.
|
Package lock provides the host-wide create lock. |
|
paths
Package paths resolves where cs-sandbox keeps its files, keeping runtime state out of the source tree and separating two concerns:
|
Package paths resolves where cs-sandbox keeps its files, keeping runtime state out of the source tree and separating two concerns: |
|
ports
Package ports allocates host SSH ports for instances.
|
Package ports allocates host SSH ports for instances. |
|
progress
Package progress draws the in-place bars a build shows while one long step runs, in the shape podman's own pull output uses — a label, a bracketed bar, a percentage, and the two sizes.
|
Package progress draws the in-place bars a build shows while one long step runs, in the shape podman's own pull output uses — a label, a bracketed bar, a percentage, and the two sizes. |
|
renew
Package renew keeps a lent host login from going stale under a sandbox.
|
Package renew keeps a lent host login from going stale under a sandbox. |
|
repo
Package repo implements the host-initiated --repo fetch/push transport.
|
Package repo implements the host-initiated --repo fetch/push transport. |
|
run
Package run is the single seam through which every external command (podman, firecracker, ssh, git, ip, dnsmasq, socat, …) is executed.
|
Package run is the single seam through which every external command (podman, firecracker, ssh, git, ip, dnsmasq, socat, …) is executed. |
|
seed
Package seed builds the per-instance seed — the security-critical interface between cs-sandbox and the guest init.
|
Package seed builds the per-instance seed — the security-critical interface between cs-sandbox and the guest init. |
|
spec
Package spec parses the --snapshot and --repo directory-sharing specs and resolves per-repo git identity.
|
Package spec parses the --snapshot and --repo directory-sharing specs and resolves per-repo git identity. |
|
state
Package state is the typed per-instance record: a sandbox's engine, type, port, VM address, and shares.
|
Package state is the typed per-instance record: a sandbox's engine, type, port, VM address, and shares. |
|
store
Package store manages shared image stores — the podman volume cs-sandbox-shared-<name> holding an image set that sandboxes reuse read-only via --image-store.
|
Package store manages shared image stores — the podman volume cs-sandbox-shared-<name> holding an image set that sandboxes reuse read-only via --image-store. |