projectworkflow

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WorkflowStatusDraft      = "draft"
	WorkflowStatusEnabled    = "enabled"
	WorkflowStatusDisabled   = "disabled"
	WorkflowStatusSuperseded = "superseded"
)
View Source
const (
	WorkflowStepKindWorkPlan        = "work_plan"
	WorkflowStepKindWorkTask        = "work_task"
	WorkflowStepKindAutomation      = "automation"
	WorkflowStepKindAutomationBatch = "automation_batch"
	WorkflowStepKindReviewGate      = "review_gate"
)
View Source
const (
	ReviewGateDecisionApproved     = "approved"
	ReviewGateDecisionRejected     = "rejected"
	ReviewGateDecisionNeedsChanges = "needs_changes"
	ReviewGateDecisionBlocked      = "blocked"
)

Variables

View Source
var ErrInvalidInput = errors.New("invalid project workflow input")

Functions

func ParseWorkflowTOML

func ParseWorkflowTOML(data []byte) ([]WorkflowDefinition, []WorkflowValidationIssue, error)

ParseWorkflowTOML decodes workflow metadata from TOML and validates every decoded workflow. It accepts either one top-level workflow or [[workflows]].

Types

type AutomationAPI

type AutomationAPI interface {
	CreateAutomation(context.Context, projectautomation.CreateAutomationInput) (projectautomation.Automation, error)
}

type CompileOptions added in v0.2.5

type CompileOptions struct {
	BranchPrefix          string
	BranchSummaryTemplate string
	DefaultChangeType     string
}

type CreateWorkflowInput

type CreateWorkflowInput struct {
	Definition     WorkflowDefinition
	CreatedByRunID string
	TraceID        string
}

type ImportWorkflowTOMLInput

type ImportWorkflowTOMLInput struct {
	ProjectID      string
	Data           []byte
	CreatedByRunID string
	TraceID        string
}

type ImportWorkflowTOMLResult

type ImportWorkflowTOMLResult struct {
	Workflows             []WorkflowDefinition         `json:"workflows,omitempty"`
	PermissionSnapshots   []WorkflowPermissionSnapshot `json:"permission_snapshots,omitempty"`
	ValidationIssues      []WorkflowValidationIssue    `json:"validation_issues,omitempty"`
	PermissionSnapshotIDs []string                     `json:"permission_snapshot_ids,omitempty"`
}

type PermissionSnapshotFilter

type PermissionSnapshotFilter struct {
	ProjectID  string `json:"project_id,omitempty"`
	WorkflowID string `json:"workflow_id,omitempty"`
	AgentID    string `json:"agent_id,omitempty"`
}

type Service

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

func New

func New(store Store) *Service

func (*Service) CallWorkflowTool

func (svc *Service) CallWorkflowTool(ctx context.Context, name string, arguments json.RawMessage) (any, error)

CallWorkflowTool adapts MCP workflow tool calls onto service-owned validation and state transitions.

func (*Service) CompileWorkflow

func (svc *Service) CompileWorkflow(ctx context.Context, input WorkflowCompileInput) (WorkflowCompileResult, error)

CompileWorkflow compiles a stored, enabled workflow into governed execution metadata.

func (*Service) CreateWorkflow

func (svc *Service) CreateWorkflow(ctx context.Context, input CreateWorkflowInput) (WorkflowDefinition, error)

func (*Service) GetWorkflow

func (svc *Service) GetWorkflow(ctx context.Context, projectID, workflowID string) (WorkflowDefinition, error)

func (*Service) ImportWorkflowTOML

func (svc *Service) ImportWorkflowTOML(ctx context.Context, input ImportWorkflowTOMLInput) (ImportWorkflowTOMLResult, error)

func (*Service) ListWorkflows

func (svc *Service) ListWorkflows(ctx context.Context, filter WorkflowFilter) ([]WorkflowDefinition, error)

func (*Service) SetCompileOptionsByProject added in v0.2.5

func (svc *Service) SetCompileOptionsByProject(options map[string]CompileOptions)

func (*Service) SetCompilerDependencies

func (svc *Service) SetCompilerDependencies(workPlans WorkPlanAPI, automations AutomationAPI)

func (*Service) UpdateWorkflowStatus

func (svc *Service) UpdateWorkflowStatus(ctx context.Context, input UpdateWorkflowStatusInput) (WorkflowDefinition, error)

func (*Service) ValidateWorkflowTOML

func (svc *Service) ValidateWorkflowTOML(_ context.Context, input ValidateWorkflowTOMLInput) (ValidateWorkflowTOMLResult, error)

type UpdateWorkflowStatusInput

type UpdateWorkflowStatusInput struct {
	ProjectID  string
	WorkflowID string
	Status     string
}

type ValidateWorkflowTOMLInput

type ValidateWorkflowTOMLInput struct {
	Data []byte
}

type ValidateWorkflowTOMLResult

type ValidateWorkflowTOMLResult struct {
	Workflows []WorkflowDefinition      `json:"workflows,omitempty"`
	Issues    []WorkflowValidationIssue `json:"issues,omitempty"`
}

type WorkflowAgentDefinition

type WorkflowAgentDefinition struct {
	ID              string    `json:"id"`
	DisplayName     string    `json:"display_name"`
	Purpose         string    `json:"purpose"`
	Instructions    string    `json:"instructions,omitempty"`
	AllowedSkills   []string  `json:"allowed_skills,omitempty"`
	AllowedTools    []string  `json:"allowed_tools,omitempty"`
	AllowedCommands []string  `json:"allowed_commands,omitempty"`
	DeniedCommands  []string  `json:"denied_commands,omitempty"`
	WorkspaceMode   string    `json:"workspace_mode,omitempty"`
	NetworkPolicy   string    `json:"network_policy,omitempty"`
	SecretPolicy    string    `json:"secret_policy,omitempty"`
	LogPolicy       string    `json:"log_policy,omitempty"`
	MaxRuntime      string    `json:"max_runtime,omitempty"`
	MaxRetries      int       `json:"max_retries,omitempty"`
	Harness         string    `json:"harness,omitempty"`
	Model           string    `json:"model,omitempty"`
	Provider        string    `json:"provider,omitempty"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type WorkflowCompileInput

type WorkflowCompileInput struct {
	ProjectID       string   `json:"project_id,omitempty"`
	WorkflowID      string   `json:"workflow_id"`
	UserRequestRef  string   `json:"user_request_ref,omitempty"`
	ContextPackRefs []string `json:"context_pack_refs,omitempty"`
	CreatedByRunID  string   `json:"created_by_run_id,omitempty"`
	// ChainRunID is the raw workflow chain run id (when compiled from a chain).
	// Forwarded onto the created WorkPlan.ChainRunID so plans link back to
	// their chain run without the synthetic CreatedByRunID token indirection.
	// See .ai/tasks/RUN_OBSERVABILITY_GAP.md §4 T3.3.
	ChainRunID    string `json:"chain_run_id,omitempty"`
	TraceID       string `json:"trace_id,omitempty"`
	TitleOverride string `json:"title_override,omitempty"`
	DryRun        bool   `json:"dry_run,omitempty"`
}

type WorkflowCompileResult

type WorkflowCompileResult struct {
	WorkflowID            string                    `json:"workflow_id,omitempty"`
	WorkPlanID            string                    `json:"work_plan_id,omitempty"`
	WorkTaskIDs           []string                  `json:"work_task_ids,omitempty"`
	ReviewerTaskIDs       []string                  `json:"reviewer_task_ids,omitempty"`
	AutomationIDs         []string                  `json:"automation_ids,omitempty"`
	PermissionSnapshotIDs []string                  `json:"permission_snapshot_ids,omitempty"`
	ValidationIssues      []WorkflowValidationIssue `json:"validation_issues,omitempty"`
	DryRun                bool                      `json:"dry_run,omitempty"`
	CompiledAt            time.Time                 `json:"compiled_at,omitempty"`
}

type WorkflowDefinition

type WorkflowDefinition struct {
	ID                  string                       `json:"id"`
	ProjectID           string                       `json:"project_id"`
	WorkflowRef         string                       `json:"workflow_ref"`
	Title               string                       `json:"title"`
	Purpose             string                       `json:"purpose"`
	Status              string                       `json:"status"`
	Agents              []WorkflowAgentDefinition    `json:"agents,omitempty"`
	Steps               []WorkflowStep               `json:"steps,omitempty"`
	ReviewGates         []WorkflowReviewGate         `json:"review_gates,omitempty"`
	PermissionSnapshots []WorkflowPermissionSnapshot `json:"permission_snapshots,omitempty"`
	CreatedByRunID      string                       `json:"created_by_run_id,omitempty"`
	TraceID             string                       `json:"trace_id,omitempty"`
	// SourceContentHash is a sha256-derived fingerprint of the TOML bytes this
	// definition was last imported from (workflowSourceContentHash). It lets an
	// operator or dashboard detect drift between the stored definition and a
	// newer on-disk workflow TOML without re-importing. Populated by
	// ImportWorkflowTOML on both create and update.
	SourceContentHash string    `json:"source_content_hash,omitempty"`
	CreatedAt         time.Time `json:"created_at"`
	UpdatedAt         time.Time `json:"updated_at"`
}

type WorkflowFilter

type WorkflowFilter struct {
	ProjectID   string `json:"project_id,omitempty"`
	Status      string `json:"status,omitempty"`
	WorkflowRef string `json:"workflow_ref,omitempty"`
}

type WorkflowPermissionSnapshot

type WorkflowPermissionSnapshot struct {
	ID              string    `json:"id"`
	ProjectID       string    `json:"project_id"`
	AgentID         string    `json:"agent_id"`
	WorkflowID      string    `json:"workflow_id"`
	Instructions    string    `json:"instructions,omitempty"`
	AllowedSkills   []string  `json:"allowed_skills,omitempty"`
	AllowedTools    []string  `json:"allowed_tools,omitempty"`
	AllowedCommands []string  `json:"allowed_commands,omitempty"`
	DeniedCommands  []string  `json:"denied_commands,omitempty"`
	WorkspaceMode   string    `json:"workspace_mode,omitempty"`
	NetworkPolicy   string    `json:"network_policy,omitempty"`
	SecretPolicy    string    `json:"secret_policy,omitempty"`
	LogPolicy       string    `json:"log_policy,omitempty"`
	MaxRuntime      string    `json:"max_runtime,omitempty"`
	MaxRetries      int       `json:"max_retries,omitempty"`
	ContentHash     string    `json:"content_hash"`
	CreatedByRunID  string    `json:"created_by_run_id,omitempty"`
	TraceID         string    `json:"trace_id,omitempty"`
	CreatedAt       time.Time `json:"created_at"`
	UpdatedAt       time.Time `json:"updated_at"`
}

type WorkflowReviewGate

type WorkflowReviewGate struct {
	ID                   string   `json:"id"`
	AppliesTo            []string `json:"applies_to,omitempty"`
	ReviewerAgent        string   `json:"reviewer_agent"`
	Required             bool     `json:"required"`
	IndependentFromOwner bool     `json:"independent_from_owner"`
	RequiredArtifacts    []string `json:"required_artifacts,omitempty"`
	AllowedActions       []string `json:"allowed_actions,omitempty"`
	Instructions         string   `json:"instructions"`
}

type WorkflowStep

type WorkflowStep struct {
	ID                      string   `json:"id"`
	Kind                    string   `json:"kind"`
	Title                   string   `json:"title"`
	Agent                   string   `json:"agent,omitempty"`
	DependsOn               []string `json:"depends_on,omitempty"`
	Description             string   `json:"description,omitempty"`
	EvidenceNeeded          []string `json:"evidence_needed,omitempty"`
	ContextPackRefs         []string `json:"context_pack_refs,omitempty"`
	FilesToRead             []string `json:"files_to_read,omitempty"`
	FilesToEdit             []string `json:"files_to_edit,omitempty"`
	LikelyFilesAffected     []string `json:"likely_files_affected,omitempty"`
	VerificationRequirement string   `json:"verification_requirement,omitempty"`
	GitOpsVerificationMode  string   `json:"gitops_verification_mode,omitempty"`
	ExpectedOutput          string   `json:"expected_output,omitempty"`
	FailureCriteria         string   `json:"failure_criteria,omitempty"`
	ReviewGate              string   `json:"review_gate,omitempty"`
	ResumeInstructions      string   `json:"resume_instructions,omitempty"`
	AcceptanceCriteria      []string `json:"acceptance_criteria,omitempty"`
	StopConditions          []string `json:"stop_conditions,omitempty"`
	VerifierLadder          []string `json:"verifier_ladder,omitempty"`
	RegressionApplicability string   `json:"regression_test_applicability,omitempty"`
	DownstreamImpactRefs    []string `json:"downstream_impact_refs,omitempty"`
	OutputContract          string   `json:"output_contract,omitempty"`
	MaxParallelTasks        int      `json:"max_parallel_tasks,omitempty"`
	AutomationStatus        string   `json:"automation_status,omitempty"`
	TriggerKind             string   `json:"trigger_kind,omitempty"`
	SchedulePolicy          string   `json:"schedule_policy,omitempty"`
}

type WorkflowValidationIssue

type WorkflowValidationIssue struct {
	Code      string `json:"code"`
	Severity  string `json:"severity"`
	FieldPath string `json:"field_path,omitempty"`
	Message   string `json:"message"`
}

func ValidateWorkflow

func ValidateWorkflow(def WorkflowDefinition) []WorkflowValidationIssue

ValidateWorkflow checks workflow metadata for unsafe content and references.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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