workloadcatalog

package
v6.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package workloadcatalog stores compiled custom workloads owned by Stroppy.

Index

Constants

View Source
const (
	BuildSchemaVersion    = 1
	SnapshotSchemaVersion = 1
)
View Source
const (
	SchemaVersion = 2
)

Variables

View Source
var (
	ErrGoUnavailable = errors.New("compatible Go toolchain is unavailable")
	ErrSourceProject = errors.New("workload source must be a Go project directory")
)
View Source
var (
	ErrNotFound      = errors.New("workload catalog entry not found")
	ErrAlreadyExists = errors.New("workload catalog entry already exists")
	ErrInvalidEntry  = errors.New("invalid workload catalog entry")
)
View Source
var (
	ErrMainPackage       = errors.New("workload package must be importable, not package main")
	ErrMissingModulePath = errors.New("workload package has no module path")
)
View Source
var (
	ErrBuildNotFound  = errors.New("build cache entry not found")
	ErrBuildAmbiguous = errors.New("build digest prefix is ambiguous")
)
View Source
var (
	ErrRuntimeNotFound = errors.New("local Stroppy runtime not found")
	ErrRuntimeStale    = errors.New("local Stroppy runtime is stale; run 'stroppy build --refresh'")
)
View Source
var ErrProbeContract = errors.New("workload probe contract failed")
View Source
var (
	ErrReplaceConflict = errors.New("conflicting local module replacements")
)

Functions

func BuildRunner

func BuildRunner(ctx context.Context, compiler *toolchain.Compiler, request *RunnerRequest) error

BuildRunner links selected workload packages into one Stroppy executable.

func CleanBuildCache

func CleanBuildCache(stroppyRoot string) error

CleanBuildCache removes reusable content-addressed artifacts.

func ModuleConfig

func ModuleConfig(
	pkg *Package,
) (requirements map[string]string, replacements moduleReplacements, err error)

ModuleConfig returns selected module requirements and replacements without changing source files.

Types

type ActiveRuntime

type ActiveRuntime struct {
	Schema               int       `json:"schema"`
	BuildDigest          string    `json:"build_digest"`
	StroppyVersion       string    `json:"stroppy_version"`
	StroppySource        string    `json:"stroppy_source,omitempty"`
	StroppyModuleVersion string    `json:"stroppy_module_version,omitempty"`
	CatalogDigest        string    `json:"catalog_digest"`
	ArtifactPath         string    `json:"artifact_path"`
	BuiltAt              time.Time `json:"built_at"`
}

ActiveRuntime identifies one published local Stroppy executable.

func (*ActiveRuntime) SDKModuleVersion

func (runtime *ActiveRuntime) SDKModuleVersion() string

SDKModuleVersion is the SDK module version this executable embeds: the merged requirement the generated go.mod carries, not the version the caller asked for.

type BuildManifest

type BuildManifest struct {
	Schema               int               `json:"schema"`
	Digest               string            `json:"digest"`
	CreatedAt            time.Time         `json:"created_at"`
	ArtifactSHA256       string            `json:"artifact_sha256"`
	StroppyVersion       string            `json:"stroppy_version"`
	StroppySource        string            `json:"stroppy_source,omitempty"`
	StroppyModuleVersion string            `json:"stroppy_module_version,omitempty"`
	GoVersion            string            `json:"go_version"`
	TargetOS             string            `json:"target_os"`
	TargetArch           string            `json:"target_arch"`
	TargetSettings       map[string]string `json:"target_settings,omitempty"`
	GOFLAGSSHA256        string            `json:"goflags_sha256"`
	IncludeBuiltIns      bool              `json:"include_built_ins"`
	Workloads            []string          `json:"workloads"`
	SnapshotDigests      []string          `json:"snapshot_digests,omitempty"`
	SourceDigests        []string          `json:"source_digests,omitempty"`
	Modules              []ModuleIdentity  `json:"modules"`
	RunnerSHA256         string            `json:"runner_sha256"`
	DriverBundle         string            `json:"driver_bundle"`
}

BuildManifest records non-secret inputs and output integrity for one cached executable.

func BuildCached

func BuildCached(
	ctx context.Context,
	compiler *toolchain.Compiler,
	request *RunnerRequest,
) (BuildManifest, bool, error)

BuildCached builds or reuses one runner and materializes it atomically at request.Output.

func InspectBuild

func InspectBuild(stroppyRoot, prefix string) (BuildManifest, error)

InspectBuild resolves one build manifest in Stroppy's cache.

func (*BuildManifest) SDKModuleVersion

func (manifest *BuildManifest) SDKModuleVersion() string

SDKModuleVersion is the SDK module version this artifact embeds: the merged requirement, not the version the caller requested.

type BuildResult

type BuildResult struct {
	Name     string
	Source   string
	Artifact string
	Package  Package
	// contains filtered or unexported fields
}

BuildResult is one compiled and probed standalone workload.

func Build

func Build(
	ctx context.Context,
	compiler *toolchain.Compiler,
	source string,
	diagnostics io.Writer,
	offline bool,
	stroppyRoot string,
) (BuildResult, error)

Build compiles one importable workload package through a generated runner.

func (*BuildResult) Cleanup

func (result *BuildResult) Cleanup()

Cleanup removes temporary build output.

type Cache

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

Cache stores completed generated binaries by build identity.

func OpenCache

func OpenCache(stroppyRoot string) (*Cache, error)

OpenCache resolves Stroppy's content-addressed build cache.

func (*Cache) Clean

func (cache *Cache) Clean() error

Clean removes reusable build artifacts while preserving active runtime state.

func (*Cache) Inspect

func (cache *Cache) Inspect(prefix string) (BuildManifest, error)

Inspect resolves a full build digest or unique prefix.

func (*Cache) Root

func (cache *Cache) Root() string

Root returns content-addressed build-cache root.

type Entry

type Entry struct {
	Schema         int       `json:"schema"`
	Name           string    `json:"name"`
	Source         string    `json:"source"`
	Package        string    `json:"package,omitempty"`
	ModulePath     string    `json:"module_path,omitempty"`
	ModuleRoot     string    `json:"module_root,omitempty"`
	SnapshotDigest string    `json:"snapshot_digest,omitempty"`
	BuildDigest    string    `json:"build_digest,omitempty"`
	BuiltAt        time.Time `json:"built_at"`
	ArtifactPath   string    `json:"artifact_path,omitempty"`
	Status         string    `json:"status,omitempty"`
}

Entry describes one active custom workload artifact.

type ModuleIdentity

type ModuleIdentity struct {
	Path        string `json:"path"`
	Version     string `json:"version,omitempty"`
	Sum         string `json:"sum,omitempty"`
	Replacement string `json:"replacement,omitempty"`
}

ModuleIdentity is one resolved module dependency or replacement.

type Package

type Package struct {
	ImportPath     string
	Directory      string
	ModulePath     string
	ModuleRoot     string
	SnapshotDigest string
}

Package describes one importable workload package and its module.

func DiscoverPackage

func DiscoverPackage(
	ctx context.Context,
	compiler *toolchain.Compiler,
	source string,
	offline bool,
) (Package, error)

DiscoverPackage resolves an importable workload package through Go tooling.

type Process

type Process struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Env    []string
	Dir    string
}

Process describes one managed workload process invocation.

type RunnerRequest

type RunnerRequest struct {
	Packages        []Package
	IncludeBuiltIns bool
	Output          string
	TargetOS        string
	TargetArch      string
	Offline         bool
	Diagnostics     io.Writer
	StroppyRoot     string
	CacheRoot       string
	BuildVersion    string
	BuildDigest     string
}

RunnerRequest describes one generated Stroppy executable.

type RuntimeProcess

type RuntimeProcess struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
	Env    []string
	Dir    string
}

RuntimeProcess describes direct argument and stream forwarding to local Stroppy.

type Snapshot

type Snapshot struct {
	Schema           int              `json:"schema"`
	Digest           string           `json:"digest"`
	ImportPath       string           `json:"import_path"`
	ModulePath       string           `json:"module_path"`
	PackageDirectory string           `json:"package_directory"`
	Modules          []SnapshotModule `json:"modules"`
}

Snapshot describes immutable workload compiler inputs owned by Stroppy.

type SnapshotFile

type SnapshotFile struct {
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
}

SnapshotFile identifies one immutable compiler input.

type SnapshotModule

type SnapshotModule struct {
	Path      string         `json:"path"`
	Directory string         `json:"directory"`
	Files     []SnapshotFile `json:"files"`
}

SnapshotModule describes one local module copied into a snapshot.

type Store

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

Store owns one local custom-workload catalog.

func Open

func Open() (*Store, error)

Open resolves the current user's Stroppy workload catalog.

func OpenAt

func OpenAt(path string) (*Store, error)

OpenAt creates a Store rooted at path without creating files yet.

func (*Store) ActiveRuntime

func (store *Store) ActiveRuntime() (ActiveRuntime, error)

ActiveRuntime returns published local runtime state.

func (*Store) BuildSnapshot

func (store *Store) BuildSnapshot(
	ctx context.Context,
	compiler *toolchain.Compiler,
	source string,
	diagnostics io.Writer,
	offline bool,
	stroppyRoot string,
) (BuildResult, Snapshot, error)

BuildSnapshot stores compiler inputs and probes one package from its owned snapshot.

func (*Store) CreateSnapshot

func (store *Store) CreateSnapshot(
	ctx context.Context,
	compiler *toolchain.Compiler,
	pkg *Package,
	offline bool,
) (Snapshot, Package, error)

CreateSnapshot copies exact local compiler inputs into Stroppy-owned storage.

func (*Store) Get

func (store *Store) Get(name string) (Entry, error)

Get returns one catalog entry by workload name.

func (*Store) List

func (store *Store) List() ([]Entry, error)

List returns valid catalog entries ordered by workload name.

func (*Store) Package

func (store *Store) Package(digest string) (Package, error)

Package resolves one owned source snapshot to an importable package.

func (*Store) Packages

func (store *Store) Packages() ([]Package, error)

Packages returns every catalog workload from its owned snapshot.

func (*Store) Publish

func (store *Store) Publish(entry *Entry, sourceArtifact string, replace bool) (publishedEntry Entry, returnErr error)

Publish atomically activates artifact or source snapshot for entry.Name.

func (*Store) RebuildRuntime

func (store *Store) RebuildRuntime(
	ctx context.Context,
	compiler *toolchain.Compiler,
	diagnostics io.Writer,
	offline bool,
	stroppyRoot, buildVersion string,
) (ActiveRuntime, bool, error)

RebuildRuntime builds and atomically activates Stroppy with every catalog workload.

func (*Store) Remove

func (store *Store) Remove(name string) (returnErr error)

Remove deletes only Stroppy-owned catalog data for name.

func (*Store) RemoveRuntime

func (store *Store) RemoveRuntime() error

RemoveRuntime removes active augmented runtime but preserves snapshots and build cache.

func (*Store) Restore

func (store *Store) Restore(entry *Entry) (returnErr error)

Restore atomically restores a previously read catalog manifest without copying artifacts.

func (*Store) Root

func (store *Store) Root() string

Root returns Stroppy-owned catalog root.

func (*Store) Run

func (store *Store) Run(ctx context.Context, name string, args []string, process *Process) error

Run executes an active catalog artifact with direct argument forwarding.

func (*Store) RunRuntime

func (store *Store) RunRuntime(
	ctx context.Context,
	stroppyVersion string,
	args []string,
	process *RuntimeProcess,
) error

RunRuntime starts current local Stroppy with direct argument and stream forwarding.

func (*Store) RuntimeStatus

func (store *Store) RuntimeStatus(stroppyVersion string) (ActiveRuntime, bool, error)

RuntimeStatus reports active state and whether catalog or Stroppy changed.

func (*Store) StroppyRoot

func (store *Store) StroppyRoot() string

StroppyRoot returns ~/.stroppy for toolchains, caches, and generated builds.

type WorkloadProbe

type WorkloadProbe struct {
	Name string `json:"name"`
}

WorkloadProbe is minimal machine-readable identity from a standalone workload.

func Probe

func Probe(ctx context.Context, artifact string) (WorkloadProbe, error)

Probe runs the standalone workload's machine-readable probe command.

Jump to

Keyboard shortcuts

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