Documentation
¶
Index ¶
- Constants
- Variables
- func IsValidationError(err error) bool
- type CompiledWorkflow
- type Compiler
- type CreateInput
- type FeatureFlags
- type GuardrailStep
- type MongoDBStore
- func (s *MongoDBStore) Close() error
- func (s *MongoDBStore) Create(ctx context.Context, input CreateInput) (*Version, error)
- func (s *MongoDBStore) Deactivate(ctx context.Context, id string) error
- func (s *MongoDBStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
- func (s *MongoDBStore) Get(ctx context.Context, id string) (*Version, error)
- func (s *MongoDBStore) ListActive(ctx context.Context) ([]Version, error)
- type Payload
- type PostgreSQLStore
- func (s *PostgreSQLStore) Close() error
- func (s *PostgreSQLStore) Create(ctx context.Context, input CreateInput) (*Version, error)
- func (s *PostgreSQLStore) Deactivate(ctx context.Context, id string) error
- func (s *PostgreSQLStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
- func (s *PostgreSQLStore) Get(ctx context.Context, id string) (*Version, error)
- func (s *PostgreSQLStore) ListActive(ctx context.Context) ([]Version, error)
- type Result
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) Create(ctx context.Context, input CreateInput) (*Version, error)
- func (s *SQLiteStore) Deactivate(ctx context.Context, id string) error
- func (s *SQLiteStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
- func (s *SQLiteStore) Get(ctx context.Context, id string) (*Version, error)
- func (s *SQLiteStore) ListActive(ctx context.Context) ([]Version, error)
- type Scope
- type Service
- func (s *Service) Create(ctx context.Context, input CreateInput) (*Version, error)
- func (s *Service) Deactivate(ctx context.Context, id string) error
- func (s *Service) EnsureDefaultGlobal(ctx context.Context, input CreateInput) error
- func (s *Service) GetView(ctx context.Context, id string) (View, error)
- func (s *Service) ListViews(ctx context.Context) ([]View, error)
- func (s *Service) Match(selector core.WorkflowSelector) (*core.ResolvedWorkflowPolicy, error)
- func (s *Service) PipelineForContext(ctx context.Context) *guardrails.Pipeline
- func (s *Service) PipelineForWorkflow(workflow *core.Workflow) *guardrails.Pipeline
- func (s *Service) Refresh(ctx context.Context) error
- func (s *Service) StartBackgroundRefresh(interval time.Duration) func()
- type Store
- type ValidationError
- type Version
- type View
Constants ¶
const ( ManagedDefaultGlobalName = "default-global" ManagedDefaultGlobalDescription = "Bootstrapped from runtime configuration" )
Variables ¶
var ErrNotFound = errors.New("workflow version not found")
ErrNotFound indicates a requested workflow version was not found.
Functions ¶
func IsValidationError ¶
IsValidationError reports whether err is a validation error.
Types ¶
type CompiledWorkflow ¶
type CompiledWorkflow struct {
Version Version
Policy *core.ResolvedWorkflowPolicy
Pipeline *guardrails.Pipeline
}
CompiledWorkflow is the immutable runtime projection cached in the hot-path snapshot.
type Compiler ¶
type Compiler interface {
Compile(version Version) (*CompiledWorkflow, error)
}
Compiler turns one persisted workflow version into its runtime projection.
func NewCompiler ¶
func NewCompiler(registry guardrails.Catalog) Compiler
NewCompiler creates the default workflow compiler for the v1 payload.
func NewCompilerWithFeatureCaps ¶
func NewCompilerWithFeatureCaps(registry guardrails.Catalog, featureCaps core.WorkflowFeatures) Compiler
NewCompilerWithFeatureCaps creates the default workflow compiler for the v1 payload with process-level feature caps applied at compile time.
type CreateInput ¶
type CreateInput struct {
Scope Scope
Activate bool
Managed bool
Name string
Description string
Payload Payload
}
CreateInput is the authoring input for one new immutable workflow version.
type FeatureFlags ¶
type FeatureFlags struct {
Cache bool `json:"cache" bson:"cache"`
Audit bool `json:"audit" bson:"audit"`
Usage bool `json:"usage" bson:"usage"`
Guardrails bool `json:"guardrails" bson:"guardrails"`
Fallback *bool `json:"fallback,omitempty" bson:"fallback,omitempty"`
}
FeatureFlags configures gateway-owned behaviors for a request.
type GuardrailStep ¶
GuardrailStep references one named guardrail and its execution step.
type MongoDBStore ¶
type MongoDBStore struct {
// contains filtered or unexported fields
}
MongoDBStore stores immutable workflow versions in MongoDB.
func NewMongoDBStore ¶
func NewMongoDBStore(database *mongo.Database) (*MongoDBStore, error)
NewMongoDBStore creates collection indexes if needed.
func (*MongoDBStore) Close ¶
func (s *MongoDBStore) Close() error
func (*MongoDBStore) Create ¶
func (s *MongoDBStore) Create(ctx context.Context, input CreateInput) (*Version, error)
func (*MongoDBStore) Deactivate ¶
func (s *MongoDBStore) Deactivate(ctx context.Context, id string) error
func (*MongoDBStore) EnsureManagedDefaultGlobal ¶
func (s *MongoDBStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
func (*MongoDBStore) ListActive ¶
func (s *MongoDBStore) ListActive(ctx context.Context) ([]Version, error)
type Payload ¶
type Payload struct {
SchemaVersion int `json:"schema_version" bson:"schema_version"`
Features FeatureFlags `json:"features" bson:"features"`
Guardrails []GuardrailStep `json:"guardrails,omitempty" bson:"guardrails,omitempty"`
}
Payload is the immutable persisted workflow JSON document.
type PostgreSQLStore ¶
type PostgreSQLStore struct {
// contains filtered or unexported fields
}
PostgreSQLStore stores immutable workflow versions in PostgreSQL.
func NewPostgreSQLStore ¶
NewPostgreSQLStore creates the workflow table and indexes if needed.
func (*PostgreSQLStore) Close ¶
func (s *PostgreSQLStore) Close() error
func (*PostgreSQLStore) Create ¶
func (s *PostgreSQLStore) Create(ctx context.Context, input CreateInput) (*Version, error)
func (*PostgreSQLStore) Deactivate ¶
func (s *PostgreSQLStore) Deactivate(ctx context.Context, id string) error
func (*PostgreSQLStore) EnsureManagedDefaultGlobal ¶
func (s *PostgreSQLStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
func (*PostgreSQLStore) ListActive ¶
func (s *PostgreSQLStore) ListActive(ctx context.Context) ([]Version, error)
type Result ¶
type Result struct {
Service *Service
Store Store
Storage storage.Storage
// contains filtered or unexported fields
}
Result holds the initialized workflow service and any owned resources.
func New ¶
func New(ctx context.Context, cfg *config.Config, compiler Compiler, refreshInterval time.Duration) (*Result, error)
New creates a workflow subsystem with its own storage connection.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore stores immutable workflow versions in SQLite.
func NewSQLiteStore ¶
func NewSQLiteStore(db *sql.DB) (*SQLiteStore, error)
NewSQLiteStore creates the workflow table and indexes if needed.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) Create ¶
func (s *SQLiteStore) Create(ctx context.Context, input CreateInput) (*Version, error)
func (*SQLiteStore) Deactivate ¶
func (s *SQLiteStore) Deactivate(ctx context.Context, id string) error
func (*SQLiteStore) EnsureManagedDefaultGlobal ¶
func (s *SQLiteStore) EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
func (*SQLiteStore) ListActive ¶
func (s *SQLiteStore) ListActive(ctx context.Context) ([]Version, error)
type Scope ¶
type Scope struct {
Provider string `json:"-" bson:"scope_provider,omitempty"`
Model string `json:"scope_model,omitempty" bson:"scope_model,omitempty"`
UserPath string `json:"scope_user_path,omitempty" bson:"scope_user_path,omitempty"`
}
Scope identifies the request selector a persisted workflow applies to. Provider stores the configured provider instance name, not the provider type.
func (Scope) MarshalJSON ¶
func (*Scope) UnmarshalJSON ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service keeps the active workflow set cached in memory.
func NewService ¶
NewService creates a workflow service backed by storage.
func (*Service) Create ¶
Create inserts a new immutable workflow version and refreshes the in-memory snapshot so future requests can match it immediately.
func (*Service) Deactivate ¶
Deactivate turns off one active workflow version and refreshes the in-memory snapshot so future requests stop matching it immediately.
func (*Service) EnsureDefaultGlobal ¶
func (s *Service) EnsureDefaultGlobal(ctx context.Context, input CreateInput) error
EnsureDefaultGlobal seeds or reconciles the managed active global workflow.
func (*Service) GetView ¶
GetView returns one workflow version view, including inactive historical versions.
func (*Service) ListViews ¶
ListViews returns the active workflows together with their effective runtime features after process-level caps are applied.
func (*Service) Match ¶
func (s *Service) Match(selector core.WorkflowSelector) (*core.ResolvedWorkflowPolicy, error)
Match returns the most-specific compiled workflow policy for one request.
func (*Service) PipelineForContext ¶
func (s *Service) PipelineForContext(ctx context.Context) *guardrails.Pipeline
PipelineForContext resolves the active guardrails pipeline for the request context.
func (*Service) PipelineForWorkflow ¶
func (s *Service) PipelineForWorkflow(workflow *core.Workflow) *guardrails.Pipeline
PipelineForWorkflow resolves the active guardrails pipeline for one request workflow.
func (*Service) Refresh ¶
Refresh reloads active workflows from storage and atomically swaps the in-memory snapshot.
func (*Service) StartBackgroundRefresh ¶
StartBackgroundRefresh periodically reloads active workflows until stopped.
type Store ¶
type Store interface {
ListActive(ctx context.Context) ([]Version, error)
Get(ctx context.Context, id string) (*Version, error)
Create(ctx context.Context, input CreateInput) (*Version, error)
EnsureManagedDefaultGlobal(ctx context.Context, input CreateInput, workflowHash string) (*Version, error)
Deactivate(ctx context.Context, id string) error
Close() error
}
Store defines persistence operations for immutable workflow versions.
type ValidationError ¶
ValidationError indicates invalid workflow input or state.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
func (*ValidationError) Unwrap ¶
func (e *ValidationError) Unwrap() error
type Version ¶
type Version struct {
ID string `json:"id" bson:"_id"`
Scope Scope `json:"scope" bson:"-"`
ScopeKey string `json:"scope_key" bson:"scope_key"`
Version int `json:"version" bson:"version"`
Active bool `json:"active" bson:"active"`
Managed bool `json:"managed_default,omitempty" bson:"managed_default,omitempty"`
Name string `json:"name" bson:"name"`
Description string `json:"description,omitempty" bson:"description,omitempty"`
Payload Payload `json:"workflow_payload" bson:"workflow_payload"`
WorkflowHash string `json:"workflow_hash" bson:"workflow_hash"`
CreatedAt time.Time `json:"created_at" bson:"created_at"`
}
Version is one immutable persisted workflow version row.
type View ¶
type View struct {
ID string `json:"id"`
Scope Scope `json:"scope"`
Version int `json:"version"`
Active bool `json:"active"`
Managed bool `json:"managed_default,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Payload Payload `json:"workflow_payload"`
WorkflowHash string `json:"workflow_hash"`
CreatedAt time.Time `json:"created_at"`
ScopeType string `json:"scope_type"`
ScopeDisplay string `json:"scope_display"`
EffectiveFeatures core.WorkflowFeatures `json:"effective_features"`
GuardrailsHash string `json:"guardrails_hash,omitempty"`
CompileError string `json:"compile_error,omitempty"`
}
View is the admin-facing representation of one active workflow version. It includes both the persisted payload and the effective runtime features after process-level feature caps are applied. Broken rows are still returned with CompileError populated so the admin API can inspect persisted workflows that no longer compile cleanly.
func NewViewFromVersion ¶
NewViewFromVersion maps the persisted workflow version into the explicit admin response shape without exposing storage-only fields or tags.