scoring

package
v0.8.3-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 6 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 is the deterministic scoring engine for PR-AF — a byte-exact port of src/pr_af/scoring.py.

LLMs reason about issues; this code computes scores. The same findings always produce the same scores, so scoring is auditable, testable, and tunable independently of the agents. Following the Contract-AF / SEC-AF pattern, scoring is intentionally separated from agent code.

Parity notes vs. Python (see design §B.3, §D):

  • This package keeps its OWN, deliberately DIVERGENT severity alias map (sevAlias): medium->important, low->suggestion, and it recognizes "trivia". It disagrees with the canonical schemas.NormalizeSeverity map (medium->suggestion, low->nitpick) and MUST NOT be shared with it.
  • pyRound reproduces Python's round() semantics (round-half-to-even on the true binary value) wherever scoring.py calls round(x, 3). Go's math.Round is half-away-from-zero and would diverge (e.g. 0.0625 -> 0.063 vs 0.062).
  • ScoreFindings assigns positional ids f_%03d in pre-sort iteration order, then stably sorts by score descending — matching Python's stable list.sort(key=..., reverse=True), which preserves the input order of equal-scored findings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeduplicateExact

func DeduplicateExact(findings []schemas.ReviewFinding) []schemas.ReviewFinding

DeduplicateExact removes exact duplicates — same file + same line range + same severity (scoring.py deduplicate_exact). This is CODE, not an LLM call; for near-duplicates the pipeline uses the DedupGate .ai() call.

func DetermineReviewEvent

func DetermineReviewEvent(findings []schemas.ScoredFinding) string

DetermineReviewEvent decides the GitHub review event from the merge-gate verdict (scoring.py determine_review_event).

Decoupled from severity: the merge gate (the `blocking` flag) is the single source of truth for "must fix before merging". Severity remains the reviewer's badness label and drives sorting/display, not the event — so a critical- severity finding that is not marked blocking does NOT request changes.

Returns one of APPROVE | COMMENT | REQUEST_CHANGES.

func ScoreFindings

func ScoreFindings(
	findings []schemas.ReviewFinding,
	adversaryResults []schemas.AdversaryResult,
	cfg config.ScoringConfig,
	aiGenerated float64,
	blastRadiusSize int,
) []schemas.ScoredFinding

ScoreFindings scores, ranks, and filters findings (scoring.py score_findings).

Steps:

  1. Apply base severity weights.
  2. Apply multipliers from adversary verdicts and global context.
  3. Filter out findings below their severity's confidence threshold.
  4. Synthesize adversary "missed_trap" findings.
  5. Stably sort by composite score descending.

Positional ids (f_%03d) are assigned in pre-sort iteration order.

Types

This section is empty.

Jump to

Keyboard shortcuts

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