: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(review_hog): large pr note once, no thumbs up after findings (#116296)
Julian Bezd27d04927b88
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex 93fcbd749c02..93260104a351 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -343,8 +343,8 @@ inline. Anoptional `suggestion_code` is stored on the finding but never posted. A PR past the lens part cap gets one sentence that says the review ran in larger parts(`ReviewMeta.lens_chunks_capped`, `large_pr_note`). A Standard review adds it to its summary line, and a cleanStandard turn posts a short review with it next to the 👍. That review has its own hidden `reviewhog:large-pr-note`-marker, so a head gets at most one, and it does not set the published watermark, so a later turn on the head still-publishes its findings.+marker, so a pull request gets it once and re-reviews do not repeat it. It does not set the published watermark, so a+later turn on the head still publishes its findings.Every finding the turn drops after scope cleaning persists as a `dropped_finding` artefact (`DroppedFindingArtefact`,written by `replace_dropped_findings` beside `replace_deduplicated_findings` in the dedup activity): the full finding@@ -468,7 +468,7 @@ pr_metadata.head_branch` is threaded (as explicit kwargs, alongside `team_id` /It answers per head: pending while a request for the head waits in the queue (the queue workflow's `requested_heads` query) or a turn on the head runs, through its publish; completed with the kind, the valid findings count, the published flag, the merge base the diff was taken against and the skipped files (filtered files, files GitHub sent without a patch, and the files of every pipeline chunk that no review unit finished, because a turn completes when only some of its units fail); failed when the turn for the head failed; None for any other head or a repository no project owns.When a publishing turn ends, after publish or after the failure is recorded, `nudge_stamphog_activity` calls stamphog's `request_rereview_after_external_review` (behind the `reviewhog-nudge-stamphog-2026-10` patch, fail-open). Stamphog decides whether a WAIT at that head runs again.**Standard turns post no status comment** (the same patch): the 👀 shows the turn runs, and the outcome is the review, a 👍 on the PR when nothing is publishable, or one failure comment per head (`post_failure_comment`, hidden `reviewhog:failed` marker) posted by `fail_status_comment_activity`.- A later publish with findings, in either mode, first removes the app's own 👍 (`remove_own_pr_reactions`, matched with `is_app_bot_author`).+ A later publish with findings, in either mode, first removes the app's own 👍 (`remove_own_pr_reactions`, matched with `is_app_bot_author`). The 👍 does not come back: a clean turn adds it only while no turn of the PR published findings (`published_head_sha` unset).Status comments that earlier turns left on the PR stay as they are, and a Standard turn never refreshes them.On the publish path of a **Deep** turn a live **status comment**(`reviewer/status_comment.py`) is posted at kickoff as one table with a row per step of the turn's review design,diff --git a/products/review_hog/backend/reviewer/tests/test_publish_review.py b/products/review_hog/backend/reviewer/tests/test_publish_review.pyindex 42ebd7960f49..fbd721066156 100644--- a/products/review_hog/backend/reviewer/tests/test_publish_review.py+++ b/products/review_hog/backend/reviewer/tests/test_publish_review.py@@ -313,9 +313,10 @@ class TestPublishReviewGate:self.remove_reactions = remove_reactionsyield- def _wire_report(self, mock_report_cls: MagicMock) -> None:+ def _wire_report(self, mock_report_cls: MagicMock, published_head_sha: str | None = None) -> None:mock_report = MagicMock()mock_report.report_markdown = "# PostHog Review"+ mock_report.published_head_sha = published_head_shamock_report_cls.objects.for_team.return_value.get.return_value = mock_report@parameterized.expand(@@ -436,13 +437,16 @@ class TestPublishReviewGate:@parameterized.expand([- ("deep", "full", None, [], None),- ("deep_large", "full", 3, [], None),- ("standard_reacts", "flash", None, [("o/r", 1, "+1")], None),+ ("deep", "full", None, None, [], None),+ ("deep_large", "full", 3, None, [], None),+ ("standard_reacts", "flash", None, None, [("o/r", 1, "+1")], None),+ # An earlier turn published findings, so a clean turn must not bring the 👍 back.+ ("standard_after_published_findings_does_not_react", "flash", None, "old", [], None),("standard_large_reacts_and_posts_the_note","flash",3,+ None,[("o/r", 1, "+1")],"**PostHog Review · Standard · reviewed `sha`**: no findings. This pull request is large, so the"" review ran in 3 parts with less depth than usual.",@@ -457,6 +461,7 @@ class TestPublishReviewGate:_name: str,review_mode: str,capped_lens_parts: int | None,+ published_head_sha: str | None,expected_reactions: list[tuple[str, int, str]],expected_note: str | None,mock_report_cls: MagicMock,@@ -467,7 +472,7 @@ class TestPublishReviewGate:# nothing publishable, so it posts no findings (guards the off-diff fix against over-surfacing).# A clean Standard turn has no status comment, so its 👍 and its large pull request note# are the only signs that it ran.- self._wire_report(mock_report_cls)+ self._wire_report(mock_report_cls, published_head_sha)mock_load.return_value = [(_finding(priority=IssuePriority.CONSIDER), _verdict())]outcome = publish_review(@@ -492,10 +497,10 @@ class TestPublishReviewGate:returnmock_post.assert_called_once()body, comments = mock_post.call_args.args[3:5]- note_marker = mock_post.call_args.kwargs["marker"]- assert body == f"{expected_note}\n\n{note_marker}"+ assert body == f"{expected_note}\n\n<!-- reviewhog:large-pr-note:rep:sha -->"assert comments == []- assert note_marker.startswith("<!-- reviewhog:large-pr-note:rep:sha")+ # The skip check matches a note from any earlier head, so re-reviews do not repeat it.+ assert mock_post.call_args.kwargs["marker"] == "<!-- reviewhog:large-pr-note:rep:"@parameterized.expand([diff --git a/products/review_hog/backend/reviewer/tools/publish_review.py b/products/review_hog/backend/reviewer/tools/publish_review.pyindex 54465ecd8bb1..57ac35555027 100644--- a/products/review_hog/backend/reviewer/tools/publish_review.py+++ b/products/review_hog/backend/reviewer/tools/publish_review.py@@ -187,12 +187,20 @@ def _review_marker(report_id: str, head_sha: str, review_mode: str | None = Nonereturn f"<!-- reviewhog:published:{report_id}:{head_sha}{suffix} -->"+def _large_pr_note_prefix(report_id: str) -> str:+ """The start of every large pull request note marker of a report, whatever the head.++ The note checks for this prefix, so a pull request gets the note once and not again on each re-review.+ """+ return f"<!-- reviewhog:large-pr-note:{report_id}:"++def _large_pr_note_marker(report_id: str, head_sha: str) -> str:- """The hidden marker of a clean Standard turn's large pull request note, so a head gets at most one.+ """The hidden marker of a clean Standard turn's large pull request note.- It differs from the published marker, so a later turn on the same head with findings still posts its review.+ It differs from the published marker, so a later turn with findings still posts its review."""- return f"<!-- reviewhog:large-pr-note:{report_id}:{head_sha} -->"+ return f"{_large_pr_note_prefix(report_id)}{head_sha} -->"def publish_review(@@ -253,22 +261,22 @@ def publish_review(repository = f"{owner}/{repo}"if not publishable:logger.info("No publishable issues found, skipping review")- # A clean Standard turn posts no findings, so the 👍 is the sign that the review ran.- if standard:+ # A clean Standard turn posts no findings, so the 👍 is the sign that the review ran. Once any turn+ # published findings, the 👍 stays off, because a later clean turn does not clear those findings.+ if standard and report.published_head_sha is None:add_pr_reaction(repository, pr_number, "+1", token=token, installation_id=installation_id)if large_pr_parts is not None:# Not a published turn: the watermark stays unset, so a later turn on this head can still publish.- note_marker = _large_pr_note_marker(report_id, head_sha)summary = render_review_summary(review_mode, head_sha, Counter(), large_pr_parts)_post_github_review(owner,repo,pr_number,- f"{summary}\n\n{footer_block}{note_marker}",+ f"{summary}\n\n{footer_block}{_large_pr_note_marker(report_id, head_sha)}",[],token=token,head_sha=head_sha,- marker=note_marker,+ marker=_large_pr_note_prefix(report_id),installation_id=installation_id,review_mode=review_mode,)