plugin

package
v1.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 18 Imported by: 0 modules, 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 implements provider binding via capability handles (PLUGIN-005): components bind to providers exclusively through PLUGIN-001 handles, so removing a provider degrades only its dependents.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRuntimeUnsupported       = errors.New("plugin: runtime not supported")
	ErrArtifactChecksumMismatch = errors.New("plugin: artifact checksum mismatch")
	ErrCapabilityNotGranted     = errors.New("plugin: capability not granted")
)

Typed seam errors. Callers match via errors.Is/As, never string matching.

Functions

func VerifyChecksum

func VerifyChecksum(unit ComponentUnit) error

VerifyChecksum checks unit.Artifact against unit.Checksum (SHA-256 hex).

Types

type Binder

type Binder interface {
	Bind(ctx contract.OperationContext, manifests []component.Manifest, factories []ProviderFactory) (BindingReport, error)
}

Binder resolves component requirements against provider factories.

func NewBinder

func NewBinder(strategy BindingStrategy) Binder

NewBinder returns a binder with the given strategy.

type Binding

type Binding struct {
	Component  string
	Capability contract.CapabilityName
	Handle     contract.CapabilityHandle
}

Binding is one satisfied requirement: a component's requirement resolved to a concrete handle.

type BindingDiagnostic

type BindingDiagnostic struct {
	Key  BindingKey
	Code string
}

type BindingKey

type BindingKey struct {
	Scope            contract.BusinessScope
	ConsumerModuleID contract.ModuleID
	CapabilityName   contract.CapabilityName
}

type BindingPlan

type BindingPlan struct {
	Revision                    uint64
	Composition                 contract.CompositionPlan
	Packages                    []contract.InstalledPackage
	Extensions                  []contract.ResolvedModuleExtension
	Bindings                    []ResolvedBinding
	Queries                     map[PublishedQueryKey]ResolvedPublishedQuery
	QueryDefinitions            map[PublishedQueryKey]contract.PublishedQuery
	BusinessReconciliationRules []BusinessReconciliationRule
	Projections                 map[PublishedProjectionKey]contract.ProjectionDefinition
	ProjectionScopes            map[PublishedProjectionKey]contract.ResourceScopeKind
	Blockers                    []BindingDiagnostic
	Warnings                    []BindingDiagnostic
	LeaseAdmission              CapabilityLeaseAdmission
	LeaseReader                 CapabilityLeaseReader
}

func ResolveInstalledModules

func ResolveInstalledModules(scope contract.BusinessScope, packages []contract.InstalledPackage, modules []contract.ModuleDescriptor, providers []ProviderRegistration, selections []ProviderSelection, revision uint64) (BindingPlan, error)

ResolveInstalledModules uses the same provider resolver while including the durable package dependency set in deterministic preflight and plan hashing.

func ResolveModules

func ResolveModules(scope contract.BusinessScope, modules []contract.ModuleDescriptor, providers []ProviderRegistration, selections []ProviderSelection, revision uint64) (BindingPlan, error)

ResolveModules produces a deterministic candidate plan. It does not open providers; health is checked only for selected providers during generation assembly.

func (BindingPlan) CanReplayPublishedQueryOffline

func (p BindingPlan) CanReplayPublishedQueryOffline(scope contract.BusinessScope, owner contract.ModuleID, name string) bool

CanReplayPublishedQueryOffline reports whether the selected provider opted into offline sync and implements actor-scoped replay enforcement.

func (BindingPlan) CanReplayPublishedQueryOfflineForActor

func (p BindingPlan) CanReplayPublishedQueryOfflineForActor(scope contract.BusinessScope, owner contract.ModuleID, name string, actor *PublishedQueryActorScope) bool

func (BindingPlan) ExecutePublishedQuery

func (p BindingPlan) ExecutePublishedQuery(ctx context.Context, scope contract.BusinessScope, owner contract.ModuleID, name string, input json.RawMessage, cursor string, limit uint16) (contract.QueryResult, error)

func (BindingPlan) ExecutePublishedQueryForActor

func (p BindingPlan) ExecutePublishedQueryForActor(ctx context.Context, scope contract.BusinessScope, owner contract.ModuleID, name string, actorScope PublishedQueryActorScope, input json.RawMessage, cursor string, limit uint16) (contract.QueryResult, error)

func (BindingPlan) InvokeCapability

InvokeCapability dispatches an operation through the provider selected in this plan. Provider identity, scope, contract, schema and binding revision are pinned before the handle is opened.

func (BindingPlan) ProviderSelections

func (p BindingPlan) ProviderSelections() ([]contract.ProviderSelection, error)

ProviderSelections returns the immutable provider choices represented by a resolved plan in deterministic key order.

func (BindingPlan) RebuildPublishedProjection

func (p BindingPlan) RebuildPublishedProjection(ctx context.Context, store PublishedProjectionStore, scope contract.BusinessScope, owner contract.ModuleID, projectionID string, inputs map[string]json.RawMessage) error

RebuildPublishedProjection reads every source under pinned provider revisions, verifies each paged result, then atomically publishes one complete snapshot through the existing analytics rebuild store.

func (BindingPlan) ReconcileCapability

ReconcileCapability addresses only the provider pinned by a prior durable attempt. It never searches another provider and never invokes the effect.

func (BindingPlan) ReplayPublishedQueryForActor

func (p BindingPlan) ReplayPublishedQueryForActor(ctx context.Context, scope contract.BusinessScope, owner contract.ModuleID, name string, actorScope PublishedQueryActorScope, input json.RawMessage, snapshotToken, afterCursor, throughCursor, replayCursor string, limit uint16) (contract.QueryReplayPage, error)

ReplayPublishedQueryForActor returns only the authenticated actor's published changes. Providers without a source-level scoped replay implementation are ineligible for offline feeds.

func (BindingPlan) Resolve

func (p BindingPlan) Resolve(key BindingKey) (ResolvedBinding, bool)

func (BindingPlan) ResolveBusinessReference

ResolveBusinessReference opens only the provider already selected for the consumer capability in this immutable plan. It does not search alternate providers when resolution fails.

type BindingReport

type BindingReport struct {
	Bound    []Binding
	Degraded []Degradation
}

BindingReport is the outcome of a bind pass.

type BindingStrategy

type BindingStrategy int

BindingStrategy selects strict vs degraded behavior.

const (
	StrategyDegraded BindingStrategy = iota // missing capability degrades, others stay live
	StrategyStrict                          // any unmet requirement aborts
)

type BusinessReconciliationRule

type BusinessReconciliationRule struct {
	OwnerModuleID            contract.ModuleID
	ID                       string
	Version                  uint32
	SourceQueryOwnerModuleID contract.ModuleID
	SourceQueryName          string
	SourceQueryInput         json.RawMessage
	SourcePageLimit          uint16
	TargetQueryOwnerModuleID contract.ModuleID
	TargetQueryName          string
	TargetQueryInput         json.RawMessage
	TargetPageLimit          uint16
	GracePeriod              time.Duration
	MaxRows                  int
	RepairCallerModuleID     contract.ModuleID
	RepairCapability         contract.CapabilityName
	RepairOperation          string
	RepairLeaseID            string
}

BusinessReconciliationRule is registered with its owning module provider. Source and target data still flow through the declared published-query contracts in the resolved binding plan.

type CapabilityInvocation

type CapabilityInvocation struct {
	Context                    contract.OperationContext
	Execution                  policy.Execution
	ModuleExecution            contract.ModuleExecution
	Operation                  contract.OperationSpec
	Meta                       contract.CommandMeta
	Payload                    json.RawMessage
	BusinessReferenceValidator contract.BusinessReferenceValidator
}

CapabilityInvocation is assembled by BindingPlan after resolving a pinned provider and operation contract. Implementations must treat Execution as the actor authority and ModuleExecution as the bounded module provenance.

type CapabilityInvocationResult

type CapabilityInvocationResult struct {
	ExecutionID contract.OperationID
	Output      json.RawMessage
}

CapabilityInvocationResult identifies the provider-side execution so retries and reconciliation can refer to the effect that actually ran.

type CapabilityLeaseAdmission

type CapabilityLeaseAdmission interface {
	AdmitCapabilityAttempt(context.Context, contract.CapabilityLease, time.Time) error
}

CapabilityLeaseAdmission is the tenant module store's durable pre-effect gate. Implementations serialize admission against security revocation.

type CapabilityLeaseOwnerAdmission

type CapabilityLeaseOwnerAdmission interface {
	EnsureCapabilityLease(context.Context, contract.CapabilityLease) error
}

CapabilityLeaseOwnerAdmission persists the provider ownership resolved by the immutable binding when issuing a lease.

type CapabilityLeaseReader

type CapabilityLeaseReader interface {
	LoadCapabilityLease(context.Context, contract.TenantID, string) (contract.CapabilityLease, bool, error)
}

CapabilityLeaseReader loads an existing durable grant without issuing or widening authority. Scheduled and other recovered work use this to bind to the grant that operators can revoke through the module store.

type CapabilityOperationHandle

type CapabilityOperationHandle interface {
	contract.CapabilityHandle
	InvokeCapability(context.Context, CapabilityInvocation) (CapabilityInvocationResult, error)
}

CapabilityOperationHandle is implemented by provider handles that execute a declared capability operation. Provider selection and operation schemas come from the immutable BindingPlan, never from the caller payload.

type CapabilityOperationReconciler

type CapabilityOperationReconciler interface {
	ReconcileCapability(context.Context, contract.PinnedDispatch, contract.CapabilityLease) (contract.ExternalOutcome, CapabilityInvocationResult, error)
}

CapabilityOperationReconciler resolves a persisted external attempt without issuing the effect again. Providers must identify the exact stable key and input digest represented by the pin.

type CapabilityOperationResult

type CapabilityOperationResult struct {
	ExecutionID  contract.OperationID `json:"execution_id"`
	Status       string               `json:"status"`
	OutputSchema contract.SchemaRef   `json:"output_schema"`
	Output       json.RawMessage      `json:"output"`
}

CapabilityOperationResult is the schema-bound result of one provider call.

type ComponentUnit

type ComponentUnit struct {
	Name     string
	Runtime  string
	Artifact []byte
	Checksum string
}

ComponentUnit is the artifact + manifest a runtime compiles.

type Degradation

type Degradation struct {
	Component  string
	Capability contract.CapabilityName
	Reason     string // "provider-absent" | "provider-unhealthy"
}

Degradation is one unmet requirement.

type ErrUnsatisfiedRequirement

type ErrUnsatisfiedRequirement struct {
	Component  string
	Capability contract.CapabilityName
}

ErrUnsatisfiedRequirement is a typed strict-binding failure.

func (*ErrUnsatisfiedRequirement) Error

func (e *ErrUnsatisfiedRequirement) Error() string

type InvokeCall

type InvokeCall struct {
	Function string
	Args     []byte
}

InvokeCall is one serialized invocation request.

type InvokeResult

type InvokeResult struct {
	Value    []byte
	Evidence effect.CleanupEvidence
}

InvokeResult is a serialized result plus cleanup evidence.

type OfflineActorScopeSupport

type OfflineActorScopeSupport interface {
	SupportsOfflineActorScope(PublishedQueryActorScope) bool
}

OfflineActorScopeSupport lets a provider fail closed for policy row scopes it cannot enforce at its source. Providers without this optional interface retain the existing contract and are expected to support every authorized actor scope they advertise as offline eligible.

type ProviderFactory

type ProviderFactory interface {
	Capability() contract.CapabilityName
	Open(ctx contract.OperationContext) (contract.CapabilityHandle, error)
}

ProviderFactory exposes one provider as a capability handle.

func NewStaticFactory

func NewStaticFactory(cap contract.CapabilityName, err error) ProviderFactory

NewStaticFactory returns a factory for cap whose Open returns a no-op handle (or err when supplied).

type ProviderKind

type ProviderKind string
const (
	ProviderInternal ProviderKind = "internal"
	ProviderExternal ProviderKind = "external"
)

type ProviderRegistration

type ProviderRegistration struct {
	TenantID                    contract.TenantID
	Scope                       contract.BusinessScope
	ProviderID                  string
	OwnerModuleID               contract.ModuleID
	Kind                        ProviderKind
	Offers                      []contract.CapabilityOffer
	Factories                   map[contract.CapabilityName]ProviderFactory
	Queries                     map[string]PublishedQueryExecutor
	BusinessReconciliationRules []BusinessReconciliationRule
	ValidateSchema              func(contract.SchemaRef, []byte) error
}

type ProviderSelection

type ProviderSelection struct {
	Key        BindingKey
	ProviderID string
}

type PublishedProjectionKey

type PublishedProjectionKey struct {
	OwnerModuleID contract.ModuleID
	ID            string
}

type PublishedQueryActorScope

type PublishedQueryActorScope struct {
	BusinessScope  contract.BusinessScope
	SubjectID      string
	OwnerOnly      bool
	OwnerField     string
	AssignedFields []string
}

PublishedQueryActorScope is derived only from verified policy execution. Providers must apply assignment filters before pagination, not after it.

type PublishedQueryExecutor

type PublishedQueryExecutor interface {
	ExecutePublishedQuery(context.Context, contract.ModuleExecution, contract.PublishedQuery, json.RawMessage, string, uint16) (contract.QueryResult, error)
}

type PublishedQueryKey

type PublishedQueryKey struct {
	Scope         contract.BusinessScope
	OwnerModuleID contract.ModuleID
	Name          string
}

type PublishedQueryReplayExecutor

type PublishedQueryReplayExecutor interface {
	ReplayPublishedQuery(context.Context, contract.ModuleExecution, contract.PublishedQuery, json.RawMessage, string, string, string, uint16) (contract.QueryReplayPage, error)
}

PublishedQueryReplayExecutor replays owner changes after an immutable query snapshot. The first page fixes ThroughCursor; all following pages must use that same high-water mark so the persisted projection cursor is gapless.

type ResolvedBinding

type ResolvedBinding struct {
	Key           BindingKey
	ProviderID    string
	OwnerModuleID contract.ModuleID
	Kind          ProviderKind
	Contract      contract.SchemaRef
	Operations    []contract.OperationSpec
	Revision      uint64
	Factory       ProviderFactory
	// contains filtered or unexported fields
}

func (ResolvedBinding) Open

type ResolvedPublishedQuery

type ResolvedPublishedQuery struct {
	Definition contract.PublishedQuery
	ProviderID string
	Revision   uint64
	// contains filtered or unexported fields
}

type RuntimeProvider

type RuntimeProvider interface {
	ID() string
	Compile(unit ComponentUnit) error
	Execute(ctx contract.OperationContext, call InvokeCall, handles []contract.CapabilityHandle) (InvokeResult, error)
	Shutdown(ctx contract.OperationContext) error
}

RuntimeProvider is the seam any execution backend implements.

type SQLPublishedQueryProvider

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

SQLPublishedQueryProvider is the durable Engine-owned adapter used by owner modules that publish query facts from the tenant database. Facts are an append-only owner projection: callers must write them in the same SQL transaction as the authoritative business effect. The provider never reads private domain tables or infers query semantics from DocTypes.

func NewSQLPublishedQueryProvider

func NewSQLPublishedQueryProvider(database *sql.DB, dialect db.Dialect) (*SQLPublishedQueryProvider, error)

NewSQLPublishedQueryProvider creates a provider over an already-open tenant database. EnsureSchema must succeed before the provider is registered.

func (*SQLPublishedQueryProvider) DeleteFactTx

func (p *SQLPublishedQueryProvider) DeleteFactTx(ctx context.Context, tx *sql.Tx, execution contract.ModuleExecution, query contract.PublishedQuery, input json.RawMessage, factKey, ownerID string) (uint64, error)

DeleteFactTx appends a tombstone. ownerID is retained on the tombstone so a deletion can only be replayed to actors who could see the prior fact.

func (*SQLPublishedQueryProvider) EnsureSchema

func (p *SQLPublishedQueryProvider) EnsureSchema(ctx context.Context) error

EnsureSchema creates only the Engine-owned append log. Domain modules remain responsible for deciding which published facts are written to it.

func (*SQLPublishedQueryProvider) ExecutePublishedQuery

func (p *SQLPublishedQueryProvider) ExecutePublishedQuery(ctx context.Context, execution contract.ModuleExecution, query contract.PublishedQuery, input json.RawMessage, cursor string, limit uint16) (contract.QueryResult, error)

func (*SQLPublishedQueryProvider) ExecutePublishedQueryForActor

func (p *SQLPublishedQueryProvider) ExecutePublishedQueryForActor(ctx context.Context, execution contract.ModuleExecution, query contract.PublishedQuery, actor PublishedQueryActorScope, input json.RawMessage, cursor string, limit uint16) (contract.QueryResult, error)

func (*SQLPublishedQueryProvider) PutFactTx

func (p *SQLPublishedQueryProvider) PutFactTx(ctx context.Context, tx *sql.Tx, execution contract.ModuleExecution, query contract.PublishedQuery, input, data json.RawMessage) (uint64, error)

PutFactTx appends a full replacement row. The caller owns tx and must commit it with the business effect that made the fact authoritative.

func (*SQLPublishedQueryProvider) ReplayPublishedQuery

func (p *SQLPublishedQueryProvider) ReplayPublishedQuery(ctx context.Context, execution contract.ModuleExecution, query contract.PublishedQuery, input json.RawMessage, after, through, replay string, limit uint16) (contract.QueryReplayPage, error)

func (*SQLPublishedQueryProvider) ReplayPublishedQueryForActor

func (p *SQLPublishedQueryProvider) ReplayPublishedQueryForActor(ctx context.Context, execution contract.ModuleExecution, query contract.PublishedQuery, actor PublishedQueryActorScope, input json.RawMessage, snapshot, after, through, replay string, limit uint16) (contract.QueryReplayPage, error)

func (*SQLPublishedQueryProvider) SupportsOfflineActorScope

func (p *SQLPublishedQueryProvider) SupportsOfflineActorScope(actor PublishedQueryActorScope) bool

type ScopedPublishedQueryExecutor

type ScopedPublishedQueryExecutor interface {
	ExecutePublishedQueryForActor(context.Context, contract.ModuleExecution, contract.PublishedQuery, PublishedQueryActorScope, json.RawMessage, string, uint16) (contract.QueryResult, error)
}

ScopedPublishedQueryExecutor implements actor row filtering in the source query so limits and cursors describe only rows visible to that actor.

type ScopedPublishedQueryReplayExecutor

type ScopedPublishedQueryReplayExecutor interface {
	ReplayPublishedQueryForActor(context.Context, contract.ModuleExecution, contract.PublishedQuery, PublishedQueryActorScope, json.RawMessage, string, string, string, string, uint16) (contract.QueryReplayPage, error)
}

ScopedPublishedQueryReplayExecutor preserves actor filtering in offline feeds. Providers must apply this scope before selecting/page-limiting changes.

type StaticFactory

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

StaticFactory is a ProviderFactory backed by a fixed capability and optional open error (for tests).

func (*StaticFactory) Capability

func (f *StaticFactory) Capability() contract.CapabilityName

func (*StaticFactory) Open

type StubProvider

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

StubProvider is an in-process fake of a WASM-like runtime (PLUGIN-008). It enforces the seam's serialization-only rule: Execute returns JSON-encoded bytes and never passes host pointers or closures across the boundary. It proves the RuntimeProvider contract is implementable by a non-Goja backend.

func NewStubProvider

func NewStubProvider(id string, required contract.CapabilityName) *StubProvider

NewStubProvider returns a stub runtime with the given ID. required is the capability Execute insists on (deny-by-default at the seam).

func (*StubProvider) Compile

func (s *StubProvider) Compile(unit ComponentUnit) error

func (*StubProvider) Execute

func (*StubProvider) ID

func (s *StubProvider) ID() string

func (*StubProvider) Shutdown

func (s *StubProvider) Shutdown(ctx contract.OperationContext) error

Jump to

Keyboard shortcuts

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