cellpack

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package cellpack is the Piglet-Binary-side counterpart to the host's prebuilt-cell seam (runtimecell.PrebuiltResolver). A Piglet Binary embeds its packed cells plus a manifest describing each cell's composition; at startup it extracts the binaries and registers a Resolver so the host serves them without any Go/Rust toolchain. A Node cell embeds its members' sources instead of a binary; the host runs them with the user's installed Node, as Stock PiG runs them.

Matching is by composition (language + cell key + target + extension set), which is stable across machines, rather than the host's from-source build hash, which embeds the toolchain version and is not reproducible on a toolchain-less consumer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register() error

Register wires this binary's embedded cells into the host prebuilt-cell seam and records source-free cell entries that startup can load directly. It is a no-op when the embedded manifest is empty (stock pig), so it never changes stock behavior.

Types

type CellEntry

type CellEntry struct {
	Language string `json:"language"` // go | rust | python | node
	Key      string `json:"key"`
	Strategy string `json:"strategy,omitempty"` // isolated | packed-go | packed-rust | packed-python | packed-node
	OS       string `json:"os"`
	Arch     string `json:"arch"`
	// Binary is the embedded file's path relative to the cells directory. For a
	// Node cell it is a tar archive of the members' sources.
	Binary string `json:"binary"`
	// Digest is the sha256 hex digest of a Node cell's archive. Startup refuses
	// an archive whose bytes do not match it and extracts the archive into a
	// directory named by it.
	Digest     string     `json:"digest,omitempty"`
	Extensions []ExtEntry `json:"extensions"`
}

CellEntry is one prebuilt cell: its composition and where its binary lives relative to the extraction directory.

type ExtEntry

type ExtEntry struct {
	Name string `json:"name"`
	Hash string `json:"hash,omitempty"`
	// Source is a Node member's source path inside its cell's extracted
	// sources, in slash form: its directory, or the file of a single-file
	// extension.
	Source string `json:"source,omitempty"`
}

ExtEntry pins one extension's identity in a cell.

type LoadedCell

type LoadedCell struct {
	Language   string
	Key        string
	Strategy   string
	BinaryPath string
	Extensions []ExtEntry
}

LoadedCell is an embedded cell extracted from the Piglet Binary binary and ready to start without source or a language toolchain.

func LoadedCells

func LoadedCells() []LoadedCell

LoadedCells returns the embedded cells extracted by Register. The returned slice is a copy, so callers may sort or filter it.

type Manifest

type Manifest struct {
	PigCoreVersion string      `json:"pigCoreVersion"`
	Cells          []CellEntry `json:"cells"`
}

Manifest describes the cells embedded in a Piglet Binary.

type Resolver

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

Resolver serves embedded cells by composition. It implements runtimecell.PrebuiltResolver.

func NewResolver

func NewResolver(m Manifest, baseDir string) *Resolver

NewResolver indexes a manifest against the directory its binaries were extracted into. A Node cell has no prebuilt runner to serve: the host stages it from its extracted sources.

func (*Resolver) ResolvePrebuilt

func (r *Resolver) ResolvePrebuilt(req runtimecell.PrebuiltRequest) (string, bool)

ResolvePrebuilt returns the embedded binary for a request's composition, or ok=false to let the host build from source. It fails closed: a pinned hash that disagrees with the request, or a missing extracted binary, is a miss.

Jump to

Keyboard shortcuts

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