rules

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const StopAction = "__stop__"

Variables

This section is empty.

Functions

func LifecycleFingerprint added in v0.13.0

func LifecycleFingerprint(config Config) string

LifecycleFingerprint identifies restart-only policy: the lifecycle block and complete exact command rules. Ordinary fuzzy rules and schedules are omitted so they can retain validated reload support.

func RuleMatches added in v0.13.0

func RuleMatches(rule Rule, eventType string, message map[string]any) bool

Types

type CheckoutMode added in v0.13.0

type CheckoutMode string
const (
	CheckoutFull      CheckoutMode = "full"
	CheckoutDelegated CheckoutMode = "delegated"
)

type Config

type Config struct {
	BoardID   string
	AgentName string
	APIURL    string
	Executor  string
	// Worktree is nil unless the configuration explicitly opts into the
	// portable lifecycle. Nil deliberately preserves the legacy manager.
	Worktree  *WorktreeConfig
	Rules     []Rule
	Schedules []Schedule
}

func LoadBytes added in v0.13.0

func LoadBytes(data []byte) (Config, error)

LoadBytes preserves LoadFile's legacy direct-loading behavior for callers which intentionally handle ordinary-rule validation themselves. Lifecycle, command-rule, and cleanup-command strict decoding still applies here.

func LoadFile

func LoadFile(path string) (Config, error)

func LoadValidatedBytes added in v0.13.0

func LoadValidatedBytes(data []byte) (Config, error)

func LoadValidatedFile added in v0.13.0

func LoadValidatedFile(path string) (Config, error)

LoadValidatedFile reads a candidate once, validates every ordinary rule and schedule semantically from those bytes, and only then normalizes it. It is intentionally separate from LoadFile for legacy callers that historically load partially specified ordinary rules.

type Engine

type Engine struct {
	Rules []Rule
}

func (Engine) Command added in v0.13.0

func (e Engine) Command(command string) (Rule, bool)

Command returns the sole configured exact command rule. Loader validation rejects duplicates, so this lookup never has fuzzy-rule ambiguity.

func (Engine) Match

func (e Engine) Match(eventType string, message map[string]any) []Rule

type ExecutionPolicy added in v0.13.0

type ExecutionPolicy string
const (
	ExecutionPrepare        ExecutionPolicy = "prepare"
	ExecutionExistingOrBase ExecutionPolicy = "existing_or_base"
)

type Hook added in v0.13.0

type Hook struct {
	Argv           []string
	TimeoutSeconds int
}

type PrepareHook added in v0.13.0

type PrepareHook struct {
	Hook
	OnCreate bool
	OnReuse  bool
}

type Rule

type Rule struct {
	Name            string
	Events          []string
	Action          string
	Model           string
	List            string
	Title           string
	Label           string
	ContentContains string
	ExcludeLabel    string
	RequireLabel    string
	Emoji           string
	RequireUser     string
	Assignee        []string
	CommentAuthor   string
	// CleanupCommand is a direct argv command run when a card enters Done. It
	// deliberately bypasses the executor and worktree lifecycle.
	CleanupCommand []string
	// CommentCommand is an exact normal-card command such as /up. It is a
	// command policy rather than fuzzy content matching.
	CommentCommand string
	Execution      ExecutionPolicy
}

func (Rule) IsCleanup added in v0.13.0

func (r Rule) IsCleanup() bool

func (Rule) IsStop

func (r Rule) IsStop() bool

func (Rule) ModelID

func (r Rule) ModelID() string

type Schedule

type Schedule struct {
	CardID        string
	Name          string
	Cron          string
	Action        string
	Model         string
	Assignee      string
	List          string
	PublishResult *bool
}

func (Schedule) ModelID

func (s Schedule) ModelID() string

func (Schedule) PublishesResult added in v0.11.0

func (s Schedule) PublishesResult() bool

PublishesResult reports whether the daemon should publish a schedule result. A missing value preserves the legacy behavior of publishing the result.

type Severity

type Severity string
const (
	ErrorSeverity   Severity = "error"
	WarningSeverity Severity = "warning"
)

type SharingEnv added in v0.13.0

type SharingEnv string
const (
	SharingEnvDisabled SharingEnv = "disabled"
	SharingEnvLink     SharingEnv = "link"
)

type SharingSkills added in v0.13.0

type SharingSkills string
const (
	SharingSkillsFallback SharingSkills = "fallback"
	SharingSkillsDisabled SharingSkills = "disabled"
)

type ValidationIssue

type ValidationIssue struct {
	Severity  Severity
	RuleIndex *int
	RuleName  string
	Message   string
}

type ValidationResult

type ValidationResult struct {
	Errors   []ValidationIssue
	Warnings []ValidationIssue
}

func ValidateBytes added in v0.13.0

func ValidateBytes(data []byte) ValidationResult

ValidateBytes performs the complete schema and semantic validation against one immutable candidate. Reload uses this companion to LoadBytes so it can never validate one file revision and install another.

func ValidateFile

func ValidateFile(path string) ValidationResult

func (ValidationResult) IsValid

func (r ValidationResult) IsValid() bool

type WorktreeAdoption added in v0.13.0

type WorktreeAdoption struct {
	CardID       string
	Path         string
	CommonGitDir string
	Branch       string
}

type WorktreeBase added in v0.13.0

type WorktreeBase struct {
	Remote string
	Ref    string
}

type WorktreeCheckout added in v0.13.0

type WorktreeCheckout struct {
	Mode      CheckoutMode
	Bootstrap *Hook
}

type WorktreeConfig added in v0.13.0

type WorktreeConfig struct {
	Base        WorktreeBase
	Helpers     WorktreeHelpers
	Checkout    WorktreeCheckout
	Prepare     *PrepareHook
	Sharing     WorktreeSharing
	Environment WorktreeEnvironment
	Adoptions   []WorktreeAdoption
}

WorktreeConfig is intentionally repository-generic. Project setup behavior lives in administrator-installed direct argv helpers, never in this binary.

type WorktreeEnvironment added in v0.13.0

type WorktreeEnvironment struct {
	Passthrough []string
}

type WorktreeHelpers added in v0.13.0

type WorktreeHelpers struct {
	StableRoot string
}

type WorktreeSharing added in v0.13.0

type WorktreeSharing struct {
	Env    SharingEnv
	Skills SharingSkills
}

Jump to

Keyboard shortcuts

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