skillrec

package
v0.60.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	MaxCompletion = 1200
	MaxModelReply = 32 << 10
	MaxModelCards = 5
	MaxSuggestion = 200
	MaxWhy        = 300
)

The call's fixed shape (D40).

View Source
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.

View Source
const (
	MaxInput = 24 << 10
)

Find more's bounds (D40).

View Source
const MaxPrompt = 8 << 10

MaxPrompt bounds Prompt's text.

Variables

View Source
var (
	ErrModelInvalid     = errors.New("recommender_invalid")
	ErrModelUnavailable = errors.New("recommender_unavailable")
	ErrModelTimeout     = errors.New("recommender_timeout")
)

The sentinels the route maps to its outcomes; none carries the reply.

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.

func Prompt

func Prompt(c Card, repository, publicURL string) string

Prompt is c as a prompt for a local skill creator on repository (spec, Copy prompt), at most MaxPrompt bytes; "" for a removal card. Its rooms link under publicURL. An internal lesson's text is never in it.

Types

type CIFailure

type CIFailure struct {
	Check string
	Count int
	Rooms []string
	Runs  []CIRun
}

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

type CIRun struct {
	Room    string
	PR      int
	Summary string
	Paths   []string
}

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

func CICards(fs []CIFailure) []Card

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

func LessonCards(ls []Lesson) []Card

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

func Recommend(in Inputs) []Card

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

func Visible(cs []Card, ds []Dismissal) []Card

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).

func (Card) Evidence

func (c Card) Evidence() []string

Evidence is c's evidence ids, sorted: what a dismissal records and compares. At most maxEvidence: the pass and the skill, then a group card's whole group, then the shown lessons and the rooms, as many as fit.

func (Card) Removal

func (c Card) Removal() bool

Removal reports whether c proposes removing a skill.

type Dismissal

type Dismissal struct {
	Key      string
	Evidence []string
}

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

type Issue struct {
	Title string `json:"title"`
	Body  string `json:"body"`
}

Issue is a drafted issue: what the hand-off files.

func Draft

func Draft(c Card, repository, publicURL string) (Issue, error)

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

type Model struct {
	URL      string
	Alias    string
	KeyFile  string
	Deadline time.Duration
	HC       *http.Client
}

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

type ModelCount struct {
	Item  string
	Count int
	Rooms []string
}

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

type ModelSkill struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

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.

func (Outcome) Ended

func (o Outcome) Ended() int

Ended is the ended tasks in both groups.

func (Outcome) Enough

func (o Outcome) Enough() bool

Enough reports whether the line has MinOutcomeTasks ended tasks to show (D41).

func (Outcome) Line

func (o Outcome) Line(window time.Duration) string

Line is the outcome line over window, the span o was counted on: counts only, no rate, no score (D41).

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.

type SkillState

type SkillState struct {
	Name              string
	OnBranch, Stopped bool
	Offers, Loads     int
	FirstOffer        *time.Time
	Outcome           Outcome
}

SkillState is one skill as the removal rules read it: Offers, Loads and Outcome over RemovalWindow, FirstOffer over all the pins retention keeps.

type Usage

type Usage struct{ PromptTokens, CompletionTokens int }

Usage is the call's token counts from the reply's own usage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL