scoring

package
v0.2.5-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 1 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 scoring computes the per-dimension scores (0-100) and the weighted global score from a set of findings, using the configurable weights from .codefit.yaml (PRD RF-07).

Compute returns a ScoreSummary (per-dimension and weighted global score), and IsBlocked reports whether a critical, unconsented security finding must block the deploy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultWeights

func DefaultWeights() map[findings.Dimension]int

DefaultWeights are the per-dimension score weights from the PRD (RF-07); they sum to 100.

func DimensionScore

func DimensionScore(fs []findings.Finding) int

DimensionScore returns the 0-100 score for a single dimension's findings: a base of 100 minus the severity penalties of the counting findings, clamped to a floor of 0.

func IsBlocked

func IsBlocked(fs []findings.Finding) bool

IsBlocked reports whether the report must block the deploy: a critical security finding that is neither suppressed (consent) nor baselined. This is non-configurable — critical security always blocks (PRD §18).

func MissingWeights added in v0.2.0

func MissingWeights(measured []findings.Dimension, weights map[findings.Dimension]int) []findings.Dimension

MissingWeights returns the measured dimensions that have NO weight. Compute iterates the weights map, so such a dimension would be silently dropped (no by_dimension entry, no global contribution). A caller runs this guard before Compute and fails loudly on a non-empty result: a measured dimension without a weight is a codefit wiring bug, never a silently incomplete score (ADR 0021).

Types

type ScoreSummary

type ScoreSummary struct {
	Global      int                         `json:"global"`
	ByDimension map[findings.Dimension]*int `json:"by_dimension"`
}

ScoreSummary is the computed result of an audit: the global score and the per-dimension breakdown, each on a 0-100 scale. A dimension whose sensor did not run is "not measured" and reported as nil (JSON null) — distinct from a dimension that was audited and scored 100. The global is re-normalized over the measured dimensions only, so unmeasured dimensions never inflate it (PRD section 21).

func Compute

func Compute(measured []findings.Dimension, fs []findings.Finding, weights map[findings.Dimension]int) ScoreSummary

Compute calculates the per-dimension scores and the weighted global score. Only the dimensions in measured are scored (others are reported as nil, "not measured"); a measured dimension with no findings scores 100. The global is the weighted average over the measured dimensions' weights only.

Jump to

Keyboard shortcuts

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