From 2c5f621e46f9c10c3eb35bf0c94859e3c4d903de Mon Sep 17 00:00:00 2001 From: huang47 <157390+huang47@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:47:48 +0800 Subject: [PATCH 1/3] fix: preserve distinct fallback review findings --- .../tests/test_workflow_judge_direct.py | 16 ++++++++++++++++ .github/workflows/cursor-review.yml | 7 ++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/cursor-review/tests/test_workflow_judge_direct.py b/.github/cursor-review/tests/test_workflow_judge_direct.py index 8c90b824..cefa0151 100644 --- a/.github/cursor-review/tests/test_workflow_judge_direct.py +++ b/.github/cursor-review/tests/test_workflow_judge_direct.py @@ -351,6 +351,22 @@ 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_keeps_distinct_diff_sides_and_severities(self): + self.configure("true") # Seed status is error, selecting the degraded union. + base = {"file": "a.py", "line": 4, "side": "LEFT", "severity": "low", "body": "issue"} + findings = [base, dict(base), {**base, "side": "RIGHT"}, {**base, "severity": "high"}] + 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], + [("LEFT", "low"), ("RIGHT", "low"), ("LEFT", "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) diff --git a/.github/workflows/cursor-review.yml b/.github/workflows/cursor-review.yml index a5661710..d882963a 100644 --- a/.github/workflows/cursor-review.yml +++ b/.github/workflows/cursor-review.yml @@ -5812,8 +5812,8 @@ jobs: 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. + # (file, line, side, severity, body) across cells to cut obvious + # repeats without hiding distinct locations or severity levels. seen, findings = set(), [] for cell in panel: if cell.get("status") != "ok": @@ -5821,7 +5821,8 @@ jobs: for fnd in cell.get("findings") or []: if not isinstance(fnd, dict): continue - key = (fnd.get("file"), fnd.get("line"), fnd.get("body")) + key = (fnd.get("file"), fnd.get("line"), fnd.get("side"), + fnd.get("severity"), fnd.get("body")) if key in seen: continue seen.add(key) From 16b23aa718e3bdaeb961792c4dd40be195e97ac0 Mon Sep 17 00:00:00 2001 From: huang47 <157390+huang47@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:48:40 +0800 Subject: [PATCH 2/3] fix: use supported finding schema in fallback regression --- .github/cursor-review/tests/test_workflow_judge_direct.py | 8 ++++---- .github/workflows/cursor-review.yml | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/cursor-review/tests/test_workflow_judge_direct.py b/.github/cursor-review/tests/test_workflow_judge_direct.py index cefa0151..bfe98d96 100644 --- a/.github/cursor-review/tests/test_workflow_judge_direct.py +++ b/.github/cursor-review/tests/test_workflow_judge_direct.py @@ -351,10 +351,10 @@ 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_keeps_distinct_diff_sides_and_severities(self): + def test_degraded_union_keeps_distinct_severities(self): self.configure("true") # Seed status is error, selecting the degraded union. - base = {"file": "a.py", "line": 4, "side": "LEFT", "severity": "low", "body": "issue"} - findings = [base, dict(base), {**base, "side": "RIGHT"}, {**base, "severity": "high"}] + base = {"file": "a.py", "line": 4, "side": "RIGHT", "severity": "low", "body": "issue"} + findings = [base, dict(base), {**base, "severity": "high"}] 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), @@ -365,7 +365,7 @@ def test_degraded_union_keeps_distinct_diff_sides_and_severities(self): retained = json.load(f)["findings"] self.assertEqual(outputs["degraded"], "true") self.assertEqual([(f["side"], f["severity"]) for f in retained], - [("LEFT", "low"), ("RIGHT", "low"), ("LEFT", "high")]) + [("RIGHT", "low"), ("RIGHT", "high")]) def test_the_seed_names_the_judge_that_will_run(self): self.assertEqual(self.configure("true")["model"], f"{JUDGE_MODEL} (direct)") diff --git a/.github/workflows/cursor-review.yml b/.github/workflows/cursor-review.yml index d882963a..298d1b33 100644 --- a/.github/workflows/cursor-review.yml +++ b/.github/workflows/cursor-review.yml @@ -5812,8 +5812,8 @@ jobs: findings = judge.get("findings") or [] else: # Judge unusable — union the per-cell findings, deduping identical - # (file, line, side, severity, body) across cells to cut obvious - # repeats without hiding distinct locations or severity levels. + # (file, line, severity, body) across cells to cut obvious + # repeats without hiding different severity levels. seen, findings = set(), [] for cell in panel: if cell.get("status") != "ok": @@ -5821,8 +5821,7 @@ jobs: for fnd in cell.get("findings") or []: if not isinstance(fnd, dict): continue - key = (fnd.get("file"), fnd.get("line"), fnd.get("side"), - fnd.get("severity"), fnd.get("body")) + key = (fnd.get("file"), fnd.get("line"), fnd.get("severity"), fnd.get("body")) if key in seen: continue seen.add(key) From 3c6a9d378e34d4545794355861fd0e1805455a2b Mon Sep 17 00:00:00 2001 From: huang47 <157390+huang47@users.noreply.github.com> Date: Wed, 28 Oct 2026 19:53:17 +0800 Subject: [PATCH 3/3] fix: retain highest severity when deduplicating --- .../tests/test_workflow_judge_direct.py | 34 +++++++++++++------ .github/workflows/cursor-review.yml | 26 +++++++++----- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/cursor-review/tests/test_workflow_judge_direct.py b/.github/cursor-review/tests/test_workflow_judge_direct.py index bfe98d96..a1218d10 100644 --- a/.github/cursor-review/tests/test_workflow_judge_direct.py +++ b/.github/cursor-review/tests/test_workflow_judge_direct.py @@ -351,21 +351,35 @@ 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_keeps_distinct_severities(self): + 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"} - findings = [base, dict(base), {**base, "severity": "high"}] + 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": 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) + 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: - retained = json.load(f)["findings"] - self.assertEqual(outputs["degraded"], "true") - self.assertEqual([(f["side"], f["severity"]) for f in retained], - [("RIGHT", "low"), ("RIGHT", "high")]) + 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)") diff --git a/.github/workflows/cursor-review.yml b/.github/workflows/cursor-review.yml index 298d1b33..20ee68dd 100644 --- a/.github/workflows/cursor-review.yml +++ b/.github/workflows/cursor-review.yml @@ -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, severity, body) across cells to cut obvious - # repeats without hiding different severity levels. - 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("severity"), 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).