Documentation
¶
Index ¶
- Variables
- func ApplyStatusTransition(policy *StatusPolicy, currentState, action string, roles []string, ...) (string, int, error)
- func ConditionExpression(condition *contract.ConditionSpec) (string, error)
- func DecodeWorkflowDefinition(data []byte) (contract.WorkflowDefinition, error)
- func DefinitionDigest(definition contract.WorkflowDefinition) (string, error)
- func GrantAllows(execution policy.Execution, required policy.Grant, ...) bool
- func NewPinnedDispatch(executionID string, scope contract.BusinessScope, caller contract.ModuleID, ...) (contract.PinnedDispatch, error)
- func RecordTriggerFromChangeEvent(event contract.EventEnvelope) (contract.EventEnvelope, bool)
- func ValidateDefinition(def contract.WorkflowDefinition, catalog *Catalog, ...) contract.ValidationResult
- func ValidateRecordActionFields(definition contract.WorkflowDefinition, schemas RecordFieldTypeRegistry) []contract.ValidationIssue
- func ValidateRecordTriggerSchema(trigger *contract.RecordTrigger, schemas RecordTriggerSchemaRegistry) []contract.ValidationIssue
- func ValidateStatusTransition(transition StatusTransition) []contract.ValidationIssue
- type Action
- type ActionClass
- type ActionContext
- type ActionInput
- type ActionKey
- type ActionRegistration
- type ActionResult
- type AuthorizationStore
- type CancelCommit
- type CancellationAuthorizer
- type CancellationRepository
- type CapabilityDispatchState
- type CapabilityLeaseAdmission
- type CapabilityLeaseManager
- type Catalog
- func (c *Catalog) Freeze() error
- func (c *Catalog) Frozen() bool
- func (c *Catalog) Register(reg ActionRegistration) error
- func (c *Catalog) Registrations() []ActionRegistration
- func (c *Catalog) Resolve(key ActionKey) (ActionRegistration, error)
- func (c *Catalog) ValidateSchemas(schemas PayloadSchemaRegistry) error
- type Claim
- type ClaimHandler
- type ClaimHandlerFunc
- type ConditionScopeProvider
- type DefinitionAuthorizer
- type DefinitionClaimHandler
- type DefinitionLister
- type DefinitionRepository
- type EventWaitRecoveryStore
- type EventWaitSubscription
- type ExecutionIdentityProvider
- type ExecutionStore
- type ExecutionWorker
- type ExecutionWorkerConfig
- type ExternalActionExecutor
- type ExternalActionFailure
- type ExternalFailureKind
- type Fence
- type HTTPSCapabilityDispatcher
- func (d *HTTPSCapabilityDispatcher) Dispatch(ctx context.Context, pin contract.PinnedDispatch, ...) (ActionResult, error)
- func (d *HTTPSCapabilityDispatcher) Reconcile(ctx context.Context, pin contract.PinnedDispatch) (contract.ExternalOutcome, ActionResult, error)
- func (d *HTTPSCapabilityDispatcher) ReconcilePinned(ctx context.Context, pin contract.PinnedDispatch, ...) (contract.ExternalOutcome, ActionResult, error)
- type HistoryEntry
- type HistoryRepository
- type HumanWaitCreator
- type HumanWaitRecoveryStore
- type HumanWaitRecoveryWorker
- type HumanWaitRuntime
- type InstanceAuthorizer
- type InstanceRepository
- type InstanceService
- func (s *InstanceService) Cancel(ctx context.Context, exec policy.Execution, id contract.InstanceID, ...) (contract.WorkflowInstance, error)
- func (s *InstanceService) Get(ctx context.Context, exec policy.Execution, id contract.InstanceID) (contract.WorkflowInstance, error)
- func (s *InstanceService) History(ctx context.Context, exec policy.Execution, id contract.InstanceID, ...) ([]HistoryEntry, error)
- func (s *InstanceService) Recent(ctx context.Context, exec policy.Execution, limit uint16) ([]contract.WorkflowInstance, error)
- func (s *InstanceService) Reconcile(ctx context.Context, exec policy.Execution, id contract.InstanceID, ...) (contract.WorkflowInstance, error)
- func (s *InstanceService) Start(ctx context.Context, exec policy.Execution, cmd contract.StartWorkflow) (contract.WorkflowInstance, error)
- func (s *InstanceService) StartFromRecordEvent(ctx context.Context, tenant contract.TenantID, site string, ...) ([]contract.WorkflowInstance, error)
- type LocalActionExecutor
- type LocalActionFailure
- type LocalActionFailureKind
- type PayloadSchemaRegistry
- type PinnedCapabilityAttempt
- type PinnedCapabilityAttemptStore
- type PinnedCapabilityDispatcher
- type PinnedCapabilityReconciler
- type PinnedCapabilityRecoveryAdmission
- type PinnedDispatchRepository
- type PreviewHistoryRepository
- type PreviewResult
- type PreviewRun
- type PreviewStep
- type ProviderCredentialResolver
- type ReconcileCommit
- type ReconciliationRepository
- type RecordFieldTypeRegistry
- type RecordTriggerSchemaRegistry
- type RequestPreparer
- type Service
- func (s *Service) AvailableActions() []ActionRegistration
- func (s *Service) Get(ctx context.Context, exec policy.Execution, id contract.DefinitionID, ...) (contract.WorkflowDefinition, contract.DefinitionVersionRef, error)
- func (s *Service) ListLatest(ctx context.Context, exec policy.Execution) ([]contract.DefinitionVersionRef, error)
- func (s *Service) Preview(ctx context.Context, exec policy.Execution, ...) (PreviewRun, error)
- func (s *Service) PreviewHistory(ctx context.Context, exec policy.Execution, limit uint16) ([]PreviewRun, error)
- func (s *Service) Publish(ctx context.Context, exec policy.Execution, ...) (contract.DefinitionVersionRef, error)
- func (s *Service) SetModuleSnapshotLookup(lookup func(contract.TenantID) (contract.ModuleSnapshot, error))
- func (s *Service) Validate(ctx context.Context, exec policy.Execution, ...) (contract.ValidationResult, error)
- func (s *Service) ValidateCandidate(definition contract.WorkflowDefinition) contract.ValidationResult
- func (s *Service) ValidateCandidateWithRecordSchemas(definition contract.WorkflowDefinition, ...) contract.ValidationResult
- type Signal
- type SignalStore
- type StartInstanceInput
- type StatusActionConfig
- type StatusPolicy
- type StatusPolicyReader
- type StatusPolicyRepository
- type StatusTransition
- type StepCommit
- type SubjectAuthorization
- type TenantServiceIdentityProvider
- type TimedWaitRecoveryStore
- type WaitFieldRegistry
Constants ¶
This section is empty.
Variables ¶
var RecordTriggerEventPatterns = []string{"kora.%.after!_insert", "kora.%.after!_save", "record.created", "record.updated"}
RecordTriggerEventPatterns are the outbox event types that can start record-triggered workflows: kernel change events, plus legacy record.* events written before each mutation had a single change event.
Functions ¶
func ApplyStatusTransition ¶
func ApplyStatusTransition(policy *StatusPolicy, currentState, action string, roles []string, doc *doctype.Document) (string, int, error)
ApplyStatusTransition evaluates the selected transition against a record snapshot. The caller persists the returned status in its current SQL tx.
func ConditionExpression ¶
func ConditionExpression(condition *contract.ConditionSpec) (string, error)
ConditionExpression turns the editor's typed field condition into the deterministic expression understood by the workflow evaluator.
func DecodeWorkflowDefinition ¶
func DecodeWorkflowDefinition(data []byte) (contract.WorkflowDefinition, error)
DecodeWorkflowDefinition applies the same size and unknown-field boundary used by API handlers before a typed definition reaches validation.
func DefinitionDigest ¶
func DefinitionDigest(definition contract.WorkflowDefinition) (string, error)
DefinitionDigest identifies the exact definition content used by previews and publication readiness checks.
func GrantAllows ¶
func GrantAllows(execution policy.Execution, required policy.Grant, scope contract.BusinessScope) bool
GrantAllows checks a trusted action registration against the exact persisted workflow business scope.
func NewPinnedDispatch ¶
func NewPinnedDispatch(executionID string, scope contract.BusinessScope, caller contract.ModuleID, bindingRevision uint64, providerID string, lease contract.CapabilityLease, action contract.CapabilityAction, idempotency contract.IdempotencyKey, input json.RawMessage) (contract.PinnedDispatch, error)
func RecordTriggerFromChangeEvent ¶
func RecordTriggerFromChangeEvent(event contract.EventEnvelope) (contract.EventEnvelope, bool)
RecordTriggerFromChangeEvent projects a kernel change event onto the record trigger contract. Writes without record identity, deletes, and updates that changed no field start no workflow.
func ValidateDefinition ¶
func ValidateDefinition(def contract.WorkflowDefinition, catalog *Catalog, schemas PayloadSchemaRegistry, waits WaitFieldRegistry) contract.ValidationResult
ValidateDefinition rejects malformed or unsafe graphs before they can be published. It does not mutate the definition or resolve runtime effects.
func ValidateRecordActionFields ¶
func ValidateRecordActionFields(definition contract.WorkflowDefinition, schemas RecordFieldTypeRegistry) []contract.ValidationIssue
ValidateRecordActionFields binds common registered action inputs to the selected table. This keeps notification recipients and typed form controls verifiable before a definition is published.
func ValidateRecordTriggerSchema ¶
func ValidateRecordTriggerSchema(trigger *contract.RecordTrigger, schemas RecordTriggerSchemaRegistry) []contract.ValidationIssue
func ValidateStatusTransition ¶
func ValidateStatusTransition(transition StatusTransition) []contract.ValidationIssue
Types ¶
type Action ¶
type Action interface {
Execute(context.Context, ActionContext, ActionInput) (ActionResult, error)
}
type ActionClass ¶
type ActionClass string
const ( ActionLocal ActionClass = "local_transaction" ActionExternal ActionClass = "external" )
type ActionContext ¶
type ActionContext struct {
Execution policy.Execution
BusinessScope contract.BusinessScope
CausationDepth uint16
RequiredGrant policy.Grant
InstanceID contract.InstanceID
StepID contract.StepID
ExecutionID string
Subject contract.SubjectRef
IdempotencyKey contract.IdempotencyKey
PinnedDispatch *contract.PinnedDispatch
}
type ActionInput ¶
type ActionInput struct {
Schema contract.SchemaRef `json:"schema"`
Data json.RawMessage `json:"data"`
}
type ActionRegistration ¶
type ActionRegistration struct {
Key ActionKey
Class ActionClass
InputSchema contract.SchemaRef
OutputSchema contract.SchemaRef
RequiredGrant policy.Grant
External Action
Local LocalActionExecutor
Capability *contract.CapabilityAction
ProviderID string
BindingRevision uint64
CallerModuleID contract.ModuleID
PinnedDispatcher PinnedCapabilityDispatcher
CapabilityLease *contract.CapabilityLease
LocalCapabilityLease *contract.CapabilityLease
CredentialResolver ProviderCredentialResolver
}
type ActionResult ¶
type ActionResult struct {
Schema contract.SchemaRef `json:"schema"`
Data json.RawMessage `json:"data"`
}
type AuthorizationStore ¶
type AuthorizationStore interface {
UserRoles(context.Context, string, contract.PrincipalID) ([]string, bool, error)
Subject(context.Context, contract.SubjectRef) (SubjectAuthorization, error)
WorkflowStarter(context.Context, contract.TenantID, contract.InstanceID) (contract.PrincipalID, error)
}
AuthorizationStore is the tenant-persistence boundary used by production workflow policies to recheck membership, subject ownership, and start actor.
type CancelCommit ¶
type CancelCommit struct {
Tenant contract.TenantID
InstanceID contract.InstanceID
Actor contract.PrincipalID
Site string
ExpectedRevision contract.Revision
Reason string
IdempotencyKey contract.IdempotencyKey
}
type CancellationAuthorizer ¶
type CancellationAuthorizer interface {
CanCancelWorkflow(context.Context, policy.Execution, contract.WorkflowInstance) (bool, error)
}
CancellationAuthorizer decides whether the verified actor may cancel a workflow instance.
type CancellationRepository ¶
type CancellationRepository interface {
Cancel(context.Context, CancelCommit) (contract.WorkflowInstance, error)
}
type CapabilityDispatchState ¶
type CapabilityDispatchState struct {
Dispatch contract.PinnedDispatch
Outcome contract.ExternalOutcome
ReconciledAt time.Time
Evidence string
}
type CapabilityLeaseAdmission ¶
type CapabilityLeaseAdmission interface {
AdmitCapabilityAttempt(context.Context, contract.CapabilityLease, time.Time) error
}
CapabilityLeaseAdmission is implemented by the tenant module store. The admission update serializes with lease revocation before a new provider call.
type CapabilityLeaseManager ¶
type CapabilityLeaseManager interface {
CapabilityLeaseAdmission
EnsureCapabilityLease(context.Context, contract.CapabilityLease) error
}
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is mutable only during assembly. Freeze is required before lookup and makes the action set stable for published definition validation.
func NewCatalog ¶
func NewCatalog() *Catalog
func (*Catalog) Register ¶
func (c *Catalog) Register(reg ActionRegistration) error
func (*Catalog) Registrations ¶
func (c *Catalog) Registrations() []ActionRegistration
Registrations returns a stable, caller-owned snapshot for capability discovery. Adapter values are intentionally omitted from the public shape; callers may expose only Key, Class and schema metadata.
func (*Catalog) ValidateSchemas ¶
func (c *Catalog) ValidateSchemas(schemas PayloadSchemaRegistry) error
type Claim ¶
type Claim struct {
Tenant contract.TenantID
BusinessScope contract.BusinessScope
CausationDepth uint16
InstanceID contract.InstanceID
StepID contract.StepID
// Attempt is the next durable attempt number for this step execution,
// derived by the store from persisted attempts when the lease is claimed.
Attempt uint8
Owner string
Fence Fence
// LeaseUntil is informational for scheduling. Store mutations compare the
// persisted lease to database time and never trust this caller timestamp.
LeaseUntil time.Time
Revision contract.Revision
// FirstAttemptAt is the database timestamp of the first durable attempt for
// this step and keeps retries bounded across worker restarts.
FirstAttemptAt time.Time
}
Claim is an optimistic, tenant-scoped lease. Stores must validate owner, fence, revision, step, and DB-time lease validity on every mutation.
type ClaimHandler ¶
ClaimHandler executes one claimed workflow step and returns only after its fenced transition (or transaction-bound local effect) has committed.
type ClaimHandlerFunc ¶
func (ClaimHandlerFunc) HandleClaim ¶
func (f ClaimHandlerFunc) HandleClaim(ctx context.Context, claim Claim) error
type ConditionScopeProvider ¶
type ConditionScopeProvider interface {
Scope(context.Context, policy.Execution, contract.WorkflowInstance) (expression.Scope, error)
}
ConditionScopeProvider supplies authorized, read-only subject data for a pure workflow condition. It must use the supplied service identity and the instance's pinned subject revision, and project only fields visible under the tenant's current read policy.
type DefinitionAuthorizer ¶
type DefinitionClaimHandler ¶
type DefinitionClaimHandler struct {
// contains filtered or unexported fields
}
DefinitionClaimHandler loads the instance's immutable pinned definition and executes one action, condition, end, or transactionally-created human wait step. Timed and event waits require a separate durable continuation worker.
func NewDefinitionClaimHandler ¶
func NewDefinitionClaimHandler(store ExecutionStore, instances InstanceRepository, definitions DefinitionRepository, catalog *Catalog, schemas PayloadSchemaRegistry, identities ExecutionIdentityProvider, conditions ConditionScopeProvider, evaluator expression.Evaluator, leases CapabilityLeaseAdmission, humanWait ...HumanWaitRuntime) (*DefinitionClaimHandler, error)
func (*DefinitionClaimHandler) HandleClaim ¶
func (h *DefinitionClaimHandler) HandleClaim(ctx context.Context, claim Claim) error
type DefinitionLister ¶
type DefinitionLister interface {
ListLatestDefinitions(context.Context, contract.TenantID) ([]contract.DefinitionVersionRef, error)
}
DefinitionLister is implemented by durable repositories that can enumerate the latest immutable version for each tenant workflow.
type DefinitionRepository ¶
type DefinitionRepository interface {
PublishDefinition(context.Context, contract.TenantID, contract.WorkflowDefinition, contract.PrincipalID, contract.IdempotencyKey, time.Time) (contract.DefinitionVersionRef, error)
GetDefinition(context.Context, contract.TenantID, contract.DefinitionID, uint32) (contract.WorkflowDefinition, contract.DefinitionVersionRef, error)
}
type EventWaitRecoveryStore ¶
type EventWaitRecoveryStore interface {
ResumeEventSignals(context.Context, contract.TenantID, uint16) (uint16, error)
}
EventWaitRecoveryStore scans durable signal/subscription pairs left by a bounded acceptance pass or a process interruption.
type EventWaitSubscription ¶
type EventWaitSubscription struct {
EventType string
CorrelationField string
CorrelationValue string
OnEvent contract.StepID
}
EventWaitSubscription binds one event wait to the workflow subject. The correlation value is derived from the persisted instance, never the event caller or workflow definition payload.
type ExecutionIdentityProvider ¶
type ExecutionIdentityProvider interface {
ForWorkflow(context.Context, contract.TenantID, contract.InstanceID) (policy.Execution, error)
RequireActionGrants(context.Context, contract.TenantID, []policy.Grant) error
}
ExecutionIdentityProvider is owned by runtime assembly. It must return a verified service identity for the claimed tenant; workflow JSON and the original human starter are never identity sources for action execution.
type ExecutionStore ¶
type ExecutionStore interface {
ClaimDue(context.Context, contract.TenantID, string, uint16, time.Duration) ([]Claim, error)
Renew(context.Context, Claim, time.Duration) (Claim, error)
BeginExternalAttempt(context.Context, Claim, string, contract.IdempotencyKey, *contract.PinnedDispatch) (*contract.PinnedDispatch, error)
CommitStep(context.Context, StepCommit) error
Release(context.Context, Claim) error
}
ExecutionStore is the durable executor boundary. Implementations must make claim and commit predicates atomic with their persisted lease state.
type ExecutionWorker ¶
type ExecutionWorker struct {
// contains filtered or unexported fields
}
ExecutionWorker owns a bounded tenant claim loop. It is not itself a business executor; the handler must perform exactly one step and commit it through the fenced transaction boundary before returning nil.
func NewExecutionWorker ¶
func NewExecutionWorker(store ExecutionStore, handler ClaimHandler, config ExecutionWorkerConfig, onError func(error)) (*ExecutionWorker, error)
type ExecutionWorkerConfig ¶
type ExternalActionExecutor ¶
type ExternalActionExecutor struct {
// contains filtered or unexported fields
}
ExternalActionExecutor is the durable dispatch boundary for provider-backed workflow actions. It persists attempt ownership before invoking the adapter and returns the fenced transition the caller must commit immediately after the effect result is known.
func NewExternalActionExecutor ¶
func NewExternalActionExecutor(store ExecutionStore, identities ExecutionIdentityProvider, schemas PayloadSchemaRegistry, leases CapabilityLeaseAdmission) (*ExternalActionExecutor, error)
func (*ExternalActionExecutor) Execute ¶
func (e *ExternalActionExecutor) Execute(ctx context.Context, claim Claim, definition contract.WorkflowDefinition, step contract.StepDefinition, registration ActionRegistration, subject ...contract.SubjectRef) (StepCommit, error)
Execute validates the pinned action input and service identity, writes the running-attempt marker, then calls the registered external adapter. Adapter errors and invalid output are uncertain because the provider may have applied the effect before the response was lost or rejected locally.
type ExternalActionFailure ¶
type ExternalActionFailure struct {
Kind ExternalFailureKind
Cause error
}
ExternalActionFailure may be returned only when the adapter has evidence for the stated outcome. Wrapping a network error as NotApplied is unsafe unless the provider confirms rejection before applying the effect.
func (*ExternalActionFailure) Error ¶
func (e *ExternalActionFailure) Error() string
func (*ExternalActionFailure) Unwrap ¶
func (e *ExternalActionFailure) Unwrap() error
type ExternalFailureKind ¶
type ExternalFailureKind uint8
ExternalFailureKind records only what an adapter can prove about an unsuccessful provider call. Unclassified errors remain outcome-unknown.
const ( ExternalOutcomeUnknown ExternalFailureKind = iota ExternalNotAppliedRetryable ExternalNotAppliedPermanent )
type HTTPSCapabilityDispatcher ¶
type HTTPSCapabilityDispatcher struct {
ProviderID string
Endpoint string
StatusEndpoint string
Client *http.Client
}
HTTPSCapabilityDispatcher sends pinned operations to one configured external provider endpoint. Provider identity and URL are fixed at assembly; only the encrypted-secret reference is resolved immediately before transport.
func (*HTTPSCapabilityDispatcher) Dispatch ¶
func (d *HTTPSCapabilityDispatcher) Dispatch(ctx context.Context, pin contract.PinnedDispatch, lease contract.CapabilityLease, registration ActionRegistration, input json.RawMessage) (ActionResult, error)
func (*HTTPSCapabilityDispatcher) Reconcile ¶
func (d *HTTPSCapabilityDispatcher) Reconcile(ctx context.Context, pin contract.PinnedDispatch) (contract.ExternalOutcome, ActionResult, error)
func (*HTTPSCapabilityDispatcher) ReconcilePinned ¶
func (d *HTTPSCapabilityDispatcher) ReconcilePinned(ctx context.Context, pin contract.PinnedDispatch, lease contract.CapabilityLease, registration ActionRegistration) (contract.ExternalOutcome, ActionResult, error)
type HistoryEntry ¶
type HistoryEntry = contract.WorkflowHistoryEntry
type HistoryRepository ¶
type HistoryRepository interface {
ListHistory(context.Context, contract.TenantID, contract.InstanceID, uint16) ([]HistoryEntry, error)
ListRecentInstances(context.Context, contract.TenantID, uint16) ([]contract.WorkflowInstance, error)
}
HistoryRepository exposes bounded, tenant-scoped run history for an already-authorized workflow instance.
type HumanWaitCreator ¶
type HumanWaitCreator interface {
CreateHumanWait(context.Context, *requests.PreparedSubmission, StepCommit) (requests.RequestRecord, error)
}
type HumanWaitRecoveryStore ¶
type HumanWaitRecoveryStore interface {
ExpireDue(context.Context, contract.TenantID, uint16) (uint16, error)
ResumeTerminalHumanWaits(context.Context, contract.TenantID, uint16) (uint16, error)
}
HumanWaitRecoveryStore is the durable terminal-request recovery boundary. Implementations must bound both the returned batch and transaction scope.
type HumanWaitRecoveryWorker ¶
type HumanWaitRecoveryWorker struct {
// contains filtered or unexported fields
}
HumanWaitRecoveryWorker polls durable request state for one loaded tenant. Run returns after cancellation and owns no goroutine other than its caller's loop; runtime composition is responsible for launching and joining it.
func (*HumanWaitRecoveryWorker) Run ¶
func (w *HumanWaitRecoveryWorker) Run(ctx context.Context)
Run performs one recovery pass immediately, then one bounded pass per tick. A failed pass is reported and retried at the next interval; durable request state remains available for recovery. Cancellation interrupts the store call.
type HumanWaitRuntime ¶
type HumanWaitRuntime struct {
Requests RequestPreparer
Store HumanWaitCreator
Now func() time.Time
}
type InstanceAuthorizer ¶
type InstanceAuthorizer interface {
CanStartWorkflow(context.Context, policy.Execution, contract.DefinitionID, contract.SubjectRef) (bool, error)
CanReadWorkflow(context.Context, policy.Execution, contract.SubjectRef) (bool, error)
CanReconcileWorkflow(context.Context, policy.Execution, contract.WorkflowInstance) (bool, error)
}
type InstanceRepository ¶
type InstanceRepository interface {
StartInstance(context.Context, StartInstanceInput) (contract.WorkflowInstance, error)
GetInstance(context.Context, contract.TenantID, contract.InstanceID) (contract.WorkflowInstance, error)
}
type InstanceService ¶
type InstanceService struct {
// contains filtered or unexported fields
}
func NewInstanceService ¶
func NewInstanceService(definitions DefinitionRepository, instances InstanceRepository, authorizer InstanceAuthorizer, catalog *Catalog, schemas PayloadSchemaRegistry, waits WaitFieldRegistry, now func() time.Time, newID func() string) (*InstanceService, error)
func (*InstanceService) Cancel ¶
func (s *InstanceService) Cancel(ctx context.Context, exec policy.Execution, id contract.InstanceID, cmd contract.CancelWorkflow) (contract.WorkflowInstance, error)
Cancel cancels a non-running workflow generation after current authorization. A live human request must be resolved through the request service so request and workflow terminal events can be coordinated by the normal recovery path.
func (*InstanceService) Get ¶
func (s *InstanceService) Get(ctx context.Context, exec policy.Execution, id contract.InstanceID) (contract.WorkflowInstance, error)
func (*InstanceService) History ¶
func (s *InstanceService) History(ctx context.Context, exec policy.Execution, id contract.InstanceID, limit uint16) ([]HistoryEntry, error)
History returns bounded execution history only after the caller is authorized to read the associated record and workflow instance.
func (*InstanceService) Recent ¶
func (s *InstanceService) Recent(ctx context.Context, exec policy.Execution, limit uint16) ([]contract.WorkflowInstance, error)
Recent returns only instances whose record subjects are readable by the current actor. The repository query is tenant-scoped and strictly bounded.
func (*InstanceService) Reconcile ¶
func (s *InstanceService) Reconcile(ctx context.Context, exec policy.Execution, id contract.InstanceID, cmd contract.ReconcileWorkflow) (contract.WorkflowInstance, error)
Reconcile records a privileged operator decision for one uncertain external action. It rechecks current authorization and delegates the state transition and actor-scoped idempotency receipt to one tenant transaction.
func (*InstanceService) Start ¶
func (s *InstanceService) Start(ctx context.Context, exec policy.Execution, cmd contract.StartWorkflow) (contract.WorkflowInstance, error)
func (*InstanceService) StartFromRecordEvent ¶
func (s *InstanceService) StartFromRecordEvent(ctx context.Context, tenant contract.TenantID, site string, event contract.EventEnvelope) ([]contract.WorkflowInstance, error)
StartFromRecordEvent starts each published record-triggered definition once. It accepts only the Engine kernel's durable record events; unlike the public start API, the event actor is already authenticated by the transaction that wrote the outbox row. A deterministic idempotency key makes at-least-once delivery safe across worker retries and restarts.
type LocalActionExecutor ¶
type LocalActionExecutor interface {
ExecuteLocal(context.Context, Claim, ActionContext, ActionKey, ActionInput, contract.StepID) (ActionResult, error)
}
LocalActionExecutor must atomically validate the claim, invoke the domain operation, and persist workflow progress with its idempotency receipt.
type LocalActionFailure ¶
type LocalActionFailure struct {
Kind LocalActionFailureKind
Cause error
}
LocalActionFailure carries transaction outcome evidence from an adapter. Plain errors remain conservatively uncertain for compatibility.
func (*LocalActionFailure) Error ¶
func (e *LocalActionFailure) Error() string
func (*LocalActionFailure) Unwrap ¶
func (e *LocalActionFailure) Unwrap() error
type LocalActionFailureKind ¶
type LocalActionFailureKind uint8
const ( // LocalActionNotAppliedRetryable means the action transaction was rolled // back before its commit request; retrying cannot duplicate a local effect. LocalActionNotAppliedRetryable LocalActionFailureKind = iota + 1 // LocalActionNotAppliedPermanent is a deterministic domain or validation // rejection known to have rolled back. LocalActionNotAppliedPermanent // LocalActionOutcomeUnknown means commit may have reached the database and // an operator-visible uncertain outcome must be persisted. LocalActionOutcomeUnknown )
type PayloadSchemaRegistry ¶
type PinnedCapabilityAttempt ¶
type PinnedCapabilityAttempt struct {
Dispatch contract.PinnedDispatch
Lease contract.CapabilityLease
}
PinnedCapabilityAttempt keeps internal revocation data beside the persisted provider pin without adding lease metadata to the public PinnedDispatch type.
func (PinnedCapabilityAttempt) Validate ¶
func (a PinnedCapabilityAttempt) Validate() error
type PinnedCapabilityAttemptStore ¶
type PinnedCapabilityAttemptStore interface {
BeginPinnedExternalAttempt(context.Context, Claim, string, contract.IdempotencyKey, contract.PinnedDispatch, contract.CapabilityLease) (*PinnedCapabilityAttempt, error)
}
PinnedCapabilityAttemptStore atomically persists the provider pin and its private durable lease for each pinned workflow attempt.
type PinnedCapabilityDispatcher ¶
type PinnedCapabilityDispatcher interface {
Dispatch(context.Context, contract.PinnedDispatch, contract.CapabilityLease, ActionRegistration, json.RawMessage) (ActionResult, error)
Reconcile(context.Context, contract.PinnedDispatch) (contract.ExternalOutcome, ActionResult, error)
}
PinnedCapabilityDispatcher ensures a durable external action keeps the selected provider and capability binding across retries.
type PinnedCapabilityReconciler ¶
type PinnedCapabilityReconciler interface {
ReconcilePinned(context.Context, contract.PinnedDispatch, contract.CapabilityLease, ActionRegistration) (contract.ExternalOutcome, ActionResult, error)
}
PinnedCapabilityReconciler receives the durable lease so it can resolve the original credential reference after restart or provider cutover.
type PinnedCapabilityRecoveryAdmission ¶
type PinnedCapabilityRecoveryAdmission interface {
AdmitPinnedCapabilityRecovery(context.Context, contract.PinnedDispatch, contract.CapabilityLease, contract.TenantID, contract.InstanceID, contract.StepID, time.Time) error
}
type PinnedDispatchRepository ¶
type PinnedDispatchRepository interface {
LoadPinnedCapabilityAttempt(context.Context, contract.TenantID, contract.InstanceID, contract.StepID) (PinnedCapabilityAttempt, error)
}
PinnedDispatchRepository loads the durable provider identity for an uncertain action so reconciliation always addresses the provider that was called.
type PreviewHistoryRepository ¶
type PreviewHistoryRepository interface {
RecordPreview(context.Context, contract.TenantID, contract.PrincipalID, PreviewRun) error
ListPreviews(context.Context, contract.TenantID, uint16) ([]PreviewRun, error)
HasSuccessfulPreview(context.Context, contract.TenantID, contract.DefinitionID, uint32, string) (bool, error)
}
type PreviewResult ¶
type PreviewResult struct {
Matched bool `json:"matched"`
Outcome string `json:"outcome,omitempty"`
Steps []PreviewStep `json:"steps"`
}
PreviewResult never represents a live workflow instance. Actions are only described; they are not dispatched and records are never mutated.
func PreviewRecordDefinition ¶
func PreviewRecordDefinition(ctx context.Context, definition contract.WorkflowDefinition, raw json.RawMessage) (PreviewResult, error)
PreviewRecordDefinition evaluates only the graph and typed conditions. It deliberately does not invoke registered actions, providers, approval policies, waits, or the normal instance store.
type PreviewRun ¶
type PreviewRun struct {
ID string `json:"id"`
DefinitionID contract.DefinitionID `json:"definition_id"`
DefinitionVersion uint32 `json:"definition_version"`
DefinitionDigest string `json:"definition_digest"`
Status string `json:"status"`
Outcome string `json:"outcome,omitempty"`
Failure string `json:"failure,omitempty"`
Steps []PreviewStep `json:"steps"`
CreatedAt time.Time `json:"created_at"`
}
PreviewRun is durable, side-effect-free workflow test history. Sample record values are intentionally excluded to avoid retaining customer data.
type PreviewStep ¶
type PreviewStep struct {
StepID string `json:"step_id"`
Kind string `json:"kind"`
Result string `json:"result"`
}
PreviewStep is a side-effect-free account of what a sample record would do.
type ProviderCredentialResolver ¶
type ProviderCredentialResolver interface {
ResolveCredential(context.Context, string) (string, error)
}
ProviderCredentialResolver resolves one secret reference at dispatch time. Implementations must return generic errors that do not contain secret values.
type ReconcileCommit ¶
type ReconcileCommit struct {
Tenant contract.TenantID
InstanceID contract.InstanceID
Actor contract.PrincipalID
Site string
ExpectedRevision contract.Revision
StepID contract.StepID
Outcome contract.ReconciliationOutcome
EvidenceRef string
Reason string
NextStep contract.StepID
Status contract.InstanceStatus
IdempotencyKey contract.IdempotencyKey
}
type ReconciliationRepository ¶
type ReconciliationRepository interface {
Reconcile(context.Context, ReconcileCommit) (contract.WorkflowInstance, error)
}
ReconciliationRepository records privileged operator decisions for unknown external outcomes with an immutable, scoped idempotency receipt.
type RecordFieldTypeRegistry ¶
type RequestPreparer ¶
type RequestPreparer interface {
PrepareWorkflowSubmit(context.Context, policy.Execution, contract.SubmitRequest, contract.RequestSource) (*requests.PreparedSubmission, error)
}
RequestPreparer validates and prepares a workflow submission before it is committed.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repository DefinitionRepository, authorizer DefinitionAuthorizer, catalog *Catalog, schemas PayloadSchemaRegistry, waits WaitFieldRegistry, now func() time.Time) (*Service, error)
func (*Service) AvailableActions ¶
func (s *Service) AvailableActions() []ActionRegistration
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, exec policy.Execution, id contract.DefinitionID, version uint32) (contract.WorkflowDefinition, contract.DefinitionVersionRef, error)
func (*Service) ListLatest ¶
func (*Service) Preview ¶
func (s *Service) Preview(ctx context.Context, exec policy.Execution, definition contract.WorkflowDefinition, record json.RawMessage) (PreviewRun, error)
Preview validates and simulates a record-triggered definition without dispatching actions, then stores a redacted durable result for Studio.
func (*Service) PreviewHistory ¶
func (*Service) Publish ¶
func (s *Service) Publish(ctx context.Context, exec policy.Execution, definition contract.WorkflowDefinition, key contract.IdempotencyKey) (contract.DefinitionVersionRef, error)
func (*Service) SetModuleSnapshotLookup ¶
func (*Service) Validate ¶
func (s *Service) Validate(ctx context.Context, exec policy.Execution, definition contract.WorkflowDefinition) (contract.ValidationResult, error)
func (*Service) ValidateCandidate ¶
func (s *Service) ValidateCandidate(definition contract.WorkflowDefinition) contract.ValidationResult
ValidateCandidate performs the same read-only definition checks used by publication, without requiring a user execution identity. Callers must already be inside a trusted configuration-validation boundary; this method never persists or publishes the definition.
func (*Service) ValidateCandidateWithRecordSchemas ¶
func (s *Service) ValidateCandidateWithRecordSchemas(definition contract.WorkflowDefinition, recordSchemas RecordTriggerSchemaRegistry) contract.ValidationResult
ValidateCandidateWithRecordSchemas validates an inactive configuration candidate against its proposed record schema while retaining the tenant's registered action and payload schemas. It never persists or publishes.
type Signal ¶
type Signal struct {
Tenant contract.TenantID
Event contract.EventEnvelope
}
Signal is an event delivered by a trusted tenant-scoped consumer. Tenant is the stable tenant identity; Event.Site may be a tenant route alias.
type SignalStore ¶
type SignalStore interface {
AcceptSignal(context.Context, Signal) (uint32, error)
ResumeEventSignals(context.Context, contract.TenantID, uint16) (uint16, error)
}
SignalStore durably accepts trusted events and resumes bounded batches of matching event waits. Duplicate event IDs and concurrent workers are safe.
type StartInstanceInput ¶
type StartInstanceInput struct {
Tenant contract.TenantID
BusinessScope contract.BusinessScope
CausationDepth uint16
ID contract.InstanceID
Definition contract.WorkflowDefinition
DefinitionDigest string
Subject contract.SubjectRef
Actor contract.PrincipalID
IdempotencyKey contract.IdempotencyKey
Site string
Now time.Time
}
type StatusActionConfig ¶
type StatusActionConfig struct {
StateField string `json:"state_field"`
InitialState string `json:"initial_state"`
StatusTransition
}
StatusActionConfig is the complete policy for one registered record.update_status step. Publishing the workflow publishes this policy and its executable transition together.
type StatusPolicy ¶
type StatusPolicy struct {
Table string
StateField string
InitialState string
Transitions []StatusTransition
}
StatusPolicy is assembled from registered record.update_status steps in published workflow definitions. It is deliberately not a separate config resource: the transition and its execution graph are published together.
type StatusPolicyReader ¶
type StatusPolicyReader interface {
GetStatusPolicy(context.Context, contract.TenantID, string) (*StatusPolicy, bool, error)
}
StatusPolicyReader resolves published status actions for domain authorization such as policy-managed approval assignment.
type StatusPolicyRepository ¶
type StatusPolicyRepository interface {
GetStatusPolicyInTx(context.Context, *sql.Tx, contract.TenantID, string) (*StatusPolicy, bool, error)
}
StatusPolicyRepository resolves transition policy from the latest published record.update_status steps inside the record transaction that applies it.
type StatusTransition ¶
type StatusTransition struct {
Action string `json:"transition_action"`
From string `json:"from"`
To string `json:"to"`
AllowedRoles []string `json:"allowed_roles,omitempty"`
RequireFields []string `json:"required_fields,omitempty"`
Condition string `json:"condition,omitempty"`
DocStatus int `json:"doc_status,omitempty"`
}
type StepCommit ¶
type StepCommit struct {
Claim Claim
ExecutionID string
Attempt uint8
// AttemptStarted indicates an external attempt row was durably created
// before the side effect began; commit must finalize that exact row.
AttemptStarted bool
IdempotencyKey contract.IdempotencyKey
Status contract.InstanceStatus
NextStep contract.StepID
NextWakeAt *time.Time
EventWait *EventWaitSubscription
Result ActionResult
Failure string
Events []contract.EventEnvelope
}
func WithExecutionEvent ¶
func WithExecutionEvent(change StepCommit, kind string) (StepCommit, error)
WithExecutionEvent adds the required data-minimal lifecycle event for a fenced transition performed by an in-process local action executor.
type SubjectAuthorization ¶
type TenantServiceIdentityProvider ¶
type TenantServiceIdentityProvider struct {
// contains filtered or unexported fields
}
TenantServiceIdentityProvider binds one runtime generation to a configured workflow service identity. Construct one per tenant runtime after the assembly layer has validated the service principal and its narrow grants.
func NewTenantServiceIdentityProvider ¶
func NewTenantServiceIdentityProvider(tenant contract.TenantID, actor contract.ActorContext, grants []policy.Grant) (*TenantServiceIdentityProvider, error)
func (*TenantServiceIdentityProvider) ForWorkflow ¶
func (p *TenantServiceIdentityProvider) ForWorkflow(ctx context.Context, tenant contract.TenantID, instance contract.InstanceID) (policy.Execution, error)
func (*TenantServiceIdentityProvider) RequireActionGrants ¶
func (p *TenantServiceIdentityProvider) RequireActionGrants(ctx context.Context, tenant contract.TenantID, grants []policy.Grant) error
RequireActionGrants checks the immutable tenant service identity at runtime assembly. Action registrations are trusted assembly data; definitions cannot add grants to this set.
type TimedWaitRecoveryStore ¶
type TimedWaitRecoveryStore interface {
ResumeDueTimedWaits(context.Context, contract.TenantID, uint16) (uint16, error)
}
TimedWaitRecoveryStore resumes generic workflow timeout steps. Human waits remain owned by request terminal-state recovery, which selects their outcome.