assets

package
v0.2.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

The fixtures in this package are representative, non-installable payloads. They are not a versioned release manifest or cache manager.

Index

Constants

View Source
const (
	// FeasibilitySchemaVersion identifies representative fixture metadata.
	FeasibilitySchemaVersion = "flowbaton.g001.feasibility.v1"
	FeasibilityOnlyScope     = "representative-fixture-not-release-artifact"
)
View Source
const (
	GitHubRepository     = "larchwave/flowbaton"
	GitHubSignerWorkflow = "larchwave/flowbaton/.github/workflows/release-publish.yml"
)
View Source
const ManifestSchemaVersion = "flowbaton.assets.v0"

Variables

View Source
var (
	ErrUnresolvedAsset       = errors.New("asset was not resolved by the compatibility contract")
	ErrArchiveSourceRequired = errors.New("archive source is required")
	ErrCacheRootRequired     = errors.New("asset cache root is required")
	ErrInvalidAssetCache     = errors.New("invalid asset cache")
)
View Source
var (
	ErrInvalidAssetManifest    = errors.New("invalid asset manifest")
	ErrNoCompatibleAsset       = errors.New("no compatible asset")
	ErrAssetNotReleaseEligible = errors.New("asset is not release eligible")
)
View Source
var (
	ErrVerifierRequired       = errors.New("identity verifier is required")
	ErrInvalidManifest        = errors.New("invalid feasibility manifest")
	ErrCompressedSizeMismatch = errors.New("compressed size mismatch")
	ErrCompressedHashMismatch = errors.New("compressed hash mismatch")
	ErrPayloadSizeMismatch    = errors.New("payload size mismatch")
	ErrPayloadHashMismatch    = errors.New("payload hash mismatch")
	ErrModeMismatch           = errors.New("payload mode mismatch")
	ErrAlreadyPublished       = errors.New("fixture destination already exists")
)

Functions

This section is empty.

Types

type AcquiredAsset

type AcquiredAsset struct {
	Directory    string
	IdentityPath string
}

type ArchiveFormat

type ArchiveFormat string
const (
	ArchiveFormatGZIP    ArchiveFormat = "gzip"
	ArchiveFormatTarGZIP ArchiveFormat = "tar+gzip"
)

type ArchiveSource

type ArchiveSource interface {
	Open(context.Context, Asset) (io.ReadCloser, error)
}

type Asset

type Asset struct {
	ID            string        `json:"id"`
	Status        AssetStatus   `json:"status"`
	HostVersion   string        `json:"host_version"`
	AssetVersion  string        `json:"asset_version"`
	HostOS        string        `json:"host_os"`
	HostArch      string        `json:"host_arch"`
	Platform      Platform      `json:"platform"`
	AssetHash     string        `json:"asset_hash"`
	Archive       AssetArchive  `json:"archive"`
	Files         []AssetFile   `json:"files"`
	Identity      AssetIdentity `json:"identity"`
	Compatibility Compatibility `json:"compatibility"`
}

type AssetArchive

type AssetArchive struct {
	Format             ArchiveFormat `json:"format"`
	SHA256             string        `json:"sha256"`
	Size               int64         `json:"size"`
	UncompressedSHA256 string        `json:"uncompressed_sha256"`
	UncompressedSize   int64         `json:"uncompressed_size"`
}

type AssetFile

type AssetFile struct {
	Path   string `json:"path"`
	SHA256 string `json:"sha256"`
	Size   int64  `json:"size"`
	Mode   string `json:"mode"`
}

type AssetIdentity

type AssetIdentity struct {
	Kind  VerificationKind `json:"kind"`
	Value string           `json:"value"`
	Path  string           `json:"path"`
}

type AssetStatus

type AssetStatus string
const (
	AssetStatusRepresentative AssetStatus = "representative-not-release-artifact"
	AssetStatusRelease        AssetStatus = "release"
)

type CommandIdentityVerifier

type CommandIdentityVerifier struct {
	Run CommandRunner
}

CommandIdentityVerifier performs the platform-native identity checks after archive hashes and paths have been verified. Android uses apkanalyzer's manifest parser; iOS uses codesign's designated bundle identifier.

func (CommandIdentityVerifier) Verify

func (verifier CommandIdentityVerifier) Verify(ctx context.Context, candidate VerificationCandidate) error

type CommandRunner

type CommandRunner func(context.Context, string, ...string) ([]byte, error)

CommandRunner runs one external verification command. The injected seam keeps provenance verification testable without trusting a fake gh executable.

type Compatibility

type Compatibility struct {
	AndroidAPI IntegerRange `json:"android_api"`
	Xcode      VersionRange `json:"xcode"`
	IOSRuntime VersionRange `json:"ios_runtime"`
}

type FeasibilityManifest

type FeasibilityManifest struct {
	SchemaVersion    string           `json:"schema_version"`
	Scope            string           `json:"scope"`
	Platform         Platform         `json:"platform"`
	ArtifactName     string           `json:"artifact_name"`
	Identity         string           `json:"identity"`
	VerificationKind VerificationKind `json:"verification_kind"`
	Mode             fs.FileMode      `json:"mode"`
	CompressedSHA256 string           `json:"compressed_sha256"`
	PayloadSHA256    string           `json:"payload_sha256"`
	CompressedSize   int64            `json:"compressed_size"`
	PayloadSize      int64            `json:"payload_size"`
	BudgetBytes      int64            `json:"budget_bytes"`
}

FeasibilityManifest is the minimum metadata needed to test the compressed-payload pipeline.

type FeasibilityPublisher

type FeasibilityPublisher struct {
	Verifier IdentityVerifier
}

FeasibilityPublisher performs verified extraction followed by atomic publication in a caller-provided temporary cache. Locking, cache recovery, release selection, and retention policy are outside this bounded component.

func (FeasibilityPublisher) Publish

func (p FeasibilityPublisher) Publish(ctx context.Context, cacheRoot string, fixture Fixture) (PublishedFixture, error)

Publish validates and expands one representative gzip payload into a sibling temporary directory, invokes the identity verifier, rechecks bytes and mode, and publishes the complete directory with one atomic rename.

type FileLocker

type FileLocker struct{}

FileLocker uses an operating-system advisory file lock. The lock is released by the kernel if the owning process terminates, so interrupted acquisitions cannot leave a permanent lock behind.

func (FileLocker) Lock

func (FileLocker) Lock(ctx context.Context, path string) (Unlocker, error)

type Fixture

type Fixture struct {
	Manifest   FeasibilityManifest
	Compressed []byte
}

Fixture pairs deterministic gzip bytes with their feasibility metadata.

func RepresentativeFixtures

func RepresentativeFixtures() []Fixture

RepresentativeFixtures returns fresh copies so a corruption test or caller cannot alter the package's embedded fixture bytes.

type GitHubReleaseSource

type GitHubReleaseSource struct {
	Client  *http.Client
	Run     CommandRunner
	TempDir string
	BaseURL string
}

GitHubReleaseSource downloads driver archives from the release matching the host version and verifies their GitHub build attestation before Manager reads or publishes any bytes.

func (GitHubReleaseSource) DownloadManifest

func (source GitHubReleaseSource) DownloadManifest(ctx context.Context, hostVersion string) ([]byte, error)

DownloadManifest obtains and verifies the release's driver manifest. The manifest is itself an attested release artifact, so it cannot redirect asset selection before provenance has been established.

func (GitHubReleaseSource) Open

func (source GitHubReleaseSource) Open(ctx context.Context, asset Asset) (io.ReadCloser, error)

type IdentityVerifier

type IdentityVerifier interface {
	Verify(context.Context, VerificationCandidate) error
}

IdentityVerifier represents the Android package-identity or iOS bundle-signature check required before publication.

type IntegerRange

type IntegerRange struct {
	Min int `json:"min"`
	Max int `json:"max"`
}

type Locker

type Locker interface {
	Lock(context.Context, string) (Unlocker, error)
}

type Manager

type Manager struct {
	// CacheRoot is the drivers directory. Production callers use
	// ~/.flowbaton/drivers; tests and isolated tools inject a temporary root.
	CacheRoot string
	Source    ArchiveSource
	Verifier  IdentityVerifier
	Locker    Locker
}

func (Manager) Acquire

func (m Manager) Acquire(ctx context.Context, resolved ResolvedAsset) (acquired AcquiredAsset, returnErr error)

func (Manager) Cleanup

func (m Manager) Cleanup(ctx context.Context, policy RetentionPolicy) error

func (Manager) EnsureCacheRoot

func (m Manager) EnsureCacheRoot() error

EnsureCacheRoot creates and validates the manager's cache boundary without acquiring an asset. Metadata stored beside version directories uses the same no-symlink path contract as archive publication.

type Manifest

type Manifest struct {
	SchemaVersion   string  `json:"schema_version"`
	ManifestVersion string  `json:"manifest_version"`
	Assets          []Asset `json:"assets"`
}

func ParseManifest

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

type NonRegularCandidateError

type NonRegularCandidateError struct {
	Path string
	Mode fs.FileMode
}

NonRegularCandidateError reports that the extracted asset was replaced by a symlink, directory, device, or other non-regular filesystem entry. Path and Mode come from Lstat, so inspecting the error never follows the entry.

func (*NonRegularCandidateError) Error

func (e *NonRegularCandidateError) Error() string

type Platform

type Platform string

Platform identifies the device platform represented by a feasibility fixture.

const (
	PlatformAndroid      Platform = "android"
	PlatformIOSSimulator Platform = "ios-simulator"
)

type PublishedFixture

type PublishedFixture struct {
	Directory string
	AssetPath string
}

PublishedFixture describes a successfully and atomically published fixture.

type Request

type Request struct {
	ID           string
	AssetVersion string
	Platform     Platform
}

type ResolvedAsset

type ResolvedAsset struct {
	Asset           Asset
	ManifestVersion string
	Runtime         Runtime
	// contains filtered or unexported fields
}

func Resolve

func Resolve(manifest Manifest, runtime Runtime, request Request) (ResolvedAsset, error)

type RetentionPolicy

type RetentionPolicy struct {
	ActiveHostVersion   string
	ActiveAssetHashes   []string
	PreviousHostVersion string
}

RetentionPolicy keeps the selected asset hashes for the active host version and the complete immediately previous host version. Other directories are removed only when their cache marker proves Flowbaton ownership.

type Runtime

type Runtime struct {
	HostVersion       string
	HostOS            string
	HostArch          string
	AndroidAPI        int
	XcodeVersion      string
	IOSRuntimeVersion string
}

type Unlocker

type Unlocker interface {
	Unlock() error
}

type VerificationCandidate

type VerificationCandidate struct {
	Path     string
	Platform Platform
	Identity string
	Kind     VerificationKind
}

VerificationCandidate is passed to an injected platform-aware verifier after the payload has passed internal hash and mode checks but before publication.

type VerificationKind

type VerificationKind string

VerificationKind identifies the external identity check an artifact requires. The publisher injects this check; it does not implement Android package parsing or Apple code-signature verification itself.

const (
	VerificationPackageIdentity         VerificationKind = "package-identity"
	VerificationBundleSignatureIdentity VerificationKind = "bundle-signature-identity"
)

type VersionRange

type VersionRange struct {
	Min string `json:"min"`
	Max string `json:"max"`
}

Jump to

Keyboard shortcuts

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