microsandbox

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package microsandbox is the pure-Go client for the colocated SDK helper. Core owns lifecycle intent; the helper owns no database or background service.

Index

Constants

View Source
const MaxOutputBytes = 1024 * 1024
View Source
const MaxRequestBytes = 72 * 1024 * 1024
View Source
const MaxResponseBytes = 16 * 1024 * 1024
View Source
const ProtocolVersion = 8
View Source
const SDKVersion = "v0.7.8"

Variables

View Source
var NodeArtifacts = []providerassets.Artifact{
	{Path: "native/bin/oac-microsandbox-provider", Suffix: "microsandbox-provider", Role: "runtime"},
	{Path: "native/microsandbox/msb", Suffix: "msb", Role: "runtime"},
	{Path: "native/microsandbox/libkrunfw.so.5.6.1", Suffix: "libkrunfw.so.5.6.1", Role: "runtime"},
}

NodeArtifacts are the native files a microsandbox node installs beside the shared node payload.

Functions

func BuildNode added in v0.0.10

func BuildNode(c sandbox.NodeConfig, options sandbox.LocalOptions, result *sandbox.Built) (func(), error)

BuildNode constructs the node-local microsandbox adapter from a validated node configuration.

func CheckpointClass added in v0.0.10

func CheckpointClass(c Config) (sandbox.CheckpointCompatibility, error)

CheckpointClass deliberately admits only identical native and host execution profiles. Paths, hostname and local SDK cache identities are not compatibility.

func CheckpointStore added in v0.0.10

func CheckpointStore(c Config) (string, error)

CheckpointStore opens only an explicitly configured, private checkpoint root. Its marker is an operator-owned identity, never inferred from workspace paths.

func HelperEnvironment

func HelperEnvironment(env []string, c Config) []string

Strip native selector and credential-bearing inherited configuration. Operator proxy settings are not passed into guest environments by this adapter.

func Labels

func Labels(c Config, r sandbox.Reference) map[string]string

func Name

func Name(c Config, r sandbox.Reference, g uint64) string

func Operations

func Operations() providercontract.Operations

Operations is this adapter's complete authored resource contract.

func Policy

func Policy() sandbox.DeploymentPolicy

func Setup added in v0.0.13

func Setup() sandbox.SetupDeclaration

Setup declares how the console connects microsandbox nodes.

func SnapshotEvidence added in v0.0.13

func SnapshotEvidence(digest, checkpointID, root string) string

SnapshotEvidence encodes the native digest, checkpoint ID and checkpoint root; the root is last because it may contain spaces.

func SnapshotReference

func SnapshotReference(c Config, r sandbox.Reference, operation string) string

func ValidReference

func ValidReference(r sandbox.Reference) bool

func ValidateBootstrap

func ValidateBootstrap(b sandbox.Bootstrap) error

func ValidateCommand

func ValidateCommand(c sandbox.Command) error

func ValidateCompute

func ValidateCompute(c Config, r sandbox.Reference, v Compute) error

func ValidateRequest

func ValidateRequest(q Request) error

func ValidateSnapshot

func ValidateSnapshot(c Config, r sandbox.Reference, s SnapshotIdentity) error

Types

type Caller

type Caller interface {
	Call(context.Context, Request) (Response, error)
}

type Compute

type Compute = sandbox.Compute

These aliases keep the helper wire private while Core uses provider-neutral types.

type Config

type Config struct {
	InstallationID string
	HelperPath     string
	RuntimeHome    string
	CheckpointRoot string
	RuntimePath    string
	FirmwarePath   string
	RuntimeSHA256  string
	FirmwareSHA256 string
	Image          string
	MemoryMiB      uint32
	CPUs           uint8
	RootDiskMiB    uint32
	Network        NetworkPolicy
}

Config is trusted deployment configuration. Paths and hashes refer to one immutable, qualified installation. Network is explicitly used on create and restore.

func (Config) Validate

func (c Config) Validate() error

type LeaseIdentity

type LeaseIdentity struct {
	InstallationID      string `json:"installation_id"`
	Generation          uint64 `json:"generation"`
	SpecificationDigest string `json:"specification_digest"`
}

LeaseIdentity is recorded by the installer before a generation can spawn a helper. Neither opener adopts a missing record or a replacement lease inode.

type Metrics

type Metrics struct {
	ObservedAt       time.Time
	Uptime           time.Duration
	VCPUTimeNs       uint64
	MemoryBytes      uint64
	MemoryLimitBytes uint64
}

Metrics is the bounded provider-helper projection used by Core observability. ObservedAt and Uptime preserve the same native registry sample at millisecond precision. It excludes instantaneous CPU percent and provider-native names.

type Native added in v0.0.10

type Native struct {
	HelperPath     string  `json:"helper_path"`
	RuntimeHome    string  `json:"runtime_home"`
	CheckpointRoot string  `json:"checkpoint_root"`
	RuntimePath    string  `json:"runtime_path"`
	FirmwarePath   string  `json:"firmware_path"`
	Image          string  `json:"image"`
	RuntimeSHA256  string  `json:"runtime_sha256"`
	FirmwareSHA256 string  `json:"firmware_sha256"`
	Network        Network `json:"network"`
}

Native is the node configuration's native object for microsandbox: the helper, Runtime and firmware paths, the installation's verified Runtime image and artifact hashes, the private store and the network policy. The helper owns local paths; no ambient backend is selected. Resources come from the deployment specification.

type Network added in v0.0.10

type Network struct {
	DefaultEgress  string `json:"default_egress"`
	DefaultIngress string `json:"default_ingress"`
	Rules          []Rule `json:"rules"`
}

type NetworkPolicy

type NetworkPolicy struct {
	DefaultEgress  string
	DefaultIngress string
	Rules          []NetworkRule
}

type NetworkRule

type NetworkRule struct{ Action, Direction, Destination, Protocol, Port string }

type ProcessCaller

type ProcessCaller struct {

	// LeasePath belongs to the permanent node state namespace, not a release.
	// It is never unlinked, including after the generation is collected.
	LeasePath     string
	LeaseIdentity LeaseIdentity
	// contains filtered or unexported fields
}

ProcessCaller never kills a mutating helper on a Core response timeout. The helper retains its allocation flock until the SDK mutation settles, including after Core exits. Output is still drained and bounded by this waiter.

func (*ProcessCaller) Call

func (p *ProcessCaller) Call(ctx context.Context, q Request) (Response, error)

func (*ProcessCaller) Quiescent

func (p *ProcessCaller) Quiescent() bool

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func NewWithCaller

func NewWithCaller(c Config, caller Caller) (*Provider, error)

func (*Provider) Create

func (p *Provider) Create(ctx context.Context, b sandbox.Bootstrap) (sandbox.Info, error)

func (*Provider) DeleteSnapshot

func (p *Provider) DeleteSnapshot(ctx context.Context, r sandbox.Reference, s SnapshotIdentity) error

func (*Provider) GetCompute

func (p *Provider) GetCompute(ctx context.Context, r sandbox.Reference, c Compute) (State, error)

func (*Provider) GetInfo

func (p *Provider) GetInfo(ctx context.Context, r sandbox.Reference) (sandbox.Info, error)

func (*Provider) Initial

func (p *Provider) Initial(ctx context.Context, r sandbox.Reference) (Compute, error)

func (*Provider) Kill

func (p *Provider) Kill(ctx context.Context, r sandbox.Reference) error

func (*Provider) KillCompute

func (p *Provider) KillCompute(ctx context.Context, r sandbox.Reference, c Compute) error

func (*Provider) NewCompute

func (p *Provider) NewCompute(ctx context.Context, r sandbox.Reference, generation uint64, snapshot *SnapshotIdentity) (Compute, error)

func (*Provider) Observe

func (p *Provider) Observe(ctx context.Context, target runtimeobs.Target) (runtimeobs.Sample, error)

Observe reads one point-in-time native metrics snapshot through the existing one-shot helper. The persisted compute receipt selects the exact generation; browser input and provider display names never select a sandbox.

func (*Provider) ProviderOperations

func (*Provider) ProviderOperations() providercontract.Operations

func (*Provider) Renew

func (p *Provider) Renew(ctx context.Context, r sandbox.Reference) (sandbox.Info, error)

func (*Provider) RenewCompute added in v0.0.13

func (p *Provider) RenewCompute(ctx context.Context, r sandbox.Reference, c Compute) (State, error)

RenewCompute observes: a microsandbox VM has no native lease.

func (*Provider) RestorePreparation added in v0.0.13

func (p *Provider) RestorePreparation(ctx context.Context, r sandbox.Reference, key string) (bool, error)

The preparation cache addresses the initial compute, like RunCommand.

func (*Provider) Resume

func (p *Provider) Resume(ctx context.Context, q ResumeRequest) (State, error)

func (*Provider) ResumeCompute

func (p *Provider) ResumeCompute(ctx context.Context, r sandbox.Reference, c Compute) (State, error)

ResumeCompute thaws the exact resident source after an aborted suspension. It never starts stopped compute or restores a checkpoint.

func (*Provider) RunCommand

func (*Provider) RunCommandCompute

func (p *Provider) RunCommandCompute(ctx context.Context, r sandbox.Reference, c Compute, command sandbox.Command) (sandbox.CommandResult, error)

func (*Provider) SavePreparation added in v0.0.13

func (p *Provider) SavePreparation(ctx context.Context, r sandbox.Reference, key string) error

func (*Provider) Suspend

func (p *Provider) Suspend(ctx context.Context, q SuspendRequest) (State, error)

type Request

type Request struct {
	Workspace *WorkspaceDirectory `json:",omitempty"`
	Version   int
	Operation string
	Config    Config
	Reference sandbox.Reference
	Compute   Compute
	Bootstrap *sandbox.Bootstrap
	Command   *sandbox.Command
	Suspend   *SuspendRequest
	Resume    *ResumeRequest
	Snapshot  *SnapshotIdentity
	// Key is the opaque preparation cache key.
	Key      string `json:",omitempty"`
	Deadline time.Time
}

type Response

type Response struct {
	// CreateSettled binds State to a completed Create rejection or an initial_info
	// absence whose allocation lock permanently prevents a later initial Create.
	CreateSettled bool `json:",omitempty"`
	Version       int
	State         *State
	Command       *sandbox.CommandResult
	Metrics       *Metrics
	Restored      bool `json:",omitempty"`
	ErrorCode     string
}

type ResumeRequest

type ResumeRequest = sandbox.ResumeRequest

type Rule added in v0.0.10

type Rule struct {
	Action      string `json:"action"`
	Direction   string `json:"direction"`
	Destination string `json:"destination"`
	Protocol    string `json:"protocol"`
	Port        string `json:"port"`
}

type SnapshotIdentity

type SnapshotIdentity = sandbox.SnapshotIdentity

type State

type State = sandbox.ComputeState

type SuspendRequest

type SuspendRequest = sandbox.SuspendRequest

type WorkspaceDirectory added in v0.0.10

type WorkspaceDirectory struct {
	Path     string
	ObjectID string
}

Request and Response are the finite, private helper boundary. Confidential Bootstrap and Command bytes travel only through stdin and are never logged. WorkspaceDirectory is the resolved private helper input, without filesystem adapter configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL