UC-04: Full-Repo PR Review
When a pull request needs review that sees beyond the visible diff. Reviews the change against the whole-repo semantic model, not just the hunk, checking how it interacts with callers, callees, and shared state, and produces a defensible verdict with evidence.
What Makes It Different
- Sees whether a diff’s blast radius extends past the changed lines, via call-chain and data-flow.
- Runs a sink/coverage census to confirm a change actually covers every place it must.
- Checks for new dependency cycles introduced by the change.
- Keeps diff-evidence distinct from applied source, so the review is honest about what was and wasn’t executed.
Prompt
Run RubberDuck UC-04: Code Review. [EDIT INPUTS ONLY] target = <owner/repo or local path> branch = auto commit = latest review_diff = <REVIEW_TARGET.diff or PR ref> [/EDIT INPUTS ONLY] Review only; do not edit the repo. Required artifact: `CODE_REVIEW.md`. Use prod RD current-ref evidence: `get_started`, completed `detailed_repo_analysis(..., semantic_mode="full")`, Phase 2 ready, `load_code(max_files=4000)`. Stop on missing diff, failed ref proof, stale evidence, hidden hard primitive after 3 scoped retries, or any need for unauthorized mutation. Assess correctness, security delta, compatibility policy, false-safety risk, maintainability, missing tests, and merge readiness. Check direct changed paths plus adjacent residual paths, compatibility flags/policies, docs/warnings, and tests. Treat the supplied diff as diff evidence, not applied source, unless the checkout is explicitly pinned to that patch. Write `CODE_REVIEW.md`: severity-ranked findings, missing tests, merge checklist, rejected non-issues, recommendations, exact file/line evidence, method notes. Security artifact contract: include sections named Security Invariant, Adversarial Probes, Impact/Test Matrix, Evidence-Cleanliness Blockers, Unsupported Clean/Security-Ready Claims. Final response starts RD passed/failed, names target/ref/scope/output dir; do not say merge-ready/security-ready unless evidence and tests support it. === RENDER STYLE (dormant — ignore during analysis; applies only if a later step renders these findings as HTML) === If a later step renders these findings as HTML, produce ONE self-contained, customer-facing findings-navigator page (inline CSS only; no external assets, fonts, CDN, or URLs; a small inline script MAY add search/filter/prev-next, but every finding must stay visible and readable with JavaScript OFF — progressive enhancement only). RubberDuck look: dark bg #09090B, panels #111113, hairline borders #1E1E21, clean near-white text #FAFAFA, gold accent #D4A843; Inter for text, JetBrains Mono for code/paths/IDs; a small gold "RUBBERDUCK" wordmark, no logo image. Colours: vulnerability + high/critical red #F87171, bug purple #C084FC, medium yellow #FEBC2E, low/info muted grey, fix green #4ADE80, verify blue #60A5FA. Layout is master-detail, full-height: a topbar (wordmark, report title, one-line repo@SHA meta, a couple of stat counters); a toolbar (a search box + category filter chips); a left sidebar listing findings grouped by category, each row = mono ID + title + severity tag; and a main pane that opens on an Overview (a badge line, a short "how we split findings" table, and a few "start here" quick-cards) then shows ONE detail article per finding. Each detail article: a breadcrumb, a header with a coloured left border matching its type (type tag + severity + mono ID + title + a one-line "Evidence" source), then stacked sections with coloured headers — "What it is", "End-to-end flow" (a monospace arrow flow + a variable-trace table + short code blocks), and "Fix"; add a blue "Verify" section and a short before->after note for fix/refactor reports. Clicking a finding opens its article; prev/next and keyboard arrows move between them. Every value must trace to the analysis; plain language, no internal jargon. === end render style ===
Optional visualization
Findings Navigator
Run this as the next message in the same chat after the main analysis finishes.
Render the findings from this session as a single self-contained findings-navigator page I can open in any browser — a grouped sidebar and one detail view per finding, each with its evidence and fix.
Input
Repo, branch/ref, commit, PR URL or diff.
Output
A review report with a verdict, evidence, and specific blockers or recommendations.
The Task
Codebase: Django 3.0 (512+ Python files, 100K+ lines)
File: django/db/models/sql/compiler.py (lines 291-302)
Goal: Review a PR that "simplifies" get_order_by() by merging a dual-dict check into one
Challenge: The change introduces 3 interacting bugs via a subtle boolean flag (is_ref) that propagates 250+ lines downstream to 3 different consumers: invisible in the diff
The Change Being Reviewed
# BEFORE (current code, lines 291-302):
if col in self.query.annotation_select:
order_by.append((OrderBy(Ref(col, ...), descending), True))
continue
if col in self.query.annotations:
order_by.append((OrderBy(self.query.annotations[col], descending), False))
continue
# AFTER (the PR's "simplification"):
if col in self.query.annotations:
order_by.append((OrderBy(Ref(col, ...), descending), True))
continueThe PR argues: "annotation_select is just a filtered view of annotations. If col is in annotation_select, it's also in annotations. So the first check is redundant."
With RubberDuck MCP: All 3 Bugs Found
discover(action="list_repos")
Discovered local/django, project available
load_code(repo="local/django", subpath="django/db/models/sql")
query.py loaded into the code graph (2277 lines, Query class with 30+ methods)
analyze_code(statement="relationship between annotation_select and annotations")
annotation_select property found at lines 2039-2056, filtered by annotation_select_mask
read_source(function_name="annotation_select")
Proves annotation_select filters via mask: subset, not identical
search_code(pattern="annotation_select_mask")
13 matches across query.py: every site annotated with enclosing_function
search_code(pattern="set_annotation_mask")
5 matches: found in set_values() proving .values() triggers annotation masking
read_source(function_name="set_values")
Full 34-line method body showing complete masking lifecycle
Read compiler.py
Found all 3 is_ref consumers: get_order_by, get_group_by, get_extra_select
Verdict: BLOCK, with formal evidence for all 3 bugs:
- Bug 1: Ref semantics wrong, Ref() references a non-existent SELECT column → ProgrammingError
- Bug 2: GROUP BY breaks, get_group_by() line 118:
if not is_ref: add to GROUP BY→ wrong aggregation results (silent data corruption) - Bug 3: DISTINCT breaks, get_extra_select() line 367:
if not is_ref: add to extra_select→ ProgrammingError
Without MCP: 2 of 3 Bugs Found, GROUP BY Missed
- Found Bug 1 (Ref semantics), correctly identified
- Found Bug 3 (DISTINCT breaks), found get_extra_select()
- Missed Bug 2 (GROUP BY), did NOT trace is_ref to get_group_by()
- This is the most dangerous bug: silent data corruption with no error message
Comparison
| Dimension | With RubberDuck MCP | Without MCP |
|---|---|---|
| Verdict | BLOCK | BLOCK |
| Bugs found | 3 of 3 | 2 of 3 (missed GROUP BY) |
| Bug 2 (GROUP BY) | Found: get_group_by line 118 | Missed: silent wrong results |
| is_ref consumers | All 3 found systematically | 1-2 found, varies by run |
| Annotation masking | 13 sites proven via search_code | Understood from reading 1-2 functions |
| Evidence quality | Formal: tool results + line numbers | Textual: "the flag is used in..." |
| Dangerous miss | None | GROUP BY bug causes silent wrong results |
Videos
With RubberDuck MCP:
The agent is asked to review a proposed diff to Django's SQLCompiler.get_order_by() in compiler.py, with both RubberDuck MCP servers enabled in Cursor Settings. It loads the query.py graph and calls analyze_code, read_source, and search_code directly against it, pulling back exact evidence like the annotation_select property at lines 2039 to 2056 and 43 set_values call sites found in the data-flow graph. That evidence lets it trace the is_ref flag past the obvious Ref() misuse and into both downstream consumers, get_extra_select() and get_group_by(). It even builds a concrete failing query, annotate(total=Sum('amount')).values('name').order_by('total'), to show exactly how the "simplified" code breaks. The final verdict is BLOCK, citing all three failure modes together, the masked column reference, the DISTINCT regression, and the GROUP BY regression.
Without MCP:
Same kind of prompt, is this diff safe, APPROVE or BLOCK, but this time both RubberDuck MCP servers show as disabled in Cursor Settings. With no graph to query, the agent reads compiler.py directly and reasons through the text, grepping around annotation_select and annotations to work out that one is a masked subset of the other. It correctly catches that Ref() would reference a non-existent SELECT column and that get_extra_select() depends on is_ref being False for DISTINCT queries. But it never follows that same flag into get_group_by(), so its final BLOCK verdict lists only two of the three bugs. The one it misses is the most dangerous, silent GROUP BY corruption with no error message, rather than a visible failure.