labels

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 5 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 labels encodes patchy's state machine: the security-* GitHub issue labels that carry every finding's state, and the legal transitions between states. GitHub issues are the pipeline's only state store, so this package is the single source of truth for label names, value formats, and the transition table — every component parses and renders labels through it.

GitHub caps label names at 50 characters, so labels carry only values that fit (the session label is truncated to a prefix); the full metadata always lives in the report comment's YAML frontmatter, which is the source of truth for anything a label abbreviates.

Index

Constants

View Source
const (
	KeySource         = "security-source"
	KeyAdvisory       = "security-advisory"
	KeyAlert          = "security-alert"
	KeyFinding        = "security-finding"
	KeyAccumulation   = "security-accumulation"
	KeySeverity       = "security-severity"
	KeyPriority       = "security-priority"
	KeyRecommendation = "security-recommendation"
	KeyConfidence     = "security-recommendation-confidence"
	KeyTokenBudget    = "security-token-budget"
	KeyMaxTurns       = "security-max-turns"
	KeyAttempts       = "security-attempts"
	KeyClassifier     = "security-classifier"
	KeyRemediator     = "security-remediator"
)

Label keys. Every patchy label is "<key>: <value>"; multi-valued keys (advisory, alert) emit one label per value.

View Source
const MaxLen = 50

MaxLen is GitHub's label-name length cap; Render never emits a longer name.

Variables

This section is empty.

Functions

func CanTransition

func CanTransition(from, to State) bool

CanTransition reports whether moving the security-finding state from `from` to `to` is legal. The empty state means the label is absent (a new issue). Self-transitions are always legal no-ops.

func Diff

func Diff(prev, next Set) (add, remove []string)

Diff returns the label names to add to and remove from an issue to move it from prev to next. Labels outside the security- namespace are never touched.

func Name

func Name(key, value string) string

Name renders a single label name ("key: value"), enforcing MaxLen — the form used for GitHub label filters and search queries.

func Terminal

func Terminal(s State) bool

Terminal reports whether the state has no outgoing transitions.

Types

type Accumulation

type Accumulation string

Accumulation is the security-accumulation value gating the 1-hour window.

const (
	AccumulationOpen     Accumulation = "open"
	AccumulationComplete Accumulation = "complete"
)

AccumulationOpen collects further alerts into the issue; AccumulationComplete releases it to the remediation controller.

type Level

type Level string

Level is a severity or priority value.

const (
	LevelLow      Level = "low"
	LevelMedium   Level = "medium"
	LevelHigh     Level = "high"
	LevelCritical Level = "critical"
)

The severity/priority scale. GHAS emits critical, so the scale is four-valued even where DESIGN.md prose says three.

type Recommendation

type Recommendation string

Recommendation is the classifier's verdict — the same vocabulary the agent writes in its report frontmatter (internal/report.Recommendation).

const (
	RecommendationRemediate Recommendation = "remediate"
	RecommendationIgnore    Recommendation = "ignore"
	RecommendationManual    Recommendation = "manual"
)

The classifier verdicts.

type Set

type Set struct {
	Source         string
	Advisories     []string
	Alerts         []int
	Finding        State
	Accumulation   Accumulation
	Severity       Level
	Priority       Level
	Recommendation Recommendation
	Confidence     *float64
	TokenBudget    int
	MaxTurns       int
	Attempts       int
	Classifier     string
	Remediator     string
	Classification *Usage
	Remediation    *Usage
}

Set is the typed view of one issue's patchy labels. Zero fields render no label; pointer fields distinguish absent from zero.

func Parse

func Parse(names []string) Set

Parse builds a Set from raw GitHub label names. It is tolerant: labels without the security- prefix, unknown keys, and unparseable values are ignored — issues carry human labels too, and a foreign security-* label must never wedge the pipeline.

func (Set) Render

func (s Set) Render() []string

Render emits the label names for the set, deterministically ordered, each within MaxLen. Zero fields emit nothing.

type State

type State string

State is the security-finding lifecycle value.

const (
	StateOpened          State = "opened"
	StateContextEnhanced State = "context-enhanced"
	StateClassifying     State = "classifying"
	StateClassified      State = "classified"
	StateInReview        State = "in-review"
	StateRemediated      State = "remediated"
	StateAttempted       State = "attempted"
)

The security-finding states, in pipeline order. Remediated and Attempted are terminal; Attempted marks a finding handed back to humans after remediation failed or was exhausted.

type Usage

type Usage struct {
	InputTokens  int
	OutputTokens int
	Turns        int
	CostUSD      float64
	Session      string
	Elapsed      time.Duration
}

Usage is the per-stage agent accounting surfaced as labels.

Jump to

Keyboard shortcuts

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