SmolBox.ArtifactStore.Directory (SmolBox v0.1.0)

Copy Markdown View Source

Small host-owned local artifact adapter for examples and development.

The root must already exist with mode 0700, on a trusted local filesystem. Only trusted host code may modify it or its ancestors. Guest bytes never select a path: identities are hashed into filenames, and output blobs are addressed by SHA-256. Atomic hard-link installation refuses to replace a different receipt. Files are synced before installation. This is not an object-storage service or a claim of crash durability for arbitrary filesystems; the host owns filesystem durability, disk quotas, backup, and removal of unreferenced blobs/temp files.

seed/4 registers an approved input. read_output/4 retrieves a stored output. Each read is bounded to one MiB. Output replacement requires a distinct execution identity. No archive extraction, globbing, URLs, or guest-selected host paths are supported. The adapter must not share its root with untrusted host processes.

Summary

Functions

Configure an absolute existing private directory with mode 0700.

Read a collected output using its execution handle and manifest destination.

Store approved input bytes under a scope and opaque source reference.

Types

t()

@type t() :: %SmolBox.ArtifactStore.Directory{root: String.t()}

Functions

new(root)

@spec new(String.t()) :: {:ok, t()} | {:error, SmolBox.Error.t()}

Configure an absolute existing private directory with mode 0700.

The directory is not created by this call. Pass the returned context as {SmolBox.ArtifactStore.Directory, context} in the runtime's :artifact_store option. This adapter is not a process and needs no supervisor child.

read_output(store, arg, destination, max)

@spec read_output(t(), {String.t(), String.t()}, String.t(), pos_integer()) ::
  {:ok, binary()} | {:error, SmolBox.Error.t()}

Read a collected output using its execution handle and manifest destination.

max is a positive byte limit up to 1 MiB. This reads host artifact storage and remains usable after VM cleanup. :not_found means no receipt/blob was found; check the execution's collection state before expecting an output.

seed(store, scope, reference, bytes)

@spec seed(t(), String.t(), String.t(), binary()) :: :ok | {:error, SmolBox.Error.t()}

Store approved input bytes under a scope and opaque source reference.

Bytes must fit within 1 MiB. The source reference is used as "source" in an input manifest; it is not a filename. Repeating identical bytes succeeds; different bytes under the same reference return an identity conflict.