Documentation
¶
Overview ¶
Package selection chooses the most useful representation of collected files under a token budget. It is shared by the non-interactive CLI and the TUI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
File format.FileEntry
PreferredMode string
Signals Signals
AreaWeight float64
Area string
}
Candidate is a collected file plus the mode preference supplied by history or another caller.
type Decision ¶
type Decision struct {
Path string `json:"path"`
Area string `json:"area,omitempty"`
Mode Mode `json:"mode"`
Selected bool `json:"selected"`
Score float64 `json:"score"`
Utility float64 `json:"utility"`
Tokens int `json:"tokens"`
FullTokens int `json:"full_tokens"`
SignatureTokens int `json:"signature_tokens"`
Role string `json:"role,omitempty"`
RoleConfidence float64 `json:"role_confidence,omitempty"`
TaskRelevance float64 `json:"task_relevance,omitempty"`
Signals Signals `json:"signals,omitempty"`
Reason string `json:"reason"`
}
Decision explains the automatic decision for one candidate.
type Report ¶
type Report struct {
Result Result
Skipped []walker.SkippedItem
}
Report contains selection decisions and optional scan skips for display.
type Request ¶
type Request struct {
Budget int
MaxStates int // zero uses the default sparse-DP state limit.
Prompt string // optional task text used to improve path relevance.
// Tuning carries the optimizer's numeric knobs. The zero value means the
// built-in defaults; config layers pass an explicit tuning to override.
Tuning Tuning
}
Request controls automatic selection.
type Result ¶
Result contains every decision and the finalized files selected for output.
func Select ¶
Select chooses a mode for every file. With no budget it preserves the established score/filter modes. With a budget it reserves guaranteed slots for high-retention files (entrypoints, docs, config) and uses sparse dynamic programming for the rest, choosing among full, signature, and skip variants to maximize total utility rather than simply taking files in score order.
type Signals ¶
type Signals struct {
Recency float64 `json:"recency,omitempty"`
Churn float64 `json:"churn,omitempty"`
Centrality float64 `json:"centrality,omitempty"`
Role float64 `json:"role,omitempty"`
TestAffinity float64 `json:"test_affinity,omitempty"`
// Distance is the import-graph hop count from a follow seed. It is zero
// for ordinary selections and carried through to reports so the walk
// that picked a file stays observable.
Distance float64 `json:"distance,omitempty"`
}
Signals are optional ranking inputs retained for explainable reports.
type Tuning ¶
type Tuning struct {
BaseMin float64
BaseMax float64
RelevanceWeight float64
PreferenceBonus float64
SignatureBonus float64
SkipMultiplier float64
SigQualityMin float64
SigQualityMax float64
// TestTaskBoost raises test-file utility when the prompt is test-focused.
TestTaskBoost float64
// RetentionFloor is the minimum retention value at or above which a file
// is guaranteed a slot under budget (its best affordable variant is
// reserved first). Files below the floor compete through the DP.
RetentionFloor float64
// AreaDiminishing reduces utility for later files in the same area.
AreaDiminishing float64
// area may consume when several distinct areas are present.
AreaBudgetShare float64
// AreaRoots maps directory prefixes to explicit area names. Longest
// matching prefix wins; this lets repositories override inferred areas.
AreaRoots map[string]string
// Retention overrides the lang role defaults per role name (e.g.
// "entrypoint"). Config takes priority over the lang default.
Retention map[string]float64
// SkipRoles are role names that automatic selection excludes before
// optimization. An empty list uses the conservative built-in defaults.
SkipRoles []string
}
Tuning holds every numeric knob the utility optimizer reads. Values come from the config [scoring] section; the zero value resolves to the defaults below, so no tuning numbers are hardcoded in the DP itself.