pluginregistry

package
v4.0.0-alpha.17 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package pluginregistry records native plugin declarations before runtime execution is enabled.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilComponent is returned when a plugin registers a nil component.
	ErrNilComponent = errors.New("plugin component is nil")

	// ErrDuplicateComponent is returned when a fully qualified component name already exists.
	ErrDuplicateComponent = errors.New("duplicate plugin component")

	// ErrCapabilityNotAllowed is returned when module config does not allow a required capability.
	ErrCapabilityNotAllowed = errors.New("plugin capability is not allowed")

	// ErrInvalidDescriptor is returned when a registered component descriptor is invalid.
	ErrInvalidDescriptor = errors.New("invalid plugin component descriptor")

	// ErrInvalidPolicyAttribute is returned when a plugin policy attribute cannot be converted.
	ErrInvalidPolicyAttribute = errors.New("invalid plugin policy attribute")

	// ErrDuplicateDebugModule is returned when a plugin debug selector already exists.
	ErrDuplicateDebugModule = errors.New("duplicate plugin debug module")

	// ErrInvalidDebugModule is returned when a plugin debug module declaration is invalid.
	ErrInvalidDebugModule = errors.New("invalid plugin debug module")
)

Functions

func BuildSourcePlan

func BuildSourcePlan(components []Component, mode pipeline.ModeMask) (pipeline.Plan, error)

BuildSourcePlan derives the shared dependency and registration-order execution plan.

func NewNativeDecisionContribution

func NewNativeDecisionContribution(
	registry *Registry,
	moduleName string,
	ownership policyregistry.NamespaceOwnership,
) (policyregistry.DefinitionContribution, error)

NewNativeDecisionContribution adapts one module's committed generic declarations inward.

Types

type ArgsView

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

ArgsView exposes immutable policy effect arguments to native plugins.

func NewArgsView

func NewArgsView(data map[string]any) *ArgsView

NewArgsView returns a read-only view over policy effect arguments.

func (*ArgsView) Decode

func (v *ArgsView) Decode(target any) error

Decode strictly decodes the current argument subtree into target.

func (*ArgsView) Get

func (v *ArgsView) Get(path string) (any, bool)

Get resolves a dot-separated argument path.

func (*ArgsView) GetPath

func (v *ArgsView) GetPath(path []string) (any, bool)

GetPath resolves a segment-based argument path.

func (*ArgsView) IsZero

func (v *ArgsView) IsZero() bool

IsZero reports whether the argument view has no keys.

func (*ArgsView) Sub

func (v *ArgsView) Sub(path string) pluginapi.ArgsView

Sub returns an argument view rooted at a dot-separated path.

func (*ArgsView) SubPath

func (v *ArgsView) SubPath(path []string) pluginapi.ArgsView

SubPath returns an argument view rooted at a segment-based path.

type Component

type Component struct {
	Value                            any
	DecisionFactProviderDescriptor   pluginapi.DecisionFactProviderDescriptor
	DecisionEffectProviderDescriptor pluginapi.DecisionEffectProviderDescriptor
	SourceDescriptor                 pluginapi.SourceDescriptor
	HookDescriptor                   pluginapi.HookDescriptor
	QualifiedName                    string
	ModuleName                       string
	LocalName                        string
	Kind                             ComponentKind
	Origin                           ComponentOrigin
}

Component describes one registered plugin component without enabling execution.

func (Component) Clone

func (component Component) Clone() Component

Clone detaches mutable descriptor metadata while retaining the registered component owner.

type ComponentKind

type ComponentKind string

ComponentKind identifies one plugin extension point family.

const (
	// ComponentKindInitTask identifies an init task component.
	ComponentKindInitTask ComponentKind = "init_task"

	// ComponentKindEnvironmentSource identifies an environment source component.
	ComponentKindEnvironmentSource ComponentKind = "environment_source"

	// ComponentKindSubjectSource identifies a subject source component.
	ComponentKindSubjectSource ComponentKind = "subject_source"

	// ComponentKindBackend identifies a backend component.
	ComponentKindBackend ComponentKind = "backend"

	// ComponentKindObligationTarget identifies an obligation target component.
	ComponentKindObligationTarget ComponentKind = "obligation_target"

	// ComponentKindPostActionTarget identifies a post-action target component.
	ComponentKindPostActionTarget ComponentKind = "post_action_target"

	// ComponentKindHook identifies a hook component.
	ComponentKindHook ComponentKind = "hook"

	// ComponentKindDecisionFactProvider identifies a generic decision fact provider.
	ComponentKindDecisionFactProvider ComponentKind = "decision_fact_provider"

	// ComponentKindDecisionEffectProvider identifies a generic decision effect provider.
	ComponentKindDecisionEffectProvider ComponentKind = "decision_effect_provider"
)

type ComponentOrigin

type ComponentOrigin string

ComponentOrigin identifies which integration surface registered a component.

const (
	// ComponentOriginNative identifies components registered by native Go plugins.
	ComponentOriginNative ComponentOrigin = "go"

	// ComponentOriginLua identifies components adapted from existing Lua configuration.
	ComponentOriginLua ComponentOrigin = "lua"
)

type ConfigView

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

ConfigView exposes one immutable-looking plugin configuration subtree.

func NewConfigView

func NewConfigView(data map[string]any) *ConfigView

NewConfigView returns a read-only view over a defensive copy of data.

func (*ConfigView) Decode

func (v *ConfigView) Decode(target any) error

Decode strictly decodes the current subtree into target.

func (*ConfigView) Get

func (v *ConfigView) Get(path string) (any, bool)

Get resolves a dot-separated configuration path.

func (*ConfigView) GetPath

func (v *ConfigView) GetPath(path []string) (any, bool)

GetPath resolves a segment-based configuration path.

func (*ConfigView) IsZero

func (v *ConfigView) IsZero() bool

IsZero reports whether the view has no keys.

func (*ConfigView) Sub

func (v *ConfigView) Sub(path string) pluginapi.ConfigView

Sub returns a view rooted at a dot-separated configuration path.

func (*ConfigView) SubPath

func (v *ConfigView) SubPath(path []string) pluginapi.ConfigView

SubPath returns a view rooted at a segment-based configuration path.

type DebugModule

type DebugModule struct {
	Selector    string
	ModuleName  string
	LocalName   string
	Description string
	Origin      ComponentOrigin
}

DebugModule describes one registered plugin debug selector.

type PolicyAttributeRegistrar

type PolicyAttributeRegistrar interface {
	Register(policyregistry.AttributeDefinition) error
}

PolicyAttributeRegistrar accepts converted policy attributes during registrar commit.

type Registrar

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

Registrar records declarations for one module instance.

func (*Registrar) Capabilities

func (r *Registrar) Capabilities() []pluginapi.Capability

Capabilities returns capabilities required during registration.

func (*Registrar) Commit

func (r *Registrar) Commit() error

Commit publishes staged registrar declarations to the shared registry.

func (*Registrar) Components

func (r *Registrar) Components() []Component

Components returns components declared through this registrar.

func (*Registrar) Config

func (r *Registrar) Config() pluginapi.ConfigView

Config returns the plugin-owned configuration subtree for the module instance.

func (*Registrar) DebugModules

func (r *Registrar) DebugModules() []DebugModule

DebugModules returns plugin-local debug modules declared through this registrar.

func (*Registrar) PolicyAttributes

func (r *Registrar) PolicyAttributes() []policyregistry.AttributeDefinition

PolicyAttributes returns policy attributes declared through this registrar.

func (*Registrar) RegisterBackend

func (r *Registrar) RegisterBackend(backend pluginapi.Backend) error

RegisterBackend records a backend declaration.

func (*Registrar) RegisterDebugModule

func (r *Registrar) RegisterDebugModule(definition pluginapi.DebugModuleDefinition) error

RegisterDebugModule records a plugin-local debug module declaration.

func (*Registrar) RegisterDecisionEffectProvider

func (r *Registrar) RegisterDecisionEffectProvider(provider pluginapi.DecisionEffectProvider) error

RegisterDecisionEffectProvider stages one target-aware policy-selected effect provider.

func (*Registrar) RegisterDecisionFactProvider

func (r *Registrar) RegisterDecisionFactProvider(provider pluginapi.DecisionFactProvider) error

RegisterDecisionFactProvider stages one target-aware generic fact provider.

func (*Registrar) RegisterEnvironmentSource

func (r *Registrar) RegisterEnvironmentSource(source pluginapi.EnvironmentSource) error

RegisterEnvironmentSource records an environment source declaration.

func (*Registrar) RegisterHook

func (r *Registrar) RegisterHook(hook pluginapi.Hook) error

RegisterHook records a hook declaration.

func (*Registrar) RegisterInitTask

func (r *Registrar) RegisterInitTask(task pluginapi.InitTask) error

RegisterInitTask records an init task declaration.

func (*Registrar) RegisterObligationTarget

func (r *Registrar) RegisterObligationTarget(target pluginapi.ObligationTarget) error

RegisterObligationTarget records an obligation target declaration.

func (*Registrar) RegisterPolicyAttribute

func (r *Registrar) RegisterPolicyAttribute(definition pluginapi.AttributeDefinition) error

RegisterPolicyAttribute records a native plugin policy attribute declaration.

func (*Registrar) RegisterPostActionTarget

func (r *Registrar) RegisterPostActionTarget(target pluginapi.PostActionTarget) error

RegisterPostActionTarget records a post-action target declaration.

func (*Registrar) RegisterSubjectSource

func (r *Registrar) RegisterSubjectSource(source pluginapi.SubjectSource) error

RegisterSubjectSource records a subject source declaration.

func (*Registrar) RequireCapability

func (r *Registrar) RequireCapability(capability pluginapi.Capability) error

RequireCapability records one capability required by the module instance.

type Registry

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

Registry stores fully qualified plugin component declarations.

func NewRegistry

func NewRegistry(options ...RegistryOption) *Registry

NewRegistry returns an empty plugin component registry.

func (*Registry) Backends

func (r *Registry) Backends() []Component

Backends returns registered backend components.

func (*Registry) Components

func (r *Registry) Components() []Component

Components returns registered components in registration order.

func (*Registry) ComponentsByKind

func (r *Registry) ComponentsByKind(kind ComponentKind) []Component

ComponentsByKind returns registered components of one kind in registration order.

func (*Registry) DebugModules

func (r *Registry) DebugModules() []DebugModule

DebugModules returns registered plugin debug selectors in registration order.

func (*Registry) DebugModulesByModule

func (r *Registry) DebugModulesByModule(moduleName string) []DebugModule

DebugModulesByModule returns registered plugin debug selectors for one module.

func (*Registry) DecisionEffectProviders

func (r *Registry) DecisionEffectProviders() []Component

DecisionEffectProviders returns committed generic effect-provider components.

func (*Registry) DecisionFactProviders

func (r *Registry) DecisionFactProviders() []Component

DecisionFactProviders returns committed generic fact-provider components.

func (*Registry) EnvironmentSources

func (r *Registry) EnvironmentSources() []Component

EnvironmentSources returns registered environment source components.

func (*Registry) HasDebugSelector

func (r *Registry) HasDebugSelector(selector string) bool

HasDebugSelector reports whether an exact plugin debug selector is registered.

func (*Registry) Hooks

func (r *Registry) Hooks() []Component

Hooks returns registered hook components.

func (*Registry) InitTasks

func (r *Registry) InitTasks() []Component

InitTasks returns registered init task components.

func (*Registry) Lookup

func (r *Registry) Lookup(qualifiedName string) (Component, bool)

Lookup returns a registered component by fully qualified name.

func (*Registry) NewRegistrar

func (r *Registry) NewRegistrar(module config.PluginModule) *Registrar

NewRegistrar creates a registrar scoped to one configured module instance.

func (*Registry) ObligationTargets

func (r *Registry) ObligationTargets() []Component

ObligationTargets returns registered obligation target components.

func (*Registry) PolicyAttributes

func (r *Registry) PolicyAttributes() []policyregistry.AttributeDefinition

PolicyAttributes returns plugin-registered policy attributes in registration order.

func (*Registry) PostActionTargets

func (r *Registry) PostActionTargets() []Component

PostActionTargets returns registered post-action target components.

func (*Registry) SubjectSources

func (r *Registry) SubjectSources() []Component

SubjectSources returns registered subject source components.

type RegistryOption

type RegistryOption func(*Registry)

RegistryOption customizes a component registry.

func WithPolicyAttributeRegistrar

func WithPolicyAttributeRegistrar(registrar PolicyAttributeRegistrar) RegistryOption

WithPolicyAttributeRegistrar forwards committed plugin policy attributes to the policy registry.

Jump to

Keyboard shortcuts

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