plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plugin defines immutable, language-neutral contracts for server, presentation-host, and client plugins.

Product behavior lives behind these descriptors. A descriptor says what a plugin provides, requires, publishes, consumes, and is permitted to access; implementation selection, configuration values, deployment, and secrets remain separate artifacts.

Index

Constants

View Source
const (
	ProfileFormatVersion = 1
	LockFormatVersion    = 1
)
View Source
const DescriptorFormatVersion = 1

Variables

View Source
var ErrContractMismatch = errors.New("plugin service contract mismatch")

ErrContractMismatch describes an exact service contract disagreement.

Functions

func MarshalProfile

func MarshalProfile(profile Profile) ([]byte, error)

MarshalProfile returns deterministic, newline-terminated strict JSON.

func ValidateContract

func ValidateContract(contract Contract) error

ValidateContract is exported for profile/deployment decoders that admit a contract independently of a complete descriptor.

func ValidateIdentity

func ValidateIdentity(identity Identity) error

ValidateIdentity verifies an immutable descriptor identity.

Types

type Asset

type Asset struct {
	Name      string `json:"name" yaml:"name"`
	MediaType string `json:"media_type" yaml:"media_type"`
	Digest    string `json:"digest" yaml:"digest"`
}

Asset pins one implementation-independent module or presentation resource. The deployment chooses where the bytes are served from; the descriptor records what bytes are part of this revision.

type Catalog

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

Catalog stores immutable plugin descriptor revisions. It never resolves an implementation binary or secret; those are deployment concerns.

func NewCatalog

func NewCatalog() *Catalog

func (*Catalog) Identities

func (catalog *Catalog) Identities() []Identity

Identities returns a deterministic snapshot without exposing catalog-owned descriptor slices.

func (*Catalog) Latest

func (catalog *Catalog) Latest(name string) (Descriptor, Identity, error)

Latest returns the greatest registered revision for a symbolic name. It is used only when deliberately generating a new lock; mounting consumes the exact lock and never calls Latest.

func (*Catalog) Register

func (catalog *Catalog) Register(descriptor Descriptor) (Identity, error)

Register validates and stores one immutable descriptor revision.

func (*Catalog) Resolve

func (catalog *Catalog) Resolve(identity Identity) (Descriptor, error)

Resolve returns the exact descriptor named by an immutable identity.

type Contract

type Contract struct {
	Name     string `json:"name" yaml:"name"`
	Revision uint64 `json:"revision" yaml:"revision"`
	Digest   string `json:"digest" yaml:"digest"`
}

Contract identifies one immutable service, event, or schema vocabulary. Name alone is used for dependency lookup; revision and digest prevent two implementations from silently assigning different meanings to that name.

func (Contract) Compatible

func (contract Contract) Compatible(other Contract) bool

Compatible proves that two exact service contracts have the same meaning.

type DependencyBinding

type DependencyBinding struct {
	Service  Contract `json:"service"`
	Provider string   `json:"provider"`
	Optional bool     `json:"optional,omitempty"`
}

DependencyBinding is the exact provider selected for one consumer service.

type Descriptor

type Descriptor struct {
	FormatVersion uint64        `json:"format_version" yaml:"format_version"`
	Name          string        `json:"name" yaml:"name"`
	Revision      uint64        `json:"revision" yaml:"revision"`
	Realm         Realm         `json:"realm" yaml:"realm"`
	Platforms     []string      `json:"platforms" yaml:"platforms"`
	Provides      []Contract    `json:"provides,omitempty" yaml:"provides,omitempty"`
	Requires      []Requirement `json:"requires,omitempty" yaml:"requires,omitempty"`
	Events        []Event       `json:"events,omitempty" yaml:"events,omitempty"`
	ConfigSchema  *Contract     `json:"config_schema,omitempty" yaml:"config_schema,omitempty"`
	StateSchema   *Contract     `json:"state_schema,omitempty" yaml:"state_schema,omitempty"`
	Permissions   []Permission  `json:"permissions,omitempty" yaml:"permissions,omitempty"`
	Assets        []Asset       `json:"assets,omitempty" yaml:"assets,omitempty"`
	Lifecycle     Lifecycle     `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
}

Descriptor is the complete immutable composition and permission contract of a plugin revision.

func (Descriptor) Canonical

func (descriptor Descriptor) Canonical() (Descriptor, error)

Canonical validates and sorts all declaration-order-insensitive fields.

func (Descriptor) Clone

func (descriptor Descriptor) Clone() Descriptor

Clone returns a recursively independent descriptor.

func (Descriptor) Digest

func (descriptor Descriptor) Digest() (string, error)

Digest computes the canonical content digest.

func (Descriptor) Identity

func (descriptor Descriptor) Identity() (Identity, error)

Identity returns the exact content-addressed descriptor identity.

func (Descriptor) Validate

func (descriptor Descriptor) Validate() error

Validate checks a complete descriptor without consulting a catalog.

type Event

type Event struct {
	Contract  Contract       `json:"contract" yaml:"contract"`
	Direction EventDirection `json:"direction" yaml:"direction"`
}

Event declares a typed event extension point.

type EventDirection

type EventDirection string

EventDirection is relative to a plugin.

const (
	Publishes EventDirection = "publishes"
	Consumes  EventDirection = "consumes"
)

type Identity

type Identity struct {
	Name     string `json:"name" yaml:"name"`
	Revision uint64 `json:"revision" yaml:"revision"`
	Digest   string `json:"digest" yaml:"digest"`
}

Identity pins one immutable plugin descriptor revision.

type Layer

type Layer struct {
	Name string     `json:"name" yaml:"name"`
	Rows []LayerRow `json:"rows" yaml:"rows"`
}

Layer is one ordered profile patch.

type LayerRow

type LayerRow struct {
	ID     string        `json:"id" yaml:"id"`
	Remove bool          `json:"remove,omitempty" yaml:"remove,omitempty"`
	Entry  *ProfileEntry `json:"entry,omitempty" yaml:"entry,omitempty"`
}

LayerRow replaces a complete row by stable ID, appends a new row, or removes a row. Partial mutation is intentionally unsupported: it makes the effective composition printable and reviewable.

type Lifecycle

type Lifecycle struct {
	QuiesceTimeoutMS uint64 `json:"quiesce_timeout_ms,omitempty" yaml:"quiesce_timeout_ms,omitempty"`
	DisposeTimeoutMS uint64 `json:"dispose_timeout_ms,omitempty" yaml:"dispose_timeout_ms,omitempty"`
	Snapshot         bool   `json:"snapshot,omitempty" yaml:"snapshot,omitempty"`
	Restore          bool   `json:"restore,omitempty" yaml:"restore,omitempty"`
}

Lifecycle declares bounded transition support. Zero timeouts select the runtime's bounded defaults rather than meaning unbounded.

type Lock

type Lock struct {
	FormatVersion      uint64        `json:"format_version" yaml:"format_version"`
	ProfileFingerprint string        `json:"profile_fingerprint" yaml:"profile_fingerprint"`
	Fingerprint        string        `json:"fingerprint" yaml:"fingerprint"`
	Entries            []LockedEntry `json:"entries" yaml:"entries"`
}

Lock is the complete descriptor resolution for one frozen profile.

func ResolveProfile

func ResolveProfile(profile Profile, catalog *Catalog) (Lock, error)

ResolveProfile deliberately creates a new exact lock using the latest registered descriptor for every symbolic row.

func (Lock) Clone

func (lock Lock) Clone() Lock

Clone returns a recursively independent lock.

func (Lock) Validate

func (lock Lock) Validate() error

Validate verifies lock structure, profile binding, and fingerprint.

type LockedEntry

type LockedEntry struct {
	ID     string   `json:"id" yaml:"id"`
	Plugin Identity `json:"plugin" yaml:"plugin"`
}

LockedEntry binds a stable profile row to an exact plugin descriptor.

type Permission

type Permission struct {
	Kind       string   `json:"kind" yaml:"kind"`
	Resource   string   `json:"resource" yaml:"resource"`
	Operations []string `json:"operations" yaml:"operations"`
	// Authority names the typed authority contract required at the effect
	// boundary. It is empty for capabilities that cannot perform an external
	// effect, such as rendering an already-redacted snapshot.
	Authority string `json:"authority,omitempty" yaml:"authority,omitempty"`
}

Permission is a ceiling, not a grant. Deployment policy and the authority host may narrow it further. Operations are declaration-order-insensitive.

type Plan

type Plan struct {
	ProfileFingerprint string          `json:"profile_fingerprint"`
	LockFingerprint    string          `json:"lock_fingerprint"`
	Realm              Realm           `json:"realm"`
	Fingerprint        string          `json:"fingerprint"`
	Entries            []PlannedEntry  `json:"entries"`
	Exports            []PlannedExport `json:"exports,omitempty"`
}

Plan is the immutable static plugin composition consumed by a realm runtime.

func Compile

func Compile(profile Profile, lock Lock, catalog *Catalog) (Plan, error)

Compile verifies a frozen profile and lock, binds every visible service to one exact provider, rejects dependency cycles, and emits deterministic mount order. It never falls back to a newer catalog revision.

func (Plan) Clone

func (plan Plan) Clone() Plan

Clone returns a recursively independent plan.

func (Plan) Validate

func (plan Plan) Validate() error

Validate proves that a plan is self-contained, exact, dependency ordered, and unmodified since compilation.

type PlannedEntry

type PlannedEntry struct {
	Entry        ProfileEntry        `json:"entry"`
	Identity     Identity            `json:"identity"`
	Descriptor   Descriptor          `json:"descriptor"`
	Dependencies []DependencyBinding `json:"dependencies,omitempty"`
}

PlannedEntry is one mount in deterministic dependency order.

type PlannedExport

type PlannedExport struct {
	Name     string   `json:"name"`
	Provider string   `json:"provider"`
	Service  Contract `json:"service"`
}

PlannedExport is an exact externally visible service boundary.

type Profile

type Profile struct {
	FormatVersion uint64          `json:"format_version" yaml:"format_version"`
	Name          string          `json:"name" yaml:"name"`
	Revision      uint64          `json:"revision" yaml:"revision"`
	Realm         Realm           `json:"realm" yaml:"realm"`
	Fingerprint   string          `json:"fingerprint" yaml:"fingerprint"`
	Scopes        []ProfileScope  `json:"scopes" yaml:"scopes"`
	Entries       []ProfileEntry  `json:"entries" yaml:"entries"`
	Exports       []ProfileExport `json:"exports,omitempty" yaml:"exports,omitempty"`
}

Profile is one realm's ordered, patchable plugin tree.

func Compose

func Compose(base Profile, revision uint64, layers ...Layer) (Profile, error)

Compose applies ordered whole-row layers and freezes the resulting revision.

func FreezeProfile

func FreezeProfile(profile Profile) (Profile, error)

FreezeProfile canonicalizes non-semantic collections and computes a profile fingerprint. Entry order is semantic and is preserved.

func ParseProfile

func ParseProfile(source []byte) (Profile, error)

ParseProfile decodes strict JSON and verifies the fingerprint.

func (Profile) Clone

func (profile Profile) Clone() Profile

Clone returns a recursively independent profile.

func (Profile) Validate

func (profile Profile) Validate() error

Validate verifies structure and the stored fingerprint.

type ProfileEntry

type ProfileEntry struct {
	ID     string `json:"id" yaml:"id"`
	Plugin string `json:"plugin" yaml:"plugin"`
	Scope  string `json:"scope" yaml:"scope"`
}

ProfileEntry mounts one symbolic plugin in a scope. Values and implementation bindings are deliberately absent and live in separate artifacts.

type ProfileExport

type ProfileExport struct {
	Name     string `json:"name" yaml:"name"`
	Provider string `json:"provider" yaml:"provider"`
	Service  string `json:"service" yaml:"service"`
}

ProfileExport exposes one provider service as a profile boundary. Application launchers use exports instead of reaching into a plugin implementation.

type ProfileScope

type ProfileScope struct {
	Path    string   `json:"path" yaml:"path"`
	Isolate []string `json:"isolate,omitempty" yaml:"isolate,omitempty"`
}

ProfileScope is a service visibility boundary. A child sees services in its own scope and ancestors unless an isolation boundary names that service.

type Realm

type Realm string

Realm is the trust and lifecycle plane in which a plugin runs.

const (
	ServerRealm           Realm = "server"
	PresentationHostRealm Realm = "presentation_host"
	ClientRealm           Realm = "client"
)

type Requirement

type Requirement struct {
	Contract Contract `json:"contract" yaml:"contract"`
	Optional bool     `json:"optional,omitempty" yaml:"optional,omitempty"`
}

Requirement is one service contract a plugin consumes. Optional requirements do not delay mounting, but if a matching service is present it must still match this exact contract.

Directories

Path Synopsis
Package httpservice provides realm-neutral, scoped HTTP routing mechanics for plugin compositions.
Package httpservice provides realm-neutral, scoped HTTP routing mechanics for plugin compositions.
Package runtime mounts one immutable plugin plan with scoped services and reversible lifecycle effects.
Package runtime mounts one immutable plugin plan with scoped services and reversible lifecycle effects.

Jump to

Keyboard shortcuts

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