Documentation
¶
Overview ¶
Package workers defines worker executor interfaces and implementations for script and model-based workers.
Index ¶
- Constants
- func InputTokens(tokens ...interfaces.Token) []any
- func PanicAsFailedResult(dispatch interfaces.WorkDispatch, recovered any, duration time.Duration) interfaces.WorkResult
- func ProviderFailureDecisionFromMetadata(metadata *interfaces.ProviderFailureMetadata) interfaces.ProviderFailureDecision
- func ValidateBuiltInRunnerPrerequisites(id string) error
- func WorkDispatchInputTokens(dispatch interfaces.WorkDispatch) []interfaces.Token
- func WorkLogFields(metadata interfaces.ExecutionMetadata, keysAndValues ...any) []any
- type AgentContext
- type AgentExecutor
- type AgentExecutorOption
- type CommandEnvClassification
- type CommandEnvDiagnosticProjection
- type CommandRequest
- type CommandResult
- type CommandRunner
- type CronWorkstationType
- type DefaultPromptRenderer
- type Dispatcher
- type ExecCommandRunner
- type InferenceEventRecorder
- type LoggingCommandRunner
- type MockWorkerCommandRunner
- type NoopExecutor
- type OutputParser
- type PollerWorkstationType
- type PostResultAction
- type PromptContext
- type PromptData
- type PromptHistory
- type PromptRenderer
- type PromptTemplateContract
- type PromptTemplateDiagnostic
- type PromptTemplateDiagnosticKind
- type PromptTemplateUnavailableAccessPattern
- type PromptTemplateValidationResult
- type PromptTemplateVariableCategory
- type PromptTemplateVariableReference
- type Provider
- type ProviderError
- type ProviderErrorCorpus
- type ProviderErrorCorpusEntry
- type RecordingProvider
- type RecordingProviderOption
- type RepeaterWorkstationType
- type ResolvedFields
- type Runner
- type RunnerStatus
- type ScriptEventRecorder
- type ScriptExecutor
- type ScriptExecutorOption
- type ScriptWrapProvider
- type ScriptWrapProviderOption
- type StandardWorkstationType
- type TokenData
- type Tool
- type WorkerExecutor
- type WorkerPool
- type WorkerRunner
- type WorkstationExecutor
- type WorkstationRequestExecutor
- type WorkstationTypeRegistry
- func (r *WorkstationTypeRegistry) Get(kind interfaces.WorkstationKind) (WorkstationTypeStrategy, bool)
- func (r *WorkstationTypeRegistry) IsValid(kind interfaces.WorkstationKind) bool
- func (r *WorkstationTypeRegistry) Kinds() []interfaces.WorkstationKind
- func (r *WorkstationTypeRegistry) Register(s WorkstationTypeStrategy)
- type WorkstationTypeStrategy
Constants ¶
const ( // RedactedCommandEnvValue is written when an environment key looks sensitive. RedactedCommandEnvValue = "<redacted>" // MetadataOnlyCommandEnvValue is written when only the key's presence is safe to preserve. MetadataOnlyCommandEnvValue = "<metadata-only>" )
const ( WorkLogEventWorkerPoolSubmitted = workerexecutor.WorkLogEventWorkerPoolSubmitted WorkLogEventWorkerPoolExecutorEntered = workerexecutor.WorkLogEventWorkerPoolExecutorEntered WorkLogEventWorkerPoolResponseSubmitted = workerexecutor.WorkLogEventWorkerPoolResponseSubmitted WorkLogEventCommandRunnerRequested = workerexecutor.WorkLogEventCommandRunnerRequested WorkLogEventCommandRunnerCompleted = workerexecutor.WorkLogEventCommandRunnerCompleted WorkLogEventCommandRunnerRequestDetails = workerexecutor.WorkLogEventCommandRunnerRequestDetails WorkLogEventCommandRunnerOutputDetails = workerexecutor.WorkLogEventCommandRunnerOutputDetails )
const ( PromptTemplateDiagnosticKindSyntaxError = workerprompting.PromptTemplateDiagnosticKindSyntaxError PromptTemplateDiagnosticKindInvalidVariable = workerprompting.PromptTemplateDiagnosticKindInvalidVariable )
Variables ¶
This section is empty.
Functions ¶
func InputTokens ¶
func InputTokens(tokens ...interfaces.Token) []any
InputTokens converts typed petri tokens into the shared dispatch representation.
func PanicAsFailedResult ¶
func PanicAsFailedResult(dispatch interfaces.WorkDispatch, recovered any, duration time.Duration) interfaces.WorkResult
func ProviderFailureDecisionFromMetadata ¶
func ProviderFailureDecisionFromMetadata(metadata *interfaces.ProviderFailureMetadata) interfaces.ProviderFailureDecision
func ValidateBuiltInRunnerPrerequisites ¶ added in v0.0.5
ValidateBuiltInRunnerPrerequisites checks PATH-visible prerequisites for one built-in runner before the runtime attempts dispatch.
func WorkDispatchInputTokens ¶
func WorkDispatchInputTokens(dispatch interfaces.WorkDispatch) []interfaces.Token
WorkDispatchInputTokens returns the token payload as typed petri tokens.
func WorkLogFields ¶
func WorkLogFields(metadata interfaces.ExecutionMetadata, keysAndValues ...any) []any
Types ¶
type AgentContext ¶
type AgentContext = workerexecutor.AgentContext
type AgentExecutor ¶
type AgentExecutor = workerexecutor.AgentExecutor
type AgentExecutorOption ¶
type AgentExecutorOption = workerexecutor.AgentExecutorOption
type CommandEnvClassification ¶
type CommandEnvClassification string
CommandEnvClassification describes how a command environment entry may be represented in persisted diagnostics.
const ( CommandEnvClassificationSafe CommandEnvClassification = "safe" CommandEnvClassificationRedacted CommandEnvClassification = "redacted" CommandEnvClassificationMetadataOnly CommandEnvClassification = "metadata_only" )
func ClassifyCommandEnvKey ¶
func ClassifyCommandEnvKey(name string) CommandEnvClassification
ClassifyCommandEnvKey returns the diagnostic exposure class for one command environment key. Sensitive-looking names are always redacted, even when they also appear in the safe allowlist.
type CommandEnvDiagnosticProjection ¶
type CommandEnvDiagnosticProjection struct {
Count int `json:"count"`
Keys []string `json:"keys,omitempty"`
Values map[string]string `json:"values,omitempty"`
}
CommandEnvDiagnosticProjection is the safe diagnostic view of a subprocess environment. Values contains only allowlisted raw values or explicit markers.
func ProjectCommandEnvForDiagnostics ¶
func ProjectCommandEnvForDiagnostics(env []string) CommandEnvDiagnosticProjection
ProjectCommandEnvForDiagnostics converts subprocess environment entries into the shared safe diagnostic representation used before replay persistence.
type CommandRequest ¶
type CommandRequest = workerprocess.CommandRequest
type CommandResult ¶
type CommandResult = workerprocess.CommandResult
type CommandRunner ¶
type CommandRunner = workerprocess.CommandRunner
type CronWorkstationType ¶
type CronWorkstationType struct{}
CronWorkstationType identifies service-triggered cron workstations. Cron ticks submit through the service ingress; once dispatched, results advance through the normal arc sets.
func (*CronWorkstationType) HandleResult ¶
func (c *CronWorkstationType) HandleResult(_ interfaces.WorkResult) PostResultAction
HandleResult routes cron execution results through normal arc handling.
func (*CronWorkstationType) Kind ¶
func (c *CronWorkstationType) Kind() interfaces.WorkstationKind
Kind returns WorkstationKindCron.
type DefaultPromptRenderer ¶
type DefaultPromptRenderer = workerprompting.DefaultPromptRenderer
type Dispatcher ¶
type Dispatcher interface {
// Dispatch executes a work dispatch synchronously, blocking until the
// result is available.
Dispatch(ctx context.Context, dispatch *interfaces.WorkDispatch) (interfaces.WorkResult, error)
// WorkerState returns a point-in-time snapshot of the dispatcher state.
WorkerState() interfaces.WorkerState
// Tick processes all currently queued dispatches synchronously, blocking
// until each submitted element completes.
Tick()
// Run starts the goroutine-based async dispatch loop (existing behaviour).
Run()
}
Dispatcher manages worker execution. It supports two execution modes:
- Synchronous (via Tick): all queued dispatches are executed inline; used by test harnesses to control execution step-by-step.
- Asynchronous (via Run): dispatches are executed in goroutines; used in production.
type ExecCommandRunner ¶
type ExecCommandRunner = workerprocess.ExecCommandRunner
type InferenceEventRecorder ¶
type InferenceEventRecorder = workerprovider.InferenceEventRecorder
type LoggingCommandRunner ¶
type LoggingCommandRunner = workerprocess.LoggingCommandRunner
type MockWorkerCommandRunner ¶
type MockWorkerCommandRunner = mockworker.MockWorkerCommandRunner
type NoopExecutor ¶
type NoopExecutor = workerexecutor.NoopExecutor
type OutputParser ¶
type OutputParser = workerexecutor.OutputParser
type PollerWorkstationType ¶ added in v0.0.5
type PollerWorkstationType struct{}
PollerWorkstationType identifies service-supervised ingress pollers. Until poller-specific lifecycle orchestration runs, completed dispatches still route through the normal arc handling.
func (*PollerWorkstationType) HandleResult ¶ added in v0.0.5
func (p *PollerWorkstationType) HandleResult(_ interfaces.WorkResult) PostResultAction
HandleResult routes poller execution results through normal arc handling.
func (*PollerWorkstationType) Kind ¶ added in v0.0.5
func (p *PollerWorkstationType) Kind() interfaces.WorkstationKind
Kind returns WorkstationKindPoller.
type PostResultAction ¶
type PostResultAction string
PostResultAction determines what the engine should do after processing a work result.
const ( // ActionAdvance routes tokens normally via the appropriate arc set (output/rejection/failure). // This is the behavior of the "standard" workstation type. ActionAdvance PostResultAction = "advance" // ActionRepeat keeps the token in its input place and re-fires the transition // on the next tick. Used by the "repeater" workstation type. ActionRepeat PostResultAction = "repeat" )
type PromptContext ¶
type PromptContext = workerprompting.PromptContext
type PromptData ¶
type PromptData = workerprompting.PromptData
type PromptHistory ¶
type PromptHistory = workerprompting.PromptHistory
type PromptRenderer ¶
type PromptRenderer = workerprompting.PromptRenderer
type PromptTemplateContract ¶ added in v0.0.5
type PromptTemplateContract = workerprompting.PromptTemplateContract
type PromptTemplateDiagnostic ¶ added in v0.0.5
type PromptTemplateDiagnostic = workerprompting.PromptTemplateDiagnostic
type PromptTemplateDiagnosticKind ¶ added in v0.0.5
type PromptTemplateDiagnosticKind = workerprompting.PromptTemplateDiagnosticKind
type PromptTemplateUnavailableAccessPattern ¶ added in v0.0.5
type PromptTemplateUnavailableAccessPattern = workerprompting.PromptTemplateUnavailableAccessPattern
type PromptTemplateValidationResult ¶ added in v0.0.5
type PromptTemplateValidationResult = workerprompting.PromptTemplateValidationResult
type PromptTemplateVariableCategory ¶ added in v0.0.5
type PromptTemplateVariableCategory = workerprompting.PromptTemplateVariableCategory
type PromptTemplateVariableReference ¶ added in v0.0.5
type PromptTemplateVariableReference = workerprompting.PromptTemplateVariableReference
type Provider ¶
type Provider = workerprovider.Provider
type ProviderError ¶
type ProviderError = workerprovider.ProviderError
func NewProviderError ¶
func NewProviderError(errorType interfaces.ProviderErrorType, message string, cause error) *ProviderError
func NewProviderErrorWithSession ¶
func NewProviderErrorWithSession(errorType interfaces.ProviderErrorType, message string, cause error, session *interfaces.ProviderSessionMetadata) *ProviderError
type ProviderErrorCorpus ¶
type ProviderErrorCorpus = workerprovider.ProviderErrorCorpus
type ProviderErrorCorpusEntry ¶
type ProviderErrorCorpusEntry = workerprovider.ProviderErrorCorpusEntry
type RecordingProvider ¶
type RecordingProvider = workerprovider.RecordingProvider
type RecordingProviderOption ¶
type RecordingProviderOption = workerprovider.RecordingProviderOption
type RepeaterWorkstationType ¶
type RepeaterWorkstationType struct{}
RepeaterWorkstationType re-fires a transition after a non-terminal result. CONTINUE outcomes keep the token in its input place (ActionRepeat) so the worker is invoked again on the next tick. ACCEPTED, REJECTED, and FAILED outcomes advance normally via the appropriate arc set.
func (*RepeaterWorkstationType) HandleResult ¶
func (r *RepeaterWorkstationType) HandleResult(result interfaces.WorkResult) PostResultAction
HandleResult returns ActionRepeat for CONTINUE outcomes (the worker signals "not done yet") and ActionAdvance for ACCEPTED, REJECTED, or FAILED.
func (*RepeaterWorkstationType) Kind ¶
func (r *RepeaterWorkstationType) Kind() interfaces.WorkstationKind
Kind returns WorkstationKindRepeater.
type ResolvedFields ¶
type ResolvedFields = workerprompting.ResolvedFields
func ResolveTemplateFields ¶
func ResolveTemplateFields( workingDirTemplate string, envTemplates map[string]string, tokens []interfaces.Token, wfCtx *factory_context.FactoryContext, worktreeTemplate string, ) (*ResolvedFields, error)
type Runner ¶ added in v0.0.5
type Runner interface {
Execute(ctx context.Context, request interfaces.RunnerExecutionRequest) (interfaces.RunnerExecutionResult, error)
}
Runner executes one shared runner request and returns the normalized runner result used by standard orchestration flows.
func RunnerFromProvider ¶ added in v0.0.5
type RunnerStatus ¶ added in v0.0.5
type RunnerStatus struct {
Metadata interfaces.RunnerMetadata
Available bool
}
RunnerStatus reports whether a built-in runner can be selected safely in the current build before dispatch starts.
func BuiltInRunnerStatus ¶ added in v0.0.5
func BuiltInRunnerStatus(id string) (RunnerStatus, bool)
BuiltInRunnerStatus reports the build-local availability of one stable runner registration.
type ScriptEventRecorder ¶
type ScriptEventRecorder = workerexecutor.ScriptEventRecorder
type ScriptExecutor ¶
type ScriptExecutor = workerexecutor.ScriptExecutor
type ScriptExecutorOption ¶
type ScriptExecutorOption = workerexecutor.ScriptExecutorOption
type ScriptWrapProvider ¶
type ScriptWrapProvider = workerprovider.ScriptWrapProvider
type ScriptWrapProviderOption ¶
type ScriptWrapProviderOption = workerprovider.ScriptWrapProviderOption
type StandardWorkstationType ¶
type StandardWorkstationType struct{}
StandardWorkstationType implements the default fire-once behavior. Tokens are always routed via the appropriate arc set regardless of outcome.
func (*StandardWorkstationType) HandleResult ¶
func (s *StandardWorkstationType) HandleResult(_ interfaces.WorkResult) PostResultAction
HandleResult always returns ActionAdvance — standard workstations route every result.
func (*StandardWorkstationType) Kind ¶
func (s *StandardWorkstationType) Kind() interfaces.WorkstationKind
Kind returns WorkstationKindStandard.
type TokenData ¶
type TokenData = workerprompting.TokenData
type Tool ¶
type Tool = workerexecutor.Tool
type WorkerExecutor ¶
type WorkerExecutor interface {
Execute(ctx context.Context, dispatch interfaces.WorkDispatch) (interfaces.WorkResult, error)
}
WorkerExecutor is the side-effect interface — what actually happens when a transition fires. This is the only place where external I/O occurs. Everything else in the factory is pure CPN state manipulation.
type WorkerPool ¶
type WorkerPool = workerexecutor.WorkerPool
func NewWorkerPool ¶
func NewWorkerPool(logger logging.Logger) *WorkerPool
type WorkerRunner ¶
type WorkerRunner = workerexecutor.WorkerRunner
type WorkstationExecutor ¶
type WorkstationExecutor = workerexecutor.WorkstationExecutor
type WorkstationRequestExecutor ¶
type WorkstationRequestExecutor interface {
Execute(ctx context.Context, request interfaces.WorkstationExecutionRequest) (interfaces.WorkResult, error)
}
WorkstationRequestExecutor handles worker-owned execution requests after the dispatch-owned contract has been resolved for one workstation invocation.
type WorkstationTypeRegistry ¶
type WorkstationTypeRegistry struct {
// contains filtered or unexported fields
}
WorkstationTypeRegistry maps workstation kinds to their strategy implementations. The registry is pre-populated with the "standard" type and can be extended with additional types via Register.
func NewWorkstationTypeRegistry ¶
func NewWorkstationTypeRegistry() *WorkstationTypeRegistry
NewWorkstationTypeRegistry creates a registry pre-populated with the "standard" "repeater", "cron", and "poller" types.
func (*WorkstationTypeRegistry) Get ¶
func (r *WorkstationTypeRegistry) Get(kind interfaces.WorkstationKind) (WorkstationTypeStrategy, bool)
Get returns the strategy for the given kind, or (nil, false) if not registered.
func (*WorkstationTypeRegistry) IsValid ¶
func (r *WorkstationTypeRegistry) IsValid(kind interfaces.WorkstationKind) bool
IsValid returns true if the given kind is registered.
func (*WorkstationTypeRegistry) Kinds ¶
func (r *WorkstationTypeRegistry) Kinds() []interfaces.WorkstationKind
Kinds returns all registered workstation kind names.
func (*WorkstationTypeRegistry) Register ¶
func (r *WorkstationTypeRegistry) Register(s WorkstationTypeStrategy)
Register adds a workstation type strategy to the registry.
type WorkstationTypeStrategy ¶
type WorkstationTypeStrategy interface {
// Kind returns the workstation kind this strategy handles.
Kind() interfaces.WorkstationKind
// HandleResult examines a work result and returns the action the engine
// should take. For "standard" workstations this always returns ActionAdvance.
HandleResult(result interfaces.WorkResult) PostResultAction
}
WorkstationTypeStrategy defines the execution semantics for a workstation type. Implementations determine how results are routed after a worker completes.
Adding a new workstation type requires:
- Implementing this interface
- Registering the implementation with NewWorkstationTypeRegistry or Registry.Register
No engine internals need to be modified.