You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Workflow compilation, validation, engine integration, safe-outputs, and GitHub Actions YAML generation for agentic workflow files.
Overview
The workflow package is the compilation core of gh-aw. It transforms parsed markdown frontmatter (from pkg/parser) and markdown body text into complete GitHub Actions .lock.yml files. Compilation covers the full lifecycle: frontmatter parsing into strongly-typed configuration structs, multi-pass validation (schema, permissions, security, strict mode), engine-specific step generation (Copilot, Claude, Codex, Gemini, custom), safe-output job construction, and final YAML serialization.
The package is organized around three major subsystems:
Compiler (compiler*.go, compiler_types.go): The Compiler struct drives the main compilation pipeline. It accepts a markdown file path (or pre-parsed WorkflowData), builds the full GitHub Actions workflow YAML, and writes the .lock.yml file only when the content has changed.
Engine registry (agentic_engine.go, *_engine.go): A pluggable engine architecture where each AI engine (copilot, claude, codex, gemini, crush, custom) implements a set of focused interfaces (Engine, CapabilityProvider, WorkflowExecutor, MCPConfigProvider, etc.). Engines are registered in a global EngineRegistry and looked up by name at compile time.
Validation (validation.go, strict_mode_*.go, *_validation.go): A layered validation system organized by domain. Each validator is a focused file under 300 lines. Validation runs both at compile time and optionally in strict mode for production deployments.
The package is intentionally large (~320 source files) because it encodes all GitHub Actions generation logic, including per-action job builders for every supported safe-output type (add comment, add labels, assign to user, close issue, update PR, etc.).
Public API
Core Compiler Types
Type
Kind
Description
Compiler
struct
Main compilation engine; use NewCompiler(opts...)
CompilerOption
func type
Functional option for configuring a Compiler
WorkflowData
struct
Complete in-memory representation of a compiled workflow
Network configuration for SRT (allowed/blocked domains, Unix sockets)
SRTFilesystemConfig
struct
Filesystem configuration for SRT (denyRead, allowWrite, denyWrite)
Sandbox Constants
Name
Type
Description
SandboxTypeAWF
SandboxType
AWF sandbox type ("awf")
SandboxTypeDefault
SandboxType
Alias for AWF for backward compatibility ("default")
MCP Scripts
The MCP Scripts subsystem provides inline custom tool definitions (JavaScript, shell, Python, or Go) that are compiled into a local MCP server at workflow runtime.
Type
Kind
Description
MCPScriptsConfig
struct
Parsed mcp-scripts: block; holds transport mode and a map of tool configurations
MCPScriptToolConfig
struct
Configuration for a single MCP script tool (description, inputs, script/run/py/go, env, timeout)
MCPScriptParam
struct
An input parameter for a script tool (type, description, required, default)
MCPScriptsToolJSON
struct
Tool entry serialized to tools.json for the MCP server
Generates the standard ASCII-art + regeneration-instructions header comment for compiled lock files; sourceFile is the .md source path, generatedBy names the generator, and customInstructions is appended verbatim
Validation Functions
Function
Signature
Description
ValidateEventFilters
func(map[string]any) error
Validates on: event filter patterns
ValidateGlobPatterns
func(map[string]any) error
Validates glob patterns in trigger filters
Step Types
Type
Kind
Description
WorkflowStep
struct
A single GitHub Actions step with all standard fields
GitHubActionStep
[]string
A multi-line run step (slice of command strings)
Function
Signature
Description
MapToStep
func(map[string]any) (*WorkflowStep, error)
Converts a YAML map to a typed WorkflowStep
SliceToSteps
func([]any) ([]*WorkflowStep, error)
Converts a YAML slice to typed steps
StepsToSlice
func([]*WorkflowStep) []any
Converts typed steps back to a YAML slice
Repository Configuration
Type
Kind
Description
RepoConfig
struct
Repository-level configuration from .github/gh-aw.yml
Function
Signature
Description
LoadRepoConfig
func(gitRoot string) (*RepoConfig, error)
Loads and parses the repo config file
FormatRunsOn
func(RunsOnValue, string) string
Formats a runs-on: value for YAML output
Threat Detection
Type
Kind
Description
ThreatDetectionConfig
struct
Configuration for the threat detection job
Function
Signature
Description
IsDetectionJobEnabled
func(*SafeOutputsConfig) bool
Returns whether threat detection is enabled
Safe Update Manifest
Type
Kind
Description
GHAWManifest
struct
Signed manifest embedded in lock files for integrity checking
File-per-domain decomposition: Each validation concern and job-builder lives in its own file. The 300-line limit is enforced by convention; validation files exceeding it SHOULD be split.
Functional compiler options: CompilerOption functions follow the standard Go functional-options pattern, keeping NewCompiler signature stable as options are added.
Engine interface composition: Rather than one monolithic Engine interface, capabilities are split into focused interfaces (CapabilityProvider, WorkflowExecutor, etc.) and combined via CodingAgentEngine. This prevents engines from being forced to implement unused methods.
Content-addressed lock files: Lock files are only written when the normalized YAML content changes (heredoc delimiters are normalized before comparison). This avoids unnecessary git churn.
YAML 1.1/1.2 compatibility: The package uses goccy/go-yaml for all GitHub Actions YAML generation to ensure compatibility with GitHub Actions' YAML parser.
Dependencies
Internal:
pkg/parser — frontmatter extraction and import processing
Compiler instances are NOT safe for concurrent use. Create a new Compiler for each concurrent compilation. The GetGlobalEngineRegistry() singleton is initialized once at startup and is safe for concurrent reads thereafter.
Constants (MaxLockFileSize) and action pin data are read-only after initialization and are safe for concurrent access.
This specification is automatically maintained by the spec-extractor workflow.