Documentation
¶
Overview ¶
Package roles provides role prompt loading and stage-based role selection helpers.
Package roles provides role prompt loading and stage-based role selection helpers.
Index ¶
- func BuildRoleAssignmentPrompt(promptTemplate string, request RoleAssignmentRequest) (string, error)
- func EncodeRoleAssignmentRequest(request RoleAssignmentRequest) ([]byte, error)
- func LoadRoleAssignmentPrompt(root string) (string, error)
- type AuditLogger
- type LLMInvoker
- type Registry
- func (registry Registry) CustomGlobalPromptPath() (string, bool)
- func (registry Registry) CustomRolePromptPath(role index.Role) (string, bool)
- func (registry Registry) PromptFiles(role index.Role) []string
- func (registry Registry) RolePromptPath(role index.Role) (string, bool)
- func (registry Registry) Roles() []index.Role
- type RoleAssignmentCaps
- type RoleAssignmentRequest
- type RoleAssignmentResult
- type RoleAssignmentTask
- type RoleDefinition
- type Stage
- type StageRoleSelector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRoleAssignmentPrompt ¶
func BuildRoleAssignmentPrompt(promptTemplate string, request RoleAssignmentRequest) (string, error)
BuildRoleAssignmentPrompt combines the prompt template with the request JSON.
func EncodeRoleAssignmentRequest ¶
func EncodeRoleAssignmentRequest(request RoleAssignmentRequest) ([]byte, error)
EncodeRoleAssignmentRequest serializes the role assignment request as JSON.
func LoadRoleAssignmentPrompt ¶
LoadRoleAssignmentPrompt reads the role assignment prompt from the repo root.
Types ¶
type AuditLogger ¶
type AuditLogger interface {
LogAgentOutcome(taskID string, role string, agent string, status string, exitCode int) error
}
AuditLogger records audit events for role assignment.
type LLMInvoker ¶
LLMInvoker executes a prompt and returns the raw model response.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry captures available roles and prompt paths loaded from disk.
func LoadRegistry ¶
LoadRegistry loads role prompts from the repository root.
func (Registry) CustomGlobalPromptPath ¶
CustomGlobalPromptPath returns the global prompt path when configured.
func (Registry) CustomRolePromptPath ¶
CustomRolePromptPath returns the custom prompt path for a role when available.
func (Registry) PromptFiles ¶
PromptFiles returns the ordered prompt files for the supplied role.
Prompt order:
- .governator/roles/<role>.md
- .governator/custom-prompts/_global.md
- .governator/custom-prompts/<role>.md
func (Registry) RolePromptPath ¶
RolePromptPath returns the repo-relative prompt path for a role, if present.
type RoleAssignmentCaps ¶
type RoleAssignmentCaps struct {
Global int `json:"global"`
DefaultRole int `json:"default_role"`
Roles roleIntMap `json:"roles"`
InFlight roleIntMap `json:"in_flight"`
}
RoleAssignmentCaps captures concurrency caps and in-flight counts for role selection.
type RoleAssignmentRequest ¶
type RoleAssignmentRequest struct {
Task RoleAssignmentTask `json:"task"`
Stage Stage `json:"stage"`
AvailableRoles []index.Role `json:"available_roles"`
Caps RoleAssignmentCaps `json:"caps"`
}
RoleAssignmentRequest represents the JSON input sent to the role assignment LLM.
func (RoleAssignmentRequest) Validate ¶
func (request RoleAssignmentRequest) Validate() error
Validate ensures the role assignment request meets the contract requirements.
type RoleAssignmentResult ¶
type RoleAssignmentResult struct {
Role index.Role
Rationale string
RawResponse string
Fallback bool
}
RoleAssignmentResult captures the selected role and LLM rationale.
func SelectRole ¶
func SelectRole( ctx context.Context, invoker LLMInvoker, promptTemplate string, request RoleAssignmentRequest, warn func(string), auditor AuditLogger, ) (RoleAssignmentResult, error)
SelectRole invokes the role assignment LLM to choose a role at dispatch time.
type RoleAssignmentTask ¶
type RoleAssignmentTask struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Path string `json:"path"`
Content string `json:"content"`
}
RoleAssignmentTask captures the task metadata needed for role selection.
type RoleDefinition ¶
RoleDefinition describes a role and its primary prompt path.
type Stage ¶
type Stage string
Stage labels the worker lifecycle stage used for runtime role selection.
const ( // StageWork selects the role for implementation work. StageWork Stage = "work" // StageTest selects the role for test execution. StageTest Stage = "test" // StageReview selects the role for review execution. StageReview Stage = "review" // StageResolve selects the role for conflict resolution. StageResolve Stage = "resolve" )
type StageRoleSelector ¶
StageRoleSelector maps lifecycle stages to roles, falling back to a default role.
func (StageRoleSelector) RoleForStage ¶
func (selector StageRoleSelector) RoleForStage(stage Stage) (index.Role, error)
RoleForStage selects the role to use for the supplied stage.