guardrails

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package guardrails implements repository surface-area checks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckBudgetCounts

func CheckBudgetCounts(data string, inventoryCounts map[string]int) []string

CheckBudgetCounts verifies that the Current column in BUDGETS.md agrees with the counts derived from the reviewed inventories.

func CheckCanonicalExecutorDocs

func CheckCanonicalExecutorDocs(data string) []string

CheckCanonicalExecutorDocs rejects stale claims for unsupported outbound resolvers.

func CheckCompatibilityDocs

func CheckCompatibilityDocs(data string) []string

CheckCompatibilityDocs requires the documented v0.4 introduction boundary for the compatibility import paths.

func CheckCompatibilityReleaseClaims

func CheckCompatibilityReleaseClaims(data string) []string

CheckCompatibilityReleaseClaims rejects affirmative claims that v0.3.0 publishes a compat/v03 path. It recognizes both release-first and path-first wording so a claim cannot evade the check by changing its word order.

func CheckDependencyRules

func CheckDependencyRules(packages []Package, rules []DependencyRule) []string

CheckDependencyRules checks direct imports. Transitive dependencies are checked at their own direct edge.

func CheckDeprecations

func CheckDeprecations(root string, now time.Time) ([]string, error)

CheckDeprecations requires a future removal deadline on hand-written Go deprecations.

func CheckForbiddenProductionSymbols

func CheckForbiddenProductionSymbols(packages []Package) ([]string, error)

CheckForbiddenProductionSymbols rejects removed declarations in non-test Go files. Keep this source-level check alongside dependency rules so deleted authorities cannot be reintroduced behind an otherwise legal import edge.

func CompareInventory

func CompareInventory(name string, expected, actual []string) error

CompareInventory returns a useful error when expected and actual lines differ.

func DiscoverExamples

func DiscoverExamples(root string) ([]string, error)

DiscoverExamples returns immediate runnable example directories. Shared assets without Go source remain under examples but are not product examples.

func DiscoverModules

func DiscoverModules(root string) ([]string, error)

DiscoverModules returns every repository Go module, including untracked modules.

func MatchPackage

func MatchPackage(pattern, importPath string) bool

MatchPackage reports whether an import path matches an exact or /... pattern.

func ModulePath

func ModulePath(directory string) (string, error)

ModulePath reads the declared module path from a module directory.

func ParseRecipes

func ParseRecipes(data string) []string

ParseRecipes returns the sorted recipe inventory from a Justfile.

func PublicAPI

func PublicAPI(packages []Package) ([]string, error)

PublicAPI returns a deterministic source-level inventory of root exported declarations.

func PublicAPIForModule

func PublicAPIForModule(packages []Package, path string) ([]string, error)

PublicAPIForModule returns exported declarations for one declared module.

func PublicPackages

func PublicPackages(packages []Package) []string

PublicPackages returns importable root-module packages outside internal directories.

func PublicPackagesForModule

func PublicPackagesForModule(packages []Package, path string) []string

PublicPackagesForModule returns importable packages for one declared module.

func ReadInventory

func ReadInventory(path string) ([]string, error)

ReadInventory reads nonempty, non-comment lines.

func TopLevelDirectories

func TopLevelDirectories(root string) ([]string, error)

TopLevelDirectories returns reviewed product directories that contain at least one included source or configuration asset. Untracked assets are included deliberately; generated output is excluded by Git ignore rules.

func WriteInventory

func WriteInventory(path, description string, values []string) error

WriteInventory writes a generated inventory with its review warning.

Types

type DependencyRule

type DependencyRule struct {
	From   string
	To     string
	Reason string
}

DependencyRule prohibits direct imports from one package pattern to another.

func LoadDependencyRules

func LoadDependencyRules(path string) ([]DependencyRule, error)

LoadDependencyRules parses tab-separated from, to, and reason fields.

type Package

type Package struct {
	ImportPath string
	Name       string
	Dir        string
	GoFiles    []string
	Imports    []string
}

Package describes the fields from go list that the checks use.

func GoList

func GoList(root string) ([]Package, error)

GoList returns repository packages from the root module.

func GoListModule

func GoListModule(directory string) ([]Package, error)

GoListModule returns packages declared by the module in directory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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