Documentation
¶
Overview ¶
Package workflows provides Temporal workflow definitions for contextd automation.
Package workflows provides Temporal workflow definitions for contextd automation.
This file contains shared types used across multiple workflows and activities.
Package workflows provides Temporal workflow definitions for contextd automation.
Index ¶
- Variables
- func FetchFileContentActivity(ctx context.Context, input FetchFileContentInput) (string, error)
- func FormatErrorForResult(operation string, err error) string
- func NewGitHubClient(ctx context.Context, token config.Secret) (*github.Client, error)
- func RemoveVersionMismatchCommentActivity(ctx context.Context, input PostVersionCommentInput) error
- func WrapActivityError(operation string, err error) error
- type CategorizeFilesInput
- type CategorizedFiles
- type DocumentationValidationInput
- type DocumentationValidationResult
- type ErrorSeverity
- type FetchFileContentInput
- type FetchPRFilesInput
- type FileChange
- type GitHubClientConfig
- type PluginUpdateValidationConfig
- type PluginUpdateValidationResult
- type PostCommentInput
- type PostCommentResult
- func PostReminderCommentActivity(ctx context.Context, input PostCommentInput) (*PostCommentResult, error)
- func PostSuccessCommentActivity(ctx context.Context, input PostCommentInput) (*PostCommentResult, error)
- func PostVersionMismatchCommentActivity(ctx context.Context, input PostVersionCommentInput) (*PostCommentResult, error)
- type PostVersionCommentInput
- type RetryConfig
- type SchemaValidationResult
- type ValidateSchemasInput
- type ValidationIssue
- type VersionValidationConfig
- type VersionValidationResult
- type WorkflowError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidInput indicates workflow input validation failed. ErrInvalidInput = errors.New("invalid workflow input") // ErrEmptyField indicates a required field is empty. ErrEmptyField = errors.New("required field is empty") // ErrInvalidGitHubIdentifier indicates an invalid GitHub owner/repo name. ErrInvalidGitHubIdentifier = errors.New("invalid GitHub identifier") // ErrInvalidPRNumber indicates an invalid PR number. ErrInvalidPRNumber = errors.New("invalid PR number") // ErrPathTraversal indicates a path contains traversal attempts. ErrPathTraversal = errors.New("path traversal detected") // ErrMissingToken indicates GitHubToken is missing. ErrMissingToken = errors.New("GitHub token is required") )
Validation errors
Functions ¶
func FetchFileContentActivity ¶
func FetchFileContentActivity(ctx context.Context, input FetchFileContentInput) (string, error)
FetchFileContentActivity fetches the content of a single file from GitHub.
func FormatErrorForResult ¶ added in v0.3.2
FormatErrorForResult formats an error for inclusion in workflow result.Errors slice. This creates a human-readable error message for end users.
func NewGitHubClient ¶
NewGitHubClient creates a GitHub client with proper authentication.
func RemoveVersionMismatchCommentActivity ¶
func RemoveVersionMismatchCommentActivity(ctx context.Context, input PostVersionCommentInput) error
RemoveVersionMismatchCommentActivity removes the version mismatch comment if it exists. This is called when versions match to clean up any previous mismatch comments.
func WrapActivityError ¶ added in v0.3.2
WrapActivityError wraps an activity error with operation context. Use this when an activity fails to provide consistent error messages.
Types ¶
type CategorizeFilesInput ¶
type CategorizeFilesInput struct {
Files []FileChange // List of files to categorize
}
CategorizeFilesInput defines parameters for file categorization.
type CategorizedFiles ¶
type CategorizedFiles struct {
CodeFiles []string // Files that affect plugin behavior
PluginFiles []string // Files in .claude-plugin/
OtherFiles []string // Other files (tests, docs, etc.)
}
CategorizedFiles contains files categorized by type.
func CategorizeFilesActivity ¶
func CategorizeFilesActivity(ctx context.Context, input CategorizeFilesInput) (*CategorizedFiles, error)
CategorizeFilesActivity categorizes files by whether they affect the plugin.
Error Handling:
- This activity performs pure logic and doesn't fail under normal circumstances
- No external dependencies, so no network or I/O errors
type DocumentationValidationInput ¶
type DocumentationValidationInput struct {
Owner string // Repository owner
Repo string // Repository name
PRNumber int // Pull request number
HeadSHA string // Commit SHA
CodeFiles []string // List of code files changed
PluginFiles []string // List of plugin files changed
}
DocumentationValidationInput defines parameters for ValidateDocumentationActivity.
type DocumentationValidationResult ¶
type DocumentationValidationResult struct {
Valid bool `json:"valid"` // Whether documentation is valid
Summary string `json:"summary"` // Summary of validation
FilesReviewed int `json:"files_reviewed,omitempty"` // Number of files reviewed
CriticalIssues []ValidationIssue `json:"critical_issues"` // Critical issues found
HighIssues []ValidationIssue `json:"high_issues"` // High priority issues
MediumIssues []ValidationIssue `json:"medium_issues"` // Medium priority issues
LowIssues []ValidationIssue `json:"low_issues"` // Low priority issues
}
DocumentationValidationResult represents validation findings.
func ValidateDocumentationActivity ¶
func ValidateDocumentationActivity(ctx context.Context, input DocumentationValidationInput) (*DocumentationValidationResult, error)
ValidateDocumentationActivity validates that plugin docs match code changes. TODO: Implement Claude API integration
type ErrorSeverity ¶ added in v0.3.2
type ErrorSeverity string
Error severity levels for workflow errors
const ( // ErrorSeverityCritical indicates the workflow must fail ErrorSeverityCritical ErrorSeverity = "critical" // ErrorSeverityHigh indicates a major issue but workflow can continue ErrorSeverityHigh ErrorSeverity = "high" // ErrorSeverityLow indicates a minor issue that doesn't affect main functionality ErrorSeverityLow ErrorSeverity = "low" )
type FetchFileContentInput ¶
type FetchFileContentInput struct {
Owner string // Repository owner
Repo string // Repository name
Path string // File path (restricted to allowed paths)
Ref string // Commit SHA or branch name
GitHubToken config.Secret // GitHub API token
}
FetchFileContentInput defines parameters for fetching file content from GitHub.
func (*FetchFileContentInput) ValidateComprehensive ¶ added in v0.3.2
func (i *FetchFileContentInput) ValidateComprehensive() error
ValidateComprehensive performs comprehensive validation with GitHub identifier patterns, path traversal checks, and other security validations.
type FetchPRFilesInput ¶
type FetchPRFilesInput struct {
Owner string // Repository owner
Repo string // Repository name
PRNumber int // Pull request number
GitHubToken config.Secret // GitHub API token
}
FetchPRFilesInput defines parameters for fetching PR file changes.
func (*FetchPRFilesInput) ValidateComprehensive ¶ added in v0.3.2
func (i *FetchPRFilesInput) ValidateComprehensive() error
ValidateComprehensive performs comprehensive validation with GitHub identifier patterns, path traversal checks, and other security validations.
type FileChange ¶
type FileChange struct {
Path string // File path relative to repository root
Status string // "added", "modified", "removed", "renamed"
Additions int // Number of lines added
Deletions int // Number of lines deleted
}
FileChange represents a changed file in a pull request.
func FetchPRFilesActivity ¶
func FetchPRFilesActivity(ctx context.Context, input FetchPRFilesInput) ([]FileChange, error)
FetchPRFilesActivity fetches the list of files changed in a PR.
Error Handling:
- Returns error if GitHub client creation fails
- Returns error if listing PR files fails (404, network errors, etc.)
type GitHubClientConfig ¶
GitHubClientConfig holds GitHub client configuration.
type PluginUpdateValidationConfig ¶
type PluginUpdateValidationConfig struct {
Owner string // GitHub repository owner
Repo string // GitHub repository name
PRNumber int // Pull request number
BaseBranch string // Base branch (usually "main")
HeadBranch string // PR branch
HeadSHA string // PR commit SHA
GitHubToken config.Secret // GitHub API token for activities
UseAgentValidation bool // Whether to use AI agent for documentation validation
}
PluginUpdateValidationConfig configures the plugin validation workflow.
func (*PluginUpdateValidationConfig) ValidateComprehensive ¶ added in v0.3.2
func (c *PluginUpdateValidationConfig) ValidateComprehensive() error
ValidateComprehensive performs comprehensive validation with GitHub identifier patterns, path traversal checks, and other security validations.
type PluginUpdateValidationResult ¶
type PluginUpdateValidationResult struct {
CodeFilesChanged []string // Files that affect plugin behavior
PluginFilesChanged []string // Files in .claude-plugin/
NeedsUpdate bool // Whether plugin needs updating
SchemaValid bool // Whether schemas are valid JSON
AgentValidation *DocumentationValidationResult // Agent validation results (if enabled)
AgentValidationRan bool // Whether agent validation was executed
CommentPosted bool // Whether we posted a comment
CommentURL string // URL of posted comment
Errors []string // Any errors encountered
}
PluginUpdateValidationResult contains validation results.
func PluginUpdateValidationWorkflow ¶
func PluginUpdateValidationWorkflow(ctx workflow.Context, config PluginUpdateValidationConfig) (*PluginUpdateValidationResult, error)
PluginUpdateValidationWorkflow validates plugin updates in a PR.
This workflow: 1. Fetches PR file changes from GitHub 2. Detects if code changes require plugin updates 3. Validates plugin schemas if modified 4. Posts reminder comments if needed 5. Posts success message if plugin updated correctly
type PostCommentInput ¶
type PostCommentInput struct {
Owner string // Repository owner
Repo string // Repository name
PRNumber int // Pull request number
CodeFiles []string // List of code files changed
PluginFiles []string // List of plugin files changed
GitHubToken config.Secret // GitHub API token
AgentValidation *DocumentationValidationResult // Optional agent validation results
}
PostCommentInput defines parameters for posting comments.
type PostCommentResult ¶
type PostCommentResult struct {
URL string // URL of the posted or updated comment
}
PostCommentResult represents the result of posting a GitHub comment.
func PostReminderCommentActivity ¶
func PostReminderCommentActivity(ctx context.Context, input PostCommentInput) (*PostCommentResult, error)
PostReminderCommentActivity posts a reminder comment to the PR.
func PostSuccessCommentActivity ¶
func PostSuccessCommentActivity(ctx context.Context, input PostCommentInput) (*PostCommentResult, error)
PostSuccessCommentActivity posts a success message to the PR.
func PostVersionMismatchCommentActivity ¶
func PostVersionMismatchCommentActivity(ctx context.Context, input PostVersionCommentInput) (*PostCommentResult, error)
PostVersionMismatchCommentActivity posts a version mismatch comment to the PR.
type PostVersionCommentInput ¶
type PostVersionCommentInput struct {
Owner string // Repository owner
Repo string // Repository name
PRNumber int // Pull request number
VersionFile string // Version from VERSION file
PluginVersion string // Version from plugin.json
GitHubToken config.Secret // GitHub API token
}
PostVersionCommentInput defines parameters for posting version-related comments.
func (*PostVersionCommentInput) ValidateComprehensive ¶ added in v0.3.2
func (i *PostVersionCommentInput) ValidateComprehensive() error
ValidateComprehensive performs comprehensive validation with GitHub identifier patterns, path traversal checks, and other security validations.
type RetryConfig ¶ added in v0.3.2
type RetryConfig struct {
// MaxRetries is the maximum number of retry attempts.
// Default: 3
MaxRetries int
// InitialBackoff is the initial backoff duration.
// Default: 1 second
InitialBackoff time.Duration
// MaxBackoff is the maximum backoff duration.
// Default: 30 seconds
MaxBackoff time.Duration
// BackoffMultiplier is the multiplier for exponential backoff.
// Default: 2
BackoffMultiplier float64
}
RetryConfig configures retry behavior for GitHub API calls.
func DefaultRetryConfig ¶ added in v0.3.2
func DefaultRetryConfig() *RetryConfig
DefaultRetryConfig returns the default retry configuration for GitHub API calls.
func (*RetryConfig) ApplyDefaults ¶ added in v0.3.2
func (c *RetryConfig) ApplyDefaults()
ApplyDefaults sets default values for unset fields.
type SchemaValidationResult ¶
type SchemaValidationResult struct {
Valid bool // Whether the schema is valid
Errors []string // Validation errors, if any
}
SchemaValidationResult represents schema validation results.
func ValidatePluginSchemasActivity ¶
func ValidatePluginSchemasActivity(ctx context.Context, input ValidateSchemasInput) (*SchemaValidationResult, error)
ValidatePluginSchemasActivity validates JSON schemas in plugin files.
Error Handling:
- Returns error if GitHub client creation fails
- Returns error if file fetch fails
- Returns error if file content decoding fails
- Returns result with Valid=false for invalid JSON (doesn't error)
type ValidateSchemasInput ¶
type ValidateSchemasInput struct {
Owner string // Repository owner
Repo string // Repository name
HeadSHA string // Commit SHA to validate
FilePath string // Path to schema file
GitHubToken config.Secret // GitHub API token
}
ValidateSchemasInput defines parameters for schema validation.
type ValidationIssue ¶
type ValidationIssue struct {
File string `json:"file"` // File path
Line int `json:"line,omitempty"` // Line number (if applicable)
Severity string `json:"severity,omitempty"` // Issue severity
Issue string `json:"issue"` // Description of the issue
Current string `json:"current,omitempty"` // Current value/state
ShouldBe string `json:"should_be,omitempty"` // Expected value/state
Fix string `json:"fix"` // How to fix the issue
Impact string `json:"impact,omitempty"` // Impact description
}
ValidationIssue represents a single validation finding.
type VersionValidationConfig ¶
type VersionValidationConfig struct {
Owner string // GitHub repository owner
Repo string // GitHub repository name
PRNumber int // Pull request number
HeadSHA string // PR commit SHA
GitHubToken config.Secret // GitHub API token for activities
}
VersionValidationConfig configures the version validation workflow.
func (*VersionValidationConfig) Validate ¶ added in v0.3.2
func (c *VersionValidationConfig) Validate() error
Validate checks that all required fields are set.
func (*VersionValidationConfig) ValidateComprehensive ¶ added in v0.3.2
func (c *VersionValidationConfig) ValidateComprehensive() error
ValidateComprehensive performs comprehensive validation with GitHub identifier patterns, path traversal checks, and other security validations.
type VersionValidationResult ¶
type VersionValidationResult struct {
VersionMatches bool // Whether VERSION file matches plugin.json
VersionFile string // Version from VERSION file
PluginVersion string // Version from plugin.json
CommentPosted bool // Whether we posted a comment
CommentURL string // URL of posted comment
Errors []string // Any errors encountered
}
VersionValidationResult contains validation results.
func VersionValidationWorkflow ¶
func VersionValidationWorkflow(ctx workflow.Context, config VersionValidationConfig) (*VersionValidationResult, error)
VersionValidationWorkflow validates that VERSION file matches plugin.json.
This workflow: 0. Validates input configuration 1. Fetches VERSION file content from PR 2. Fetches plugin.json and extracts version 3. Validates both versions are valid semantic versions 4. Compares versions 5. Posts comment if versions don't match
type WorkflowError ¶ added in v0.3.2
type WorkflowError struct {
Operation string // The operation that failed (e.g., "fetch_version_file", "validate_schema")
Severity ErrorSeverity // How severe the error is
Err error // The underlying error
Context string // Additional context about the error
}
WorkflowError represents a structured error in a workflow
func NewWorkflowError ¶ added in v0.3.2
func NewWorkflowError(operation string, severity ErrorSeverity, err error, context string) *WorkflowError
NewWorkflowError creates a new workflow error with context
func (*WorkflowError) Error ¶ added in v0.3.2
func (e *WorkflowError) Error() string
Error implements the error interface
func (*WorkflowError) Unwrap ¶ added in v0.3.2
func (e *WorkflowError) Unwrap() error
Unwrap allows errors.Is and errors.As to work with WorkflowError