Documentation
¶
Overview ¶
Package config provides YAML configuration parsing and validation for the Guardian CLI tool. It handles reading, writing, and validating the various configuration files stored in the .agreements/ directory.
Index ¶
- func SaveConstitution(path string, c *Constitution) error
- func SaveException(path string, e *Exception) error
- func SaveProposal(path string, p *Proposal) error
- func SaveVote(path string, v *Vote) error
- func ValidateConstitution(c *Constitution) error
- func ValidateException(e *Exception) error
- func ValidateProposal(p *Proposal) error
- func ValidateRules(r *RulesFile) error
- func ValidateVote(v *Vote) error
- type Constitution
- type Exception
- type ExceptionPolicy
- type Governance
- type Identity
- type LLMConfig
- type LLMPrompts
- type Proposal
- type ProposalChange
- type QuorumConfig
- type Role
- type RoleMember
- type Rule
- type RuleOverride
- type RulesFile
- type Vote
- type VoterRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveConstitution ¶
func SaveConstitution(path string, c *Constitution) error
SaveConstitution writes a Constitution to the given path as YAML.
func SaveException ¶
SaveException writes an Exception to the given path as YAML.
func SaveProposal ¶
SaveProposal writes a Proposal to the given path as YAML.
func ValidateConstitution ¶
func ValidateConstitution(c *Constitution) error
ValidateConstitution validates a Constitution for required fields and correct enum values.
func ValidateException ¶
ValidateException validates an Exception for required fields.
func ValidateProposal ¶
ValidateProposal validates a Proposal for required fields and correct enum values.
func ValidateRules ¶
ValidateRules validates a RulesFile for required fields and correct values.
func ValidateVote ¶
ValidateVote validates a Vote for required fields and correct enum values.
Types ¶
type Constitution ¶
type Constitution struct {
Governance Governance `yaml:"governance"`
Identity Identity `yaml:"identity"`
Roles map[string]Role `yaml:"roles"`
LLM LLMConfig `yaml:"llm"`
}
Constitution represents the top-level constitution.yml configuration file.
func LoadConstitution ¶
func LoadConstitution(path string) (*Constitution, error)
LoadConstitution reads and parses a constitution.yml file from the given path.
type Exception ¶
type Exception struct {
ID string `yaml:"id"`
RuleID string `yaml:"rule_id"`
Paths []string `yaml:"paths"`
Reason string `yaml:"reason"`
CreatedBy string `yaml:"created_by"`
CreatedAt time.Time `yaml:"created_at"`
ExpiresAt *time.Time `yaml:"expires_at,omitempty"`
}
Exception represents a temporary or permanent exemption from a rule for specific file paths.
func LoadAllExceptions ¶
LoadAllExceptions reads all YAML exception files from the given directory.
func LoadException ¶
LoadException reads and parses an exception YAML file from the given path.
type ExceptionPolicy ¶
type ExceptionPolicy struct {
RequireApproval bool `yaml:"require_approval"`
}
ExceptionPolicy configures how exceptions are handled.
type Governance ¶
type Governance struct {
Voters []VoterRef `yaml:"voters"`
Quorum QuorumConfig `yaml:"quorum"`
ForbidSelfApproval bool `yaml:"forbid_self_approval"`
AllowVoteChange bool `yaml:"allow_vote_change"`
ProposalTTLDays int `yaml:"proposal_ttl_days"`
PerRuleOverrides map[string]RuleOverride `yaml:"per_rule_overrides"`
Exceptions ExceptionPolicy `yaml:"exceptions"`
}
Governance defines the voting and proposal governance rules.
type Identity ¶
type Identity struct {
AllowedDomains []string `yaml:"allowed_domains"`
RequireSignedCommits bool `yaml:"require_signed_commits"`
}
Identity configures identity verification settings.
type LLMConfig ¶
type LLMConfig struct {
Provider string `yaml:"provider"` // deepseek|openai|claude|custom
Endpoint string `yaml:"endpoint"`
Model string `yaml:"model"`
Prompts LLMPrompts `yaml:"prompts"`
}
LLMConfig configures the LLM provider used by Guardian.
type LLMPrompts ¶
type LLMPrompts struct {
CheckSystem string `yaml:"check_system"`
ProposeSystem string `yaml:"propose_system"`
}
LLMPrompts allows overriding the built-in LLM system prompts.
type Proposal ¶
type Proposal struct {
ID string `yaml:"id"`
RuleID string `yaml:"rule_id"`
ProposalType string `yaml:"proposal_type"` // modify|add|remove
Change ProposalChange `yaml:"change"`
Reason string `yaml:"reason"`
Impact string `yaml:"impact"`
CreatedBy string `yaml:"created_by"`
CreatedAt time.Time `yaml:"created_at"`
Status string `yaml:"status"` // proposed|accepted|rejected|withdrawn|expired
}
Proposal represents a proposal to modify, add, or remove a rule.
func LoadAllProposals ¶
LoadAllProposals reads all YAML proposal files from the given directory. It returns only files with .yml or .yaml extensions.
func LoadProposal ¶
LoadProposal reads and parses a proposal YAML file from the given path.
type ProposalChange ¶
type ProposalChange struct {
Description string `yaml:"description"`
Details string `yaml:"details"`
}
ProposalChange describes the proposed change.
type QuorumConfig ¶
type QuorumConfig struct {
Type string `yaml:"type"` // majority|two_thirds|unanimous|custom
Threshold float64 `yaml:"threshold"` // for custom
}
QuorumConfig defines the quorum calculation method.
type Role ¶
type Role struct {
Members []RoleMember `yaml:"members"`
}
Role defines a named role and its members.
type RoleMember ¶
type RoleMember struct {
Email string `yaml:"email"`
}
RoleMember represents a single member within a role.
type Rule ¶
type Rule struct {
ID string `yaml:"id"`
Description string `yaml:"description"`
Type string `yaml:"type"`
Config map[string]interface{} `yaml:"config"`
Severity string `yaml:"severity"`
}
Rule defines a single rule that Guardian checks code changes against.
type RuleOverride ¶
type RuleOverride struct {
Quorum QuorumConfig `yaml:"quorum"`
}
RuleOverride allows per-rule quorum overrides.
type RulesFile ¶
type RulesFile struct {
Rules []Rule `yaml:"rules"`
}
RulesFile represents the rules.yml configuration containing all rule definitions.
type Vote ¶
type Vote struct {
ProposalID string `yaml:"proposal_id"`
VoterEmail string `yaml:"voter_email"`
Decision string `yaml:"decision"` // yes|no
Comment string `yaml:"comment"`
VotedAt time.Time `yaml:"voted_at"`
}
Vote represents a voter's decision on a proposal.