Documentation
¶
Overview ¶
Package tasks provides task selection and priority scoring.
Package tasks defines task structures and loading from various sources. Tasks can come from GitHub issues, local files, or inline definitions.
Index ¶
- func ClearCustom()
- func DefaultIntervalForCategory(cat TaskCategory) time.Duration
- func GetCostEstimate(taskType TaskType) (min, max int, err error)
- func IsCustom(taskType TaskType) bool
- func RegisterCustom(def TaskDefinition) error
- func RegisterCustomTasksFromConfig(customs []config.CustomTaskConfig) error
- func UnregisterCustom(taskType TaskType)
- type CostTier
- type Queue
- type RiskLevel
- type ScoredTask
- type Selector
- func (s *Selector) AddSimulatedCooldown(taskType string, project string)
- func (s *Selector) ClearSimulatedCooldowns()
- func (s *Selector) FilterByBudget(tasks []TaskDefinition, budget int64) []TaskDefinition
- func (s *Selector) FilterByCooldown(tasks []TaskDefinition, project string) []TaskDefinition
- func (s *Selector) FilterEnabled(tasks []TaskDefinition) []TaskDefinition
- func (s *Selector) FilterUnassigned(tasks []TaskDefinition, project string) []TaskDefinition
- func (s *Selector) HasSimulatedCooldown(taskType string, project string) bool
- func (s *Selector) IsAssigned(taskID string) bool
- func (s *Selector) IsOnCooldown(taskType TaskType, project string) (bool, time.Duration, time.Duration)
- func (s *Selector) ScoreTask(taskType TaskType, project string) float64
- func (s *Selector) SelectAndAssign(budget int64, project string) *ScoredTask
- func (s *Selector) SelectNext(budget int64, project string) *ScoredTask
- func (s *Selector) SelectRandom(budget int64, project string) *ScoredTask
- func (s *Selector) SelectTopN(budget int64, project string, n int) []ScoredTask
- func (s *Selector) SetContextMentions(mentions []string)
- func (s *Selector) SetTaskSources(sources []string)
- type Task
- type TaskCategory
- type TaskDefinition
- func AllDefinitions() []TaskDefinition
- func AllDefinitionsSorted() []TaskDefinition
- func GetDefinition(taskType TaskType) (TaskDefinition, error)
- func GetTasksByCategory(category TaskCategory) []TaskDefinition
- func GetTasksByCostTier(tier CostTier) []TaskDefinition
- func GetTasksByRiskLevel(risk RiskLevel) []TaskDefinition
- type TaskType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultIntervalForCategory ¶
func DefaultIntervalForCategory(cat TaskCategory) time.Duration
DefaultIntervalForCategory returns the default re-run interval for a task category.
func GetCostEstimate ¶
GetCostEstimate returns the estimated token cost range for a task type.
func RegisterCustom ¶
func RegisterCustom(def TaskDefinition) error
RegisterCustom registers a custom task definition. Returns an error if the type is already registered (built-in or custom).
func RegisterCustomTasksFromConfig ¶
func RegisterCustomTasksFromConfig(customs []config.CustomTaskConfig) error
RegisterCustomTasksFromConfig converts custom task configs into TaskDefinitions and registers them. If any registration fails, previously registered tasks from this call are rolled back.
func UnregisterCustom ¶
func UnregisterCustom(taskType TaskType)
UnregisterCustom removes a custom task type. Built-in types are not affected.
Types ¶
type CostTier ¶
type CostTier int
CostTier represents the estimated token cost for a task.
func (CostTier) TokenRange ¶
TokenRange returns the min and max estimated tokens for this tier.
type ScoredTask ¶
type ScoredTask struct {
Definition TaskDefinition
Score float64
Project string
}
ScoredTask represents a task with its computed score.
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector handles task selection based on priority scoring.
func NewSelector ¶
NewSelector creates a new task selector.
func (*Selector) AddSimulatedCooldown ¶
AddSimulatedCooldown marks a task+project as on cooldown for preview simulation. Subsequent calls to FilterByCooldown will exclude this combination.
func (*Selector) ClearSimulatedCooldowns ¶
func (s *Selector) ClearSimulatedCooldowns()
ClearSimulatedCooldowns removes all simulated cooldowns.
func (*Selector) FilterByBudget ¶
func (s *Selector) FilterByBudget(tasks []TaskDefinition, budget int64) []TaskDefinition
FilterByBudget returns tasks that fit within the given budget. Budget is in tokens.
func (*Selector) FilterByCooldown ¶
func (s *Selector) FilterByCooldown(tasks []TaskDefinition, project string) []TaskDefinition
FilterByCooldown returns tasks whose cooldown period has elapsed. Tasks that have never run or have no interval (<=0) are always included. Also excludes tasks with simulated cooldowns (used by preview).
func (*Selector) FilterEnabled ¶
func (s *Selector) FilterEnabled(tasks []TaskDefinition) []TaskDefinition
FilterEnabled returns only enabled tasks from the given list. Tasks with DisabledByDefault require explicit inclusion in tasks.enabled.
func (*Selector) FilterUnassigned ¶
func (s *Selector) FilterUnassigned(tasks []TaskDefinition, project string) []TaskDefinition
FilterUnassigned returns tasks that are not currently assigned.
func (*Selector) HasSimulatedCooldown ¶
HasSimulatedCooldown returns whether a task+project has a simulated cooldown.
func (*Selector) IsAssigned ¶
IsAssigned returns whether a task ID is currently assigned.
func (*Selector) IsOnCooldown ¶
func (s *Selector) IsOnCooldown(taskType TaskType, project string) (bool, time.Duration, time.Duration)
IsOnCooldown returns whether a task is on cooldown for a project. Returns (onCooldown, remainingTime, totalInterval).
func (*Selector) ScoreTask ¶
ScoreTask calculates the priority score for a task. Formula: base_priority + staleness_bonus + context_bonus + task_source_bonus
func (*Selector) SelectAndAssign ¶
func (s *Selector) SelectAndAssign(budget int64, project string) *ScoredTask
SelectAndAssign selects the best task and marks it as assigned. Returns the selected task or nil if none available.
func (*Selector) SelectNext ¶
func (s *Selector) SelectNext(budget int64, project string) *ScoredTask
SelectNext returns the best task for the given budget and project. Returns nil if no suitable task is found.
func (*Selector) SelectRandom ¶ added in v0.3.0
func (s *Selector) SelectRandom(budget int64, project string) *ScoredTask
SelectRandom returns a random task from the eligible pool. It applies the same filter pipeline as SelectNext but picks randomly instead of by highest score. The returned ScoredTask still has an accurate Score for display purposes. Returns nil if no task is eligible.
func (*Selector) SelectTopN ¶
func (s *Selector) SelectTopN(budget int64, project string, n int) []ScoredTask
SelectTopN returns the top N tasks by score that fit within budget.
func (*Selector) SetContextMentions ¶
SetContextMentions sets tasks mentioned in claude.md/agents.md. These tasks get a +2 context bonus.
func (*Selector) SetTaskSources ¶
SetTaskSources sets tasks from td/github issues. These tasks get a +3 task source bonus.
type Task ¶
type Task struct {
ID string
Title string
Description string
Priority int
Type TaskType // Optional: links to a TaskDefinition
}
Task represents a unit of work for an AI agent.
type TaskCategory ¶
type TaskCategory int
TaskCategory represents the type of output a task produces.
const ( // CategoryPR - "It's done - here's the PR" // Fully formed, review-ready artifacts. CategoryPR TaskCategory = iota // CategoryAnalysis - "Here's what I found" // Completed analysis with conclusions, no code touched. CategoryAnalysis // CategoryOptions - "Here are options - what do you want to do?" // Surfaces judgment calls, tradeoffs, design forks. CategoryOptions // CategorySafe - "I tried it safely" // Required execution/simulation but left no lasting side effects. CategorySafe // CategoryMap - "Here's the map" // Pure context laid out cleanly. CategoryMap // CategoryEmergency - "For when things go sideways" // Artifacts you hope to never need. CategoryEmergency )
func (TaskCategory) String ¶
func (c TaskCategory) String() string
String returns a human-readable description of the task category.
type TaskDefinition ¶
type TaskDefinition struct {
Type TaskType
Category TaskCategory
Name string
Description string
CostTier CostTier
RiskLevel RiskLevel
DefaultInterval time.Duration
DisabledByDefault bool // Requires explicit opt-in via tasks.enabled
}
TaskDefinition describes a built-in task type.
func AllDefinitions ¶
func AllDefinitions() []TaskDefinition
AllDefinitions returns all registered task definitions.
func AllDefinitionsSorted ¶
func AllDefinitionsSorted() []TaskDefinition
AllDefinitionsSorted returns all registered task definitions sorted by Category first, then by Name within each category. This provides stable, deterministic ordering for CLI output.
func GetDefinition ¶
func GetDefinition(taskType TaskType) (TaskDefinition, error)
GetDefinition returns the definition for a task type.
func GetTasksByCategory ¶
func GetTasksByCategory(category TaskCategory) []TaskDefinition
GetTasksByCategory returns all task definitions in a category.
func GetTasksByCostTier ¶
func GetTasksByCostTier(tier CostTier) []TaskDefinition
GetTasksByCostTier returns all task definitions with a given cost tier.
func GetTasksByRiskLevel ¶
func GetTasksByRiskLevel(risk RiskLevel) []TaskDefinition
GetTasksByRiskLevel returns all task definitions with a given risk level.
func (TaskDefinition) EstimatedTokens ¶
func (d TaskDefinition) EstimatedTokens() (min, max int)
EstimatedTokens returns the token range for this task definition.
type TaskType ¶
type TaskType string
TaskType represents a specific type of task.
const ( TaskLintFix TaskType = "lint-fix" TaskBugFinder TaskType = "bug-finder" TaskAutoDRY TaskType = "auto-dry" TaskSkillGroom TaskType = "skill-groom" TaskAPIContractVerify TaskType = "api-contract-verify" TaskBackwardCompat TaskType = "backward-compat" TaskBuildOptimize TaskType = "build-optimize" TaskDocsBackfill TaskType = "docs-backfill" TaskCommitNormalize TaskType = "commit-normalize" TaskChangelogSynth TaskType = "changelog-synth" TaskReleaseNotes TaskType = "release-notes" TaskADRDraft TaskType = "adr-draft" TaskTDReview TaskType = "td-review" )
Category 1: "It's done - here's the PR"
const ( TaskDocDrift TaskType = "doc-drift" TaskSemanticDiff TaskType = "semantic-diff" TaskDeadCode TaskType = "dead-code" TaskDependencyRisk TaskType = "dependency-risk" TaskTestGap TaskType = "test-gap" TaskTestFlakiness TaskType = "test-flakiness" TaskLoggingAudit TaskType = "logging-audit" TaskMetricsCoverage TaskType = "metrics-coverage" TaskPerfRegression TaskType = "perf-regression" TaskCostAttribution TaskType = "cost-attribution" TaskSecurityFootgun TaskType = "security-footgun" TaskPIIScanner TaskType = "pii-scanner" TaskPrivacyPolicy TaskType = "privacy-policy" TaskSchemaEvolution TaskType = "schema-evolution" TaskEventTaxonomy TaskType = "event-taxonomy" TaskRoadmapEntropy TaskType = "roadmap-entropy" TaskBusFactor TaskType = "bus-factor" TaskKnowledgeSilo TaskType = "knowledge-silo" )
Category 2: "Here's what I found"
const ( TaskGroomer TaskType = "task-groomer" TaskGuideImprover TaskType = "guide-improver" TaskIdeaGenerator TaskType = "idea-generator" TaskTechDebtClassify TaskType = "tech-debt-classify" TaskWhyAnnotator TaskType = "why-annotator" TaskEdgeCaseEnum TaskType = "edge-case-enum" TaskErrorMsgImprove TaskType = "error-msg-improve" TaskSLOSuggester TaskType = "slo-suggester" TaskUXCopySharpener TaskType = "ux-copy-sharpener" TaskA11yLint TaskType = "a11y-lint" TaskServiceAdvisor TaskType = "service-advisor" TaskOwnershipBoundary TaskType = "ownership-boundary" TaskOncallEstimator TaskType = "oncall-estimator" )
Category 3: "Here are options"
const ( TaskMigrationRehearsal TaskType = "migration-rehearsal" TaskContractFuzzer TaskType = "contract-fuzzer" TaskGoldenPath TaskType = "golden-path" TaskPerfProfile TaskType = "perf-profile" TaskAllocationProfile TaskType = "allocation-profile" )
Category 4: "I tried it safely"
const ( TaskVisibilityInstrument TaskType = "visibility-instrument" TaskRepoTopology TaskType = "repo-topology" TaskPermissionsMapper TaskType = "permissions-mapper" TaskDataLifecycle TaskType = "data-lifecycle" TaskFeatureFlagMonitor TaskType = "feature-flag-monitor" TaskCISignalNoise TaskType = "ci-signal-noise" TaskHistoricalContext TaskType = "historical-context" )
Category 5: "Here's the map"
const ( TaskRunbookGen TaskType = "runbook-gen" TaskRollbackPlan TaskType = "rollback-plan" TaskPostmortemGen TaskType = "postmortem-gen" )
Category 6: "For when things go sideways"
func DefaultDisabledTaskTypes ¶
func DefaultDisabledTaskTypes() []TaskType
DefaultDisabledTaskTypes returns task types that are disabled by default and require explicit opt-in via the tasks.enabled config list.