General-purpose, language-agnostic sandbox specification and multi-language SDK suite.
palmshed/sandbox provides a canonical runtime specification (spec/) and SDKs for secure process execution, filesystem isolation, resource limits, network policies, and stdout/stderr streaming across pluggable execution backends.
- SDK Release Version:
v1.3.0(Phase 2 complete plus the optional RFC 0006 OS filesystem isolation extension, the optional RFC 0007 CPU hard quota extension, best-effortpeakMemoryBytes, bounded retained output withtruncated, and macOS Seatbelt confinement) - Runtime Specification:
1.3.0(the 1.0.0 contract stays frozen; 1.1.0, 1.2.0, and 1.3.0 add only optional extensions and one documented retention behavior; seespec/version.md) - Stability: Stable. The runtime contract is frozen at v1.0.0 with 1.1.0, 1.2.0, and 1.3.0 adding only optional extensions plus the documented retention behavior. API contracts follow Semantic Versioning rules outlined in
spec/compatibility.mdand changes are gated by the 6-month deprecation policy (spec/deprecations.md). - Network isolation note: On macOS,
networkIsolationistrue(5/5 adversarial leak tests pass). On Linux, it is dynamically probed atinit():truewhen unprivileged user namespaces are available,falseon CI runners where they are restricted (falls back to proxy env vars). On Windows it isfalse(no native unprivileged network isolation; see RFC 0004). The Docker backend mapsdisabled/allow/proxypolicies since backend-parity work item#4. - v1.0 security guarantee: Native v1.0 provides soft process isolation with a hardened virtual filesystem boundary. OS-level filesystem isolation for executed workloads ships in v1.1.0 as an optional, capability-reported extension (
osFilesystemIsolation; RFC 0006). Platform status:- OS-level filesystem isolation (RFC 0006): implemented for Linux (Landlock +
unshare --user, runtime-allowlist confinement) and macOS (Seatbelt profile viasandbox-exec, allow-default with targeted denies); reportedsupportedonly after a real confined self-test. Windows isunsupported - Windows network isolation: unsupported (no native unprivileged mechanism; RFC 0004)
- Docker resource/network enforcement: enforced since backend-parity work item
#4(cpuLimits,memoryLimits,networkIsolationalltruewith integration coverage) cpuQuota: hard rate cap that throttles instead of killing, shipped in v1.2.0 (RFC 0007); enforced on Linux, Windows, and Docker where each platform's probe passes, macOS reportsfalse(cpuTimeLimittime budgets are enforced everywherecpuLimitsistrue)
- OS-level filesystem isolation (RFC 0006): implemented for Linux (Landlock +
- Firecracker design status: the six-track backend design is complete and recorded (RFC 0012), but no real VM has booted and no capability has been verified. Implementation awaits a real KVM-capable host and guest-agent
READY; until then the backend remains unvalidated with all capability claims unpromoted.
- Runtime Specification (
spec/): JSON Schemas & versioning (spec/version.md). - Compliance Suite (
compliance/): Cross-language conformance test suite. - SDKs (
sdk/): Reference TypeScript SDK (sdk/typescript, published to npm as1.3.0); Rust SDK released asv0.1.0(sdk/rust); Go SDK released asgo-v0.1.0(sdk/go,-raceverified); Python SDK released aspy-v0.1.0(sdk/python, async-first). Each non-npm SDK carries its own tag namespace (v0.x,go-v0.x,py-v0.x) so version lines stay independent. - Backends (
backends/): Native process driver, Docker container driver; Firecracker design complete per RFC 0012 (six-track sequence decided) with implementation blocked on a real KVM-capable host; WASI remains planned.
npm install @palmshed/sandboximport { Sandbox } from '@palmshed/sandbox';
const sandbox = await Sandbox.create({
cpu: 2,
memory: "512MB",
timeout: 30000,
network: "disabled",
backend: "native"
});
const execution = await sandbox.exec("node -v");
await execution.wait();
console.log("Node version:", execution.stdout());
await sandbox.destroy();See AGENTS.md for full architectural guidelines and specification rules.
The repository uses a shared preflight and verification pipeline
(scripts/), the same scripts CI runs:
npm run preflight:quick- fast developer feedback (git state, prose punctuation, required READMEs, SDK typecheck).npm run preflight- full deterministic gate: SDK build/typecheck/tests, compliance/TCK, repro laboratory, examples, consumer test, JSON-schema validation, docs, workflows, package tarball, and git state.npm run preflight:release- preflight plus the release-readiness gate (SDK version == spec version == git tag, CHANGELOG entry).npm run production:validate- builds, packs, and installs the release artifact, then runs the production scenario suite and a soak smoke against the packed package (never the workspace build). This is the release confidence gate CI runs on the Ubuntu/macOS/Windows matrix.
Run the production suite alone with node production/run.mjs (--list,
--only <ids>, --verbose); see production/README.md.
Set SANDBOX_LOG=debug to emit lifecycle and resource-enforcement events to
stderr (off by default):
SANDBOX_LOG=debug node your-app.mjsEmitted events (consistent across the native and Docker backends):
| Event | Meaning |
|---|---|
backend.init |
Backend initialized (capability flags + configured limits) |
exec.start |
Execution started (backend, pid where available, limits) |
exec.end |
Execution finished (exit code, duration, timeout flag, CPU ms) |
resource.enforced |
A resource limit was enforced (cpu / memory / disk) |
backend.destroy |
Backend torn down |
Log lines contain identifiers and resource configuration only: never
secrets, environment values, command contents, or filesystem contents. See
docs/errors.md for the error-code reference.