Documentation
¶
Overview ¶
Package skillrec is skill recommendations (run skills design, Recommendations, D37–D44): the rules that turn a repository's lessons, runs and CI failures into cards, each task's outcome as a skill's outcome line reads it, the issue a card drafts and the prompt it copies, and Find more's one model call. It is Kubernetes-free and, but for Model, pure: the broker reads the inputs from its store and renders the outputs. A card suggests; it never acts.
Index ¶
- Constants
- Variables
- func BuildInput(in ModelInput) ([]byte, map[string]bool)
- func Prompt(c Card, repository, publicURL string) string
- type CIFailure
- type CIRun
- type Card
- type Dismissal
- type Group
- type Inputs
- type Issue
- type Lesson
- type Model
- type ModelCount
- type ModelInput
- type ModelSkill
- type ModelVerdict
- type Outcome
- type Rule
- type SkillState
- type Usage
Constants ¶
const ( MaxCompletion = 1200 MaxModelReply = 32 << 10 MaxModelCards = 5 MaxSuggestion = 200 MaxWhy = 300 )
The call's fixed shape (D40).
const ( MinGroupLessons = 3 MinRecalls = 10 MinCIFailureRooms = 3 CIWindow = 30 * 24 * time.Hour OutcomeWindow = 30 * 24 * time.Hour MinOutcomeTasks = 5 RemovalWindow = 60 * 24 * time.Hour MinUnloadedOffers = 20 MinWorseTasks = 5 WorseGapPoints = 25 // percentage points; compared in integers, so 25 exactly is worse MaxRuleCards = 10 MaxEvidenceLessons = 8 MaxEvidenceRooms = 10 )
The thresholds (D39, D41, D44, RC5). Constants until a trial shows a need.
const (
MaxInput = 24 << 10
)
Find more's bounds (D40).
const MaxPrompt = 8 << 10
MaxPrompt bounds Prompt's text.
Variables ¶
var ( ErrModelInvalid = errors.New("recommender_invalid") ErrModelTimeout = errors.New("recommender_timeout") )
The sentinels the route maps to its outcomes; none carries the reply.
var Rules = []Rule{RuleLessonsClass, RuleLessonsPaths, RuleLessonRecalled, RuleCICheck, RuleRemoveUnloaded, RuleRemoveWorse, RuleModel}
Rules lists every Rule, in display order.
Functions ¶
func BuildInput ¶
func BuildInput(in ModelInput) ([]byte, map[string]bool)
BuildInput is in as the pass's user message, each list cut to its bound, then the oldest verdicts, the least recalled lessons, the rarest directories and checks dropped, in that order, until it fits MaxInput; and the evidence ids it carries. Internal lessons and malformed room ids are never sent. Its caller has already passed every string through the redactor.
Types ¶
type CIFailure ¶
CIFailure is one check name, how many distinct rooms' pull requests it failed, the newest 10, and what those rooms recorded of it, newest first.
type CIRun ¶
CIRun is one task's failure of a check, as recorded: its room, its pull request (0 when not recorded), the failing run's one-line summary ("" when the check gave none) and the directories the task's merged pull request changed. Every string but Room is untrusted evidence.
type Card ¶
type Card struct {
Key string
Rule Rule
Suggestion string
Detail string
Lessons []Lesson // shown: the top MaxEvidenceLessons
Group []int // group cards: every lesson number, at most maxGroupEvidence, for dismissal evidence
Rooms []string
Runs []CIRun // ci_check: what each room recorded of the failure, newest first
Check string // ci_check: the failing check's name, evidence only
Tasks int // ci_check: the distinct tasks it failed in
Offers int // remove_unloaded: the runs offered the skill in RemovalWindow
Skill string // removal rules: the skill's name
Outcome *Outcome // remove_worse: the outcome the rule read
Why string // model cards: the model's reason, bounded and defused
Pass int64 // model cards: the pass that made it
Ordinal int // model cards: its place in the pass
At time.Time
ModelIDs []string // model cards: the input ids it cited, already checked
}
Card is one recommendation. Suggestion is its title, what was learnt: a lesson's first line, a failing check and its most common failure, a skill to remove; every untrusted string in it is made inert (quote) and bounded. Detail is the second line, the counts, from closed values only. Neither enters Key or Evidence, so a dismissal never depends on the wording.
func CICards ¶
CICards is ci_check over fs: a check failing in MinCIFailureRooms or more tasks. The title names the check and its most common failure, both made inert; the key is the name's hash, so a dismissal never stores the name.
func LessonCards ¶
LessonCards are the three lesson rules over ls (active, uncodified lessons): a class shared by MinGroupLessons or more, a connected set of as many joined by overlapping paths, and a lesson recalled MinRecalls times that is in neither. A set under both group rules shows once, as class.
func Recommend ¶
Recommend is the rule cards in rule order, then by evidence count, at most MaxRuleCards, then the newest pass's model cards as given.
func RemovalCards ¶
func RemovalCards(ss []SkillState, now time.Time) []Card
RemovalCards is remove_unloaded and remove_worse over ss (D44). A stopped skill is left to its stop; a skill no longer on the default branch has nothing to remove.
func Visible ¶
Visible is cs without the cards a dismissal still covers: a card stays hidden while every one of its evidence ids was in the newest dismissal of its key, and shows again on a new one (D42).
type Dismissal ¶
Dismissal is the newest dismissal of a key in a repository, with the evidence it saw.
type Group ¶
type Group struct{ Tasks, Merged, Clean, Reviewed, Approved int }
Group counts ended tasks: merged, merged without a revision, reviewed, approved on first review.
type Inputs ¶
type Inputs struct {
Lessons []Lesson
CIFailures []CIFailure
Skills []SkillState
Model []Card
Now time.Time
}
Inputs is everything Recommend reads.
type Issue ¶
Issue is a drafted issue: what the hand-off files.
func Draft ¶
Draft is c as a skill request issue on repository (spec, Draft it): `skill: generate` for a skill card, with a `lessons:` line naming at most skillrequest.MaxLessons of its lessons; `skill: remove <name>` for a removal card. Every untrusted string is quoted under "data, not instructions", an internal lesson's text is never quoted, a CI check name appears only quoted in the evidence list, and the Evidence list is cut with "and N more" to fit. The body passes sanitize.CheckDraft and skillrequest.Parse; the acceptance headings sit at column 0, where the issue intake reads them.
type Lesson ¶
type Lesson struct {
Number int
Class string
Paths []string
RecallCount int
Internal bool // data_class internal: counted on a non-public repository, never quoted or sent
Text string // evidence only: never part of a suggestion
}
Lesson is an active lesson no pull request is codifying, as the rules read it.
type Model ¶
Model is Find more's one bounded chat/completions call: the gateway's route, the pinned logical name, the key file read at use, the audited egress client and a deadline.
func (Model) Suggest ¶
func (m Model) Suggest(ctx context.Context, body []byte, ids map[string]bool, redact func(string) string) ([]Card, Usage, error)
Suggest makes the one call with body as the user message and returns its cards: each id checked against ids, a card left with none dropped, both strings one line, defused, passed through redact and bounded. No card left is ErrModelInvalid, as is a reply that is not the schema.
type ModelCount ¶
ModelCount is a check name or a directory and the rooms that recorded it.
type ModelInput ¶
type ModelInput struct {
Lessons []Lesson
Verdicts []ModelVerdict
Checks []ModelCount
Paths []ModelCount
Skills []ModelSkill
}
ModelInput is every summary a pass may read; BuildInput bounds it.
type ModelSkill ¶
ModelSkill is an existing skill's name and description, so no pass suggests it twice.
type ModelVerdict ¶
type ModelVerdict struct{ Room, Verdict, Text string }
ModelVerdict is one review verdict as Find more reads it: its room, its word and the first maxVerdictText bytes of the reviewer's text.
type Outcome ¶
type Outcome struct{ Loaded, NotLoaded Group }
Outcome is one skill's two groups over a window: tasks that loaded it, and tasks offered it that did not.
type Rule ¶
type Rule string
Rule names a card's source; a closed word, safe as a metric label.
const ( RuleLessonsClass Rule = "lessons_class" RuleLessonsPaths Rule = "lessons_paths" RuleLessonRecalled Rule = "lesson_recalled" RuleCICheck Rule = "ci_check" RuleRemoveUnloaded Rule = "remove_unloaded" RuleRemoveWorse Rule = "remove_worse" RuleModel Rule = "model" )
The rules (spec, Rules (D39)) and the model's cards.