Documentation
¶
Overview ¶
Package config models and loads .codefit.yaml, the per-project configuration committed to the repository. It is a leaf package (no codefit dependencies) so that both the core context and the language providers can reference its types without creating import cycles.
Skeleton: the struct shape mirrors the PRD's .codefit.yaml. Validation, defaulting and merging with the global config are not implemented yet.
Index ¶
Constants ¶
const ( CriticalityProduction = "production" CriticalityTest = "test" CriticalityExample = "example" )
Path-criticality classes (RF-11).
Variables ¶
This section is empty.
Functions ¶
func ExpandGlobs ¶
ExpandGlobs resolves glob patterns (with ** support) to the set of existing files under root, project-relative and de-duplicated. It is used to turn schema_paths, test_dirs and ignore.paths into concrete file lists.
Types ¶
type Baseline ¶
Baseline configures the adoption baseline (RF-10): when enabled only new findings are reported.
type Config ¶
type Config struct {
Version string `yaml:"version"`
Project Project `yaml:"project"`
Database Database `yaml:"database"`
Sensors Sensors `yaml:"sensors"`
Report Report `yaml:"report"`
Cache Cache `yaml:"cache"`
Baseline Baseline `yaml:"baseline"`
MCP MCP `yaml:"mcp"`
Ignore Ignore `yaml:"ignore"`
}
Config is the parsed representation of .codefit.yaml. Fields mirror the PRD schema; this is a skeleton, so zero values are acceptable until the loader and validators are implemented.
func Load ¶
Load reads, parses and validates a .codefit.yaml file from path. Validation errors are located (path:line) so the user can jump to the offending line.
It does not yet apply defaulting or merge with the global user config; those are layered on by the caller.
func (*Config) PathCriticalityFor ¶
PathCriticalityFor classifies a project-relative file path as "production", "test" or "example" by matching it against the configured path_criticality globs, or returns "" when nothing matches.
Test and example take precedence over production so that, e.g., a *_test.go living under a production directory is correctly treated as test (lower severity), not production.
type Database ¶
type Database struct {
Paradigm string `yaml:"paradigm"` // oltp | olap | mixed (auto by default)
Type string `yaml:"type"`
SchemaPaths []string `yaml:"schema_paths"`
ORM string `yaml:"orm"`
}
Database declares the DB paradigm and schema sources for the DB sensor.
type Ignore ¶
type Ignore struct {
Paths []string `yaml:"paths"`
Findings []IgnoreFinding `yaml:"findings"`
}
Ignore holds path globs and finding suppressions. Critical security suppressions require an embedded ConsentRecord (validated later).
type IgnoreFinding ¶
type IgnoreFinding struct {
ID string `yaml:"id"`
Reason string `yaml:"reason"`
AcceptedBy string `yaml:"accepted_by"`
AcceptedAt string `yaml:"accepted_at"`
}
IgnoreFinding suppresses a finding by ID. For critical security findings the consent fields are mandatory.
type PathCriticality ¶
type PathCriticality struct {
Production []string `yaml:"production"`
Test []string `yaml:"test"`
Example []string `yaml:"example"`
}
PathCriticality classifies directories so the engine can raise or lower a finding's severity by where it lives. A secret in a test is noise; in production it is critical (RF-11). Language providers supply sensible defaults via LanguageProvider.DefaultPathCriticality.
type Project ¶
type Project struct {
Name string `yaml:"name"`
Language string `yaml:"language"`
Framework string `yaml:"framework"`
Description string `yaml:"description"`
PathCriticality PathCriticality `yaml:"path_criticality"`
}
Project holds project identity and the path-criticality classification that weights finding severity by location (RF-11).
type Report ¶
type Report struct {
Output string `yaml:"output"`
OutFile string `yaml:"out_file"`
IncludeInfo bool `yaml:"include_info"`
ScoreWeights map[string]int `yaml:"score_weights"`
}
Report configures output format and the per-dimension score weights (which must sum to 100).
type SensorToggle ¶
type SensorToggle struct {
Enabled bool `yaml:"enabled"`
}
SensorToggle is the minimal per-sensor config common to every sensor.
type Sensors ¶
type Sensors struct {
Security SensorToggle `yaml:"security"`
Review SensorToggle `yaml:"review"`
DB SensorToggle `yaml:"db"`
Complexity SensorToggle `yaml:"complexity"`
Practices SensorToggle `yaml:"practices"`
Tests SensorToggle `yaml:"tests"`
}
Sensors toggles and tunes each sensor. Skeleton: only the enable flags and a couple of representative knobs are modeled.