Installation
Convergent creation
Microsandbox::Sandbox.connect_or_create()
starting, starts it when it is created, stopped, or crashed, and creates it only when the name is absent. Options apply only to creation; an existing sandbox keeps its persisted configuration. Concurrent callers converge on the winning identity. Replace options are rejected because replacement conflicts with convergence.
Sandbox.create when name conflicts must remain an error, or explicit replace options when the old identity should be discarded.
SandboxBuilder
builder.connect_or_create()
Microsandbox::Sandbox.connect_or_create.
Sandbox
A live sandbox connection returned bycreate, connect_or_create, start, connect_or_start, or restart.
sandbox.id
sandbox.wait_for_status()
created, starting, running, draining, paused, stopped, or crashed. Returns a refreshed metadata handle. Use Ruby’s Timeout.timeout or an application cancellation mechanism when a deadline is required.
sandbox.restart()
force: true to kill, timeout: in seconds to change shutdown convergence, or detached: true for a local background start.
On microsandbox cloud, graceful restart is supported, but timeout expiry cannot escalate to force kill. force: true is local-only, and detached: affects only local process ownership.
sandbox.destroy()
SandboxHandle
Obtain a metadata handle without opening the guest-agent connection:handle.id
handle.connect_or_start()
starting, or start it when it is created, stopped, or crashed. draining and paused are rejected. detached: true affects only a required local start; connecting to an already-running sandbox does not change ownership.
handle.wait_for_status()
status, returning a refreshed handle. The method does not have a built-in timeout.
handle.restart()
Sandbox#restart.
handle.destroy()
Identity errors
Ruby currently surfaces stale identity protection throughMicrosandbox::Error. The message includes was replaced; unlike Rust, TypeScript, Python, and Go, the Ruby SDK does not yet expose a dedicated SandboxReplacedError subclass.
Live lifecycle example
Runruby examples/lifecycle_convergence.rb from sdk/ruby to exercise convergent creation and reuse, stable identity, connect, wait, exec, restart, destroy, same-name replacement, and stale-handle rejection against a live microVM.