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
- Variables
- func MarshalProfile(profile Profile) ([]byte, error)
- func ValidateContract(contract Contract) error
- func ValidateIdentity(identity Identity) error
- type Asset
- type Catalog
- type Contract
- type DependencyBinding
- type Descriptor
- type Event
- type EventDirection
- type Identity
- type Layer
- type LayerRow
- type Lifecycle
- type Lock
- type LockedEntry
- type Permission
- type Plan
- type PlannedEntry
- type PlannedExport
- type Profile
- type ProfileEntry
- type ProfileExport
- type ProfileScope
- type Realm
- type Requirement
Constants ¶
const ( ProfileFormatVersion = 1 LockFormatVersion = 1 )
const DescriptorFormatVersion = 1
Variables ¶
var ErrContractMismatch = errors.New("plugin service contract mismatch")
ErrContractMismatch describes an exact service contract disagreement.
Functions ¶
func MarshalProfile ¶
MarshalProfile returns deterministic, newline-terminated strict JSON.
func ValidateContract ¶
ValidateContract is exported for profile/deployment decoders that admit a contract independently of a complete descriptor.
func ValidateIdentity ¶
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 ¶
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.
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 ¶
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 ¶
ResolveProfile deliberately creates a new exact lock using the latest registered descriptor for every symbolic row.
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.
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 FreezeProfile ¶
FreezeProfile canonicalizes non-semantic collections and computes a profile fingerprint. Entry order is semantic and is preserved.
func ParseProfile ¶
ParseProfile decodes strict JSON and verifies the 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 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. |