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:
- Apply base severity weights.
- Apply multipliers from adversary verdicts and global context.
- Filter out findings below their severity's confidence threshold.
- Synthesize adversary "missed_trap" findings.
- Stably sort by composite score descending.
Positional ids (f_%03d) are assigned in pre-sort iteration order.
Types ¶
This section is empty.