engine

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package engine contains the certification scoring and status logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CertifyUnit

func CertifyUnit(
	unit domain.Unit,
	rules []domain.PolicyRule,
	ev []domain.Evidence,
	expiryCfg domain.ExpiryConfig,
	now time.Time,
) domain.CertificationRecord

CertifyUnit runs the full certification pipeline for a single unit.

func SaveReportArtifacts added in v0.2.0

func SaveReportArtifacts(certDir string, fr report.FullReport) error

SaveReportArtifacts writes REPORT_CARD.md (compact summary), badge.json, and the unit certificate tree from a pre-computed FullReport.

REPORT_CARD.md is the Card format — a compact summary with overall grade, language breakdown, package links, and top issues.

The reports/ tree contains navigable markdown certificates:

reports/index.md → reports/<pkg>/index.md → reports/<pkg>/<file>/<symbol>.md

For the full per-unit report, use `certify report --format full`. For interactive browsing, use `certify report --site`.

func SaveReportArtifactsFromStore added in v0.2.0

func SaveReportArtifactsFromStore(certDir string, store *record.Store, repo, commit string, now time.Time) error

SaveReportArtifactsFromStore is a convenience wrapper that loads records from the store, generates a FullReport, and writes all artifacts. Used by the certify command where no FullReport exists yet.

func Score

Score computes dimension scores from evidence and evaluation results. Only dimensions with actual evidence are included in the returned map. Dimensions without evidence are absent — they don't dilute the average.

func StatusFromScore

func StatusFromScore(score float64, hasBlockingViolations bool) domain.Status

StatusFromScore determines certification status from a weighted score.

Types

type Certifier added in v0.2.0

type Certifier struct {
	Root           string              // repo root (for reading source files)
	Store          *record.Store       // record persistence (nil = don't save)
	Matcher        *policy.Matcher     // policy matcher (nil = no policy rules)
	Overrides      []domain.Override   // governance overrides
	ExpiryCfg      domain.ExpiryConfig // expiry window config
	Agent          *agent.Coordinator  // optional AI reviewer (nil = skip)
	AgentTimeout   time.Duration       // per-unit timeout for agent calls
	RunID          string              // current run ID (set once per invocation)
	PolicyVersions []string            // active policy pack versions ("name@version")

	// Per-unit attribution data (set by CollectRepoEvidence or manually for tests)
	RepoLintFindings []evidence.LintFinding // raw lint findings for per-unit attribution
	RepoCoverProfile string                 // raw coverage profile for per-unit coverage

	// Deep analysis (type-aware cross-file analysis for Go)
	DeepAnalyzer *analysis.DeepGoAnalyzer // nil = skip deep analysis
}

Certifier is the service that owns the full certification pipeline. It handles policy matching, evidence collection, agent review, record building, override application, and persistence.

func (*Certifier) Certify added in v0.2.0

func (c *Certifier) Certify(ctx context.Context, unit domain.Unit, repoEvidence []domain.Evidence, now time.Time) (*CertifyResult, error)

Certify runs the full certification pipeline for a single unit. repoEvidence is shared across units and should be collected once via CollectRepoEvidence().

func (*Certifier) CollectRepoEvidence added in v0.2.0

func (c *Certifier) CollectRepoEvidence() []domain.Evidence

CollectRepoEvidence runs all available tool runners and returns repo-level evidence. Also retains raw lint findings and coverage profile for per-unit attribution.

type CertifyResult added in v0.2.0

type CertifyResult struct {
	Record      domain.CertificationRecord
	AgentReview *agent.ReviewResult // nil if agent not used or skipped
}

CertifyResult holds the outcome of certifying a single unit.

Jump to

Keyboard shortcuts

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