config

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteDefaults

func WriteDefaults(workspacePath string) error

WriteDefaults serializes DefaultConfig and DefaultRegistry to the workspace directory. Also writes header-def.yaml and default templates. Existing files are not overwritten.

func WriteMigrationDefaults

func WriteMigrationDefaults(workspacePath string) error

WriteMigrationDefaults writes the default migration.yaml to the workspace if it does not exist.

Types

type ArtifactTypeConfig

type ArtifactTypeConfig struct {
	Prefix          string   `yaml:"prefix" validate:"required"`
	Suffix          string   `yaml:"suffix,omitempty"`
	NameFormat      string   `yaml:"name_format" validate:"required"`
	FileNameFormat  string   `yaml:"file_name_format,omitempty"`
	AllowedChildren []string `yaml:"allowed_children"`
}

ArtifactTypeConfig defines an artifact type's behavior.

type CheckpointRetention added in v1.1.0

type CheckpointRetention struct {
	RetentionDays int `yaml:"retention_days" validate:"omitempty,gte=1"`
}

CheckpointRetention configures checkpoint file retention policy.

type DirectoryCondition

type DirectoryCondition struct {
	Status []string `yaml:"status"`
	Type   []string `yaml:"type"`
}

DirectoryCondition specifies when a directory rule applies.

type DirectoryRule

type DirectoryRule struct {
	Path      string             `yaml:"path" validate:"required"`
	Condition DirectoryCondition `yaml:"condition"`
}

DirectoryRule maps conditions to a target directory path.

type DocumentClassConfig

type DocumentClassConfig struct {
	Name         string   `yaml:"name" validate:"required"`
	GlobPatterns []string `yaml:"glob_patterns" validate:"required,min=1"`
	ArtifactType string   `yaml:"artifact_type" validate:"required"`
	Keywords     []string `yaml:"keywords"`
}

DocumentClassConfig defines how a class of documents is detected and mapped.

type FieldConfig

type FieldConfig struct {
	Type     string   `yaml:"type" validate:"required,oneof=enum string int"`
	Values   []string `yaml:"values"`
	Default  string   `yaml:"default"`
	Optional bool     `yaml:"optional"`
	// ExternalMap holds translation rules for external systems (e.g., Jira, ADO).
	// Uses map[string]any because external system payloads have heterogeneous value types.
	ExternalMap map[string]any `yaml:"external_map"`
}

FieldConfig defines a custom field's schema.

type FieldDef

type FieldDef struct {
	Type      string   `yaml:"type" validate:"required"`
	Values    []string `yaml:"values,omitempty"`
	Default   string   `yaml:"default,omitempty"`
	Optional  bool     `yaml:"optional,omitempty"`
	Immutable bool     `yaml:"immutable,omitempty"`
}

FieldDef describes a single field's schema in header-def.yaml.

type HeaderDefConfig

type HeaderDefConfig struct {
	Defaults SystemDefaults            `yaml:"defaults" validate:"required"`
	Types    map[string]*TypeDefConfig `yaml:"types" validate:"required,min=1"`
}

HeaderDefConfig holds the parsed header-def.yaml configuration defining per-type field schemas with immutable defaults.

func LoadHeaderDef

func LoadHeaderDef(workspacePath string) (*HeaderDefConfig, error)

LoadHeaderDef reads and validates header-def.yaml from the workspace directory.

func (*HeaderDefConfig) IsImmutable

func (h *HeaderDefConfig) IsImmutable(fieldName string) bool

IsImmutable returns true if the given field name is a system-managed immutable field.

func (*HeaderDefConfig) ResolveFieldSchema

func (h *HeaderDefConfig) ResolveFieldSchema(artifactType string) (map[string]*FieldDef, error)

ResolveFieldSchema returns the field definitions for a given artifact type, merged with the system defaults.

type HierarchyLevel

type HierarchyLevel struct {
	Level int      `yaml:"level" validate:"required,gte=1,lte=5"`
	Types []string `yaml:"types" validate:"required,min=1"`
}

HierarchyLevel maps a hierarchy depth to one or more artifact types.

type HookEventThresholds

type HookEventThresholds struct {
	BlockedStaleDays int `yaml:"blocked_stale_days" validate:"gte=0"`
}

HookEventThresholds controls derived signal computation for v1 event types. Deferred signals (stash_overflow, shipment_ready) will add thresholds in v2.

type HooksConfig

type HooksConfig struct {
	Enabled            bool                 `yaml:"enabled"`
	EventThresholds    HookEventThresholds  `yaml:"event_thresholds,omitempty"`
	AgentSubscriptions map[string][]string  `yaml:"agent_subscriptions,omitempty"`
	Lifecycle          LifecycleHooksConfig `yaml:"lifecycle,omitempty"`
	Notifications      NotificationsConfig  `yaml:"notifications,omitempty"`
}

HooksConfig configures the agent hook event system.

func DefaultHooksConfig

func DefaultHooksConfig() *HooksConfig

DefaultHooksConfig returns the default v1 HooksConfig with blocked_stale threshold and subscriptions for the Stage and Ship agents.

func LoadHooks

func LoadHooks(workspacePath string) (*HooksConfig, error)

LoadHooks reads hooks.yaml from the workspace directory. If the file is missing, DefaultHooksConfig is returned so callers always have a valid config.

type LifecycleHooksConfig

type LifecycleHooksConfig struct {
	ValidateTransition bool                `yaml:"validate_transition"`
	EmitEvents         bool                `yaml:"emit_events"`
	Transitions        map[string][]string `yaml:"transitions,omitempty"`
}

LifecycleHooksConfig controls built-in lifecycle hook behavior.

type MigrationConfig

type MigrationConfig struct {
	DocumentClasses []DocumentClassConfig `yaml:"document_classes" validate:"required,min=1,dive"`
	DefaultLayout   string                `yaml:"default_layout" validate:"required,oneof=flat structured mixed"`
	SourcePaths     []SourcePathConfig    `yaml:"source_paths" validate:"dive"`
}

MigrationConfig holds the parsed migration.yaml configuration.

func DefaultMigrationConfig

func DefaultMigrationConfig() *MigrationConfig

DefaultMigrationConfig returns a sensible default migration configuration for common Backlog.md layouts.

func LoadMigrationConfig

func LoadMigrationConfig(workspacePath string) (*MigrationConfig, error)

LoadMigrationConfig reads and validates migration.yaml from the workspace.

func (*MigrationConfig) MatchClass

func (c *MigrationConfig) MatchClass(filePath string) string

MatchClass finds the document class that matches the given file path based on glob patterns. Returns the first matching class name, or empty string if none match.

func (*MigrationConfig) ResolveArtifactType

func (c *MigrationConfig) ResolveArtifactType(className string) (string, error)

ResolveArtifactType maps a document class name to its configured artifact type.

func (*MigrationConfig) Validate

func (c *MigrationConfig) Validate() error

Validate checks all struct tags and returns a descriptive error on failure.

type NotificationsConfig

type NotificationsConfig struct {
	Endpoints []WebhookEndpoint `yaml:"endpoints,omitempty"`
	RateLimit int               `yaml:"rate_limit_per_second,omitempty" validate:"omitempty,gte=1,lte=100"`
}

NotificationsConfig configures external webhook notification dispatch.

type QueueLayoutConfig

type QueueLayoutConfig struct {
	RootDir    string           `yaml:"root_dir" validate:"required"`
	Levels     []HierarchyLevel `yaml:"levels" validate:"required,min=1,dive"`
	NameFormat string           `yaml:"name_format"`
}

QueueLayoutConfig defines the hierarchical file organization for .backlogit/queue/.

type RegistryConfig

type RegistryConfig struct {
	Directories []DirectoryRule `yaml:"directories" validate:"required"`
}

RegistryConfig holds directory routing rules.

func DefaultRegistry

func DefaultRegistry() *RegistryConfig

DefaultRegistry returns default directory routing rules. Status-based rules are listed first so they take priority over type-based rules.

func LoadRegistry

func LoadRegistry(workspacePath string) (*RegistryConfig, error)

LoadRegistry reads registry.yaml from the workspace directory. If the file is missing, DefaultRegistry is returned so callers always have a valid config.

type SectionDef

type SectionDef struct {
	Name        string `yaml:"name" validate:"required"`
	Required    bool   `yaml:"required"`
	Description string `yaml:"description"`
}

SectionDef describes a single template section.

type SourcePathConfig

type SourcePathConfig struct {
	Path  string `yaml:"path" validate:"required"`
	Class string `yaml:"class" validate:"required"`
}

SourcePathConfig maps a directory path pattern to a document class.

type SystemDefaults

type SystemDefaults struct {
	ID          FieldDef `yaml:"id"`
	CreatedDate FieldDef `yaml:"created_date"`
	UpdatedDate FieldDef `yaml:"updated_date"`
}

SystemDefaults holds system-managed immutable field definitions.

type TemplateConfig

type TemplateConfig struct {
	Name         string       `yaml:"name" validate:"required"`
	ArtifactType string       `yaml:"type" validate:"required"`
	Description  string       `yaml:"description"`
	Sections     []SectionDef `yaml:"sections" validate:"required,min=1,dive"`
	Body         string       `yaml:"-"`
}

TemplateConfig represents a Markdown template with named sections.

func GetTemplateForType

func GetTemplateForType(templates []*TemplateConfig, artifactType string) *TemplateConfig

GetTemplateForType returns the first TemplateConfig whose ArtifactType matches artifactType, or nil if none is found.

func LoadTemplates

func LoadTemplates(templatesDir string) ([]*TemplateConfig, error)

LoadTemplates discovers and parses all .md template files from templatesDir. If templatesDir does not exist, it returns nil, nil (missing directory is not an error). Each file must contain YAML frontmatter followed by a Markdown body with matching <!-- BEGIN:{name} --> / <!-- END:{name} --> section tags for every declared section.

type TypeDefConfig

type TypeDefConfig struct {
	Prefix   string               `yaml:"prefix" validate:"required"`
	Suffix   string               `yaml:"suffix,omitempty"`
	IDFormat string               `yaml:"id_format" validate:"required"`
	Fields   map[string]*FieldDef `yaml:"fields" validate:"required"`
}

TypeDefConfig defines a single artifact type's field schema.

type WebhookEndpoint

type WebhookEndpoint struct {
	URL         string            `yaml:"url" validate:"required"`
	EventFilter []string          `yaml:"event_filter,omitempty"`
	Headers     map[string]string `yaml:"headers,omitempty"`
	TimeoutSecs int               `yaml:"timeout_secs,omitempty" validate:"omitempty,gte=1,lte=60"`
}

WebhookEndpoint defines a single webhook notification target.

type WorkspaceConfig

type WorkspaceConfig struct {
	ArtifactTypes       map[string]*ArtifactTypeConfig `yaml:"artifact_types" validate:"required,min=1"`
	Fields              map[string]*FieldConfig        `yaml:"fields"`
	BugLevel            int                            `yaml:"bug_level,omitempty" validate:"omitempty,oneof=2 3"`
	MaxSlugLength       int                            `yaml:"max_slug_length" validate:"gte=10,lte=200"`
	QueueLayout         *QueueLayoutConfig             `yaml:"queue_layout"`
	CheckpointRetention CheckpointRetention            `yaml:"checkpoint_retention,omitempty"`
}

WorkspaceConfig holds the parsed workspace configuration.

func DefaultConfig

func DefaultConfig() *WorkspaceConfig

DefaultConfig returns a sensible default workspace configuration.

func Load

func Load(_ context.Context, workspacePath string) (*WorkspaceConfig, error)

Load reads and validates config.yaml from the workspace directory.

func (*WorkspaceConfig) Validate

func (c *WorkspaceConfig) Validate() error

Validate checks all struct tags and returns a descriptive error on failure.

Jump to

Keyboard shortcuts

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