runtimebundle

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotPrepared means the verified native runtime is not present in the
	// local cache. Preparation is always an explicit operation.
	ErrNotPrepared = errors.New("gomonty native runtime is not prepared")
	// ErrIntegrity means bytes on disk or in a downloaded bundle do not match
	// the hashes committed with this Go module.
	ErrIntegrity = errors.New("gomonty native runtime integrity check failed")
	// ErrUnsupported means there is no runtime manifest for the current target.
	ErrUnsupported = errors.New("gomonty native runtime target is unsupported")
	// ErrBuildPrerequisite means local build preparation cannot prove that the
	// reviewed compiler and target are available.
	ErrBuildPrerequisite = errors.New("gomonty native runtime build prerequisite is not satisfied")
)

Functions

func ComputeNativeSourceDigest

func ComputeNativeSourceDigest(sourceDir string) (string, error)

ComputeNativeSourceDigest hashes every reviewed input executed or compiled by PrepareBuild. Generated target directories and native outputs are excluded.

func DefaultCacheRoot

func DefaultCacheRoot() (string, error)

DefaultCacheRoot returns the cache root used by both Prepare and the loader. GOMONTY_CACHE_DIR is an explicit location override; it does not weaken hash verification.

func VerifyInputFiles

func VerifyInputFiles(manifest Manifest, inputRoot string) error

VerifyInputFiles checks whether build outputs reproduce every committed release file byte-for-byte. It is an explicit reproducibility audit, not a requirement for locally built runtimes.

func VerifyInputTarget

func VerifyInputTarget(manifest Manifest, inputRoot, targetID string) error

VerifyInputTarget performs that exact-byte audit for one target.

func VerifyReleaseAssets

func VerifyReleaseAssets(manifest Manifest, assetRoot string) error

VerifyReleaseAssets proves that exact release bytes match a manifest.

func WriteManifest

func WriteManifest(path string, manifest Manifest) error

WriteManifest writes canonical, reviewable manifest JSON.

Types

type File

type File struct {
	Role       string `json:"role"`
	Name       string `json:"name"`
	SHA256     string `json:"sha256"`
	Size       int64  `json:"size"`
	Executable bool   `json:"executable"`
}

File describes an exact file installed from a runtime release asset.

func InspectInputTarget

func InspectInputTarget(manifest Manifest, inputRoot, targetID string) ([]File, error)

InspectInputTarget validates one local build's exact layout and returns the hashes it actually produced. It deliberately does not claim that an unpinned local toolchain reproduces a committed release byte-for-byte.

type HTTPDoer

type HTTPDoer interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPDoer is the transport port used by download preparation.

type Manifest

type Manifest struct {
	Schema         int      `json:"schema"`
	RuntimeVersion string   `json:"runtime_version"`
	ReleaseTag     string   `json:"release_tag"`
	ReleaseBaseURL string   `json:"release_base_url"`
	MontyVersion   string   `json:"monty_version"`
	MontyCommit    string   `json:"monty_commit"`
	RustToolchain  string   `json:"rust_toolchain"`
	SourceSHA256   string   `json:"native_source_sha256"`
	Targets        []Target `json:"targets"`
	// contains filtered or unexported fields
}

Manifest is the committed trust root for one native runtime release.

The JSON representation is intentionally public to the repository tooling, but the Go type remains internal so consumers cannot replace the manifest at runtime.

func CurrentManifest

func CurrentManifest() (Manifest, error)

CurrentManifest loads and validates the immutable manifest embedded in the package. Only text metadata, never native code, is embedded in the Go module.

func GenerateReleaseAssets

func GenerateReleaseAssets(manifest Manifest, inputRoot, outputRoot string) (Manifest, error)

GenerateReleaseAssets is used only by repository release automation. It creates deterministic ZIP files and returns a manifest containing hashes for both each archive and both files inside it.

func ParseManifest

func ParseManifest(raw []byte) (Manifest, error)

ParseManifest decodes and strictly validates a manifest. It is exported only for the repository's release tooling and tests.

func (Manifest) AssetURL

func (m Manifest) AssetURL(target Target, baseURL string) string

AssetURL returns the immutable release URL for target. A non-empty base URL is an explicit mirror override; hashes remain anchored in the manifest.

func (Manifest) CurrentTarget

func (m Manifest) CurrentTarget() (Target, error)

CurrentTarget returns the manifest entry selected for the current process. Linux libc is detected from the running system so callers cannot silently prepare a GNU runtime on musl, or the reverse, because of a missing build tag.

func (Manifest) Digest

func (m Manifest) Digest() string

Digest returns the SHA-256 of the exact manifest bytes.

func (Manifest) TargetFor

func (m Manifest) TargetFor(goos, goarch, variant string) (Target, error)

TargetFor resolves an exact platform tuple.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate rejects ambiguous or incomplete manifests rather than guessing at an installation layout.

type Mode

type Mode string

Mode selects the only two operations allowed to create a prepared runtime.

const (
	ModeDownload Mode = "download"
	ModeBuild    Mode = "build"
)

type Options

type Options struct {
	Mode       Mode
	SourceDir  string
	BaseURL    string
	HTTPClient HTTPDoer

	// CacheRoot is intentionally internal-package surface. The public API uses
	// the same default root as the loader; tests can isolate it here.
	CacheRoot string
}

Options configures an explicit preparation operation.

type Result

type Result struct {
	RuntimeVersion string `json:"runtime_version"`
	Target         string `json:"target"`
	Origin         string `json:"origin"`
	RustToolchain  string `json:"rust_toolchain"`
	Directory      string `json:"directory"`
	LibraryPath    string `json:"library_path"`
	WorkerPath     string `json:"worker_path"`
}

Result identifies an installed runtime that was verified against the embedded manifest in this process.

func Locate

func Locate() (Result, error)

Locate verifies and returns the current target's prepared runtime. No network, build tool, shared-library loader, or child process is invoked.

func Prepare

func Prepare(ctx context.Context, options Options) (Result, error)

Prepare downloads or locally builds the current target, verifies every byte, and atomically installs it. It never loads the shared library or starts the worker.

type Target

type Target struct {
	ID            string `json:"id"`
	GOOS          string `json:"goos"`
	GOARCH        string `json:"goarch"`
	Variant       string `json:"variant,omitempty"`
	RustTarget    string `json:"rust_target"`
	Asset         string `json:"asset"`
	ArchiveSHA256 string `json:"archive_sha256"`
	ArchiveSize   int64  `json:"archive_size"`
	Files         []File `json:"files"`
}

Target describes one release asset and its exact installed contents.

func (Target) File

func (t Target) File(role string) (File, bool)

Jump to

Keyboard shortcuts

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