plugin

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 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 resolves module capability bindings and executes published provider operations. Providers are exposed to callers as capability handles, so removing a provider degrades only its dependents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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, installed InstalledModules) (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

CanReplayPublishedQueryOfflineForActor additionally asks the provider whether it can enforce the given actor scope at its source.

func (BindingPlan) ExecutePublishedQuery

ExecutePublishedQuery reads one page of a published query. A nil actor runs the query without a verified actor; otherwise the actor scope narrows rows.

func (BindingPlan) InvokeCapability

func (p BindingPlan) InvokeCapability(ctx context.Context, execution policy.Execution, call CapabilityCall) (CapabilityOperationResult, error)

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, key PublishedProjectionKey, 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, key PublishedQueryKey, actorScope PublishedQueryActorScope, req QueryReplayRequest) (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

func (p BindingPlan) ResolveBusinessReference(ctx context.Context, execution policy.Execution, req BusinessReferenceRequest) (contract.ResolvedBusinessRef, error)

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 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 BusinessReferenceRequest

type BusinessReferenceRequest struct {
	Scope    contract.BusinessScope
	Consumer contract.ModuleID
	Rule     contract.ReferenceRule
	Ref      contract.BusinessRef
}

BusinessReferenceRequest is one reference a consumer module asks to resolve under the rule that declares it.

type CapabilityCall

type CapabilityCall struct {
	Lease      contract.CapabilityLease
	Scope      contract.BusinessScope
	Caller     contract.ModuleID
	Capability contract.CapabilityName
	Operation  string
	Meta       contract.CommandMeta
	Payload    json.RawMessage
}

CapabilityCall names one operation of a consumer's capability and carries the lease, idempotency metadata and payload it runs with.

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 FactStream

type FactStream struct {
	Execution contract.ModuleExecution
	Query     contract.PublishedQuery
	Input     json.RawMessage
}

FactStream names the change stream one published query input writes to: the verified owner execution, the query and the query input.

type InstalledModules

type InstalledModules struct {
	Packages   []contract.InstalledPackage
	Modules    []contract.ModuleDescriptor
	Providers  []ProviderRegistration
	Selections []ProviderSelection
	Revision   uint64
}

InstalledModules is the durable module set of one scope at one revision.

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, QueryPageRequest) (contract.QueryResult, error)
}

PublishedQueryExecutor reads one page of a published query without a verified actor.

type PublishedQueryKey

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

PublishedQueryKey names one published query of an owner module in a scope.

type PublishedQueryReplayExecutor

type PublishedQueryReplayExecutor interface {
	ReplayPublishedQuery(context.Context, contract.ModuleExecution, contract.PublishedQuery, QueryReplayRequest) (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 QueryInputError

type QueryInputError struct {
	Field   string
	Message string
}

QueryInputError is a published-query call the caller got wrong: input that fails the query's input schema, a missing required input, a page outside the registered bounds. Transports report it as a client error. Message is bounded and safe to return; the validator's own text is never exposed.

func (*QueryInputError) Error

func (e *QueryInputError) Error() string

type QueryPageRequest

type QueryPageRequest struct {
	Input  json.RawMessage
	Cursor string
	Limit  uint16
}

QueryPageRequest is one page of a published query: the caller's input, the continuation cursor ("" for the first page) and the page size (0 selects the query's PageLimit).

type QueryReplayRequest

type QueryReplayRequest struct {
	Input    json.RawMessage
	Snapshot string
	After    string
	Through  string
	Replay   string
	Limit    uint16
}

QueryReplayRequest is one page of changes after a query snapshot. The zero Through and Replay cursors start a new replay; Snapshot is only read by actor-scoped replay.

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
}

ResolvedPublishedQuery is a published query bound to the provider the plan selected for it.

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, stream FactStream, 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

ExecutePublishedQuery reads one snapshot page of the durable facts for every owner.

func (*SQLPublishedQueryProvider) ExecutePublishedQueryForActor

ExecutePublishedQueryForActor reads one snapshot page, narrowed to the facts owned by the actor when the scope is owner-only.

func (*SQLPublishedQueryProvider) PutFactTx

func (p *SQLPublishedQueryProvider) PutFactTx(ctx context.Context, tx *sql.Tx, stream FactStream, 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

ReplayPublishedQuery replays the changes after a snapshot for every owner. The snapshot token is derived from req.After.

func (*SQLPublishedQueryProvider) ReplayPublishedQueryForActor

ReplayPublishedQueryForActor replays the changes after req.Snapshot, narrowed to the actor's facts when the scope is owner-only.

func (*SQLPublishedQueryProvider) SupportsOfflineActorScope

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

type ScopedPublishedQueryExecutor

type ScopedPublishedQueryExecutor interface {
	ExecutePublishedQueryForActor(context.Context, contract.ModuleExecution, contract.PublishedQuery, PublishedQueryActorScope, QueryPageRequest) (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, QueryReplayRequest) (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

Jump to

Keyboard shortcuts

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