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): readable validator verdicts, shown first in comments (#71888)

Alex Lebedev1b1a9051d373
diff --git a/products/review_hog/CONTEXT.md b/products/review_hog/CONTEXT.md
new file mode 100644
index 000000000000..f81bb7176c0e
--- /dev/null
+++ b/products/review_hog/CONTEXT.md
@@ -0,0 +1,10 @@
+# ReviewHog — glossary
+
+Vocabulary settled while working on the product. Pure vocabulary — no spec, no implementation detail beyond what a term needs to be unambiguous.
+
+- **Finding body** — the reviewer's description of a problem (`Issue.issue`, persisted as `ReviewIssueFinding.body`). Dual-audience text: it is rendered verbatim in the published comment AND consumed by three downstream LLM stages (the validator's `ISSUE` payload, dedup's fresh/prior finding payloads, and future turns' covered-findings block).
+- **Validator argumentation** — the validator's why-valid / why-dismissed reasoning (`IssueValidation.argumentation`). For a _valid_ finding it is presentation-only (humans + the copy-paste fix prompt); its only pipeline consumer is dedup's `prior_ruling`, and only when the finding was _dismissed_.
+- **Published copy** — what humans read on GitHub (inline comment sections, report body) and in the Code review UI. Today it is byte-identical to the pipeline payload; nothing requires that.
+- **Pipeline payload** — the same finding/verdict fields as consumed by downstream LLM stages (validator, dedup, covered-findings). The quality-critical audience.
+- **Structural conciseness vs compression** — _structural_: the same information content reshaped into labeled bullets (claim / trigger / evidence / impact); _compression_: dropping information to save words. The no-quality-loss constraint rules out compression of pipeline payloads; it does not rule out restructuring.
+- **Verify, don't restate** — the rule for validator argumentation: it is the _verification delta_ (what was checked, what was found with file:line evidence, confirmed impact, priority rationale), never a restatement of the finding body's claim. Safe because the full body always travels with the argumentation — every consumer, human or LLM, receives both in the same comment or payload.
diff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.md
index 1d835902e152..8625a56bd94b 100644
--- a/products/review_hog/DECISIONS.md
+++ b/products/review_hog/DECISIONS.md
@@ -225,6 +225,20 @@ Helpers `_shields_badge` / `_finding_badge_line` + `_PRIORITY_BADGE` carry the l
Color mechanism was a user decision (badge images, Greptile-style, accepting the external-image dependency) over the GitHub-native emoji/alert alternative.
An earlier iteration also surfaced the problem/fix inline and un-collapsed two sections; that was reverted — the collapsed structure is intentional and stays.
+### ✅ BUILT 2026-07-17 — comment readability: bulleted validator verdicts, shown first in the comment
+
+Grilled with the user 2026-07-17 (vocabulary in `CONTEXT.md`). Problem: published findings are meaningful but read as prose blobs.
+Constraint: zero quality loss for the validator and for anything reading validator output downstream.
+Key facts driving the design: the finding body is dual-audience (rendered verbatim on GitHub AND consumed by the validator's `ISSUE` payload, dedup's fresh/prior payloads, and future turns' covered-findings block), while the validator's `argumentation` is presentation-only for _valid_ findings (its sole pipeline consumer is dedup's `prior_ruling`, dismissed findings only) — and the full body always travels with the argumentation, in the same comment or payload.
+So the risk is **compression** (dropping information), not **structure** (same facts as labeled bullets); restructuring the validator's output is safe without an e2e round.
+
+What shipped (all prompt/template-level, reversible — no ADR):
+
+- **Verify, don't restate — the validator's `argumentation` is now labeled bullets** (Checked / Found / Impact / Priority): the verification delta only, never a restatement of the body's claim — restatement is where most of the bloat lived (real comments restated nearly every fact). Changed together: the field description (`models/issue_validation.py`), `prompts/issue_validation/prompt.jinja`, and the checked-in `schema.json` (hand-synced; `generate_all_schemas()` re-emits it at run start anyway). Not yet observed live — check the argumentation shape on the next dogfood run.
+- **Validation-first comment layout.** The argumentation is human-facing, so its `<details>` block moved to FIRST under the title + badge line — reading order: claim (title) → why it's real (validation bullets) → description / suggested fix / AI-fix prompt for whoever wants more. Applied in both renderers: `_format_issue_comment` (`publish_review.py`) and the body's off-diff section (`prepare_validation_markdown.py`). Everything stays collapsed (user choice — compact scan on multi-finding reviews).
+- **Reviewer finding body stays prose — deliberately not restructured.** It feeds three LLM stages (validator, dedup, covered-findings), so a shape change there would need e2e parity verification; the user dropped that thread (and the staged/eval-plan drafted earlier the same day) as not worth the runs right now. If ever revisited: 4-arm matrix (control / reviewer-only / validator-only / both) on the frozen-PR protocol.
+- Rejected alternatives: additive TL;DR field (blob remains when expanded — the actual pain), render-time compression pass (lossy rewriting on the published text humans act on, plus an extra LLM call per finding).
+
### ✅ BUILT 2026-07-15 — reviewing-stage progress copy: "Reviewing chunks" → "Running review passes"
Live misread on [posthog#71025](https://github.com/PostHog/posthog/pull/71025) (63 additions): the
diff --git a/products/review_hog/backend/reviewer/models/issue_validation.py b/products/review_hog/backend/reviewer/models/issue_validation.py
index 0dfd886d50b2..013524731345 100644
--- a/products/review_hog/backend/reviewer/models/issue_validation.py
+++ b/products/review_hog/backend/reviewer/models/issue_validation.py
@@ -10,8 +10,15 @@ class IssueValidation(BaseModel):
is_valid: bool = Field(description="Whether the suggested change should be implemented (true) or dismissed (false)")
argumentation: str = Field(
description=(
- "Focused, concise explanation covering why the change should be implemented or dismissed."
- " Should include technical reasoning and potential impact."
+ "Your verification delta as labeled markdown bullets, never a restatement of the issue"
+ " description (the full description always travels with your verdict, so restating it only"
+ " buries your evidence). Your bullets may be read first, right under the finding title, so"
+ " they must stand on their own as evidence for that titled claim. Bullets: '- **Checked:**'"
+ " what you investigated (files, call sites, types, guards); '- **Found:**' the decisive"
+ " evidence, with file:line anchors; '- **Impact:**' the confirmed consequence (for a"
+ " dismissal, why it does not meet the bar); '- **Priority:**' only when setting"
+ " adjusted_priority, the reason. Repeat a label for several distinct points. Keep every fact"
+ " needed to justify the verdict; cut only restatement."
)
)
category: (
diff --git a/products/review_hog/backend/reviewer/prompts/issue_validation/prompt.jinja b/products/review_hog/backend/reviewer/prompts/issue_validation/prompt.jinja
index a08f0d6b310d..ebe6046754ce 100644
--- a/products/review_hog/backend/reviewer/prompts/issue_validation/prompt.jinja
+++ b/products/review_hog/backend/reviewer/prompts/issue_validation/prompt.jinja
@@ -13,6 +13,8 @@ Investigate the codebase, then either validate (keep) or dismiss (drop) the sugg
If your investigation shows the reviewer assigned the wrong severity, correct it with `adjusted_priority` (`must_fix` / `should_fix` / `consider`): raise it when the impact is worse than flagged, lower it when it is milder. Leave `adjusted_priority` null to keep the reviewer's priority — only override on real evidence, not by default. Lowering a finding to `consider` keeps it on record and marks it the lowest priority; whether it reaches the pull request then depends on the author's urgency threshold, so use it to down-rank a real-but-minor issue rather than dismissing it outright.
+Write `argumentation` as your verification delta, structured as labeled markdown bullets — `- **Checked:**` (what you investigated: files, call sites, types, guards), `- **Found:**` (the decisive evidence, with file:line anchors), `- **Impact:**` (the confirmed consequence; for a dismissal, why it does not meet the bar), and `- **Priority:**` (only when you set `adjusted_priority`). Repeat a label when you have several distinct points. Do NOT restate the issue description: the full description always travels with your verdict (in the published comment it sits collapsed just below), so restating it only buries your evidence. Your bullets may be the first thing a reader expands, right under the finding title — write them to stand on their own as evidence for that titled claim. This constrains shape, not content — keep every fact needed to justify the verdict.
+
Return your assessment as a JSON object that conforms to the provided schema.
</pr_issue_validation_instructions>
diff --git a/products/review_hog/backend/reviewer/prompts/issue_validation/schema.json b/products/review_hog/backend/reviewer/prompts/issue_validation/schema.json
index 914e38697b59..b00215afe068 100644
--- a/products/review_hog/backend/reviewer/prompts/issue_validation/schema.json
+++ b/products/review_hog/backend/reviewer/prompts/issue_validation/schema.json
@@ -18,7 +18,7 @@
"type": "boolean"
},
"argumentation": {
- "description": "Focused, concise explanation covering why the change should be implemented or dismissed. Should include technical reasoning and potential impact.",
+ "description": "Your verification delta as labeled markdown bullets, never a restatement of the issue description (the full description always travels with your verdict, so restating it only buries your evidence). Your bullets may be read first, right under the finding title, so they must stand on their own as evidence for that titled claim. Bullets: '- **Checked:**' what you investigated (files, call sites, types, guards); '- **Found:**' the decisive evidence, with file:line anchors; '- **Impact:**' the confirmed consequence (for a dismissal, why it does not meet the bar); '- **Priority:**' only when setting adjusted_priority, the reason. Repeat a label for several distinct points. Keep every fact needed to justify the verdict; cut only restatement.",
"title": "Argumentation",
"type": "string"
},
diff --git a/products/review_hog/backend/reviewer/tests/test_prepare_validation_markdown.py b/products/review_hog/backend/reviewer/tests/test_prepare_validation_markdown.py
index 4a2e1389f4ee..f77a1093359b 100644
--- a/products/review_hog/backend/reviewer/tests/test_prepare_validation_markdown.py
+++ b/products/review_hog/backend/reviewer/tests/test_prepare_validation_markdown.py
@@ -134,6 +134,38 @@ def test_other_findings_section_membership(
assert ("Membership marker finding" in body) is expected_in_section
+def test_off_diff_finding_sections_lead_with_validation() -> None:
+ # The off-diff section must render its collapsed blocks in the same deliberate reading order as
+ # the inline comment (verdict first, then description, then fix). The two renderers are separate
+ # templates, so the inline-comment order test can't catch _render_off_diff_section flipping back
+ # to description-first.
+ chunks_data = ChunksList(chunks=[_chunk(1, "bugfix")])
+ issue = Issue(
+ id="1-1-1",
+ title="Off-diff finding",
+ file="src/auth.py",
+ lines=[LineRange(start=240, end=240)],
+ issue="problem",
+ suggestion="fix",
+ priority=IssuePriority.SHOULD_FIX,
+ )
+ validations = {"1-1-1": IssueValidation(is_valid=True, argumentation="verified", category="bug")}
+
+ body = build_review_body(
+ chunks_data=chunks_data,
+ issues=[issue],
+ validations=validations,
+ pr_files=_pr_files(),
+ published_priorities=_SHOULD_FIX_PUBLISHED,
+ )
+
+ positions = [
+ body.index(f"<summary><strong>{label}</strong></summary>")
+ for label in ("Why we think it's a valid issue", "Issue description", "Suggested fix")
+ ]
+ assert positions == sorted(positions)
+
+
@pytest.mark.parametrize(
"base,adjusted,expected_count_line",
[
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 eabd84de2339..07511190fcb8 100644
--- a/products/review_hog/backend/reviewer/tests/test_publish_review.py
+++ b/products/review_hog/backend/reviewer/tests/test_publish_review.py
@@ -377,21 +377,25 @@ class TestFormatIssueComment:
# Alt text is the raw enum value, so the priority still reads when the badge image can't load.
assert f"![{alt}]" in body
- def test_layout_is_title_then_badges_then_unchanged_collapsed_sections(self) -> None:
- # The change only swapped the text meta for badges and dropped the line ref: title leads, badges
- # tag it just beneath, and all four sections stay folded. Catches a badge/title reorder, a
- # re-added `Priority | Lines` meta, or a section being surfaced inline instead of collapsed.
+ def test_layout_is_title_then_badges_then_collapsed_sections_validation_first(self) -> None:
+ # Title leads, badges tag it just beneath, and all four sections stay folded — with the
+ # validator's verdict first (the deliberate reading order: claim → why it's real → detail).
+ # Catches a badge/title reorder, a re-added `Priority | Lines` meta, a section surfaced inline
+ # instead of collapsed, or a template refactor flipping the order back to description-first.
finding = _finding()
body = _format_issue_comment(finding, _verdict())
assert body.index(f"### {finding.title}") < body.index("![should_fix]") < body.index("<details>")
- for label in (
- "Issue description",
- "Suggested fix",
- "Why we think it's a valid issue",
- "Prompt to fix with AI (copy-paste)",
- ):
- assert f"<summary><strong>{label}</strong></summary>" in body
+ positions = [
+ body.index(f"<summary><strong>{label}</strong></summary>")
+ for label in (
+ "Why we think it's a valid issue",
+ "Issue description",
+ "Suggested fix",
+ "Prompt to fix with AI (copy-paste)",
+ )
+ ]
+ assert positions == sorted(positions)
# Problem and fix stay inside <details>, not surfaced above the first one.
assert finding.body not in body[: body.index("<details>")]
assert "**Priority:**" not in body and "**Lines:**" not in body
diff --git a/products/review_hog/backend/reviewer/tools/prepare_validation_markdown.py b/products/review_hog/backend/reviewer/tools/prepare_validation_markdown.py
index 31218f63640f..9c4e11fbe187 100644
--- a/products/review_hog/backend/reviewer/tools/prepare_validation_markdown.py
+++ b/products/review_hog/backend/reviewer/tools/prepare_validation_markdown.py
@@ -170,26 +170,26 @@ def _render_off_diff_section(findings: list[tuple[Issue, IssueValidation]]) -> l
" | ".join(meta),
"",
"<details>",
- "<summary><strong>Issue description</strong></summary>",
+ "<summary><strong>Why we think it's a valid issue</strong></summary>",
"<br>",
"",
- issue.issue,
+ validation.argumentation,
"",
"</details>",
"",
"<details>",
- "<summary><strong>Suggested fix</strong></summary>",
+ "<summary><strong>Issue description</strong></summary>",
"<br>",
"",
- issue.suggestion,
+ issue.issue,
"",
"</details>",
"",
"<details>",
- "<summary><strong>Why we think it's a valid issue</strong></summary>",
+ "<summary><strong>Suggested fix</strong></summary>",
"<br>",
"",
- validation.argumentation,
+ issue.suggestion,
"",
"</details>",
"",
diff --git a/products/review_hog/backend/reviewer/tools/publish_review.py b/products/review_hog/backend/reviewer/tools/publish_review.py
index dd54e9e4c803..a28876aa8b5f 100644
--- a/products/review_hog/backend/reviewer/tools/publish_review.py
+++ b/products/review_hog/backend/reviewer/tools/publish_review.py
@@ -209,8 +209,10 @@ def _format_issue_comment(finding: ReviewIssueFinding, verdict: ValidationVerdic
"""Format a finding + its verdict as an inline comment body.
Leads with the title, then a line of colored severity/category badges (replacing the old
- `Priority | Category | Lines` text meta); the four collapsed sections below are unchanged. Line
- refs are omitted from the top — the comment is anchored inline and the lines live in the AI prompt.
+ `Priority | Category | Lines` text meta); four collapsed sections follow, the validator's verdict
+ first — it is the human-facing evidence, so the reading order is claim (title) → why it's real
+ (validation) → description / fix / AI prompt for whoever wants more. Line refs are omitted from
+ the top — the comment is anchored inline and the lines live in the AI prompt.
"""
priority = effective_priority(finding.priority, verdict.adjusted_priority)
@@ -220,26 +222,26 @@ def _format_issue_comment(finding: ReviewIssueFinding, verdict: ValidationVerdic
_finding_badge_line(priority, verdict.category),
"",
"<details>",
- "<summary><strong>Issue description</strong></summary>",
+ "<summary><strong>Why we think it's a valid issue</strong></summary>",
"<br>",
"",
- finding.body,
+ verdict.argumentation,
"",
"</details>",
"",
"<details>",
- "<summary><strong>Suggested fix</strong></summary>",
+ "<summary><strong>Issue description</strong></summary>",
"<br>",
"",
- finding.suggestion,
+ finding.body,
"",
"</details>",
"",
"<details>",
- "<summary><strong>Why we think it's a valid issue</strong></summary>",
+ "<summary><strong>Suggested fix</strong></summary>",
"<br>",
"",
- verdict.argumentation,
+ finding.suggestion,
"",
"</details>",
"",