Documentation
¶
Overview ¶
Package role loads a role's contract (role.yaml) and the project's settings for it, as described in docs/spec/role-contract.md.
Index ¶
- Constants
- Variables
- func CheckConfig(data []byte) error
- func IsConfigError(err error) bool
- func MergeSettings(defaults, over map[string]any) map[string]any
- type ConfigError
- type Model
- type ProjectConfig
- type Role
- func (r *Role) Accepts(event string) bool
- func (r *Role) Allows(kind string) bool
- func (r *Role) Enforcement(c *ProjectConfig) map[string]string
- func (r *Role) MergedSettings(c *ProjectConfig) map[string]any
- func (r *Role) PartAnswers() []string
- func (r *Role) Writes(settings map[string]any) []string
Constants ¶
const ByLevel = "by-level"
ByLevel is the setting a role with levels gets beside its own: its settings as the level alone gives them, the project's left out — what a project set is what differs from it.
Variables ¶
var Retired = map[string]string{
"release-manager": "the release-manager role is retired: workline cuts no releases, it works with the release tool a project has " +
"(docs/adr/0017-the-release-manager.md, ADR-0017). Release with one — release-please, release-plz, releaser-pleaser, " +
"semantic-release or changesets; GoReleaser to publish — and route `release: [documentalist]` before it",
}
Retired says what replaces a role workline no longer ships, by its name.
Functions ¶
func CheckConfig ¶
CheckConfig refuses a config holding a key the engine does not know.
func IsConfigError ¶
IsConfigError reports whether err, or an error it wraps, is a ConfigError.
Types ¶
type ConfigError ¶
type ConfigError struct {
// contains filtered or unexported fields
}
ConfigError is a .workline/config.yaml the engine cannot trust: unreadable, or holding a key it does not know. A key that is ignored is a setting someone believes in and nothing applies, so it blocks (principle 12).
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type Model ¶
type Model struct {
Capability string `yaml:"capability"`
Tier string `yaml:"tier"`
Effort string `yaml:"effort"`
PromoteAfter int `yaml:"promote-after"`
Timeout string `yaml:"timeout"` // how long one answer may take, e.g. "10m"; default 3m
// Tasks gives a kind of task, named by pre in in/task-kind, other needs
// than the role's: condensing a doc needs more than judging one.
Tasks map[string]Model `yaml:"tasks"`
}
Model is what kind of thinking a role needs (docs/spec/model-grid.md).
func (Model) AnswerTimeout ¶
AnswerTimeout is how long the agent may take for one answer.
type ProjectConfig ¶
type ProjectConfig struct {
AI string `yaml:"ai"` // default agent for this project: none, claude...
Forge string `yaml:"forge"` // github, gitlab, or none
Roles map[string]struct {
Settings map[string]any `yaml:"settings"`
Enforce map[string]string `yaml:"enforce"`
} `yaml:"roles"`
}
ProjectConfig is the part of .workline/config.yaml the engine reads today.
func LoadProjectConfig ¶
func LoadProjectConfig(repo string) (*ProjectConfig, error)
LoadProjectConfig reads <repo>/.workline/config.yaml. A missing file is an empty config; an unreadable or invalid one is an error.
type Role ¶
type Role struct {
Contract int `yaml:"contract"`
Name string `yaml:"name"`
Mission string `yaml:"mission"`
Events []string `yaml:"events"`
Requires []string `yaml:"requires"`
Uses []string `yaml:"uses"`
Intentions []string `yaml:"intentions"`
// PartIntentions are what a part of a question may answer with
// (in/parts): claims when unset; a reviewer's lens answers findings.
PartIntentions []string `yaml:"part-intentions"`
// OnBlock are the intentions a run still applies when post blocks:
// those that only tell why, never change what was judged (the
// reviewer's summary comment, #226). Empty: nothing applied on a block.
OnBlock []string `yaml:"on-block"`
Model Model `yaml:"model"`
Duties struct {
Reads []string `yaml:"reads"`
Writes []string `yaml:"writes"`
} `yaml:"duties"`
Context struct {
Knowledge []string `yaml:"knowledge"`
Budget int `yaml:"budget"`
} `yaml:"context"`
WithoutAI string `yaml:"without-ai"`
Settings map[string]any `yaml:"settings"`
// Levels are named sets of settings a project picks with one setting
// (docs/spec/role-adapting.md, "Levels"): setting -> value -> the
// settings laid over the role's before the project's own.
Levels map[string]map[string]map[string]any `yaml:"levels"`
Dir string `yaml:"-"`
}
Role is a parsed role.yaml, plus the folder it was loaded from.
func (*Role) Enforcement ¶
func (r *Role) Enforcement(c *ProjectConfig) map[string]string
Enforcement returns how hard each rule bites for this role in this project.
func (*Role) MergedSettings ¶
func (r *Role) MergedSettings(c *ProjectConfig) map[string]any
MergedSettings returns the role's defaults overridden by the project's settings, as docs/spec/role-contract.md says: maps merged key by key, at every depth; a list or a scalar replaced whole; a null removes the key. A level the project picks is laid over the defaults first.
func (*Role) PartAnswers ¶ added in v0.9.0
PartAnswers are the intentions a part of a question may answer with: `part-intentions`, else claims (docs/spec/role-contract.md, "In parts").