config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config loads strictcode.toml through the strictspec-generated reader and implements the consumer-native checks the schema cannot express (DESIGN.md section 12.3):

  • rule-ID validity against the registry, with tombstone rendering — a config referencing a retired ID hard-errors with the tombstone's retired_in, reason, replaced_by successors, and migration hint;
  • group-name validity;
  • suppression-shape-vs-rule matching (a rule accepts only its declared natural target shape; shape "none" accepts no suppressions at all).

Disk/registry staleness of suppression targets is NOT a load error — it is the stale-suppression rule (CATALOG.md), evaluated during analysis with the workspace in hand.

A missing config file yields the registry defaults: every rule enabled at its default severity, no suppressions, syntactic-only analysis. A present but malformed config is a hard error (lesson 31): nothing is coerced, defaulted, or skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	// PythonTypeChecker is empty for the always-on syntactic layer, or the
	// chosen checker ("pyright" | "ty") when type-checker mode is selected.
	PythonTypeChecker string
}

Analysis is the effective analysis-mode selection.

type Effective

type Effective struct {
	Analysis Analysis
	// Rules has an entry for every live registry rule.
	Rules map[string]RuleSetting
}

Effective is the fully resolved configuration.

func Defaults

func Defaults() *Effective

Defaults returns the registry-default configuration.

func Load

func Load(path string) (*Effective, error)

Load reads the config file at path. A missing file returns the defaults; any other read, parse, schema, or registry failure is a hard error.

func Parse

func Parse(raw []byte, name string) (*Effective, error)

Parse validates and resolves a config document. name is used in errors.

func (*Effective) AllSuppressions

func (e *Effective) AllSuppressions() []Suppression

AllSuppressions returns every configured suppression (input to the stale-suppression rule), sorted by rule ID.

func (*Effective) Setting

func (e *Effective) Setting(id string) RuleSetting

Setting returns the effective setting for a live rule ID. Panics on an unknown ID: callers pass registry IDs, and an unknown one is a bug.

type RuleSetting

type RuleSetting struct {
	Enabled      bool
	Severity     rules.Severity
	Thresholds   map[string]int64
	Suppressions []Suppression
	// Allow holds per-language allow lists (library-forbidden-imports:
	// subtracted from the effective forbidden set; lesson 26).
	Allow map[string][]string
	// Forbidden holds per-language replacements of the default
	// forbidden-imports list.
	Forbidden map[string][]string
}

RuleSetting is the effective per-rule configuration after group toggles and per-rule overrides.

type Suppression

type Suppression struct {
	Rule   string
	Shape  rules.SuppressionShape
	Reason string

	Path    string   // shape path
	Project string   // shape project-dep
	Dep     string   // shape project-dep
	Modules []string // shape member-set
	Member  string   // shape member
}

Suppression is one configured suppression in its rule's natural shape.

Jump to

Keyboard shortcuts

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