Repository navigation
feat(review-pr): add configurable confidence-threshold input - #23
Conversation
Add a confidence-threshold input to the PR review action that sets the minimum per-finding confidence required to post an inline comment. Findings that score below the threshold are collapsed into the existing lower-confidence summary instead of posted inline; security and high-severity CONFIRMED/LIKELY findings are always posted regardless. The input accepts a band name (strong=80, moderate/medium=55, weak=30) or a number clamped to [30, 100]. It defaults to moderate (55), which preserves the prior behavior exactly. Implementation: - score-confidence: add resolvePostThreshold() and a postThreshold option on scoreFinding/scoreFindings; replace the hardcoded inline cutoff with the configurable threshold (clamped so the negligible band is never posted inline by the default rule). - review-pr/action.yml: resolve the input in bash (mirroring resolvePostThreshold) and inject it into the agent prompt, which applies it in the posting policy. - review-pr.yml: expose and forward the new workflow_call input. - score-confidence CLI honors a CONFIDENCE_THRESHOLD env var. - Update unit tests, README, and AGENTS.md.
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The confidence-threshold input is well-implemented across all four layers:
TypeScript model (score-confidence.ts)
resolvePostThreshold correctly handles all input types — band names (strong/moderate/medium/weak), numeric strings, floats (via Math.round before clamping), NaN, undefined, and null. The clamping to [WEAK_THRESHOLD, 100] ensures the negligible band can never be posted inline by rule 4. The forwarding of postThreshold through scoreFindings → scoreFinding is sound, and the undefined passthrough correctly defers to the ?? DEFAULT_POST_THRESHOLD default inside scoreFinding.
Bash resolver (review-pr/action.yml)
The bash step faithfully mirrors resolvePostThreshold: band-name case arms match their TS equivalents, 10#$NORM forces decimal parsing for numeric strings, [ -lt 30 ]/[ -gt 100 ] clamp correctly, and the :-moderate default handles empty inputs. The read -r NORM <<< "$NORM" trim is equivalent to .trim() (strips leading/trailing ASCII whitespace; preserves internal spaces so "8 0" correctly falls through to the unrecognized branch). The else LABEL=negligible arm after clamping is dead code (SCORE is always ≥ 30) but harmless.
Agent prompt (pr-review.yaml)
The threshold T is clearly exposed in the posting-policy rules and the fallback default (T = 55) is correct for console mode. The format change in the lower-confidence summary template (BAND SCORE/100 instead of weak SCORE/100) is a useful fix — below-threshold findings may now be moderate or strong band when the threshold is raised.
Tests
Cover the full resolver surface (resolvePostThreshold) — band names, aliases, case/whitespace insensitivity, numeric types, clamping, rounding, NaN/null/undefined, and fallbacks — plus scoreFinding threshold raise/lower behavior, band-label stability, forced bypasses (security + high-severity), and scoreFindings forwarding. All assertions are correct.
No bugs were found in the introduced code.
derekmisler
left a comment
There was a problem hiding this comment.
the feature makes sense and the TS implementation looks solid, but the bash resolver in review-pr/action.yml directly contradicts the AGENTS.md convention that all new composite-action logic must live in src/ as TypeScript. resolvePostThreshold already exists and is already bundled, so this should be a thin CLI call rather than a 40-line bash mirror. two small nitpicks below the main comment too.
| # ======================================== | ||
| # BUILD REVIEW CONTEXT | ||
| # ======================================== | ||
| - name: Resolve confidence threshold |
There was a problem hiding this comment.
issue: AGENTS.md is explicit: "New logic in composite actions must be implemented as TypeScript in src/ with Vitest unit tests, not as inline bash, awk, or other scripting languages embedded in YAML files. Shell steps in action YAML files should only orchestrate calls to dist/*.js tools."
this 40-line bash resolver is a direct violation of that. resolvePostThreshold already exists in src/score-confidence/score-confidence.ts and it's already bundled to dist/score-confidence.js. the right move is to either add a resolve-threshold subcommand to that CLI or expose it via dist/resolve-confidence.js, and then replace this whole step with one line:
THRESHOLD=$(node "$ACTION_PATH/../dist/score-confidence.js" resolve-threshold "$CONFIDENCE_THRESHOLD_INPUT")the bash version has no test coverage, has behavioral divergences from the TS (e.g. negative numbers like -5 emit a warning in bash but silently default in TS), and now there are three places that need to stay in sync: the TS function, the bash resolver here, and the lookup table in pr-review.yaml. AGENTS.md already called out the two-place problem with "Change one, change both", this adds a third.
| if [ "$SCORE" -ge 80 ]; then LABEL=strong | ||
| elif [ "$SCORE" -ge 55 ]; then LABEL=moderate | ||
| elif [ "$SCORE" -ge 30 ]; then LABEL=weak | ||
| else LABEL=negligible |
There was a problem hiding this comment.
nitpick (super non-blocking): LABEL=negligible is unreachable. by the time we get here SCORE has been clamped to [30, 100], so the elif [ "$SCORE" -ge 30 ] branch always fires first. the else is dead code.
| required: false | ||
| default: "3000" | ||
| confidence-threshold: | ||
| description: "Minimum confidence for posting a finding as an inline comment. Accepts a band name (`strong`=80, `moderate`/`medium`=55, `weak`=30) or a number 0-100. Findings that score below the threshold (and are not security or high-severity) are collapsed into the lower-confidence summary instead of posted inline; they are never silently dropped. Security findings and high-severity CONFIRMED/LIKELY findings are always posted regardless. Default: moderate (55), which preserves the prior behavior. Numbers are clamped to [30, 100]." |
There was a problem hiding this comment.
nitpick (super non-blocking): says "a number 0-100" but then two sentences later "Numbers are clamped to [30, 100]". so is the accepted range 0-100 or 30-100? the reusable workflow input description gets this right ("clamped to 30-100"), worth making this consistent so users aren't surprised when 10 becomes 30.
…bash Replace the bash mirror of resolvePostThreshold() in the review-pr action with a thin call to a new resolve-threshold CLI subcommand, per the AGENTS.md rule that composite-action logic lives in src/ as tested TypeScript and shell steps only orchestrate dist/*.js tools. - Add describeThreshold() (score, band, recognized) to score-confidence.ts as the single source of truth; resolvePostThreshold now delegates to it. - Add the resolve-threshold subcommand to dist/score-confidence.js: it sets the score and label step outputs and warns on an unrecognized value via @actions/core, so the action step is a single node invocation. - Fix the bash/TS divergence: an unrecognized value such as -5 or '8 0' now warns consistently instead of only in bash. - Remove the unreachable LABEL=negligible branch (gone with the bash block). - Make the confidence-threshold input description consistent (clamped to 30-100), matching the reusable workflow and README. - Cover describeThreshold and the resolve-threshold CLI with unit tests; update AGENTS.md and the module docs to drop the bash-mirror references.
derekmisler
left a comment
There was a problem hiding this comment.
ci is green, approving!
Resolve conflict in review-pr/agents/pr-review.yaml: keep the new suggestion-block emission instruction from this branch and adopt main's configurable inline-threshold (T) wording for the lower-confidence summary bullet (from #23).
Summary
Adds a
confidence-thresholdinput to thereview-praction (and the reusableworkflow) to control the minimum per-finding confidence required to post an
inline review comment. Findings scoring below the threshold are collapsed into
the existing "Lower-confidence findings (not posted inline)" summary instead of
posted inline. Security and high-severity CONFIRMED/LIKELY findings are always
posted regardless of the threshold.
Previously the inline cutoff was hardcoded at
MODERATE_THRESHOLD(55). Thischange makes that cutoff configurable while keeping the default behavior
identical.
Behavior
strong=80,moderate/medium=55,weak=30) or a number[30, 100](the weak floor is the lowest meaningful cutoff, so negligible findings are never posted inline)moderate(55), preserving prior behavior exactlysecurityand high-severity CONFIRMED/LIKELY findings (threshold does not apply)Files changed
src/score-confidence/score-confidence.tsresolvePostThreshold()and apostThresholdoption onscoreFinding/scoreFindings; threshold-driven posting dispositionsrc/score-confidence/index.tsCONFIDENCE_THRESHOLDenv varreview-pr/action.ymlresolvePostThreshold); injects a "Review Configuration" block into the agent promptreview-pr/agents/pr-review.yamlT(rules 4 and 5); console-mode defaultT=55.github/workflows/review-pr.ymlworkflow_callinput, forwarded to the actionsrc/score-confidence/__tests__/score-confidence.test.tsreview-pr/README.md,AGENTS.mdThe TS model stays the single source of truth; the bash resolver in the action
and the agent prompt mirror it, consistent with the existing convention.
Validation
tsc --noEmit: cleanbiome ci .: clean (89 files)actionlint: cleantsupbuild: successmoderate(55) reproduces the prior dispositions, so existing tests pass unchangedNotes
review-pr.ymlisbumped (the reusable workflow pins the action by SHA, same pattern as the
sibling
exclude-paths/max-diff-linesinputs).agent prompt, tests/docs) with each finding independently verified; the items
surfaced were low-severity consistency fixes and have been applied.