Skip to content

Commit 32ccbcf

Browse files
committed
fix(tools): tolerate out-of-scope autoreview findings
1 parent 1fdafac commit 32ccbcf

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

‎.agents/skills/autoreview/scripts/autoreview‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,8 @@ def validate_report(report: dict[str, Any], repo: Path, changed_paths: set[str],
520520
if not number_in_range(report.get("overall_confidence")):
521521
raise SystemExit("review JSON overall_confidence must be numeric")
522522
finding_text = ""
523+
kept_findings: list[dict[str, Any]] = []
524+
ignored_findings: list[tuple[int, dict[str, Any], str, int]] = []
523525
for index, finding in enumerate(report["findings"]):
524526
if not isinstance(finding, dict):
525527
raise SystemExit(f"finding {index} must be an object")
@@ -554,8 +556,24 @@ def validate_report(report: dict[str, Any], repo: Path, changed_paths: set[str],
554556
if Path(rel).is_absolute() or ".." in Path(rel).parts:
555557
raise SystemExit(f"finding {index} uses invalid file path: {rel}")
556558
if rel not in changed_paths:
557-
raise SystemExit(f"finding {index} points to a file outside the reviewed change: {rel}")
559+
ignored_findings.append((index, finding, rel, line))
560+
continue
561+
kept_findings.append(finding)
558562
finding_text += "\n" + json.dumps(finding, sort_keys=True)
563+
if ignored_findings:
564+
for index, finding, rel, line in ignored_findings:
565+
title = finding.get("title", "<untitled>")
566+
print(
567+
f"autoreview ignored out-of-scope finding {index}: {title} ({rel}:{line})",
568+
file=sys.stderr,
569+
)
570+
print(bounded_field(str(finding.get("body", "")), 500), file=sys.stderr)
571+
report["findings"] = kept_findings
572+
if not kept_findings and report["overall_correctness"] == "patch is incorrect":
573+
note = f"Ignored {len(ignored_findings)} out-of-scope finding(s) outside the reviewed change."
574+
explanation = report["overall_explanation"].rstrip()
575+
report["overall_correctness"] = "patch is correct"
576+
report["overall_explanation"] = bounded_field(f"{explanation}\n\n{note}", 3000)
559577
haystack = finding_text.lower()
560578
for needle in required:
561579
if needle.lower() not in haystack:

0 commit comments

Comments
 (0)