Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(review-hog): post only changed-code findings from the second automatic review on (#117571)

Julian Bez5fe8d7dc48bc
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.md
index 1fa3a087e9cc..1ab411a0adf3 100644
--- a/products/review_hog/ARCHITECTURE.md
+++ b/products/review_hog/ARCHITECTURE.md
@@ -316,9 +316,9 @@ DevEx-owned prompts.
Each session persists as one `perspective_result` under a reserved pass (`SINGLE_AGENT_PASS_NUMBER` 2000, lenses 2001
and 2002) and its part. On a follow-up turn, a finding more than `FLASH_FOLLOW_UP_CHANGE_MARGIN_LINES` (3) lines
from any code that changed since `completed_head_sha` drops as `old_code` first (`ChangedSinceReview`). An automatic turn
-after run `FLASH_WHOLE_PR_TURNS` (2) drops every P2 and P3 finding there, so a fix only draws findings about the fix:
-one run finds only part of what is there, so the first two runs review the whole pull request, and later ones review
-the push. Earlier runs and requested turns drop only P3 findings there. The
+after run `FLASH_WHOLE_PR_TURNS` (1) drops every P2 and P3 finding there, so a fix only draws findings about the fix:
+the first run reviews the whole pull request with the larger first-review cap, and every later automatic run reviews
+the push. Requested turns (`@posthog review`, the label, the UI) drop only P3 findings there. The
two heads' PR snapshots are compared by line content per file, so lines a base merge only moved stay old. Must-fix
findings, files whose patch GitHub left out, a first review, and a re-run at the reviewed head skip the check. Step 7 then runs as two dedup calls in parallel (`dedupe_flash_findings`,
`tools/single_agent_review.py`), both one-shot OpenAI calls on `FLASH_DEDUP_MODEL` (`gpt-6-luna` @ medium,
diff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.md
index fdb6133cd45d..b4ce094d271e 100644
--- a/products/review_hog/DECISIONS.md
+++ b/products/review_hog/DECISIONS.md
@@ -198,6 +198,27 @@ read `FINAL_REPORT.md` there first (config glossary + coverage matrix + ranking)
rate drops materially (toward ≤50%) on frozen-PR evals with the valid-finding set intact (item 5's
coverage matrix as the guard); kill if valid findings drop with the noise.
+### ✅ BUILT 2026-10-15 — automatic Standard follow-ups post only changed-code findings from run 2 on
+
+- **What.** `FLASH_WHOLE_PR_TURNS` goes from 2 to 1. Run 1 still reviews the whole pull request with the doubled
+ first-review cap. From run 2 on, an automatic Standard (Flash) turn drops every P2 and P3 finding more than
+ `FLASH_FOLLOW_UP_CHANGE_MARGIN_LINES` lines from code the push changed, as `old_code`. Must-fix findings post
+ anywhere. A requested review (`@posthog review`, the label, the UI) still reviews the whole pull request.
+- **Why.** The per-PR loop complaints came from run 2 and later turns that re-reviewed unchanged code: each fix push
+ drew new should-fix findings on code the push never touched, so the author fixed and pushed again. After the
+ Oct 14 changes, run 2 produced 135 of 241 follow-up findings and 7 of its must-fix findings.
+- **Evidence.** An offline replay of 215 run-2 turns (155 after the Oct 14 cutover, 60 before) through the
+ production rule code (review-eval `experiments/2026-10-15-run2-scope-replay`):
+ - The rule suppresses 147 posted findings on 80 turns, all labeled should-fix by the model.
+ - A blind Sonnet judge graded them 91 real, 54 unsure, 2 not real, and none must-fix.
+ - 18 must-fix findings on unchanged code stay posted.
+ - 13% of the suppressed findings were caused by the push: the 3-line margin misses a changed caller that breaks an
+ unchanged callee. A 10-line margin rescues 4 of those 19 and adds 17 unrelated findings, so the margin stays.
+- **Not chosen.**
+ - A lower run-2 cap: unrelated findings still get through, only fewer of them.
+ - Run 2 as a whole-PR review only when run 1 hit its cap: cap saturation says nothing about the new push.
+ - A wider margin: see the Evidence numbers above.
+
### ✅ BUILT 2026-10-13 — Flash follow-ups drop only P3 findings on unchanged code (`reviewhog-flash-2-3`)
- **What.** The `old_code` rule from `reviewhog-flash-2-1` now drops only P3 findings on code unchanged since the last
diff --git a/products/review_hog/backend/facade/contracts.py b/products/review_hog/backend/facade/contracts.py
index ba18043335f6..cc357b25740d 100644
--- a/products/review_hog/backend/facade/contracts.py
+++ b/products/review_hog/backend/facade/contracts.py
@@ -82,7 +82,8 @@ ReviewIssueCategory = Literal[
# finding (anchor), or a finding of its own session or lens (sibling). Only records from before Flash
# stopped reading PR comments carry `dedup_comment`. `cap` is the cut in `compose_flash_findings`, and
# `budget` the cut the pull request's finding budget adds on top (`finding_budget.py`).
-# `old_code` is a follow-up turn's P3 finding on code that did not change since the last reviewed head.
+# `old_code` is a follow-up turn's finding on code that did not change since the last reviewed head: P2 and P3
+# on an automatic turn from run 2 on, P3 only on a requested turn. A first review drops nothing this way.
DropDisposition = Literal[
"old_code",
"dedup_prior",
diff --git a/products/review_hog/backend/presentation/views/reviews.py b/products/review_hog/backend/presentation/views/reviews.py
index e116e3e957f3..7bfaa572a46e 100644
--- a/products/review_hog/backend/presentation/views/reviews.py
+++ b/products/review_hog/backend/presentation/views/reviews.py
@@ -643,9 +643,10 @@ class ReviewDroppedFindingSerializer(serializers.Serializer):
)
disposition = serializers.ChoiceField(
choices=ReviewDropDisposition.choices,
- help_text="Why the turn did not post the finding. `old_code`: a follow-up turn's P3 finding on code "
- "that did not change since the last reviewed head (turns before reviewhog-flash-2-3 dropped P2 findings "
- "this way too). `dedup_prior`: repeats an earlier turn's finding. "
+ help_text="Why the turn did not post the finding. `old_code`: a follow-up turn's finding on code that "
+ "did not change since the last reviewed head. An automatic follow-up (run 2 and later) drops P2 and P3 "
+ "findings this way, a requested review drops only P3, and a first review drops none. "
+ "`dedup_prior`: repeats an earlier turn's finding. "
"`dedup_comment`: repeats a PR comment. `dedup_anchor`: repeats a main-review finding at the same "
"spot. `dedup_sibling`: repeats another finding from the same session or lens. `cap`: ranked below "
"the per-review finding limit.",
diff --git a/products/review_hog/backend/reviewer/constants.py b/products/review_hog/backend/reviewer/constants.py
index 632804dbc334..52577374d7ca 100644
--- a/products/review_hog/backend/reviewer/constants.py
+++ b/products/review_hog/backend/reviewer/constants.py
@@ -169,9 +169,11 @@ FLASH_FOLLOW_UP_CHANGE_MARGIN_LINES = 3
# The first review keeps more of what it finds. A finding the cap cuts is recorded only as a dropped finding, so
# a later turn finds it again and posts it on its own, one push at a time.
FLASH_FIRST_REVIEW_CAP_MULTIPLIER = 2
-# Turns up to this run review the whole pull request: one run finds only part of what is there, so a second pass
-# is worth it. A later automatic follow-up only comments on what its push changed, plus must-fix anywhere.
-FLASH_WHOLE_PR_TURNS = 2
+# Turns up to this run review the whole pull request. Run 1 does this with the larger cap above. Each later
+# automatic turn only comments on what its push changed, plus must-fix anywhere, so a fix push draws findings
+# about the fix and not new opinions on code that earlier turns already covered. A review someone requests
+# (comment, label, or UI) is not limited this way and reviews the whole pull request.
+FLASH_WHOLE_PR_TURNS = 1
def flash_max_findings(lens_part_count: int) -> int:
diff --git a/products/review_hog/backend/reviewer/tests/test_single_agent_review.py b/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
index 9bdc0338acc1..753d6223443b 100644
--- a/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
+++ b/products/review_hog/backend/reviewer/tests/test_single_agent_review.py
@@ -601,13 +601,13 @@ class TestDedupeFlashFindings:
@pytest.mark.parametrize(
"line,priority,changed_code_only,posts",
[
- pytest.param(30, IssuePriority.SHOULD_FIX, True, False, id="late_automatic_p2_on_unchanged_code"),
- pytest.param(30, IssuePriority.SHOULD_FIX, False, True, id="whole_pr_p2_on_unchanged_code"),
- pytest.param(11, IssuePriority.SHOULD_FIX, True, True, id="late_automatic_p2_on_the_fix"),
- pytest.param(30, IssuePriority.MUST_FIX, True, True, id="late_automatic_p1_on_unchanged_code"),
+ pytest.param(30, IssuePriority.SHOULD_FIX, True, False, id="automatic_follow_up_p2_on_unchanged_code"),
+ pytest.param(30, IssuePriority.SHOULD_FIX, False, True, id="requested_review_p2_on_unchanged_code"),
+ pytest.param(11, IssuePriority.SHOULD_FIX, True, True, id="automatic_follow_up_p2_on_the_fix"),
+ pytest.param(30, IssuePriority.MUST_FIX, True, True, id="automatic_follow_up_p1_on_unchanged_code"),
],
)
- async def test_a_late_automatic_follow_up_only_comments_on_what_the_push_changed(
+ async def test_an_automatic_follow_up_only_comments_on_what_the_push_changed(
self, pr_metadata: PRMetadata, line: int, priority: IssuePriority, changed_code_only: bool, posts: bool
) -> None:
# Each fix drew a new P2 on code it never touched, and an open finding keeps stamphog from approving,
diff --git a/products/review_hog/backend/temporal/activities.py b/products/review_hog/backend/temporal/activities.py
index 04e8b8ab73cf..89f15a8ec3b7 100644
--- a/products/review_hog/backend/temporal/activities.py
+++ b/products/review_hog/backend/temporal/activities.py
@@ -1804,7 +1804,7 @@ async def dedup_activity(input: SandboxStageInput) -> DedupResult:
fall_back_on_any_error=_is_final_attempt(),
changed_since=changed_since,
budget_left=budget_left,
- # Requested reviews and the first whole-PR turns still look at code the push did not change.
+ # Requested reviews and the first review still look at code the push did not change.
changed_code_only=input.trigger_source == TRIGGER_AUTOMATIC and input.run_index > FLASH_WHOLE_PR_TURNS,
first_review=input.run_index == 1,
)
diff --git a/products/review_hog/backend/tests/test_review_activity.py b/products/review_hog/backend/tests/test_review_activity.py
index 6e19a38cd795..a7a5f1d986b3 100644
--- a/products/review_hog/backend/tests/test_review_activity.py
+++ b/products/review_hog/backend/tests/test_review_activity.py
@@ -751,8 +751,9 @@ async def test_full_dedup_lists_other_reviewers_comments_when_the_app_login_is_n
"trigger_source,run_index,expected_budget_left,expected_changed_code_only",
[
pytest.param("automatic", 1, 2, False, id="first_review"),
- pytest.param("automatic", 2, 2, False, id="second_automatic_turn_reviews_the_whole_pr"),
+ pytest.param("automatic", 2, 2, True, id="second_automatic_turn_reviews_the_push"),
pytest.param("automatic", 3, 2, True, id="later_automatic_turn_reviews_the_push"),
+ pytest.param("comment", 2, None, False, id="requested_second_review"),
pytest.param("comment", 3, None, False, id="requested_review"),
pytest.param(None, 3, None, False, id="payload_from_before_the_field"),
],
@@ -761,7 +762,7 @@ async def test_a_standard_turn_scope_follows_its_trigger_and_run(
trigger_source: str | None, run_index: int, expected_budget_left: int | None, expected_changed_code_only: bool
) -> None:
# Automatic reviews are the safeguard that stops at must-fix findings once the budget is spent, and after
- # the first whole-PR turns they only comment on what a push changed. A review someone asks for surfaces
+ # the first review they only comment on what a push changed. A review someone asks for surfaces
# everything the turn keeps, across the pull request.
dedupe = AsyncMock(return_value=FlashSelection(kept=[], dropped=[], cap=4, lens_part_count=1))
with (
diff --git a/products/review_hog/frontend/generated/api.schemas.ts b/products/review_hog/frontend/generated/api.schemas.ts
index 85df388aedb8..90a4b934bea7 100644
--- a/products/review_hog/frontend/generated/api.schemas.ts
+++ b/products/review_hog/frontend/generated/api.schemas.ts
@@ -1048,7 +1048,7 @@ export interface ReviewDroppedFindingApi {
* @nullable
*/
source_perspective: string | null
- /** Why the turn did not post the finding. `old_code`: a follow-up turn's P3 finding on code that did not change since the last reviewed head (turns before reviewhog-flash-2-3 dropped P2 findings this way too). `dedup_prior`: repeats an earlier turn's finding. `dedup_comment`: repeats a PR comment. `dedup_anchor`: repeats a main-review finding at the same spot. `dedup_sibling`: repeats another finding from the same session or lens. `cap`: ranked below the per-review finding limit.
+ /** Why the turn did not post the finding. `old_code`: a follow-up turn's finding on code that did not change since the last reviewed head. An automatic follow-up (run 2 and later) drops P2 and P3 findings this way, a requested review drops only P3, and a first review drops none. `dedup_prior`: repeats an earlier turn's finding. `dedup_comment`: repeats a PR comment. `dedup_anchor`: repeats a main-review finding at the same spot. `dedup_sibling`: repeats another finding from the same session or lens. `cap`: ranked below the per-review finding limit.
*
* * `old_code` - On unchanged code
* * `dedup_prior` - Repeat of an earlier review
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index a3a14d3db306..02a12e64f53e 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -97348,7 +97348,7 @@ export namespace Schemas {
* @nullable
*/
source_perspective: string | null;
- /** Why the turn did not post the finding. `old_code`: a follow-up turn's P3 finding on code that did not change since the last reviewed head (turns before reviewhog-flash-2-3 dropped P2 findings this way too). `dedup_prior`: repeats an earlier turn's finding. `dedup_comment`: repeats a PR comment. `dedup_anchor`: repeats a main-review finding at the same spot. `dedup_sibling`: repeats another finding from the same session or lens. `cap`: ranked below the per-review finding limit.
+ /** Why the turn did not post the finding. `old_code`: a follow-up turn's finding on code that did not change since the last reviewed head. An automatic follow-up (run 2 and later) drops P2 and P3 findings this way, a requested review drops only P3, and a first review drops none. `dedup_prior`: repeats an earlier turn's finding. `dedup_comment`: repeats a PR comment. `dedup_anchor`: repeats a main-review finding at the same spot. `dedup_sibling`: repeats another finding from the same session or lens. `cap`: ranked below the per-review finding limit.
*
* * `old_code` - On unchanged code
* * `dedup_prior` - Repeat of an earlier review