feat(review-pr): add per-finding confidence scoring model#17
Open
Sayt-0 wants to merge 2 commits into
Open
Conversation
Score each verified finding 0-100 from the verifier verdict, evidence strength, context completeness, drafter/verifier severity concordance, and scope. Bands (strong/moderate/weak/negligible) with a default posting threshold of 55 gate inline comments; security and high-severity CONFIRMED/LIKELY findings are always posted, weak-band findings go to a visible lower-confidence summary instead of being dropped, and a medium-severity floor keeps a still-believed finding visible. The model is implemented and unit-tested in src/score-confidence (single source of truth) and mirrored in the orchestrator prompt as a strict lookup table. The verifier now emits evidence_strength and context_completeness.
CodeQL js/insecure-temporary-file: the CLI defaulted its output to a hardcoded /tmp path. Default to stdout instead (composable, no fixed temp file) and write to a file only when the caller passes an explicit output path.
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The confidence scoring model looks correct. The lookup table arithmetic, band boundaries, clamping, posting policy precedence, enum validation, and CLI wiring all check out. The TypeScript module and the YAML mirror are consistent. No bugs were found in the code introduced by this PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a precise, multi-criteria confidence scoring model for the PR reviewer. Each verified finding gets a 0 to 100 confidence score, a band, and a posting disposition, computed deterministically from several signals rather than a subjective guess.
The model lives in two synchronized surfaces:
src/score-confidence/(pure module + CLI + unit tests)review-pr/agents/pr-review.yaml"Confidence Scoring" sectiondist/is not available at agent runtime)Criteria
evidence_strength(direct / circumstantial / speculative)context_completeness(full / partial / none)in_diffandin_changed_code)Scale and threshold
verdict x evidence x contexttable (CONFIRMED 70/LIKELY 40base; evidence+18 / +8 / -4; context+12 / +4 / -10), plus concordance (+5 / 0 / -8), clamped.strong >= 80,moderate 55..79,weak 30..54,negligible < 30.strong(LIKELY tops out at 75), a property the unit tests pin.Posting policy (first match wins; the 5-comment cap is applied last)
Maps to the requested design
evidence_strengthfieldcontext_completenessfieldHow it was hardened
A design review (three independent lenses: calibration, security policy, LLM reproducibility) locked the constants, replacing error-prone post-hoc caps with the lookup table and removing band dead-zones. An adversarial verification pass then confirmed and fixed three defects:
categorywas the only enum not validated, so a misspelled value silently disabled the security floorcategoryviaassertEnumTS-to-prompt numeric consistency (all 18 table cells, bands, threshold, posting precedence, schema) was verified clean.
Compatibility with #15
#15 ("always post a review comment even with zero findings") and this change touch distinct regions of
pr-review.yamland are complementary: an empty inline set yields aAPPROVEassessment label while the summary and audit sections still go in the review body, and the review is still posted.Validation
pnpm buildpnpm test(554 tests, 84 new)tsc --noEmitbiome ciactionlintNote on runtime placement
The model is applied by the orchestrator prompt (mirroring the tested TS module) rather than invoked as a
distbundle at agent runtime, becausedist/is gitignored and not present in the agent's working tree. If invoking the compiled scorer at runtime is preferred, that is a larger pipeline change (staging the bundle plus a permission) and can be done separately.