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.

fix(review_hog): per-turn review design and large-PR note on Standard (#115932)

Julian Bez77cd5b8e257c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 94fe91ff7acb..517737e5e825 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -14707,17 +14707,17 @@ snapshots:
scenes-code-review--running-review--light:
hash: v1.k794b7964.63c1f2fdc259d9f836f7d5d10662a0cf3dcb126782fc5dd79b419650cddff949.Ifn0U5N6KEnj0rsGu6ZFGXiwsvyeUBu9dUcMOn8FlwM
scenes-code-review--saved-inbox-opt-ins--dark:
- hash: v1.k794b7964.1b565818b29311c553784d4a4ea04799bc71a69b0b0d4889d419095682a92190.ZqVGlc09mmVvHXJzw7IazXHu4AwyFYoqFWj6oKoiNCo
+ hash: v1.k794b7964.b9bd9d69529ddcacf2f6b88ae7e20acf1ebe4ae6290c3ac097c65f93151d25fb.HB5yZQZluY0GZKl1ZrQ9duFGuTLPRq6JT2vG-2Zz_H0
scenes-code-review--saved-inbox-opt-ins--light:
- hash: v1.k794b7964.d8a027d285ee93057b7256d8ce2ee1e116a365b0356162ca02b31a3a3272ad52._dl5L3t8XkGQDab6pFFpdABnEeP3Xs-7cfVeCnU8OaI
+ hash: v1.k794b7964.e5a76cf71dbfed08b5ad621ad49147193552a732eb61f815b4c0416cff6d5ffc.K2Mj9inoFE8r5e2JZs77smpAcLwm3qxPx9SMH467dIE
scenes-code-review--settings--dark:
- hash: v1.k794b7964.f4198c9e89c93c62bb7d64f2629bcadacdc8b6e352213d6745ad6a54777bb458.xhoc_PDteUzfbz3DUoi-zBxWIB6CQpet4qBk-13vkAw
+ hash: v1.k794b7964.7e8233144a14ca4347d1556cf7b4c1dc920b4f99e002d18bec41bb13f1917dd3.DgG3up9oFB37rPGmO9f8At-uACKMSHm0J7agSxs85pk
scenes-code-review--settings--light:
- hash: v1.k794b7964.78509357475fe027053c34b5e616076ba9fe3d796aa971cac23d0032e61e6e10.SlNrPoWV31uBKNWoMAav_BsvIWHwmH4cnmugxStPrHU
+ hash: v1.k794b7964.01b2b8ed7526728700eeda224fbc15b3d6a618fb393ec3c27e9c5cd1155bb79e.iwsali37_cHqySWqifEBgs6jqBlnWKTlCcf0pDfqIvk
scenes-code-review--settings-for-member--dark:
- hash: v1.k794b7964.f282e87e23f2d86bbaab8bdcf02a9418c994bceefc9904afa640b57628398165.u_xfYtqLwoe8Mprm5AoC0mw2-jimOWxM3qyk3U6Vh4U
+ hash: v1.k794b7964.868b6e3656e4d672cf7a0a00eddc988b625ff84ade9a6988bb99ad794f24797c.Dg_VdE2jJK50wzK2NrNOceje5f0Vfzo6DnwVmF_gfqk
scenes-code-review--settings-for-member--light:
- hash: v1.k794b7964.0d6092d219336a649c003dfdc791768b35b09bc798f22c2eaecc01e3f38a7937.tsvIc1AHipONPzl-yX1QHXe-mkRo3Z6tpBigBDy_Z8w
+ hash: v1.k794b7964.4295f8129a424542e71714e80f925f46d9a3b43b16968da7093de312db913649.C234AM39eak2aFy9clWtaRgsfmt9WssGeFJH7tCldlM
scenes-dashboards-customize-breakdown-colors--customize-breakdown-colors--dark:
hash: v1.k794b7964.cf89a12669d5221b2441fbfb4439b8b1b38191943438a2c1a220444148329954.B4ew6uW3gZCbPU_3vTOggsOyHojRlyvuXxh5FZnlO-0
scenes-dashboards-customize-breakdown-colors--customize-breakdown-colors--light:
diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.md
index 7441dc20b86b..7b66517150bd 100644
--- a/products/review_hog/ARCHITECTURE.md
+++ b/products/review_hog/ARCHITECTURE.md
@@ -340,8 +340,11 @@ lens part past the first, up to 10). No validator runs, so dedup writes an
accept-as-found verdict per survivor. P0/P1 store as `must_fix`, P2 as `should_fix`, P3 as `consider`, and the
finding's `reported_priority` keeps the reviewer's P0-P3, so P0 and P1 stay apart for analysis. One exception: a dedup survivor takes a more severe duplicate's level when both fold into the same stored priority (a P0 merged into a P1); the `dropped_finding` record keeps the duplicate's own level. Findings publish
inline. An
-optional `suggestion_code` is stored on the finding but never posted. A PR past the lens part cap gets one line in the status comment that says the review ran in larger parts
-(`ReviewMeta.lens_chunks_capped`). The note goes there because a clean turn posts no review.
+optional `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 clean
+Standard 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.
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
@@ -520,6 +523,8 @@ pr_metadata.head_branch` is threaded (as explicit kwargs, alongside `team_id` /
and the Flash limits (finding cap, posted priorities, lens part size and count, prompt diff budget) instead.
A change to any hashed input (a prompt, a skill, a model pin, or a Flash limit) changes it without a version bump.
The marker persists as a `turn_marker` artefact (with the hashed inputs, for comparing two fingerprints),
+ and records the turn's design. The review list, the review drawer, and the status comment read a turn's design
+ from its marker, because a later turn on the same head writes a newer snapshot with its own design.
goes on `reviewhog_review_completed` as `reviewhog_version` / `reviewhog_fingerprint`, and ends the final
status comment as a hidden `<!-- reviewhog-version: <version id> <fingerprint> -->` line (no visible text).
Best-effort like the events.
diff --git a/products/review_hog/backend/api/reviews.py b/products/review_hog/backend/api/reviews.py
index f07dbdb6a787..672e860c8ba7 100644
--- a/products/review_hog/backend/api/reviews.py
+++ b/products/review_hog/backend/api/reviews.py
@@ -960,7 +960,7 @@ def _review_payload(
"published": report.published_head_sha is not None,
"turn_published": str(run_index) in (report.published_head_shas or {}),
"review_mode": marker.review_mode if marker else None,
- "review_design": snapshot.review_design,
+ "review_design": marker.review_design if marker else snapshot.review_design,
"status_comment_url": f"{report.pr_url}#issuecomment-{report.status_comment_id}"
if report.pr_url and report.status_comment_id
else None,
diff --git a/products/review_hog/backend/reviewer/artefact_content.py b/products/review_hog/backend/reviewer/artefact_content.py
index a889ce7b1847..813b1637884d 100644
--- a/products/review_hog/backend/reviewer/artefact_content.py
+++ b/products/review_hog/backend/reviewer/artefact_content.py
@@ -357,6 +357,9 @@ class TurnMarkerArtefact(BaseModel):
skipped_paths: list[str] | None = Field(
default=None, description="The changed files the turn left out of the review."
)
+ review_design: str | None = Field(
+ default=None, description="The design the turn ran on (pipeline or single_agent)."
+ )
RUN_OUTCOME_NOTE_AUTHOR = "review_hog_run_outcome"
diff --git a/products/review_hog/backend/reviewer/fingerprint.py b/products/review_hog/backend/reviewer/fingerprint.py
index b4af966c28e0..c00d87a3a259 100644
--- a/products/review_hog/backend/reviewer/fingerprint.py
+++ b/products/review_hog/backend/reviewer/fingerprint.py
@@ -335,6 +335,7 @@ def record_turn_marker(
base_branch=snapshot.pr_metadata.base_branch if snapshot is not None else None,
base_sha=snapshot.merge_base_sha if snapshot is not None else None,
skipped_paths=snapshot.skipped_paths if snapshot is not None else None,
+ review_design=review_design,
),
attribution=ArtefactAttribution.system(),
)
diff --git a/products/review_hog/backend/reviewer/progress.py b/products/review_hog/backend/reviewer/progress.py
index 4dae0ff0244c..bf581b00dd71 100644
--- a/products/review_hog/backend/reviewer/progress.py
+++ b/products/review_hog/backend/reviewer/progress.py
@@ -50,7 +50,7 @@ from products.review_hog.backend.reviewer.constants import BLIND_SPOT_PASS_NUMBE
from products.review_hog.backend.reviewer.models.github_meta import PRMetadata
from products.review_hog.backend.reviewer.models.issues_review import IssuePriority
from products.review_hog.backend.reviewer.models.perspective_selection import ChunkPerspectiveSelection
-from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_SINGLE_AGENT
+from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_PIPELINE, REVIEW_DESIGN_SINGLE_AGENT
from products.review_hog.backend.reviewer.skill_loader import (
CANONICAL_PERSPECTIVE_SKILL_NAMES,
REVIEW_HOG_PERSPECTIVE_PREFIX,
@@ -289,12 +289,13 @@ def turn_stats(team_id: int, heads: dict[str, str | None]) -> dict[str, TurnStat
@frozen
class TurnMarker:
- """The mode and head of one executed turn, from its `turn_marker` artefact."""
+ """The mode, design and head of one executed turn, from its `turn_marker` artefact."""
review_mode: str
head_sha: str | None
# When the marker row was written, which is just before the turn's review sessions start.
started_at: datetime
+ review_design: str = REVIEW_DESIGN_PIPELINE
def turn_markers(team_id: int, report_ids: list[str]) -> dict[tuple[str, int], TurnMarker]:
@@ -308,16 +309,34 @@ def turn_markers(team_id: int, report_ids: list[str]) -> dict[tuple[str, int], T
.annotate(
marker_run_index=KeyTextTransform("run_index", _content_json()),
marker_review_mode=KeyTextTransform("review_mode", _content_json()),
+ marker_review_design=KeyTextTransform("review_design", _content_json()),
+ fingerprint_review_design=KeyTextTransform(
+ "review_design", KeyTransform("fingerprint_inputs", _content_json())
+ ),
)
.order_by("created_at", "id")
- .values("report_id", "head_sha", "marker_run_index", "marker_review_mode", "created_at")
+ .values(
+ "report_id",
+ "head_sha",
+ "marker_run_index",
+ "marker_review_mode",
+ "marker_review_design",
+ "fingerprint_review_design",
+ "created_at",
+ )
)
markers: dict[tuple[str, int], TurnMarker] = {}
for row in rows:
if row["marker_run_index"] is None or row["marker_review_mode"] is None:
continue
+ # Markers written before the explicit field carry the design only in a single-agent
+ # fingerprint. The pipeline fingerprint never had it.
+ review_design = row["marker_review_design"] or row["fingerprint_review_design"] or REVIEW_DESIGN_PIPELINE
markers[(str(row["report_id"]), int(row["marker_run_index"]))] = TurnMarker(
- review_mode=row["marker_review_mode"], head_sha=row["head_sha"], started_at=row["created_at"]
+ review_mode=row["marker_review_mode"],
+ head_sha=row["head_sha"],
+ started_at=row["created_at"],
+ review_design=review_design,
)
return markers
diff --git a/products/review_hog/backend/reviewer/status_comment.py b/products/review_hog/backend/reviewer/status_comment.py
index cc1fdf5138cb..984bc20d7ad7 100644
--- a/products/review_hog/backend/reviewer/status_comment.py
+++ b/products/review_hog/backend/reviewer/status_comment.py
@@ -48,10 +48,12 @@ from products.review_hog.backend.reviewer.models.thread_resolution import Commit
from products.review_hog.backend.reviewer.persistence import load_findings_bundle
from products.review_hog.backend.reviewer.progress import (
SnapshotStats,
+ TurnMarker,
TurnStats,
finding_counts,
progress_payload,
snapshot_stats,
+ turn_markers,
turn_stats,
)
from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_PIPELINE, REVIEW_DESIGN_SINGLE_AGENT
@@ -218,11 +220,6 @@ def _table(rows: Sequence[tuple[str, str, str]]) -> list[str]:
return [_TABLE_HEADER, _TABLE_DIVIDER, *(_table_row(*row) for row in rows)]
-def _review_design(snapshot: SnapshotStats, fallback: str) -> str:
- # The fetch records the turn's design in the snapshot. Before that, the caller's design applies.
- return (snapshot.review_design if snapshot.head_matched else None) or fallback
-
-
def _step_results(
review_design: str,
snapshot: SnapshotStats,
@@ -313,9 +310,20 @@ def _priority_counts(counts: dict[IssuePriority, int], priorities: Collection[Is
)
-def render_review_summary(review_mode: str, head_sha: str | None, counts: dict[IssuePriority, int]) -> str:
+def large_pr_note(parts: int) -> str:
+ """The sentence that tells the reader a large pull request got a shallower single-agent review."""
+ return f"This pull request is large, so the review ran in {parts} parts with less depth than usual."
+
+
+def render_review_summary(
+ review_mode: str, head_sha: str | None, counts: dict[IssuePriority, int], capped_lens_parts: int | None = None
+) -> str:
"""The one-line summary a Standard review body opens with, because Standard posts no status comment."""
- return f"**{_title(review_mode, 'reviewed', head_sha)}**: {_priority_counts(counts, PRIORITIES_BY_URGENCY)}."
+ found = _priority_counts(counts, PRIORITIES_BY_URGENCY) or "no findings"
+ summary = f"**{_title(review_mode, 'reviewed', head_sha)}**: {found}."
+ if capped_lens_parts is not None:
+ summary = f"{summary} {large_pr_note(capped_lens_parts)}"
+ return summary
def render_final_body(
@@ -345,8 +353,7 @@ def render_final_body(
note attributes the gating threshold to whoever it actually belonged to (`resolved_from`)
and links to the report in PostHog (`report_url`, auth-gated) — the PR is otherwise the only
place the author hears about held-back findings, so the comment must not dead-end.
- `capped_lens_parts` is set when a single-agent turn reviewed a PR past the lens part cap. The
- note goes here and not in the review body, because a clean turn posts no review. `raised_elsewhere`
+ `capped_lens_parts` is set when a single-agent turn reviewed a PR past the lens part cap. `raised_elsewhere`
lists the findings a Full turn did not post because another reviewer's PR comment raises them, each
linked to that comment under `pr_url`; `raised_elsewhere_count` counts all of them.
"""
@@ -377,12 +384,7 @@ def render_final_body(
summary = "Nothing to post."
lines = [_header(review_mode, "reviewed", head_sha), "", summary, "", *_table(rows)]
if capped_lens_parts is not None:
- lines.extend(
- [
- "",
- f"This pull request is large, so the review ran in {capped_lens_parts} parts with less depth than usual.",
- ]
- )
+ lines.extend(["", large_pr_note(capped_lens_parts)])
if raised_elsewhere:
shown = raised_elsewhere[:ALREADY_RAISED_SHOWN]
lines.extend(["", "Also found in comments already on this pull request, so not posted again:"])
@@ -613,6 +615,15 @@ class _TurnState:
snapshot: SnapshotStats
turn: TurnStats
pairs: list[tuple[ReviewIssueFinding, ValidationVerdict | None]]
+ marker: TurnMarker | None = None
+
+ def review_design(self, fallback: str) -> str:
+ # The marker belongs to this turn. The newest snapshot at the head can belong to a later turn on
+ # the same head. Before the marker exists, the fetch records the turn's design in the snapshot,
+ # and before the fetch the caller's design applies.
+ if self.marker is not None:
+ return self.marker.review_design
+ return (self.snapshot.review_design if self.snapshot.head_matched else None) or fallback
def _turn_state(team_id: int, report: ReviewReport, run_index: int) -> _TurnState:
@@ -622,6 +633,7 @@ def _turn_state(team_id: int, report: ReviewReport, run_index: int) -> _TurnStat
snapshot=snapshot_stats(team_id, heads).get(report_id, SnapshotStats()),
turn=turn_stats(team_id, heads).get(report_id, TurnStats()),
pairs=load_findings_bundle(team_id=team_id, report_ids=[report_id]).turn(report_id, run_index),
+ marker=turn_markers(team_id, [report_id]).get((report_id, run_index)),
)
@@ -633,7 +645,7 @@ def _render_live_body(
str(report.id),
progress_payload(team_id, report, state.snapshot, state.turn, state.pairs),
review_mode=review_mode,
- review_design=_review_design(state.snapshot, review_design),
+ review_design=state.review_design(review_design),
head_sha=report.head_sha,
snapshot=state.snapshot,
turn=state.turn,
@@ -727,7 +739,7 @@ def finalize_status_comment(input: FinalizeStatusCommentInput) -> None:
resolved_from=input.resolved_from,
report_url=report_deep_link(input.team_id, input.report_id),
review_mode=input.review_mode,
- review_design=_review_design(state.snapshot, REVIEW_DESIGN_PIPELINE),
+ review_design=state.review_design(REVIEW_DESIGN_PIPELINE),
celebrate_clean_reviews=input.celebrate_clean_reviews,
marker=input.marker,
capped_lens_parts=input.capped_lens_parts,
diff --git a/products/review_hog/backend/reviewer/tests/test_publish_review.py b/products/review_hog/backend/reviewer/tests/test_publish_review.py
index d0e6039c8a27..42ebd7960f49 100644
--- a/products/review_hog/backend/reviewer/tests/test_publish_review.py
+++ b/products/review_hog/backend/reviewer/tests/test_publish_review.py
@@ -322,30 +322,56 @@ class TestPublishReviewGate:
[
# A valid finding on an off-diff line resolves zero inline comments, but the review (its body
# carries it in the "Other findings" section) must still post, not be silently dropped.
- ("all_off_diff", [240], 0, "full", "", None),
- ("mixed", [1, 240], 1, "full", "", None),
- ("all_inline", [1], 1, "full", "", ""),
+ ("all_off_diff", [240], 0, "full", None, "", None, False),
+ ("mixed", [1, 240], 1, "full", None, "", None, False),
+ ("all_inline", [1], 1, "full", None, "", "", False),
+ ("large_all_inline", [1], 1, "full", 3, "", "", False),
# Standard has no status comment, so its review body always says which turn it is.
(
"standard_all_inline",
[1],
1,
"flash",
+ None,
"",
"**PostHog Review · Standard · reviewed `sha`**: 1 Should fix.\n\n",
+ False,
),
- ("standard_mixed", [1, 240], 1, "flash", "", None),
+ ("standard_mixed", [1, 240], 1, "flash", None, "", None, False),
+ (
+ "standard_large_all_inline",
+ [1],
+ 1,
+ "flash",
+ 3,
+ "",
+ "**PostHog Review · Standard · reviewed `sha`**: 1 Should fix. This pull request is large, so the"
+ " review ran in 3 parts with less depth than usual.\n\n",
+ True,
+ ),
+ ("standard_large_mixed", [1, 240], 1, "flash", 3, "", None, True),
# The footer must survive the inline-only body, which replaces the full body on GitHub.
- ("footer_all_inline", [1], 1, "full", "Comment `@posthog help`.", "Comment `@posthog help`.\n\n"),
+ (
+ "footer_all_inline",
+ [1],
+ 1,
+ "full",
+ None,
+ "Comment `@posthog help`.",
+ "Comment `@posthog help`.\n\n",
+ False,
+ ),
(
"standard_footer_all_inline",
[1],
1,
"flash",
+ None,
"Comment `@posthog help`.",
"**PostHog Review · Standard · reviewed `sha`**: 1 Should fix.\n\nComment `@posthog help`.\n\n",
+ False,
),
- ("footer_mixed", [1, 240], 1, "full", "Comment `@posthog help`.", None),
+ ("footer_mixed", [1, 240], 1, "full", None, "Comment `@posthog help`.", None, False),
]
)
@patch(_POST)
@@ -357,8 +383,10 @@ class TestPublishReviewGate:
finding_lines: list[int],
expected_comments: int,
review_mode: str,
+ capped_lens_parts: int | None,
footer: str,
inline_prefix: str | None,
+ body_has_large_pr_note: bool,
mock_report_cls: MagicMock,
mock_load: MagicMock,
mock_post: MagicMock,
@@ -390,6 +418,7 @@ class TestPublishReviewGate:
head_sha="sha",
published_priorities=_SHOULD_FIX_PUBLISHED,
review_mode=review_mode,
+ capped_lens_parts=capped_lens_parts,
footer=footer,
)
@@ -398,28 +427,46 @@ class TestPublishReviewGate:
assert len(mock_post.call_args.args[4]) == expected_comments
marker = mock_post.call_args.kwargs["marker"]
assert mock_post.call_args.args[3].endswith(f"{footer}\n\n{marker}" if footer else marker)
+ assert ("This pull request is large" in mock_post.call_args.args[3]) is body_has_large_pr_note
expected_inline_body = None if inline_prefix is None else f"{inline_prefix}{marker}"
assert mock_post.call_args.kwargs["inline_body"] == expected_inline_body
# A 👍 from an earlier clean turn must not sit next to these findings.
assert self.remove_reactions.call_args.args == ("o/r", 1, "+1")
self.add_reaction.assert_not_called()
- @parameterized.expand([("deep", "full", []), ("standard_reacts", "flash", [("o/r", 1, "+1")])])
+ @parameterized.expand(
+ [
+ ("deep", "full", None, [], None),
+ ("deep_large", "full", 3, [], None),
+ ("standard_reacts", "flash", None, [("o/r", 1, "+1")], None),
+ (
+ "standard_large_reacts_and_posts_the_note",
+ "flash",
+ 3,
+ [("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.",
+ ),
+ ]
+ )
@patch(_POST)
@patch(_LOAD_FINDINGS)
@patch(_REPORT)
- def test_skips_when_only_consider_findings(
+ def test_only_consider_findings_post_no_findings(
self,
_name: str,
review_mode: str,
+ capped_lens_parts: int | None,
expected_reactions: list[tuple[str, int, str]],
+ expected_note: str | None,
mock_report_cls: MagicMock,
mock_load: MagicMock,
mock_post: MagicMock,
) -> None:
# Below the should_fix threshold: a run whose only valid finding is `consider` has
- # nothing publishable, so it posts nothing (guards the off-diff fix against over-surfacing).
- # A clean Standard turn has no status comment, so its 👍 is the only sign that it ran.
+ # 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)
mock_load.return_value = [(_finding(priority=IssuePriority.CONSIDER), _verdict())]
@@ -435,11 +482,20 @@ class TestPublishReviewGate:
head_sha="sha",
published_priorities=_SHOULD_FIX_PUBLISHED,
review_mode=review_mode,
+ capped_lens_parts=capped_lens_parts,
)
assert outcome.posted is False
- mock_post.assert_not_called()
assert [c.args for c in self.add_reaction.call_args_list] == expected_reactions
+ if expected_note is None:
+ mock_post.assert_not_called()
+ return
+ mock_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 comments == []
+ assert note_marker.startswith("<!-- reviewhog:large-pr-note:rep:sha")
@parameterized.expand(
[
diff --git a/products/review_hog/backend/reviewer/tools/publish_review.py b/products/review_hog/backend/reviewer/tools/publish_review.py
index 9b211a3ddcb6..54465ecd8bb1 100644
--- a/products/review_hog/backend/reviewer/tools/publish_review.py
+++ b/products/review_hog/backend/reviewer/tools/publish_review.py
@@ -25,7 +25,7 @@ from products.review_hog.backend.reviewer.models.github_meta import PRFile
from products.review_hog.backend.reviewer.models.issues_review import IssuePriority
from products.review_hog.backend.reviewer.persistence import load_pr_snapshot, load_valid_findings
from products.review_hog.backend.reviewer.review_state import published_heads_by_mode, review_already_published
-from products.review_hog.backend.reviewer.status_comment import render_review_summary
+from products.review_hog.backend.reviewer.status_comment import large_pr_note, render_review_summary
from products.review_hog.backend.reviewer.tools.github_client import (
GitHubAPIError,
add_pr_reaction,
@@ -89,6 +89,7 @@ def publish_persisted_review(
urgency_threshold: IssuePriority,
installation_id: str | None = None,
review_mode: str = REVIEW_MODE_FULL,
+ capped_lens_parts: int | None = None,
footer: str = "",
) -> PublishOutcome:
"""Publish an already-computed review for `report_id` at `head_sha`, idempotently.
@@ -124,6 +125,7 @@ def publish_persisted_review(
published_priorities=published_priorities_for(urgency_threshold),
installation_id=installation_id,
review_mode=review_mode,
+ capped_lens_parts=capped_lens_parts,
footer=footer,
)
if outcome.posted:
@@ -185,6 +187,14 @@ def _review_marker(report_id: str, head_sha: str, review_mode: str | None = None
return f"<!-- reviewhog:published:{report_id}:{head_sha}{suffix} -->"
+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.
+
+ It differs from the published marker, so a later turn on the same head with findings still posts its review.
+ """
+ return f"<!-- reviewhog:large-pr-note:{report_id}:{head_sha} -->"
+
+
def publish_review(
*,
owner: str,
@@ -199,6 +209,7 @@ def publish_review(
published_priorities: set[IssuePriority],
installation_id: str | None = None,
review_mode: str = REVIEW_MODE_FULL,
+ capped_lens_parts: int | None = None,
footer: str = "",
) -> PublishOutcome:
"""Publish the review to GitHub: the stored body plus inline comments from the durable rows.
@@ -212,14 +223,20 @@ def publish_review(
`posted` is False when there was nothing publishable — the caller records the published-head
watermark only on a real post, so a no-op turn doesn't block a later turn (with a valid finding)
from publishing at the same head.
+
+ `capped_lens_parts` is set when a single-agent turn reviewed a PR past the lens part cap. A Standard
+ review then carries the large pull request note, and a clean Standard turn posts a short review with it.
"""
logger.info(f"Publishing review for {owner}/{repo}#{pr_number}")
report = ReviewReport.objects.for_team(team_id).get(id=report_id)
marker = _review_marker(report_id, head_sha, review_mode)
+ standard = review_mode == REVIEW_MODE_FLASH
+ large_pr_parts = capped_lens_parts if standard else None
# `footer` closes the review whichever body posts, so the inline-only body keeps it too.
footer_block = f"{footer}\n\n" if footer else ""
- body = f"{report.report_markdown}\n\n{footer_block}{marker}"
+ note_block = f"{large_pr_note(large_pr_parts)}\n\n" if large_pr_parts is not None else ""
+ body = f"{report.report_markdown}\n\n{note_block}{footer_block}{marker}"
valid_findings = load_valid_findings(team_id=team_id, report_id=report_id, run_index=run_index)
diff_lines = build_diff_line_map(pr_files)
@@ -236,9 +253,25 @@ def publish_review(
repository = f"{owner}/{repo}"
if not publishable:
logger.info("No publishable issues found, skipping review")
- # A clean Standard turn posts nothing, so the 👍 is the only sign that the review ran.
- if review_mode == REVIEW_MODE_FLASH:
+ # A clean Standard turn posts no findings, so the 👍 is the sign that the review ran.
+ if standard:
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}",
+ [],
+ token=token,
+ head_sha=head_sha,
+ marker=note_marker,
+ installation_id=installation_id,
+ review_mode=review_mode,
+ )
return PublishOutcome(posted=False)
# An earlier clean turn's 👍 would sit next to this turn's findings and contradict them.
remove_own_pr_reactions(repository, pr_number, "+1", token=token, installation_id=installation_id)
@@ -249,8 +282,8 @@ def publish_review(
inline_body = None
if len(comments) == len(publishable):
inline_body = f"{footer_block}{marker}"
- if review_mode == REVIEW_MODE_FLASH:
- summary = render_review_summary(review_mode, head_sha, Counter(publishable))
+ if standard:
+ summary = render_review_summary(review_mode, head_sha, Counter(publishable), large_pr_parts)
inline_body = f"{summary}\n\n{footer_block}{marker}"
logger.info(f"Review: {len(body)} chars body, {len(comments)} inline comments")
diff --git a/products/review_hog/backend/temporal/activities.py b/products/review_hog/backend/temporal/activities.py
index f1fd23c3b85a..a39148e2e81a 100644
--- a/products/review_hog/backend/temporal/activities.py
+++ b/products/review_hog/backend/temporal/activities.py
@@ -281,7 +281,7 @@ class ReviewMeta:
review_design_reason: str = ""
# Recorded here, so a replay fans out over the same lens parts. Older histories decode as no lens sessions.
lens_chunk_count: int = 0
- # True when the PR passed the lens part cap, so the status comment says it ran in larger parts.
+ # True when the PR passed the lens part cap, so the status comment or the Standard review says it ran in larger parts.
lens_chunks_capped: bool = False
# A single-agent turn that runs its sessions as sub-agents of one coordinator session. Recorded here
# so a replay takes the same branch. Older histories decode as separate sessions.
@@ -515,6 +515,7 @@ class PublishInput:
urgency_threshold: str = IssuePriority.CONSIDER.value
review_mode: str = REVIEW_MODE_FULL
trigger_source: str = TRIGGER_MANUAL
+ capped_lens_parts: int | None = None
@dataclass
@@ -2043,6 +2044,7 @@ def _publish(input: PublishInput) -> PublishResult:
urgency_threshold=IssuePriority(input.urgency_threshold),
installation_id=installation_id,
review_mode=input.review_mode,
+ capped_lens_parts=input.capped_lens_parts,
footer=footer,
)
if input.trigger_source == TRIGGER_AUTOMATIC:
diff --git a/products/review_hog/backend/temporal/workflow.py b/products/review_hog/backend/temporal/workflow.py
index e01d7a3b0b60..b14e5b99969b 100644
--- a/products/review_hog/backend/temporal/workflow.py
+++ b/products/review_hog/backend/temporal/workflow.py
@@ -812,6 +812,7 @@ class ReviewPRWorkflow:
urgency_threshold=urgency_threshold,
review_mode=inputs.review_mode,
trigger_source=inputs.trigger_source,
+ capped_lens_parts=meta.lens_chunk_count if meta.lens_chunks_capped else None,
),
start_to_close_timeout=_QUICK_TIMEOUT,
retry_policy=_GITHUB_POST_RETRY,
diff --git a/products/review_hog/backend/tests/test_reviews_api.py b/products/review_hog/backend/tests/test_reviews_api.py
index b4e7b4a2f024..1690894887ff 100644
--- a/products/review_hog/backend/tests/test_reviews_api.py
+++ b/products/review_hog/backend/tests/test_reviews_api.py
@@ -1,6 +1,6 @@
import json
from datetime import UTC, datetime, timedelta
-from typing import get_args
+from typing import Any, get_args
import time_machine
from posthog.test.base import APIBaseTest
@@ -51,7 +51,7 @@ from products.review_hog.backend.reviewer.progress import (
RESOLUTION_RUN_NOTE_AUTHOR,
record_run_outcome,
)
-from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_SINGLE_AGENT
+from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_PIPELINE, REVIEW_DESIGN_SINGLE_AGENT
from products.review_hog.backend.temporal.heartbeat import ReviewActivityHeartbeater
from products.signals.backend.artefact_attribution import ArtefactAttribution
from products.signals.backend.artefact_schemas import NoteArtefact
@@ -167,7 +167,16 @@ class TestRecentReviewsAPI(APIBaseTest):
attribution=ArtefactAttribution.system(),
)
- def _turn_marker(self, report: ReviewReport, *, run_index: int, review_mode: str, head_sha: str) -> None:
+ def _turn_marker(
+ self,
+ report: ReviewReport,
+ *,
+ run_index: int,
+ review_mode: str,
+ head_sha: str,
+ review_design: str | None = None,
+ fingerprint_inputs: dict[str, Any] | None = None,
+ ) -> None:
ReviewReportArtefact.add_turn_marker(
team_id=self.team.id,
report_id=str(report.id),
@@ -177,26 +186,71 @@ class TestRecentReviewsAPI(APIBaseTest):
review_mode=review_mode,
reviewhog_version="v",
reviewhog_fingerprint="f",
+ fingerprint_inputs=fingerprint_inputs or {},
+ review_design=review_design,
),
attribution=ArtefactAttribution.system(),
)
- @parameterized.expand([("flash", REVIEW_MODE_FLASH), ("full", REVIEW_MODE_FULL), ("no_marker", None)])
- def test_review_mode_comes_from_the_completed_turns_marker(self, _name: str, review_mode: str | None) -> None:
+ @parameterized.expand(
+ [
+ ("flash", REVIEW_MODE_FLASH, REVIEW_DESIGN_SINGLE_AGENT, {}, REVIEW_DESIGN_SINGLE_AGENT),
+ (
+ "flash_marker_before_design_field",
+ REVIEW_MODE_FLASH,
+ None,
+ {"review_design": REVIEW_DESIGN_SINGLE_AGENT},
+ REVIEW_DESIGN_SINGLE_AGENT,
+ ),
+ ("full", REVIEW_MODE_FULL, REVIEW_DESIGN_PIPELINE, {}, REVIEW_DESIGN_PIPELINE),
+ ("full_marker_before_design_field", REVIEW_MODE_FULL, None, {}, REVIEW_DESIGN_PIPELINE),
+ ("no_marker", None, None, {}, REVIEW_DESIGN_PIPELINE),
+ ]
+ )
+ def test_review_mode_and_design_come_from_the_completed_turns_marker(
+ self,
+ _name: str,
+ review_mode: str | None,
+ marker_design: str | None,
+ fingerprint_inputs: dict[str, Any],
+ expected_design: str,
+ ) -> None:
# A clean, unpublished Standard turn has no findings to carry its mode, which the findings-based
# fallback reads as Deep. The marker is the only source that tells the two apart. The older
# turn's marker and the in-flight turn's marker must not leak onto the completed turn.
- report = self._report(pr_number=1, acting_user=self.user, run_count=2, head_sha="c3")
- self._turn_marker(report, run_index=1, review_mode=REVIEW_MODE_FULL, head_sha="c1")
+ report = self._report(pr_number=1, acting_user=self.user, run_count=2, head_sha="c2", completed_head_sha="c2")
+ report_id = str(report.id)
+ self._turn_marker(
+ report, run_index=1, review_mode=REVIEW_MODE_FLASH, head_sha="c1", review_design=REVIEW_DESIGN_SINGLE_AGENT
+ )
+ for design in (REVIEW_DESIGN_SINGLE_AGENT, REVIEW_DESIGN_PIPELINE):
+ persist_pr_snapshot(
+ team_id=self.team.id,
+ report_id=report_id,
+ head_sha="c2",
+ pr_metadata=_pr_metadata("c2", "title"),
+ pr_comments=[],
+ pr_files=[],
+ review_design=design,
+ )
if review_mode is not None:
- self._turn_marker(report, run_index=2, review_mode=review_mode, head_sha="c2")
- self._turn_marker(report, run_index=3, review_mode=REVIEW_MODE_FULL, head_sha="c3")
+ self._turn_marker(
+ report,
+ run_index=2,
+ review_mode=review_mode,
+ head_sha="c2",
+ review_design=marker_design,
+ fingerprint_inputs=fingerprint_inputs,
+ )
+ self._turn_marker(
+ report, run_index=3, review_mode=REVIEW_MODE_FULL, head_sha="c2", review_design=REVIEW_DESIGN_PIPELINE
+ )
row = self.client.get(self.url).json()["results"][0]
detail = self.client.get(f"{self.url}{report.id}/").json()
- assert row["review_mode"] == review_mode
- assert detail["review_mode"] == review_mode
+ assert (row["review_mode"], row["review_design"]) == (review_mode, expected_design)
+ assert (detail["review_mode"], detail["review_design"]) == (review_mode, expected_design)
@parameterized.expand(
[
diff --git a/products/review_hog/backend/tests/test_temporal_workflow.py b/products/review_hog/backend/tests/test_temporal_workflow.py
index cc644e9925bc..59123aba6814 100644
--- a/products/review_hog/backend/tests/test_temporal_workflow.py
+++ b/products/review_hog/backend/tests/test_temporal_workflow.py
@@ -182,6 +182,7 @@ async def _run_full_review_pr_workflow(
review_calls: list[tuple[int, int, bool, str, tuple[str, ...]]] = []
validate_calls: list[int] = []
publish_calls: list[int] = []
+ publish_capped_lens_parts: list[int | None] = []
finalize_will_publish: list[bool] = []
remove_label_calls: list[int] = []
# Each code_review receipt appended to the signals report, as (outcome, review_url).
@@ -386,6 +387,7 @@ async def _run_full_review_pr_workflow(
async def publish_act(input: PublishInput) -> PublishResult:
_saw_mode("publish", input.review_mode)
publish_calls.append(input.pr_number)
+ publish_capped_lens_parts.append(input.capped_lens_parts)
threshold_calls.append(("publish", input.urgency_threshold))
return PublishResult(posted=publish_posts, review_url=_REVIEW_URL if publish_posts else None)
@@ -566,6 +568,7 @@ async def _run_full_review_pr_workflow(
"review": review_calls,
"validate": validate_calls,
"publish": publish_calls,
+ "publish_capped_lens_parts": publish_capped_lens_parts,
"finalize_will_publish": finalize_will_publish,
"remove_label": remove_label_calls,
"receipts": receipt_calls,
@@ -842,9 +845,16 @@ async def test_review_pr_workflow_flash_turn_threads_its_mode_and_never_chains_r
@pytest.mark.asyncio
-async def test_review_pr_workflow_single_agent_design_replaces_chunking_review_and_validation():
[email protected]("lens_chunks_capped,expected_capped_lens_parts", [(False, None), (True, 2)])
+async def test_review_pr_workflow_single_agent_design_replaces_chunking_review_and_validation(
+ lens_chunks_capped: bool, expected_capped_lens_parts: int | None
+):
recorded = await _run_full_review_pr_workflow(
- publish=True, review_mode="flash", review_design="single_agent", lens_chunk_count=2
+ publish=True,
+ review_mode="flash",
+ review_design="single_agent",
+ lens_chunk_count=2,
+ lens_chunks_capped=lens_chunks_capped,
)
assert recorded["single_agent"] == ["single_agent"]
@@ -860,6 +870,7 @@ async def test_review_pr_workflow_single_agent_design_replaces_chunking_review_a
assert recorded["review"] == []
assert recorded["validate"] == []
assert recorded["publish"] == [7]
+ assert recorded["publish_capped_lens_parts"] == [expected_capped_lens_parts]
assert recorded["designs"] == {stage: {"single_agent"} for stage in ("dedup", "track")}
diff --git a/products/review_hog/frontend/settings/FullReviewSettingsSection.tsx b/products/review_hog/frontend/settings/FullReviewSettingsSection.tsx
index e3976a2e3dbe..2960ccb37b75 100644
--- a/products/review_hog/frontend/settings/FullReviewSettingsSection.tsx
+++ b/products/review_hog/frontend/settings/FullReviewSettingsSection.tsx
@@ -102,6 +102,8 @@ export function FullReviewSettingsSection(): JSX.Element {
<YouMark shown={ownThreshold !== undefined} />
<LemonSelect<UrgencyThresholdEnumApi | 'project'>
size="small"
+ className="min-w-0 shrink"
+ truncateText={{ maxWidthClass: 'max-w-full' }}
aria-label="Mine: Post findings at or above"
value={ownThreshold ?? 'project'}
options={mineOptions(THRESHOLD_OPTIONS, projectThreshold, ownThreshold)}
@@ -135,6 +137,8 @@ export function FullReviewSettingsSection(): JSX.Element {
<YouMark shown={ownCelebrate !== undefined} />
<LemonSelect<OnOff | 'project'>
size="small"
+ className="min-w-0 shrink"
+ truncateText={{ maxWidthClass: 'max-w-full' }}
aria-label="Mine: Celebrate clean reviews"
value={ownCelebrate ?? 'project'}
options={mineOptions(ON_OFF_OPTIONS, projectCelebrate, ownCelebrate)}
diff --git a/products/review_hog/frontend/settings/SettingRow.tsx b/products/review_hog/frontend/settings/SettingRow.tsx
index 9b258c0f295a..19bed768c144 100644
--- a/products/review_hog/frontend/settings/SettingRow.tsx
+++ b/products/review_hog/frontend/settings/SettingRow.tsx
@@ -14,7 +14,7 @@ export function SettingRow({
mine: JSX.Element
}): JSX.Element {
return (
- <div className="grid grid-cols-1 items-center gap-2 border-t border-primary px-4 py-3 @min-[48rem]:grid-cols-[minmax(0,1fr)_minmax(0,14rem)_minmax(0,16rem)] @min-[48rem]:gap-3">
+ <div className="grid grid-cols-1 items-center gap-2 border-t border-primary px-4 py-3 @min-[48rem]:grid-cols-[minmax(0,1fr)_minmax(0,14rem)_minmax(0,18rem)] @min-[48rem]:gap-3">
<div className="flex min-w-0 flex-col gap-0.5">
<span className="text-sm font-semibold">{title}</span>
<span className="text-xs text-secondary">{description}</span>
@@ -23,7 +23,7 @@ export function SettingRow({
<span className="text-xs text-secondary @min-[48rem]:hidden">Project:</span>
{project}
</div>
- <div className="flex min-w-0 flex-wrap items-center gap-1">
+ <div className="flex min-w-0 items-center gap-1">
<span className="text-xs text-secondary @min-[48rem]:hidden">Mine:</span>
{mine}
</div>
diff --git a/products/review_hog/frontend/settings/SettingsTable.tsx b/products/review_hog/frontend/settings/SettingsTable.tsx
index fe458458cd01..dbbaa21dca18 100644
--- a/products/review_hog/frontend/settings/SettingsTable.tsx
+++ b/products/review_hog/frontend/settings/SettingsTable.tsx
@@ -16,7 +16,7 @@ export function SettingsTable({
{description && <p className="m-0 text-xs text-secondary">{description}</p>}
</header>
)}
- <div className="hidden grid-cols-[minmax(0,1fr)_minmax(0,14rem)_minmax(0,16rem)] gap-3 px-4 py-1.5 text-xxs font-semibold uppercase tracking-wide text-secondary @min-[48rem]:grid">
+ <div className="hidden grid-cols-[minmax(0,1fr)_minmax(0,14rem)_minmax(0,18rem)] gap-3 px-4 py-1.5 text-xxs font-semibold uppercase tracking-wide text-secondary @min-[48rem]:grid">
<span>Setting</span>
<span>Project</span>
<span>Mine</span>