Help us shape the future of Go! Take the 2026 Go Developer Survey

rules

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(r Rule)

func Run

func Run(c *Context) []model.Flag

Run applies all enabled rules with the severity overrides of the config.

func TurnScopes

func TurnScopes(c *Context) map[string]*Scope

TurnScopes gives each step the scope of its turn. The scope is conservative and grows over the session: the paths and identifiers in the prompts so far, the directories the agent read or named in a shell command before the first edit of each turn, the configured scope.paths, files whose added lines use a prompt identifier, and test files that mirror an in-scope file.

Types

type AddedLine

type AddedLine struct {
	N    int
	Text string
}

type Context

type Context struct {
	Change      model.Change
	Hunks       []model.Hunk
	Files       []gitx.FilePatch
	Sessions    []*store.SessionData
	Provenance  map[string][]model.HunkProvenance
	StepSession map[string]string
	ActorKind   map[string]string
	RawPatches  map[string]string
	RepoTop     string
	Cfg         config.Config
	Tests       *testdetect.Detector
	Redactor    *redact.Redactor
}

func NewContext

func NewContext(res *attribution.Result, sessions []*store.SessionData, repoTop string, cfg config.Config, red *redact.Redactor) *Context

func (*Context) Added

func (c *Context) Added(h model.Hunk) []AddedLine

Added gives the added lines of a hunk with their line numbers in the new file.

func (*Context) AgentLines

func (c *Context) AgentLines(h model.Hunk) int

func (*Context) AgentSteps

func (c *Context) AgentSteps(h model.Hunk) []string

func (*Context) FileAgentTouched

func (c *Context) FileAgentTouched(path string) bool

func (*Context) FilePatch

func (c *Context) FilePatch(path string) (gitx.FilePatch, bool)

func (*Context) HunksOf

func (c *Context) HunksOf(path string) []model.Hunk

func (*Context) IsSourceFile

func (c *Context) IsSourceFile(path string) bool

func (*Context) Lines

func (c *Context) Lines(h model.Hunk, kind byte) []string

func (*Context) RelPath

func (c *Context) RelPath(p string) string

RelPath turns an absolute tool path into a repository path.

func (*Context) SessionOfHunk

func (c *Context) SessionOfHunk(h model.Hunk) string

type Rule

type Rule interface {
	ID() string
	Severity() model.Severity
	Check(ctx *Context) []model.Flag
}

func All

func All() []Rule

type Scope

type Scope struct {
	Dirs  map[string]bool
	Files map[string]bool
	Names map[string]bool
	// FromPaths is false when only identifiers from the prompts formed the scope.
	FromPaths bool
	// contains filtered or unexported fields
}

func (*Scope) Contains

func (s *Scope) Contains(p string) bool

func (*Scope) Describe

func (s *Scope) Describe() string

func (*Scope) Empty

func (s *Scope) Empty() bool

Jump to

Keyboard shortcuts

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