Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/cursor-review/tests/test_workflow_judge_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,36 @@ def build(self):
with open(os.path.join(self.workdir, "consolidated.json"), encoding="utf-8") as f:
return outputs, json.load(f)

def test_degraded_union_deduplicates_at_highest_known_severity(self):
self.configure("true") # Seed status is error, selecting the degraded union.
base = {"file": "a.py", "line": 4, "side": "RIGHT", "severity": "low", "body": "issue"}
for order in (("low", "high", "low"), ("high", "low", "high")):
with self.subTest(order=order):
findings = [{**base, "severity": severity} for severity in order]
with open(os.path.join(self.workdir, "panel.json"), "w", encoding="utf-8") as f:
json.dump([{"model": "test", "review_type": "edge-case", "status": "ok", "findings": findings}], f)
done, outputs = run_step(step(self.consolidate, BUILD_STEP),
{"steps.aggregate.outputs.ok_count": "1",
"steps.aggregate.outputs.panel_inconsistent": "false"}, self.workdir)
self.assertEqual(done.returncode, 0, done.stdout + done.stderr)
with open(os.path.join(self.workdir, "consolidated.json"), encoding="utf-8") as f:
retained = json.load(f)["findings"]
self.assertEqual(outputs["degraded"], "true")
self.assertEqual([(f["side"], f["severity"]) for f in retained], [("RIGHT", "high")])

def test_degraded_union_does_not_discard_unknown_severity(self):
self.configure("true")
base = {"file": "a.py", "line": 4, "side": "RIGHT", "severity": "unknown", "body": "issue"}
with open(os.path.join(self.workdir, "panel.json"), "w", encoding="utf-8") as f:
json.dump([{"model": "test", "review_type": "edge-case", "status": "ok",
"findings": [base, {**base, "severity": "high"}]}], f)
done, _ = run_step(step(self.consolidate, BUILD_STEP),
{"steps.aggregate.outputs.ok_count": "1",
"steps.aggregate.outputs.panel_inconsistent": "false"}, self.workdir)
self.assertEqual(done.returncode, 0, done.stdout + done.stderr)
with open(os.path.join(self.workdir, "consolidated.json"), encoding="utf-8") as f:
self.assertEqual([f["severity"] for f in json.load(f)["findings"]], ["unknown", "high"])

def test_the_seed_names_the_judge_that_will_run(self):
self.assertEqual(self.configure("true")["model"], f"{JUDGE_MODEL} (direct)")
self.assertEqual(self.configure("false")["model"], CURSOR_JUDGE)
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/cursor-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5811,21 +5811,31 @@ jobs:
if not degraded:
findings = judge.get("findings") or []
else:
# Judge unusable — union the per-cell findings, deduping identical
# (file, line, body) across cells to cut the obvious cross-cell
# repetition the judge would normally collapse.
seen, findings = set(), []
# Keep the highest severity when cells report the same finding.
# Reuse the structured-output schema's severity order.
import importlib.util
spec = importlib.util.spec_from_file_location(
"review_output", os.path.join(os.environ["CURSOR_REVIEW_ASSETS"], "review-output-mcp.py"))
review_output = importlib.util.module_from_spec(spec)
spec.loader.exec_module(review_output)
priority = {name: rank for rank, name in enumerate(review_output.SEVERITIES)}
seen, findings = {}, []
for cell in panel:
if cell.get("status") != "ok":
continue
for fnd in cell.get("findings") or []:
if not isinstance(fnd, dict):
continue
key = (fnd.get("file"), fnd.get("line"), fnd.get("body"))
if key in seen:
severity = fnd.get("severity")
if not isinstance(severity, str) or severity not in priority:
findings.append(fnd)
continue
seen.add(key)
findings.append(fnd)
key = (fnd.get("file"), fnd.get("line"), fnd.get("body"))
if key not in seen:
seen[key] = len(findings)
findings.append(fnd)
elif priority[severity] < priority[findings[seen[key]]["severity"]]:
findings[seen[key]] = fnd

# auto-approve withholds on it (a reviewer leg did not succeed
# although every panel cell reports ok).
Expand Down
Loading