Documentation
¶
Index ¶
- Variables
- func LintIssue(issue *types.Issue) error
- func ParseIssueType(content string) (types.IssueType, error)
- func ParsePriority(content string) int
- func ValidateAgentID(id string) error
- func ValidateIDFormat(id string) (string, error)
- func ValidatePrefix(requestedPrefix, dbPrefix string, force bool) error
- func ValidatePrefixWithAllowed(requestedPrefix, dbPrefix, allowedPrefixes string, force bool) error
- func ValidatePriority(priorityStr string) (int, error)
- func ValidateTemplate(issueType types.IssueType, description string) error
- type IssueValidator
- func Chain(validators ...IssueValidator) IssueValidator
- func Exists() IssueValidator
- func ForClose(force bool) IssueValidator
- func ForDelete() IssueValidator
- func ForReopen() IssueValidator
- func ForUpdate() IssueValidator
- func HasStatus(allowed ...types.Status) IssueValidator
- func HasType(allowed ...types.IssueType) IssueValidator
- func NotClosed() IssueValidator
- func NotHooked(force bool) IssueValidator
- func NotPinned(force bool) IssueValidator
- func NotTemplate() IssueValidator
- type MissingSection
- type TemplateError
Constants ¶
This section is empty.
Variables ¶
var NamedRoles = []string{"crew", "polecat"}
NamedRoles are agent roles that include a worker name
var RigLevelRoles = []string{"witness", "refinery"}
RigLevelRoles are agent roles that have a rig but no name
var TownLevelRoles = []string{"mayor", "deacon"}
TownLevelRoles are agent roles that don't have a rig
var ValidAgentRoles = []string{
"mayor",
"deacon",
"witness",
"refinery",
"crew",
"polecat",
}
ValidAgentRoles are the known agent role types for ID pattern validation
Functions ¶
func LintIssue ¶
LintIssue checks an existing issue for missing template sections. Unlike ValidateTemplate, this operates on a full Issue struct. Returns nil if the issue passes validation or has no requirements.
func ParseIssueType ¶
ParseIssueType extracts and validates an issue type from content. Returns the validated type or error if invalid.
func ParsePriority ¶
ParsePriority extracts and validates a priority value from content. Supports both numeric (0-4) and P-prefix format (P0-P4). Returns the parsed priority (0-4) or -1 if invalid.
func ValidateAgentID ¶
ValidateAgentID validates that an agent ID follows the expected pattern. Canonical format: prefix-rig-role-name Patterns:
- Town-level: <prefix>-<role> (e.g., gt-mayor, bd-deacon)
- Per-rig singleton: <prefix>-<rig>-<role> (e.g., gt-gastown-witness)
- Per-rig named: <prefix>-<rig>-<role>-<name> (e.g., gt-gastown-polecat-nux)
The prefix can be any rig's configured prefix (gt-, bd-, etc.). Rig names may contain hyphens (e.g., my-project), so we parse by scanning for known role tokens from the right side of the ID. Returns nil if the ID is valid, or an error describing the issue.
func ValidateIDFormat ¶
ValidateIDFormat validates that an ID has the correct format. Supports: prefix-number (bd-42), prefix-hash (bd-a3f8e9), or hierarchical (bd-a3f8e9.1) Returns the prefix part or an error if invalid.
func ValidatePrefix ¶
ValidatePrefix checks that the requested prefix matches the database prefix. Returns an error if they don't match (unless force is true).
func ValidatePrefixWithAllowed ¶
ValidatePrefixWithAllowed checks that the requested prefix is allowed. It matches if: - force is true - dbPrefix is empty - requestedPrefix matches dbPrefix - requestedPrefix is in the comma-separated allowedPrefixes list Returns an error if none of these conditions are met.
func ValidatePriority ¶
ValidatePriority parses and validates a priority string. Returns the parsed priority (0-4) or an error if invalid. Supports both numeric (0-4) and P-prefix format (P0-P4).
func ValidateTemplate ¶
ValidateTemplate checks if the description contains all required sections for the given issue type. Returns nil if validation passes or if the issue type has no required sections.
Section matching is case-insensitive and looks for the heading text anywhere in the description (doesn't require exact markdown format).
Types ¶
type IssueValidator ¶
IssueValidator validates an issue and returns an error if validation fails. Validators can be composed using Chain() for complex validation logic.
func Chain ¶
func Chain(validators ...IssueValidator) IssueValidator
Chain composes multiple validators into a single validator. Validators are executed in order and the first error stops the chain.
func ForClose ¶
func ForClose(force bool) IssueValidator
ForClose returns a validator chain for close operations. Validates: issue exists, is not a template, and is not pinned (unless force).
func ForDelete ¶
func ForDelete() IssueValidator
ForDelete returns a validator chain for delete operations. Validates: issue exists and is not a template.
func ForReopen ¶
func ForReopen() IssueValidator
ForReopen returns a validator chain for reopen operations. Validates: issue exists, is not a template, and is closed.
func ForUpdate ¶
func ForUpdate() IssueValidator
ForUpdate returns a validator chain for update operations. Validates: issue exists and is not a template.
func HasStatus ¶
func HasStatus(allowed ...types.Status) IssueValidator
HasStatus validates that an issue has one of the allowed statuses.
func HasType ¶
func HasType(allowed ...types.IssueType) IssueValidator
HasType validates that an issue has one of the allowed types.
func NotClosed ¶
func NotClosed() IssueValidator
NotClosed validates that an issue is not already closed.
func NotHooked ¶
func NotHooked(force bool) IssueValidator
NotHooked validates that an issue is not in hooked status.
func NotPinned ¶
func NotPinned(force bool) IssueValidator
NotPinned validates that an issue is not pinned. Returns an error if the issue is pinned, unless force is true.
func NotTemplate ¶
func NotTemplate() IssueValidator
NotTemplate validates that an issue is not a template. Templates are read-only and cannot be modified.
type MissingSection ¶
type MissingSection struct {
Heading string // The expected heading, e.g., "## Steps to Reproduce"
Hint string // Guidance for what to include
}
MissingSection describes a section that should be present but isn't.
type TemplateError ¶
type TemplateError struct {
IssueType types.IssueType
Missing []MissingSection
}
TemplateError is returned when template validation fails. It contains all missing sections for a single error report.
func (*TemplateError) Error ¶
func (e *TemplateError) Error() string