: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
feat(review-hog): remove the review label trigger (#124327)
Georges-Antoine Assi07b0c69e0f22
diff --git a/.agents/skills/reviewing-with-coderabbit/SKILL.md b/.agents/skills/reviewing-with-coderabbit/SKILL.mdindex 8105c05b8c95..0faf6cee4e2f 100644--- a/.agents/skills/reviewing-with-coderabbit/SKILL.md+++ b/.agents/skills/reviewing-with-coderabbit/SKILL.md@@ -13,7 +13,7 @@ description: >This skill is switched off.PostHog Review reviews pull requests automatically in the repositories a project added in its Code review settings, for the authors its rules select.For the setup requirements, see the [PostHog Review architecture guide](../../../products/review_hog/ARCHITECTURE.md#entry-point-commands--configuration).-An eligible person can also add the `posthog-review` label to request a review.+An eligible person can also comment `@posthog review` to request a review.When this skill is invoked, or an instruction asks for a CodeRabbit CLI pass:diff --git a/docs/internal/sandboxes-setup-guide.md b/docs/internal/sandboxes-setup-guide.mdindex 740b7a6b3684..4454d3afee14 100644--- a/docs/internal/sandboxes-setup-guide.md+++ b/docs/internal/sandboxes-setup-guide.md@@ -307,10 +307,10 @@ access. A parent project's flag does not enable its child environments, even thotheir settings and reviews under the shared parent project.Newly enabled projects get every ReviewHog part: manual Full and Flash reviews, automatic Flash reviews,-the `posthog-review` label trigger, resolution, Inbox reviews, the tiered review models, and the Stamphog+the Stamphog handoff, resolution, Inbox reviews, the tiered review models, and the StamphogInbox switch.Each project needs a GitHub App integration covering the repository; review skills seed automatically.-Automatic reviews and the label trigger also need the project to claim the repository in the Code review+Automatic reviews and the Stamphog handoff also need the project to claim the repository in the Code reviewsettings. No environment variable or shared secret picks the project.Use resolution only for explicitly enabled trusted projects reviewing repositories their teams own.diff --git a/posthog/integrations/model_access_baseline.txt b/posthog/integrations/model_access_baseline.txtindex 8dff37611275..fd2a2c6cf77d 100644--- a/posthog/integrations/model_access_baseline.txt+++ b/posthog/integrations/model_access_baseline.txt@@ -74,7 +74,6 @@ products/messaging/backend/services/customerio_webhook.py 1products/messaging/backend/services/transactional_email.py 2products/review_hog/backend/activity_logging.py 2products/review_hog/backend/automatic_reviews.py 3-products/review_hog/backend/label_reviews.py 2products/review_hog/backend/ownership.py 2products/review_hog/backend/repository_settings.py 2products/review_hog/backend/reviewer/status_comment.py 2diff --git a/products/commands/backend/tests/test_results.py b/products/commands/backend/tests/test_results.pyindex 92242d88a46a..c6a3278f74b5 100644--- a/products/commands/backend/tests/test_results.py+++ b/products/commands/backend/tests/test_results.py@@ -46,7 +46,16 @@ class TestStamphogResult(SimpleTestCase):self, _name: str, status: ReviewRunStatus, verdict: ReviewVerdict, expected: str) -> None:finished = FinishedReviewRun(- run_id=uuid4(), team_id=1, repository="acme/widgets", pr_number=7, status=status, verdict=verdict+ run_id=uuid4(),+ team_id=1,+ repository="acme/widgets",+ pr_number=7,+ status=status,+ verdict=verdict,+ head_sha="abc123",+ author_login="octocat",+ head_branch="feature",+ request_external_review=False,)assert expected in stamphog_result(finished, FOLLOW_UP)diff --git a/products/review_hog/ARCHITECTURE.md b/products/review_hog/ARCHITECTURE.mdindex 45165ccc585d..2cdc91c326da 100644--- a/products/review_hog/ARCHITECTURE.md+++ b/products/review_hog/ARCHITECTURE.md@@ -5,12 +5,12 @@**PostHog Review** is the product name on every outward surface: GitHub comments, MCP tools, API docs, and UI prose.**Code review** is the name of the in-app page and its nav entry only.**ReviewHog** is the internal codename. Code, logs, metric names, keys, and developer docs use it.-The `posthog-review` label starts a review.+An `@posthog review` comment starts a Standard review, and `@posthog review --deep` starts a Deep review. No label starts a review.The UI and the text PostHog Review posts use the user-facing names. Code, API values, and stored data use the internal names.- **Standard** (internal name **Flash**, `flash`): the automatic review every push gets. A fixed set of reviewers on a lower-cost model. It never pushes to the branch.-- **Deep** (internal name **Full**, `full`): the review someone asks for with the Review button, the `posthog-review` label, or an Inbox report. It uses the requester's perspectives, validator, and threshold.+- **Deep** (internal name **Full**, `full`): the review someone asks for with the Review button, the `@posthog review --deep` comment, or an Inbox report. It uses the requester's perspectives, validator, and threshold.- **Resolve**: the stage after a Deep review that fixes review comments on the PR branch, only when the PR owner opted in (`resolve_comments`).- **Inbox review**: a Deep review of a PR the PostHog agent opened for an Inbox report. The report's assigned reviewer counts as the PR owner.- **Perspective**: one angle a Deep review reads the code from, such as logic and correctness. Each one is a review skill.@@ -152,8 +152,7 @@ re-opens triage for exactly that thread, standing verdicts ("SAFE TO FIX" / "E2Eoutcome, and everything else skips at zero cost. What's missing is the **trigger**: nothing starts a resolutionrun when the reply lands, so today the conversation only advances when someone runs `run_resolution` / theresolve-only action. Build the comment trigger — a `pull_request_review_comment` (created) event → the existing-trigger API → `start_resolution_workflow` for that PR (debounced; skip when the commenter is ReviewHog itself,-mirroring the label trigger) — so replying to an escalation gets an actual answer: implement on a go-ahead,+trigger API → `start_resolution_workflow` for that PR (debounced; skip when the commenter is ReviewHog itself) — so replying to an escalation gets an actual answer: implement on a go-ahead,decline-and-say-why on a disagreement, re-escalate with the new context otherwise. Mind the known blind spot: thework-list only fetches **unresolved** threads, so replies on already-resolved (FIXED) threads are invisible —the trigger should either unresolve-on-human-reply or the fetch must include threads with comments newer than@@ -384,9 +383,8 @@ time loop, and most of what a late round flags was already there in the first. Aa clean turn) reads from the events.The first review that posts findings on a pull request ends with one more note (`first_review_note` in-`backend/label_reviews.py`). It links the report in the PostHog Review UI (`report_deep_link`). On a Standard review,-where comment commands run, it also offers `@posthog review --deep`. A label review leaves the command out, because-its own footer already names it. Later reviews do not repeat the note: the published watermark is set after the first post.+`backend/review_notes.py`). It links the report in the PostHog Review UI (`report_deep_link`). On a Standard review,+where comment commands run, it also offers `@posthog review --deep`. Later reviews do not repeat the note: the published watermark is set after the first post.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@@ -501,7 +499,7 @@ pr_metadata.head_branch` is threaded (as explicit kwargs, alongside `team_id` /finding — if all are off-diff (no inline comments resolve) the body still posts, carrying them in theOther-findings section, so a review is never dropped wholesale. Falls back to a body-only review whenposting with inline comments fails. Authenticates with the team's installation token. Gated **per run** by `inputs.publish` (the workflow only dispatches this stage- when publishing is on); the eval CLI defaults it off, the label trigger sets it on. Both publish-idempotency+ when publishing is on); the eval CLI defaults it off, the Stamphog handoff sets it on. Both publish-idempotencymarker scans (`_review_already_posted` here, `_find_marker_comment` on the status comment) trust the markeronly in **app-bot** comments/reviews — on a public repo anyone can paste it, and a spoofed match wouldsuppress the publish or clobber a stranger's comment.@@ -914,15 +912,18 @@ See [DECISIONS.md](./DECISIONS.md) for the "reuse the leaf, own the model" boundproject selected, at most one project per installation) or `selected`. A `ReviewRepository` row is eitherselected into its project or a repository exception (`flash_for`); a repository has one row across allprojects. Ownership: a selected row (or a row in the project that claims all) → that project; else the `all`- claim → that project; else nobody, so no automatic review and the label trigger answers "not set up". The+ claim → that project; else nobody, so no automatic review and the Stamphog handoff starts nothing. Thewebhook prefilter (`OwnedRepositoryPrefilter`) caches a per-installation summary and fails open. Repositorylookups match GitHub's repository id first and then the name, and backfill both. The installation id is not partof a repository's identity (a reinstall gets a new one), so rows and personal choices are unique by name and id. The repository list in thesettings comes from the core GitHub integration's cached repository list (`repository_overview`), which thecore `installation_repositories` webhook keeps fresh. A repository write must match a name and id in that list,so a project cannot reserve a repository id the installation does not report.-- **Label trigger** — the PostHog GitHub App's own `pull_request` `labeled` delivery (`backend/label_reviews.py`).- No GitHub Action, shared secret, or environment variable is involved. See the triggers paragraph below.+- **Stamphog handoff** — Stamphog calls the finished-review callback `receivers.py` registers in its+ `facade/finished_review_hooks.py`, and the run carries `request_external_review` (`backend/stamphog_handoff.py`).+ The handoff finds the owning project by repository name and reviews the head Stamphog judged, unless that head+ already has a pending or completed review. No label, GitHub Action, shared secret, or environment variable is+ involved. See the triggers paragraph below.- **Automatic authored-PR trigger** runs in the owning project and requires that project's GitHub integration forthe delivery's installation. The rules in `backend/automatic_review_rules.py` decide, highest first: theauthor's choice for the repository (`ReviewUserRepositoryChoice`, flash/off, stored only when it differs from@@ -931,7 +932,7 @@ See [DECISIONS.md](./DECISIONS.md) for the "reuse the leaf, own the model" boundopt-in only, the default). Bot authors and authors who map to no active member get automatic Flash only when theproject sets `bot_prs=run`; the review then runs as the user who connected the installation, with defaultsettings and no resolution. No per-deploy team id picks the project for any trigger.-- **One feature flag.** `review-hog` is the only ReviewHog flag. Automatic Flash reviews, the label trigger,+- **One feature flag.** `review-hog` is the only ReviewHog flag. Automatic Flash reviews, the Stamphog handoff,resolution, manual Flash, Inbox reviews, the Stamphog Inbox switch, and the tiered review arms are availablewherever it is on. DECISIONS.md records why the separate `review-hog-internal` gate went away.- **`GITHUB_APP_SLUG`** (instance setting) names the app, and `posthog_app_login()` in@@ -948,7 +949,7 @@ See [DECISIONS.md](./DECISIONS.md) for the "reuse the leaf, own the model" bound4. Set the project rule (automatic Flash for everyone, for listed people, or opt-in only) and the bot rule.**Triggers.** Six entry points feed the same per-PR `ReviewPRQueueWorkflow`: the `run_review` CLI (manual / eval), the-`posthog-review` **label** on a PR in a repository that a project reviews (the GitHub App's own `labeled` delivery), a **UI**+**Stamphog handoff** of a refused or escalated self-driving PR in a repository that a project reviews, a **UI**"Review this PR" field in the Code review scene (any installation-accessible PR; its split button's `run_mode`also carries the review-without-resolving, resolve-only, and **Flash** variants; Flash pins resolution off), an **inbox** trigger (a`TaskRun` receiver auto-reviews self-driving Signals implementations once their PR exists — a pushed branch without@@ -961,16 +962,16 @@ It accepts `opened`, `synchronize`, and `ready_for_review` for open PRs whose heA draft is skipped (`draft_skipped`) when the PR owner turned `review_drafts` off. Its first automatic review then comes from `ready_for_review`, and `automatic_reviewed_head_sha` keeps a head that was already reviewed as a draft from a second review.A draft that is reviewed gets its first automatic review only: the push gate's `draft` rule skips the later pushes, and `ready_for_review` reviews everything since the last reviewed head, also when the author marks it ready without a push.A PR with the `skip-agent-review` label gets no automatic review (`label_skipped`). The task checks the payload labels, and the turn checks the labels its fetch reads from GitHub again, because `gh pr create --label` adds labels after the `opened` delivery.-The turn ends before the status comment, so a skip leaves nothing on the PR. Removing the label does not start a review; apply the `posthog-review` label for one.-The label, the `@posthog review` comment, and the UI button ignore both the switch and the skip label.+The turn ends before the status comment, so a skip leaves nothing on the PR. Removing the label does not start a review; comment `@posthog review` for one.+The `@posthog review` comment, the UI button, and the Stamphog handoff ignore both the switch and the skip label.The webhook handler reads only the cached ownership summary, so the task checks ownership again.Enabling the setting performs no backfill; existing PRs become eligible on their next push.The turn rechecks ownership and the rules before starting. Flash publishes every kept finding (it records `consider` as the turn's threshold) and never starts resolution.**No Flash after Full:** once a PR has a published Full review, automatic dispatch skips it (`full_review_published`), the turn's recheck refuses it, and a manual Flash request answers 409 `flash_after_full`.-The same `review_hog_authored_prs` consumer (the name is the dedup key, so it stays) routes by action through `facade/github.py::accept_pull_request_event` (`backend/pull_request_events.py`): `labeled` with the `posthog-review` label queues `process_label_event`.-That task finds the owning project and accepts a person or `stamphog[bot]` (Stamphog's hand-off) as the labeler; another bot's label gets an explaining comment, and the app token removes the label that the event named.-The review runs as the PR owner, else as the user who connected the installation (`Integration.created_by`) with default settings and no resolution; the workflow removes both labels when the run ends, and a running resolution leaves the label for a later retry.-Counters: `posthog_review_hog_authored_pr_review_total` and `posthog_review_hog_label_review_total`, keyed by outcome.+The same `review_hog_authored_prs` consumer (the name is the dedup key, so it stays) routes through `facade/github.py::accept_pull_request_event` (`backend/pull_request_events.py`), and a `labeled` delivery starts nothing.+The Stamphog handoff queues `process_stamphog_handoff`, which finds the project that owns the repository (it can differ from the Stamphog project).+The review runs as the PR owner, else as the user who connected the installation (`Integration.created_by`) with default settings and no resolution; a running resolution drops the handoff.+Counters: `posthog_review_hog_authored_pr_review_total` and `posthog_review_hog_stamphog_handoff_total`, keyed by outcome.`facade/github.py::owning_team_id(installation_id, repository)` answers the same ownership question for other products, for example a PR comment command dispatcher.The UI and MCP paths are one surface: the viewset carries the grantable `review_hog` scope (`review_hog:read` for list /retrieve / perspective_stats, `review_hog:write` for trigger). Both require the `review-hog` feature flag,@@ -994,13 +995,13 @@ Two per-PR splits run on top of these rules. Their flags are keyed like the coor`reviewhog-zero-change-skip` adds the `zero_change` rule after `quiet_small_push`: the gate compares the stored single-agent PR snapshots of the last automatically reviewed head and this head (`ChangedSinceReview`), and a PR whose reviewed files did not change skips in the treatment arm. `merge_only` already skips a push whose whole PR diff is unchanged (a base merge, a rebase, an amend), so this rule catches pushes that change only files the review leaves out, such as generated files and snapshots. The snapshots leave lockfiles out too, so a PR with a lockfile at either head never matches, and neither does a PR with a file whose patch GitHub left out (`PRChange.comparable`). The control arm reviews the push and records the match, so it is the audit. A missing snapshot never matches. A skipped push does not move the baseline, so the next comparison covers it.`reviewhog-delta-band` lets a turn that passes every rule review only what changed: from run `DELTA_BAND_FIRST_RUN_INDEX` (3) on, with changed reviewable lines at most `DELTA_BAND_MAX_CHANGE_SHARE` (3%) of the PR's reviewable lines, no dependency file changed, and a comparison the snapshots show in full: no lockfile in the PR, no file without a patch, and no file that left the PR (`plan_delta_review`). The first follow-up always reviews the whole PR. A delta turn passes the baseline head to its sessions (`SandboxStageInput.delta_since_head_sha`), runs one session per lens, and each prompt shows only the changed files with the diff blocks around the changed lines (`delta_files`), plus the earlier findings, the full repository at the head, and the git command for the whole diff since the baseline, which also shows code the PR no longer changes. A gate failure, or a baseline snapshot that is gone when the prompt is built, gives the whole-PR prompt, also in each lens session.The gate event carries `pr_changed_lines`, both arms, `coordinator`, `delta_eligible` and `delta_review`; every completed event carries `zero_change_skip_arm`, `delta_band_arm` and `delta_review`, so each split compares by arm over PR lifecycles. A coordinated PR always records the control arm of the delta split, so a delta comparison leaves out gate events with `coordinator` set.-The `next_push_likely` chance comes from a table fitted offline on closed PRs and refitted by hand. Its key is the follow-up number, capped at 8, and the PR size band (additions plus deletions: up to 200, up to 1000, more). A size cell with fewer than 10 PRs falls back to the chance for the follow-up number alone. The follow-up number is `run_index - 1`, so it also counts label and UI turns, which the fit left out.+The `next_push_likely` chance comes from a table fitted offline on closed PRs and refitted by hand. Its key is the follow-up number, capped at 8, and the PR size band (additions plus deletions: up to 200, up to 1000, more). A size cell with fewer than 10 PRs falls back to the chance for the follow-up number alone. The follow-up number is `run_index - 1`, so it also counts comment and UI turns, which the fit left out.Each rule has a `SKIP_*` switch. `no_new_commits`, `reviewhog_commits_only`, `merge_only`, `draft`, `late_follow_up`, `small_pr`, `quiet_small_push`, and `throttled` skip; the three value rules also take over a shadow match of an earlier rule, but never a gate failure, and they do not run on a retry of a turn that already finalized its head; `docs_only`, `small_change`, System One, and `next_push_likely` (`SKIP_NEXT_PUSH`) only record a shadow decision until production data confirms them.A skipped turn posts no status comment and leaves `automatic_reviewed_head_sha` in place, so the next push is judged against the last reviewed head.Any gate failure reviews the push. Each decision emits `reviewhog_push_gate_decided` with `skipped`, `would_skip`, the reason, the System One probability and model, `own_code_lines`, the lines the new own commits change in code files (empty when GitHub could not list every file of a commit), `net_code_lines` and `small_change_deferrals` (empty when the gate did not read them), `pr_draft`, the draft state the gate used (null when the snapshot is unavailable), `reviewable_lines` and `previous_findings`, the inputs of the value rules (null when the gate could not read them), and `next_push_probability` (null on a draft and when the snapshot is unavailable; set on every other decision, also when another rule decided); the event key includes it and the reason, so a draft or throttle skip and a later review at the same head stay two events, so skip rules that weigh push size can be calibrated offline.-The first automatic review and every label, UI, inbox, and manual trigger never reach the gate.-An automatic review of a draft that posts findings ends with a note: it is the only automatic review while the PR is a draft, `@posthog review` (or the `posthog-review` label when `github-commands` is off) reviews new changes sooner, and marking the PR ready reviews them otherwise. Label and UI reviews leave the note out, because they also run for authors without automatic reviews.-Reviews start only from a trigger (a push, the label, the UI, the inbox, or a manual run) and run right away.+The first automatic review and every comment, UI, inbox, Stamphog, and manual trigger never reach the gate.+An automatic review of a draft that posts findings ends with a note: it is the only automatic review while the PR is a draft, `@posthog review` (or the Code review page when `github-commands` is off) reviews new changes sooner, and marking the PR ready reviews them otherwise. Comment, UI, and Stamphog reviews leave the note out, because they also run for authors without automatic reviews.+Reviews start only from a trigger (a push, a comment, the UI, the inbox, a Stamphog handoff, or a manual run) and run right away.ReviewHog never schedules a review for later, for example on a timer after a skipped push: nobody waits for a review that arrives at an unknown time, and a late review can land while the PR sits in a merge queue or under a stack.A change that the gate skips gets reviewed at the next trigger, or not at all.diff --git a/products/review_hog/CONTEXT.md b/products/review_hog/CONTEXT.mdindex c599d05dffcf..ef0becbd7337 100644--- a/products/review_hog/CONTEXT.md+++ b/products/review_hog/CONTEXT.md@@ -2,7 +2,7 @@Vocabulary settled while working on the product. Pure vocabulary — no spec, no implementation detail beyond what a term needs to be unambiguous.-- **PostHog Review / Code review / ReviewHog** — three names for one product. **PostHog Review** is the product name on every outward surface (GitHub, MCP, API docs, UI prose). **Code review** is the in-app page and nav name only. **ReviewHog** is the internal codename for code, logs, and developer docs. The `posthog-review` label starts a review.+- **PostHog Review / Code review / ReviewHog** — three names for one product. **PostHog Review** is the product name on every outward surface (GitHub, MCP, API docs, UI prose). **Code review** is the in-app page and nav name only. **ReviewHog** is the internal codename for code, logs, and developer docs. An `@posthog review` comment starts a review, and no label does.- **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.diff --git a/products/review_hog/DECISIONS.md b/products/review_hog/DECISIONS.mdindex 185d3ace756b..61ef8ee1df44 100644--- a/products/review_hog/DECISIONS.md+++ b/products/review_hog/DECISIONS.md@@ -198,6 +198,21 @@ 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'scoverage matrix as the guard); kill if valid findings drop with the noise.+### ✅ BUILT 2026-10-29 — no label starts a review; Stamphog hands off through the finished-review hook (#124327)++- **What.** The `reviewhog` label no longer starts a review, and a `labeled` delivery starts nothing.+ This replaces the 2026-08-21 label handler below.+ When Stamphog refuses or escalates a self-driving PR, its finished-review hook (`facade/finished_review_hooks.py`) calls a callback `receivers.py` registers.+ The callback queues `process_stamphog_handoff`, which reviews the head Stamphog judged (`stamphog_handoff.py`).+ The review is Standard, or Deep once the PR has a published Deep review.+- **Why the hook.** Stamphog already calls the finished-review hooks right after its terminal save.+ A second registry would repeat it with a different payload.+ `FinishedReviewRun` gains `head_sha` and `request_external_review`, because a gate-blocked refusal is stored as `WAIT` and the verdict alone does not say to hand off.+- **No installation id in the payload.** Stamphog's installation belongs to its own GitHub App, so it never matches a PostHog App `Integration`.+ The handoff finds the owning project and installation by repository name (`RepositoryOwnership.find_by_name`).+- **Skips.** A head with a pending or completed review is not reviewed again; a failed status lookup raises so the task retries.+ A missing owner, missing integration, missing run user, or running resolution is a no-op counted in `posthog_review_hog_stamphog_handoff_total`.+### ✅ BUILT 2026-10-16 — push gate skips follow-ups that rarely surface anything (live)- **What.** Three live push gate rules run after `draft`: `late_follow_up` (the push would start review 9 or a laterdiff --git a/products/review_hog/backend/label_reviews.py b/products/review_hog/backend/label_reviews.pydeleted file mode 100644index 1c67c5204315..000000000000--- a/products/review_hog/backend/label_reviews.py+++ /dev/null@@ -1,245 +0,0 @@-"""The label trigger: the `posthog-review` label on a pull request starts a Standard review, or a Deep one-once the pull request has a published Deep review.--The PostHog GitHub App's own `labeled` delivery starts it, so the trigger works in every repository the-app is installed on and a project owns (`ownership.py`). One label add is one review: pushes do not-review again, and the workflow removes the label when the run ends.--- A person can add the label, and so can Stamphog, which hands a refused or escalated pull request to- ReviewHog this way. Another bot's label gets an explaining comment and is removed.-- The review runs in the owning project.-- It runs as the pull request owner (`pr_owner.py`). Without an owner it runs as the person who- connected the installation, with default settings and no resolution.-"""--import logging-from typing import Literal--from prometheus_client import Counter--from posthog.dataclasses import frozen-from posthog.egress.limiter.policies import Priority-from posthog.models.integration import GitHubIntegration, Integration-from posthog.models.team import Team-from posthog.otel_metrics import OtelInstrumentFactory-from posthog.permissions import posthog_feature_flag_enabled--from products.review_hog.backend.automatic_reviews import connector_user_id-from products.review_hog.backend.ownership import RepositoryOwnership, RepositoryRef-from products.review_hog.backend.pr_owner import PullRequestOwnerResolver-from products.review_hog.backend.pull_request_events import REVIEW_LABEL-from products.review_hog.backend.review_request_rules import trigger_review_mode-from products.review_hog.backend.reviewer.constants import REVIEW_MODE_FLASH, REVIEW_MODE_FULL-from products.review_hog.backend.reviewer.persistence import lift_review_tier_for_joined_trigger-from products.review_hog.backend.reviewer.tools.github_client import (- GitHubAPIError,- github_api_get_paginated,- github_api_request,- is_app_bot_author,-)--logger = logging.getLogger(__name__)-_otel = OtelInstrumentFactory("review_hog")--# Stamphog hands a refused or escalated pull request to ReviewHog with the label.-STAMPHOG_BOT_LOGIN = "stamphog[bot]"--BOT_LABEL_COMMENT = (- f"PostHog Review starts a review only when a person adds the `{REVIEW_LABEL}` label. A bot added it here, "- "so the label was removed. Add the label yourself to start a review."-)--# The rollout flag of `@posthog` pull request comments (products/commands). Read here by key,-# because the commands product already depends on this product.-COMMENT_COMMANDS_FLAG = "github-commands"---def comment_commands_enabled(team_id: int) -> bool:- """Whether `@posthog` comments run for this project's organization, so the review may point to them."""- organization_id = Team.objects.values_list("organization_id", flat=True).filter(id=team_id).first()- if organization_id is None:- return False- return posthog_feature_flag_enabled(- COMMENT_COMMANDS_FLAG, f"review-hog-team-{team_id}", organization_id=organization_id, team_id=team_id- )---def label_commands_hint(review_mode: str) -> str:- """The note a label-started review ends with: which review the label ran, and the commands for more."""- if review_mode == REVIEW_MODE_FLASH:- return (- f"This Standard review started from the `{REVIEW_LABEL}` label. Comment `@posthog review --deep` "- "for a Deep review, or `@posthog help` to see all commands."- )- return f"This Deep review started from the `{REVIEW_LABEL}` label. Comment `@posthog help` to see all commands."---def draft_review_notice(comment_commands_on: bool) -> str:- """The note an automatic review of a draft ends with: the push gate skips the draft's later pushes."""- trigger = "Comment `@posthog review`" if comment_commands_on else f"Add the `{REVIEW_LABEL}` label"- return (- "This is the only automatic review while this pull request is a draft. "- f"{trigger} to review new changes sooner. "- "Otherwise, a review of the new changes runs when you mark it ready for review."- )---def first_review_note(review_link: str, deep_command: bool) -> str:- """The note the first review on a pull request ends with: where to see the review, and how to ask for Deep."""- note = f"See this review and its findings in [PostHog Review]({review_link})."- if deep_command:- note = (- f"{note} Comment `@posthog review --deep` for a Deep review. "- "A Deep review takes longer and looks deeper than a Standard review."- )- return note---LabelReviewOutcome = Literal[- "repository_not_added",- "installation_mismatch",- "bot_labeler",- "no_run_user",- "resolution_running",- "started",-]--# The label trigger answers nobody, so a skipped label leaves no trace on the pull request. This-# counter names why labels stopped starting reviews.-LABEL_REVIEW_TOTAL = Counter(- "posthog_review_hog_label_review_total",- "Label trigger decisions, keyed by outcome",- labelnames=["outcome"],-)---def _observe(outcome: LabelReviewOutcome) -> None:- LABEL_REVIEW_TOTAL.labels(outcome=outcome).inc()- _otel.record_counter_twin(LABEL_REVIEW_TOTAL, 1, {"outcome": outcome})---@frozen-class LabelReview:- installation_id: str- repository: str- github_repo_id: int | None- pr_number: int- author_login: str- # The payload refuses forks, so the head branch is in the base repository.- head_branch: str- labeler_login: str- labeled_by_bot: bool-- @property- def ref(self) -> RepositoryRef:- return RepositoryRef(- installation_id=self.installation_id, github_repo_id=self.github_repo_id, full_name=self.repository- )-- @property- def labeler_allowed(self) -> bool:- return not self.labeled_by_bot or self.labeler_login.lower() == STAMPHOG_BOT_LOGIN-- def _github(self, integration: Integration) -> GitHubIntegration:- return GitHubIntegration(integration, source="review_hog", priority=Priority.NORMAL)-- def _bot_label_comment_posted(self, token: str) -> bool:- return any(- comment.get("body") == BOT_LABEL_COMMENT and is_app_bot_author(comment.get("user"))- for comment in github_api_get_paginated(- f"/repos/{self.repository}/issues/{self.pr_number}/comments",- token=token,- installation_id=self.installation_id,- endpoint="/repos/{owner}/{repo}/issues/{issue_number}/comments",- )- )-- def _refuse_bot_label(self, integration: Integration) -> None:- # The label goes first: a failed call retries the task, and the comment must post only once.- token = self._github(integration).get_access_token()- try:- github_api_request(- "DELETE",- f"/repos/{self.repository}/issues/{self.pr_number}/labels/{REVIEW_LABEL}",- token=token,- installation_id=self.installation_id,- endpoint="/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}",- )- except GitHubAPIError as error:- if error.status != 404:- raise- # A POST can succeed on GitHub and still fail here, so a retry checks for the earlier comment.- if self._bot_label_comment_posted(token):- return- github_api_request(- "POST",- f"/repos/{self.repository}/issues/{self.pr_number}/comments",- token=token,- installation_id=self.installation_id,- endpoint="/repos/{owner}/{repo}/issues/{issue_number}/comments",- json={"body": BOT_LABEL_COMMENT},- )-- def start(self) -> None:- # The temporal package registers the activities, which pull in the sandbox runtime.- from products.review_hog.backend.temporal.client import ( # noqa: PLC0415- start_review_pr_workflow,- workflow_running,- )- from products.review_hog.backend.temporal.types import ( # noqa: PLC0415- TRIGGER_LABEL,- resolve_pr_workflow_id,- review_pr_workflow_id,- )-- owner = RepositoryOwnership.find(self.ref)- if owner is None:- _observe("repository_not_added")- return- team_id = owner.team_id- integration = (- Integration.objects.filter(team_id=team_id, kind="github", integration_id=self.installation_id)- .order_by("id")- .first()- )- if integration is None:- _observe("installation_mismatch")- return- if not self.labeler_allowed:- self._refuse_bot_label(integration)- _observe("bot_labeler")- return- pr_owner = PullRequestOwnerResolver.resolve(- team_id, repository=self.repository, author_login=self.author_login, head_branch=self.head_branch- )- run_user_id = pr_owner.user_id or connector_user_id(team_id=team_id, installation_id=self.installation_id)- if run_user_id is None:- _observe("no_run_user")- return- github_owner, _, github_repo = self.repository.partition("/")- # The busy-guard (CONTEXT.md): a review waits until this PR's resolution run is done. The label- # stays, so a person can add it again once the run ends.- if workflow_running(- resolve_pr_workflow_id(team_id=team_id, owner=github_owner, repo=github_repo, pr_number=self.pr_number)- ):- _observe("resolution_running")- return- # Probed before the start: a same-id start joins the running turn, whose inputs keep the- # original trigger, so the label's tier lift has to be written here.- joins_running_review = workflow_running(- review_pr_workflow_id(team_id=team_id, owner=github_owner, repo=github_repo, pr_number=self.pr_number)- )- review_mode = trigger_review_mode(team_id, self.repository, self.pr_number)- start_review_pr_workflow(- pr_url=f"https://github.com/{self.repository}/pull/{self.pr_number}",- team_id=team_id,- user_id=run_user_id,- publish=True,- trigger_source=TRIGGER_LABEL,- review_mode=review_mode,- )- # Standard is excluded for the same reason as on the comment path: the lift rewrites the- # persisted arm, so the cheaper review must not raise what later turns cost.- if joins_running_review and review_mode == REVIEW_MODE_FULL:- lift_review_tier_for_joined_trigger(team_id=team_id, repository=self.repository, pr_number=self.pr_number)- _observe("started")diff --git a/products/review_hog/backend/models.py b/products/review_hog/backend/models.pyindex 0e401e96a567..e1e7a4e13c16 100644--- a/products/review_hog/backend/models.py+++ b/products/review_hog/backend/models.py@@ -119,7 +119,8 @@ class ReviewReport(UUIDModel, TeamScopedRootMixin):# signals side (the signals-side `code_review` artefact is API-deletable; this row is the durable# link). Filled once, never overwritten by later turns from another trigger.signal_report_id = models.UUIDField(null=True, blank=True)- # Which trigger created this report ("label" / "inbox" / "manual" / "ui" / "comment"); stamped on create only.+ # Which trigger created this report ("stamphog" / "inbox" / "manual" / "ui" / "comment", or "label" from+ # before labels stopped starting reviews); stamped on create only.trigger_source = models.CharField(max_length=20, default="manual")# The reviewer arm, chosen once at creation from the report's tier (see `REVIEW_ARMS_BY_TIER`)# and sticky for the report's life. Adapter/model/effort/permission-mode persist as one bundle@@ -491,7 +492,7 @@ class ReviewUserSettings(UUIDModel, TeamScopedRootMixin):review_inbox_prs = models.BooleanField(default=False, db_default=False)# Unused: values live in preferences.stamphog_review_inbox_prs = models.BooleanField(default=False, db_default=False)- # Unused: a label always runs.+ # Unused: no label starts a review.review_labeled_prs = models.BooleanField(default=True, db_default=True)# Unused: values live in preferences.resolve_comments = models.BooleanField(default=True, db_default=True)diff --git a/products/review_hog/backend/presentation/views/settings.py b/products/review_hog/backend/presentation/views/settings.pyindex c1bc06d98449..d1f14487979a 100644--- a/products/review_hog/backend/presentation/views/settings.py+++ b/products/review_hog/backend/presentation/views/settings.py@@ -54,8 +54,8 @@ class ReviewUserSettingsSerializer(serializers.Serializer):review_drafts = serializers.BooleanField(required=False,help_text="Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets "- "its first automatic review when it is marked ready for review. Applies to automatic reviews only: the "- "posthog-review label, an @posthog review comment, and the Review button still review drafts.",+ "its first automatic review when it is marked ready for review. Applies to automatic reviews only: an "+ "@posthog review comment and the Review button still review drafts.",)resolve_comments = serializers.BooleanField(required=False,diff --git a/products/review_hog/backend/pull_request_events.py b/products/review_hog/backend/pull_request_events.pyindex 7e357d15ce0a..27481a45c6bf 100644--- a/products/review_hog/backend/pull_request_events.py+++ b/products/review_hog/backend/pull_request_events.py@@ -1,7 +1,6 @@"""GitHub `pull_request` deliveries of the PostHog GitHub App, routed by action.- `opened` / `synchronize` / `ready_for_review`: an automatic review (`automatic_reviews.py`).-- `labeled` with the `posthog-review` label: a label review (`label_reviews.py`).The webhook handler runs inside the request, so this module only parses the payload, reads thecached ownership summary, and queues a Celery task. The task checks ownership and the rules again.@@ -13,7 +12,6 @@ from posthog.dataclasses import frozenfrom products.review_hog.backend.ownership import OwnedRepositoryPrefilter, RepositoryRef-REVIEW_LABEL = "posthog-review"# Authors and automation apply this label to opt a pull request out of automatic reviews.SKIP_AGENT_REVIEW_LABEL = "skip-agent-review"AUTOMATIC_REVIEW_ACTIONS = frozenset({"opened", "synchronize", "ready_for_review"})@@ -59,13 +57,8 @@ class PullRequestEvent:pr_number: intauthor_login: strhead_sha: str- head_branch: strdraft: bool = Falseskip_agent_review: bool = False- # Set on `labeled` deliveries only.- label_name: str | None = None- sender_login: str | None = None- sender_is_bot: bool = False@classmethoddef from_payload(cls, payload: Mapping[str, object]) -> "PullRequestEvent | None":@@ -90,7 +83,6 @@ class PullRequestEvent:head_sha = _text(head.get("sha"))if installation_id is None or pr_number is None or author_login is None or head_sha is None:return None- sender = _mapping(payload.get("sender"))return cls(action=action,installation_id=str(installation_id),@@ -99,12 +91,8 @@ class PullRequestEvent:pr_number=pr_number,author_login=author_login.lower(),head_sha=head_sha,- head_branch=_text(head.get("ref")) or "",draft=pull_request.get("draft") is True,skip_agent_review=has_skip_agent_review_label(_label_names(pull_request.get("labels"))),- label_name=_text(_mapping(payload.get("label")).get("name")),- sender_login=_text(sender.get("login")),- sender_is_bot=sender.get("type") == "Bot",)@property@@ -113,42 +101,23 @@ class PullRequestEvent:installation_id=self.installation_id, github_repo_id=self.github_repo_id, full_name=self.repository)- @property- def is_label_request(self) -> bool:- return self.action == "labeled" and (self.label_name or "").lower() == REVIEW_LABEL-def accept_pull_request_event(payload: Mapping[str, object]) -> None:event = PullRequestEvent.from_payload(payload)- if event is None:- return- wants_automatic_review = event.action in AUTOMATIC_REVIEW_ACTIONS- if not (wants_automatic_review or event.is_label_request):+ if event is None or event.action not in AUTOMATIC_REVIEW_ACTIONS:returnif not OwnedRepositoryPrefilter.may_be_owned(event.ref):return# Keeps Celery off the registry import path.- from products.review_hog.backend.tasks import process_authored_pr_event, process_label_event # noqa: PLC0415-- if wants_automatic_review:- process_authored_pr_event.delay(- installation_id=event.installation_id,- repository=event.repository,- author_login=event.author_login,- pr_number=event.pr_number,- head_sha=event.head_sha,- github_repo_id=event.github_repo_id,- draft=event.draft,- skip_agent_review=event.skip_agent_review,- )- return- process_label_event.delay(+ from products.review_hog.backend.tasks import process_authored_pr_event # noqa: PLC0415++ process_authored_pr_event.delay(installation_id=event.installation_id,repository=event.repository,- github_repo_id=event.github_repo_id,- pr_number=event.pr_number,author_login=event.author_login,- head_branch=event.head_branch,- labeler_login=event.sender_login or "",- labeled_by_bot=event.sender_is_bot,+ pr_number=event.pr_number,+ head_sha=event.head_sha,+ github_repo_id=event.github_repo_id,+ draft=event.draft,+ skip_agent_review=event.skip_agent_review,)diff --git a/products/review_hog/backend/receivers.py b/products/review_hog/backend/receivers.pyindex ebf52b5c62f3..e23d286dda1a 100644--- a/products/review_hog/backend/receivers.py+++ b/products/review_hog/backend/receivers.py@@ -46,6 +46,10 @@ from products.review_hog.backend.preferences import ReviewPreferencesfrom products.signals.backend.enums import ReportPriorityfrom products.signals.backend.models import SignalReportArtefactfrom products.signals.backend.report_generation.priority import persisted_report_priority+from products.stamphog.backend.facade.finished_review_hooks import (+ FinishedReviewRun,+ register_finished_review_hook as register_stamphog_finished_review_hook,+)from products.stamphog.backend.facade.inbox_hooks import register_inbox_acting_reviewer_resolverfrom products.stamphog.backend.facade.review_evidence import (ReviewEvidence,@@ -74,6 +78,24 @@ def connect() -> None:# Stamphog waits for a pending review of the head it judges and counts a completed one as# assurance. The same dependency cycle rules out a direct import.register_review_evidence_provider(review_evidence_for_stamphog)+ # Stamphog asks for a review of a self-driving PR it refused or escalated. The same dependency+ # cycle rules out a direct import.+ register_stamphog_finished_review_hook(queue_stamphog_handoff)+++def queue_stamphog_handoff(finished: FinishedReviewRun) -> None:+ """Queue the review Stamphog asks for, off Stamphog's activity."""+ if not finished.request_external_review:+ return+ from products.review_hog.backend.tasks import process_stamphog_handoff # noqa: PLC0415++ process_stamphog_handoff.delay(+ repository=finished.repository,+ pr_number=finished.pr_number,+ head_sha=finished.head_sha,+ author_login=finished.author_login,+ head_branch=finished.head_branch,+ )def review_evidence_for_stamphog(repository: str, pr_number: int, head_sha: str) -> ReviewEvidence | None:diff --git a/products/review_hog/backend/review_notes.py b/products/review_hog/backend/review_notes.pynew file mode 100644index 000000000000..040a57cbd61c--- /dev/null+++ b/products/review_hog/backend/review_notes.py@@ -0,0 +1,39 @@+"""The notes a published review ends with, and the comment-commands rollout check they depend on."""++from posthog.models.team import Team+from posthog.permissions import posthog_feature_flag_enabled++# The rollout flag of `@posthog` pull request comments (products/commands). Read here by key,+# because the commands product already depends on this product.+COMMENT_COMMANDS_FLAG = "github-commands"+++def comment_commands_enabled(team_id: int) -> bool:+ """Whether `@posthog` comments run for this project's organization, so the review may point to them."""+ organization_id = Team.objects.values_list("organization_id", flat=True).filter(id=team_id).first()+ if organization_id is None:+ return False+ return posthog_feature_flag_enabled(+ COMMENT_COMMANDS_FLAG, f"review-hog-team-{team_id}", organization_id=organization_id, team_id=team_id+ )+++def draft_review_notice(comment_commands_on: bool) -> str:+ """The note an automatic review of a draft ends with: the push gate skips the draft's later pushes."""+ trigger = "Comment `@posthog review`" if comment_commands_on else "Start a review in PostHog Review"+ return (+ "This is the only automatic review while this pull request is a draft. "+ f"{trigger} to review new changes sooner. "+ "Otherwise, a review of the new changes runs when you mark it ready for review."+ )+++def first_review_note(review_link: str, deep_command: bool) -> str:+ """The note the first review on a pull request ends with: where to see the review, and how to ask for Deep."""+ note = f"See this review and its findings in [PostHog Review]({review_link})."+ if deep_command:+ note = (+ f"{note} Comment `@posthog review --deep` for a Deep review. "+ "A Deep review takes longer and looks deeper than a Standard review."+ )+ return notediff --git a/products/review_hog/backend/reviewer/constants.py b/products/review_hog/backend/reviewer/constants.pyindex 6f695c8ead52..8e0f0f165b65 100644--- a/products/review_hog/backend/reviewer/constants.py+++ b/products/review_hog/backend/reviewer/constants.py@@ -328,14 +328,14 @@ _TIER_BY_PRIORITY: dict[ReportPriority, ReviewTier] = {}-# The trigger sources (`temporal/types.py`) that carry an explicit ask for a review: a label, the-# CLI, the Code review scene and its MCP tool (both stamped `ui`, so an agent driving the MCP+# The trigger sources (`temporal/types.py`) that carry an explicit ask for a review: a Stamphog handoff,+# the CLI, the Code review scene and its MCP tool (both stamped `ui`, so an agent driving the MCP# tool on someone's behalf counts as that person asking), or an `@posthog review` comment. Inbox# and automatic authored-PR triggers fire without a per-PR request. A trigger from this set on an inbox-created report lifts its tier# (`upsert_review_report`). Spelled out here because persistence cannot import the temporal# package (its `__init__` imports the activities, which import persistence); `test_constants.py`# locks the set to the trigger constants.-HUMAN_TRIGGER_SOURCES = frozenset({"label", "manual", "ui", "comment"})+HUMAN_TRIGGER_SOURCES = frozenset({"stamphog", "label", "manual", "ui", "comment"})def select_review_tier(*, agent_pr: bool, signal_priority: ReportPriority | None) -> ReviewTier:diff --git a/products/review_hog/backend/stamphog_handoff.py b/products/review_hog/backend/stamphog_handoff.pynew file mode 100644index 000000000000..364815ad9e8b--- /dev/null+++ b/products/review_hog/backend/stamphog_handoff.py@@ -0,0 +1,126 @@+"""The Stamphog handoff: Stamphog refused or escalated a self-driving pull request, so PostHog Review+reviews the head Stamphog judged. The review is Standard, or Deep once the pull request has a published+Deep review.++Stamphog calls the finished-review callback `receivers.py` registers, after the refusal wins its terminal+save. The callback queues a Celery task, and the task starts the review here.++- The review runs in the project that owns the repository (`ownership.py`), found by name. Stamphog's+ project and GitHub App installation play no part.+- It runs as the pull request owner (`pr_owner.py`). Without an owner it runs as the person who+ connected the installation, with default settings and no resolution.+- A head that already has a pending or completed review is not reviewed again.+"""++import logging+from typing import Literal++from prometheus_client import Counter++from posthog.dataclasses import frozen+from posthog.integrations import IntegrationManager+from posthog.otel_metrics import OtelInstrumentFactory++from products.review_hog.backend.automatic_reviews import connector_user_id+from products.review_hog.backend.facade.review_status_types import HeadReviewState+from products.review_hog.backend.head_review_status import HeadReviewStatusLookup+from products.review_hog.backend.ownership import RepositoryOwnership+from products.review_hog.backend.pr_owner import PullRequestOwnerResolver+from products.review_hog.backend.review_request_rules import trigger_review_mode+from products.review_hog.backend.reviewer.constants import REVIEW_MODE_FULL+from products.review_hog.backend.reviewer.persistence import lift_review_tier_for_joined_trigger++logger = logging.getLogger(__name__)+_otel = OtelInstrumentFactory("review_hog")++StamphogHandoffOutcome = Literal[+ "repository_not_added",+ "integration_missing",+ "head_already_reviewed",+ "no_run_user",+ "resolution_running",+ "started",+]++# The handoff answers nobody, so a skipped handoff leaves no trace on the pull request. This+# counter names why handoffs stopped starting reviews.+STAMPHOG_HANDOFF_TOTAL = Counter(+ "posthog_review_hog_stamphog_handoff_total",+ "Stamphog handoff decisions, keyed by outcome",+ labelnames=["outcome"],+)+++def _observe(outcome: StamphogHandoffOutcome) -> None:+ STAMPHOG_HANDOFF_TOTAL.labels(outcome=outcome).inc()+ _otel.record_counter_twin(STAMPHOG_HANDOFF_TOTAL, 1, {"outcome": outcome})+++@frozen+class StamphogHandoff:+ repository: str+ pr_number: int+ head_sha: str+ author_login: str+ # Stamphog reviews only same-repository pull requests, so the head branch is in the base repository.+ head_branch: str++ def start(self) -> None:+ # The temporal package registers the activities, which pull in the sandbox runtime.+ from products.review_hog.backend.temporal.client import ( # noqa: PLC0415+ start_review_pr_workflow,+ workflow_running,+ )+ from products.review_hog.backend.temporal.types import ( # noqa: PLC0415+ TRIGGER_STAMPHOG,+ resolve_pr_workflow_id,+ review_pr_workflow_id,+ )++ owner = RepositoryOwnership.find_by_name(self.repository)+ if owner is None:+ _observe("repository_not_added")+ return+ team_id = owner.team_id+ if not IntegrationManager.github.oauth.exists(team_id, external_id=owner.installation_id):+ _observe("integration_missing")+ return+ # A lookup that fails raises, so the task retries instead of reading an outage as "no review".+ status = HeadReviewStatusLookup(team_id, self.repository, self.pr_number, self.head_sha).status()+ if status is not None and status.state in (HeadReviewState.PENDING, HeadReviewState.COMPLETED):+ _observe("head_already_reviewed")+ return+ pr_owner = PullRequestOwnerResolver.resolve(+ team_id, repository=self.repository, author_login=self.author_login, head_branch=self.head_branch+ )+ run_user_id = pr_owner.user_id or connector_user_id(team_id=team_id, installation_id=owner.installation_id)+ if run_user_id is None:+ _observe("no_run_user")+ return+ github_owner, _, github_repo = self.repository.partition("/")+ # The busy-guard (CONTEXT.md): a review waits until this PR's resolution run is done.+ if workflow_running(+ resolve_pr_workflow_id(team_id=team_id, owner=github_owner, repo=github_repo, pr_number=self.pr_number)+ ):+ _observe("resolution_running")+ return+ # Probed before the start: a same-id start joins the running turn, whose inputs keep the+ # original trigger, so the handoff's tier lift has to be written here.+ joins_running_review = workflow_running(+ review_pr_workflow_id(team_id=team_id, owner=github_owner, repo=github_repo, pr_number=self.pr_number)+ )+ review_mode = trigger_review_mode(team_id, self.repository, self.pr_number)+ start_review_pr_workflow(+ pr_url=f"https://github.com/{self.repository}/pull/{self.pr_number}",+ team_id=team_id,+ user_id=run_user_id,+ publish=True,+ trigger_source=TRIGGER_STAMPHOG,+ review_mode=review_mode,+ requested_head_sha=self.head_sha,+ )+ # Standard is excluded for the same reason as on the comment path: the lift rewrites the+ # persisted arm, so the cheaper review must not raise what later turns cost.+ if joins_running_review and review_mode == REVIEW_MODE_FULL:+ lift_review_tier_for_joined_trigger(team_id=team_id, repository=self.repository, pr_number=self.pr_number)+ _observe("started")diff --git a/products/review_hog/backend/tasks/__init__.py b/products/review_hog/backend/tasks/__init__.pyindex a09d49ec54e8..9f6597944972 100644--- a/products/review_hog/backend/tasks/__init__.py+++ b/products/review_hog/backend/tasks/__init__.py@@ -1,2 +1,2 @@from products.review_hog.backend.tasks.tasks import * # noqa: F401,F403-from products.review_hog.backend.tasks.tasks import process_authored_pr_event, process_label_event # noqa: F401+from products.review_hog.backend.tasks.tasks import process_authored_pr_event, process_stamphog_handoff # noqa: F401diff --git a/products/review_hog/backend/tasks/tasks.py b/products/review_hog/backend/tasks/tasks.pyindex d9613a893326..d8951580e7bc 100644--- a/products/review_hog/backend/tasks/tasks.py+++ b/products/review_hog/backend/tasks/tasks.py@@ -1,7 +1,7 @@from celery import shared_taskfrom products.review_hog.backend.automatic_reviews import AuthoredPRReview-from products.review_hog.backend.label_reviews import LabelReview+from products.review_hog.backend.stamphog_handoff import StamphogHandoff@shared_task(@@ -50,26 +50,20 @@ def process_authored_pr_event(retry_backoff=True,retry_backoff_max=300,retry_jitter=True,- name="products.review_hog.backend.tasks.process_label_event",+ name="products.review_hog.backend.tasks.process_stamphog_handoff",)-def process_label_event(+def process_stamphog_handoff(*,- installation_id: str,repository: str,- github_repo_id: int | None,pr_number: int,+ head_sha: str,author_login: str,head_branch: str,- labeler_login: str,- labeled_by_bot: bool,) -> None:- LabelReview(- installation_id=installation_id,+ StamphogHandoff(repository=repository,- github_repo_id=github_repo_id,pr_number=pr_number,+ head_sha=head_sha,author_login=author_login,head_branch=head_branch,- labeler_login=labeler_login,- labeled_by_bot=labeled_by_bot,).start()diff --git a/products/review_hog/backend/temporal/activities.py b/products/review_hog/backend/temporal/activities.pyindex 37b59341b483..3561f690b421 100644--- a/products/review_hog/backend/temporal/activities.py+++ b/products/review_hog/backend/temporal/activities.py@@ -40,16 +40,11 @@ from products.review_hog.backend.app_identity import posthog_app_loginfrom products.review_hog.backend.automatic_reviews import automatic_flash_allowed, observe_dispatchfrom products.review_hog.backend.facade.enums import ReviewRequestRefusalfrom products.review_hog.backend.facade.finished_review_hooks import FinishedReview, get_finished_review_hooks-from products.review_hog.backend.label_reviews import (- comment_commands_enabled,- draft_review_notice,- first_review_note,- label_commands_hint,-)from products.review_hog.backend.models import ReviewProjectSettings, ReviewReport, ReviewUserSettingsfrom products.review_hog.backend.pr_owner import PullRequestOwnerResolverfrom products.review_hog.backend.preferences import ReviewPreferences-from products.review_hog.backend.pull_request_events import REVIEW_LABEL, has_skip_agent_review_label+from products.review_hog.backend.pull_request_events import has_skip_agent_review_label+from products.review_hog.backend.review_notes import comment_commands_enabled, draft_review_notice, first_review_notefrom products.review_hog.backend.review_request_rules import ResolutionGate, full_review_publishedfrom products.review_hog.backend.reviewer.artefact_content import ReviewIssueFinding, ValidationVerdictfrom products.review_hog.backend.reviewer.constants import (@@ -241,6 +236,7 @@ from products.review_hog.backend.temporal.types import (TRIGGER_AUTOMATIC,TRIGGER_LABEL,TRIGGER_MANUAL,+ TRIGGER_STAMPHOG,)from products.signals.backend.artefact_attribution import ArtefactAttributionfrom products.signals.backend.artefact_schemas import CodeReview, CodeReviewCounts@@ -374,9 +370,6 @@ class ResolveActingUserResult:acting_user_id: int | None# The acting user's preferences, snapshotted here so mid-run edits don't flip gates between# stages. Defaults match the code defaults (and cover payloads serialized before these existed).- # `review_labeled_prs` is always True: no setting turns the label trigger off. The field stays,- # because recorded workflow histories carry it and their replay still reads it.- review_labeled_prs: bool = Trueurgency_threshold: str = IssuePriority.CONSIDER.valuereview_inbox_prs: bool = False# Which chain link resolved: "author" | "default" | "override" (observability + tests).@@ -1070,9 +1063,9 @@ def _resolve_acting_user(input: ResolveActingUserInput) -> ResolveActingUserResuacting_user_id, resolved_from = input.override_user_id, "override"else:acting_user_id, resolved_from = owner.user_id, "author"- # Label-trigger fallback: someone explicitly asked for this review, so borrow the run user- # the trigger already resolved. Other triggers keep the owner-only contract and skip.- if acting_user_id is None and input.trigger_source == TRIGGER_LABEL:+ # Stamphog-handoff fallback: the review was explicitly asked for, so borrow the run user the+ # trigger already resolved. Other triggers keep the owner-only contract and skip.+ if acting_user_id is None and input.trigger_source in (TRIGGER_STAMPHOG, TRIGGER_LABEL):acting_user_id, resolved_from = input.default_user_id, "default"automatic_allowed = input.trigger_source == TRIGGER_AUTOMATIC and _automatic_review_allowed(input, acting_user_id)flash_after_full = _flash_after_full(input)@@ -1106,7 +1099,6 @@ def _resolve_acting_user(input: ResolveActingUserInput) -> ResolveActingUserResuresolution = ResolutionGate(owner_user_id=owner.user_id, owner_opted_in=owner_preferences.resolve_comments)return ResolveActingUserResult(acting_user_id=acting_user_id,- review_labeled_prs=True,# .value unwraps the TextChoices member, because the payload must hold the plain value.urgency_threshold=preferences.urgency_threshold.value,review_inbox_prs=preferences.review_inbox_prs,@@ -2182,20 +2174,16 @@ async def build_body_activity(input: BuildBodyInput) -> None:def _publish(input: PublishInput) -> PublishResult:token, installation_id = _installation_auth(input.team_id, f"{input.owner}/{input.repo}")commands_on = comment_commands_enabled(input.team_id)- footer = ""- if input.trigger_source == TRIGGER_LABEL and commands_on:- footer = label_commands_hint(input.review_mode)- # Only an automatic turn can promise the review on ready: a label or UI review runs for authors+ # Only an automatic turn can promise the review on ready: a comment or UI review runs for authors# without automatic reviews too. Only an automatic turn is held to the finding budget, too.draft_notice = ""comment_commands_on = Falseif input.trigger_source == TRIGGER_AUTOMATIC:comment_commands_on = commands_ondraft_notice = draft_review_notice(comment_commands_on)- # The label footer already names the Deep command.intro_note = first_review_note(report_deep_link(input.team_id, input.report_id),- deep_command=commands_on and input.review_mode == REVIEW_MODE_FLASH and not footer,+ deep_command=commands_on and input.review_mode == REVIEW_MODE_FLASH,)outcome = publish_persisted_review(team_id=input.team_id,@@ -2210,7 +2198,6 @@ def _publish(input: PublishInput) -> PublishResult:installation_id=installation_id,review_mode=input.review_mode,capped_lens_parts=input.capped_lens_parts,- footer=footer,draft_notice=draft_notice,first_review_note=intro_note,answers_request=input.trigger_source in REQUESTED_TRIGGERS,@@ -2245,12 +2232,15 @@ async def publish_review_activity(input: PublishInput) -> PublishResult:raise _wait_for_github_reset(error) from error+_LEGACY_REVIEW_LABEL = "posthog-review"++def _remove_trigger_label(input: RemoveTriggerLabelInput) -> None:token, installation_id = _installation_auth(input.team_id, f"{input.owner}/{input.repo}")try:github_api_request("DELETE",- f"/repos/{input.owner}/{input.repo}/issues/{input.pr_number}/labels/{REVIEW_LABEL}",+ f"/repos/{input.owner}/{input.repo}/issues/{input.pr_number}/labels/{_LEGACY_REVIEW_LABEL}",token=token,endpoint="/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}",installation_id=installation_id,@@ -2264,7 +2254,7 @@ def _remove_trigger_label(input: RemoveTriggerLabelInput) -> None:@scoped_temporal()@close_db_connectionsasync def remove_trigger_label_activity(input: RemoveTriggerLabelInput) -> None:- """Remove the review label that started a label-triggered review, if it is still present."""+ """Remove the review label of a label run started before the label trigger was removed."""await database_sync_to_async(_remove_trigger_label, thread_sensitive=False)(input)diff --git a/products/review_hog/backend/temporal/types.py b/products/review_hog/backend/temporal/types.pyindex 11a277d6eb94..a11f9f4be6d6 100644--- a/products/review_hog/backend/temporal/types.py+++ b/products/review_hog/backend/temporal/types.py@@ -9,18 +9,21 @@ from posthog.dataclasses import frozenfrom products.review_hog.backend.reviewer.constants import REVIEW_MODE_FULL# How a review run was triggered. Gates are trigger-aware: inbox → `review_inbox_prs`, automatic →-# the repository rules; label, manual (CLI/eval), ui (an explicit human ask from the Code review-# scene) and comment (an `@posthog review` pull request comment) → ungated. Plain strings (not an-# Enum) so Temporal payloads stay forward/backward-compatible across deploys.+# the repository rules; stamphog (a Stamphog refusal of a self-driving PR), manual (CLI/eval), ui+# (an explicit human ask from the Code review scene) and comment (an `@posthog review` pull request+# comment) → ungated. Plain strings (not an Enum) so Temporal payloads stay forward/backward-compatible+# across deploys.+TRIGGER_STAMPHOG = "stamphog"+# No new run uses it. Label runs started before the label trigger was removed still replay with it.TRIGGER_LABEL = "label"TRIGGER_INBOX = "inbox"TRIGGER_MANUAL = "manual"TRIGGER_UI = "ui"TRIGGER_COMMENT = "comment"TRIGGER_AUTOMATIC = "automatic"-# The triggers a person starts and then waits on for an answer. An inbox review comes from the signals-# agent, so it is not one of them.-REQUESTED_TRIGGERS = frozenset({TRIGGER_LABEL, TRIGGER_MANUAL, TRIGGER_UI, TRIGGER_COMMENT})+# The triggers that ask for a review and then wait on an answer. A Stamphog handoff counts, because+# Inbox triage reads the answer. An inbox review comes from the signals agent, so it is not one of them.+REQUESTED_TRIGGERS = frozenset({TRIGGER_STAMPHOG, TRIGGER_LABEL, TRIGGER_MANUAL, TRIGGER_UI, TRIGGER_COMMENT})@frozen@@ -53,7 +56,7 @@ class ReviewPRWorkflowInputs:pr_number: int | None = Nonepublish: bool = Falseacting_user_id: int | None = None- # Which trigger started this run (TRIGGER_LABEL / TRIGGER_INBOX / TRIGGER_MANUAL).+ # Which trigger started this run (TRIGGER_STAMPHOG / TRIGGER_INBOX / TRIGGER_MANUAL).trigger_source: str = TRIGGER_MANUAL# The signals report whose implementation this run reviews (inbox trigger only): stamped onto the# ReviewReport as provenance, and the target of the `code_review` artefact receipt.diff --git a/products/review_hog/backend/temporal/workflow.py b/products/review_hog/backend/temporal/workflow.pyindex a775800cf0a1..20f7aa892d64 100644--- a/products/review_hog/backend/temporal/workflow.py+++ b/products/review_hog/backend/temporal/workflow.py@@ -444,6 +444,7 @@ class ReviewPRWorkflow:raise ApplicationError(str(e), non_retryable=True, type=cause.type) from efinally:terminal = completed or non_retryable or _out_of_attempts()+ # Label run histories from before the deploy can hold a scheduled label removal; delete once they drain.if (workflow.patched("remove-reviewhog-trigger-label-2026-08")and terminal@@ -564,19 +565,9 @@ class ReviewPRWorkflow:return report_id# Trigger-aware opt-outs, read off the resolve-time settings snapshot (mid-run edits can't# flip gates). Inbox re-checks the receiver-side gate here for snapshot-at-resolve- # consistency. A label always runs, and manual stays ungated.- # Histories from before the patch recorded the label opt-out, so they replay its early return.- if (- inputs.trigger_source == TRIGGER_LABEL- and not workflow.patched("reviewhog-label-always-runs-2026-10")- and inputs.acting_user_id is None- and not acting.review_labeled_prs- ):- workflow.logger.info(- f"PR author '{meta.author_login}' (user {acting.acting_user_id}) has labeled-PR reviews "- "turned off; skipping review"- )- return report_id+ # consistency. A Stamphog handoff and manual stay ungated.+ # Histories that carry the patch marker replay with deprecate_patch; delete it once those runs drain.+ workflow.deprecate_patch("reviewhog-label-always-runs-2026-10")if inputs.trigger_source == TRIGGER_INBOX and not acting.review_inbox_prs:workflow.logger.info(f"Acting user {acting.acting_user_id} has inbox reviews turned off; skipping review")return report_iddiff --git a/products/review_hog/backend/tests/test_acting_user.py b/products/review_hog/backend/tests/test_acting_user.pyindex 9a8d4c48c889..d4981055e2d1 100644--- a/products/review_hog/backend/tests/test_acting_user.py+++ b/products/review_hog/backend/tests/test_acting_user.py@@ -14,7 +14,7 @@ from products.review_hog.backend.models import ()from products.review_hog.backend.reviewer.progress import run_outcome_markersfrom products.review_hog.backend.temporal.activities import ResolveActingUserInput, _resolve_acting_user-from products.review_hog.backend.temporal.types import TRIGGER_AUTOMATIC, TRIGGER_LABEL, TRIGGER_MANUAL+from products.review_hog.backend.temporal.types import TRIGGER_AUTOMATIC, TRIGGER_MANUAL, TRIGGER_STAMPHOG_SELF = "SELF"@@ -48,7 +48,6 @@ class TestResolveActingUser(BaseTest):result = _resolve_acting_user(ResolveActingUserInput(team_id=self.team.id, author_login="octocat", override_user_id=None))- assert result.review_labeled_prs is Trueassert result.review_inbox_prs is Falseassert result.urgency_threshold == "consider"assert result.resolve_comments is False@@ -67,7 +66,7 @@ class TestResolveActingUser(BaseTest):team_id=self.team.id,author_login="ghost",override_user_id=None,- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,default_user_id=self.user.id,))@@ -201,21 +200,21 @@ class TestResolveActingUser(BaseTest):assert result.resolve_comments is Trueassert result.celebrate_clean_reviews is False- def test_label_trigger_falls_back_to_the_run_user(self) -> None:- # Unmapped author on a labeled PR → the run user the trigger already resolved, passed- # through as default_user_id so acting and sandbox identity can never drift.+ def test_stamphog_handoff_falls_back_to_the_run_user(self) -> None:+ # Unmapped author → the run user the trigger already resolved, passed through as+ # default_user_id so acting and sandbox identity can never drift.result = _resolve_acting_user(ResolveActingUserInput(team_id=self.team.id,author_login="ghost",override_user_id=None,- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,default_user_id=self.user.id,))assert (result.acting_user_id, result.resolved_from) == (self.user.id, "default")- def test_non_label_triggers_keep_the_author_only_contract(self) -> None:+ def test_other_triggers_keep_the_author_only_contract(self) -> None:result = _resolve_acting_user(ResolveActingUserInput(team_id=self.team.id,@@ -236,7 +235,7 @@ class TestResolveActingUser(BaseTest):)as_author = _resolve_acting_user(ResolveActingUserInput(- team_id=self.team.id, author_login="octocat", override_user_id=None, trigger_source=TRIGGER_LABEL+ team_id=self.team.id, author_login="octocat", override_user_id=None, trigger_source=TRIGGER_STAMPHOG))assert as_author.resolved_from == "author"@@ -248,12 +247,11 @@ class TestResolveActingUser(BaseTest):team_id=self.team.id,author_login="ghost",override_user_id=None,- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,default_user_id=self.user.id,))assert (as_default.acting_user_id, as_default.resolved_from) == (self.user.id, "default")- assert as_default.review_labeled_prs is Trueassert as_default.resolve_comments is False# Same borrowed-user protection: the run user's own media preference never shapes# someone else's PR.@@ -271,7 +269,7 @@ class TestResolveActingUser(BaseTest):)as_author = _resolve_acting_user(ResolveActingUserInput(- team_id=self.team.id, author_login="octocat", override_user_id=None, trigger_source=TRIGGER_LABEL+ team_id=self.team.id, author_login="octocat", override_user_id=None, trigger_source=TRIGGER_STAMPHOG))assert (as_author.resolved_from, as_author.urgency_threshold) == ("author", "must_fix")@@ -282,14 +280,17 @@ class TestResolveActingUser(BaseTest):team_id=self.team.id,author_login="octocat",override_user_id=self.user.id,- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,))assert as_author_override.celebrate_clean_reviews is False# ...while an override by someone else (a UI requester on a teammate's PR) does not.as_override = _resolve_acting_user(ResolveActingUserInput(- team_id=self.team.id, author_login="ghost", override_user_id=self.user.id, trigger_source=TRIGGER_LABEL+ team_id=self.team.id,+ author_login="ghost",+ override_user_id=self.user.id,+ trigger_source=TRIGGER_STAMPHOG,))assert (as_override.resolved_from, as_override.urgency_threshold) == ("override", "must_fix")@@ -299,7 +300,7 @@ class TestResolveActingUser(BaseTest):team_id=self.team.id,author_login="ghost",override_user_id=None,- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,default_user_id=self.user.id,))diff --git a/products/review_hog/backend/tests/test_automatic_reviews.py b/products/review_hog/backend/tests/test_automatic_reviews.pyindex 57a0fa1502c8..4fe260686809 100644--- a/products/review_hog/backend/tests/test_automatic_reviews.py+++ b/products/review_hog/backend/tests/test_automatic_reviews.py@@ -1,6 +1,7 @@import hmacimport jsonfrom collections.abc import Mapping+from uuid import uuid4from posthog.test.base import BaseTestfrom unittest.mock import MagicMock, patch@@ -24,7 +25,7 @@ from posthog.models.organization import OrganizationMembershipfrom posthog.models.team import Teamfrom posthog.models.user import User-from products.review_hog.backend.label_reviews import BOT_LABEL_COMMENT+from products.review_hog.backend.facade.review_status_types import HeadReviewState, HeadReviewStatusfrom products.review_hog.backend.models import (ReviewInstallationClaim,ReviewProjectSettings,@@ -35,16 +36,17 @@ from products.review_hog.backend.models import ()from products.review_hog.backend.ownership import OwnedRepositoryPrefilterfrom products.review_hog.backend.pull_request_events import accept_pull_request_event-from products.review_hog.backend.reviewer.tools.github_client import GitHubAPIError-from products.review_hog.backend.tasks import process_authored_pr_event, process_label_event+from products.review_hog.backend.receivers import queue_stamphog_handoff+from products.review_hog.backend.tasks import process_authored_pr_event, process_stamphog_handofffrom products.review_hog.backend.webhook_consumers import WEBHOOK_CONSUMERS+from products.stamphog.backend.facade.enums import ReviewRunStatus, ReviewVerdict+from products.stamphog.backend.facade.finished_review_hooks import FinishedReviewRun_QUEUE = "products.review_hog.backend.tasks.process_authored_pr_event.delay"-_LABEL_QUEUE = "products.review_hog.backend.tasks.process_label_event.delay"+_HANDOFF_QUEUE = "products.review_hog.backend.tasks.process_stamphog_handoff.delay"_START = "products.review_hog.backend.temporal.client.start_review_pr_workflow"_BUSY = "products.review_hog.backend.temporal.client.workflow_running"-_GITHUB = "products.review_hog.backend.label_reviews.github_api_request"-_GITHUB_LIST = "products.review_hog.backend.label_reviews.github_api_get_paginated"+_HEAD_STATUS = "products.review_hog.backend.stamphog_handoff.HeadReviewStatusLookup.status"_SECRET = "test-review-hog-webhook-secret"_HEAD_SHA = "a" * 40_DISPATCH_METRIC = "posthog_review_hog_authored_pr_review_total"@@ -81,13 +83,11 @@ def _payload(}-def _label_payload(- *, label: str = "posthog-review", sender: str = "OctoCat", sender_type: str = "User", login: str = "OctoCat"-) -> dict[str, object]:+def _label_payload(label: str) -> dict[str, object]:return {- **_payload(action="labeled", login=login),+ **_payload(action="labeled"),"label": {"name": label},- "sender": {"login": sender, "type": sender_type},+ "sender": {"login": "OctoCat", "type": "User"},}@@ -218,46 +218,12 @@ class TestAuthoredPRWebhook(SimpleTestCase):assert enqueue.called == expected_enqueue- @parameterized.expand(- [- ("person_adds_the_label", "posthog-review", "OctoCat", "User", True),- ("person_adds_the_retired_label", "reviewhog", "OctoCat", "User", False),- ("label_name_ignores_case", "PostHog-Review", "OctoCat", "User", True),- # The task explains the refusal on the pull request and removes the label.- ("bot_adds_the_label", "posthog-review", "renovate[bot]", "Bot", True),- ("another_label", "bug", "OctoCat", "User", False),- ]- )+ @parameterized.expand([("review_label", "posthog-review"), ("legacy_label", "reviewhog")])@patch(_QUEUE)- @patch(_LABEL_QUEUE)- def test_a_review_label_queues_a_label_review(- self,- _name: str,- label: str,- sender: str,- sender_type: str,- expected_enqueue: bool,- label_enqueue: MagicMock,- enqueue: MagicMock,- ) -> None:- body = json.dumps(_label_payload(label=label, sender=sender, sender_type=sender_type)).encode()-- assert self._post(body).status_code == 202+ def test_a_review_label_starts_no_review(self, _name: str, label: str, enqueue: MagicMock) -> None:+ assert self._post(json.dumps(_label_payload(label)).encode()).status_code == 202enqueue.assert_not_called()- if expected_enqueue:- label_enqueue.assert_called_once_with(- installation_id=_INSTALLATION_ID,- repository="PostHog/posthog",- github_repo_id=_REPO_ID,- pr_number=42,- author_login="octocat",- head_branch="feature",- labeler_login=sender,- labeled_by_bot=sender_type == "Bot",- )- else:- label_enqueue.assert_not_called()@patch(_QUEUE)def test_non_post_does_not_enqueue(self, enqueue: MagicMock) -> None:@@ -461,7 +427,7 @@ class TestAuthoredPRReviewTask(BaseTest):start.assert_called_once_with(**self._expected_start(team_id=other_team.id, user_id=self.user.id))-class TestLabelReviewTask(BaseTest):+class TestStamphogHandoffTask(BaseTest):def setUp(self) -> None:super().setUp()self.connector = User.objects.create_and_join(self.organization, "[email protected]", None)@@ -482,37 +448,56 @@ class TestLabelReviewTask(BaseTest):team=self.team, installation_id=_INSTALLATION_ID, full_name="PostHog/posthog", selected=True)self.enterContext(patch(_BUSY, return_value=False))+ self.enterContext(patch(_HEAD_STATUS, return_value=None))self.start = self.enterContext(patch(_START))- self.github = self.enterContext(patch(_GITHUB))- self.github_comments = self.enterContext(patch(_GITHUB_LIST, return_value=[]))- self.enterContext(patch("products.review_hog.backend.label_reviews.GitHubIntegration.get_access_token"))- def _queued_event(self, payload: dict[str, object]) -> Mapping[str, object]:- with patch(_LABEL_QUEUE) as enqueue:- accept_pull_request_event(payload)+ def _finished(self, author_login: str, *, request_external_review: bool = True) -> FinishedReviewRun:+ return FinishedReviewRun(+ run_id=uuid4(),+ team_id=self.team.id + 1000,+ repository="PostHog/posthog",+ pr_number=42,+ status=ReviewRunStatus.COMPLETED,+ verdict=ReviewVerdict.REFUSED,+ head_sha=_HEAD_SHA,+ author_login=author_login,+ head_branch="feature",+ request_external_review=request_external_review,+ )++ def _queued_handoff(self, author_login: str) -> Mapping[str, object]:+ with patch(_HANDOFF_QUEUE) as enqueue:+ queue_stamphog_handoff(self._finished(author_login))enqueue.assert_called_once()return enqueue.call_args.kwargs- def _run(self, payload: dict[str, object]) -> None:- process_label_event.run(**self._queued_event(payload))+ def _run(self, author_login: str = "octocat") -> None:+ process_stamphog_handoff.run(**self._queued_handoff(author_login))- @parameterized.expand([("the_author_owns_it", "OctoCat", "author"), ("no_owner", "stranger", "connector")])- def test_a_label_review_runs_as_the_owner_else_as_the_connector(+ @parameterized.expand([("the_author_owns_it", "octocat", "author"), ("no_owner", "stranger", "connector")])+ def test_a_handoff_runs_as_the_owner_else_as_the_connector(self, _name: str, author_login: str, run_as: str) -> None:- self._run(_label_payload(login=author_login))+ self._run(author_login)self.start.assert_called_once_with(pr_url="https://github.com/PostHog/posthog/pull/42",team_id=self.team.id,user_id=self.user.id if run_as == "author" else self.connector.id,publish=True,- trigger_source="label",+ trigger_source="stamphog",review_mode="flash",+ requested_head_sha=_HEAD_SHA,)- def test_a_label_after_a_published_deep_review_runs_deep(self) -> None:- # A Standard request after a published Deep review is dropped, so the label would do nothing.+ def test_a_finished_run_that_asks_for_no_review_queues_nothing(self) -> None:+ with patch(_HANDOFF_QUEUE) as enqueue:+ queue_stamphog_handoff(self._finished("octocat", request_external_review=False))++ enqueue.assert_not_called()++ def test_a_handoff_after_a_published_deep_review_runs_deep(self) -> None:+ # A Standard request after a published Deep review is dropped, so the handoff would do nothing.ReviewReport.objects.for_team(self.team.id).create(team=self.team,repository="posthog/posthog",@@ -522,68 +507,39 @@ class TestLabelReviewTask(BaseTest):published_heads_by_mode={"full": _HEAD_SHA},)- self._run(_label_payload())+ self._run()assert self.start.call_args.kwargs["review_mode"] == "full"- @parameterized.expand(- [- ("another_bot", "posthog-review", "renovate[bot]", False),- ("stamphog_hands_off", "posthog-review", "stamphog[bot]", True),- ]- )- def test_only_stamphog_may_label_as_a_bot(self, _name: str, label: str, sender: str, starts: bool) -> None:- self._run(_label_payload(label=label, sender=sender, sender_type="Bot"))-- assert self.start.called == starts- calls = [(call.args[0], call.args[1]) for call in self.github.call_args_list]- if starts:- assert calls == []- else:- assert calls == [- ("DELETE", "/repos/PostHog/posthog/issues/42/labels/posthog-review"),- ("POST", "/repos/PostHog/posthog/issues/42/comments"),- ]-- def test_a_retried_bot_label_refusal_comments_once(self) -> None:- queued = self._queued_event(_label_payload(sender="renovate[bot]", sender_type="Bot"))- gone = GitHubAPIError("gone", status=404)- # The second POST fails after GitHub stored the comment, so the third run finds it and skips.- self.github.side_effect = [- GitHubAPIError("boom", status=502),- gone,- GitHubAPIError("boom", status=502),- gone,- ]- posted = {"body": BOT_LABEL_COMMENT, "user": {"login": "posthog[bot]", "type": "Bot"}}- self.github_comments.side_effect = [[], [posted]]-- for _ in range(2):- with self.assertRaises(GitHubAPIError):- process_label_event.run(**queued)- process_label_event.run(**queued)-- calls = [call.args[0] for call in self.github.call_args_list]- assert calls == ["DELETE", "DELETE", "POST", "DELETE"]- self.start.assert_not_called()-@parameterized.expand([("repository_not_added", "repository_not_added"),+ ("integration_missing", "integration_missing"),("no_run_user", "no_run_user"),+ ("head_pending", "head_already_reviewed"),+ ("head_completed", "head_already_reviewed"),])- def test_a_label_without_an_owning_project_or_run_user_starts_nothing(self, change: str, outcome: str) -> None:- queued = self._queued_event(_label_payload(login="stranger"))+ def test_a_handoff_that_has_nothing_to_start_starts_nothing(self, change: str, outcome: str) -> None:+ queued = self._queued_handoff("stranger")if change == "repository_not_added":self.repository.delete()- else:+ elif change == "integration_missing":+ self.integration.team = Team.objects.create(organization=self.organization)+ self.integration.save(update_fields=["team"])+ elif change == "no_run_user":self.integration.created_by = Noneself.integration.save(update_fields=["created_by"])- before = REGISTRY.get_sample_value("posthog_review_hog_label_review_total", {"outcome": outcome}) or 0.0+ else:+ state = HeadReviewState.PENDING if change == "head_pending" else HeadReviewState.COMPLETED+ status = HeadReviewStatus(+ state=state, review_kind="", findings_count=0, published=False, head_sha=_HEAD_SHA+ )+ self.enterContext(patch(_HEAD_STATUS, return_value=status))+ before = REGISTRY.get_sample_value("posthog_review_hog_stamphog_handoff_total", {"outcome": outcome}) or 0.0- process_label_event.run(**queued)+ process_stamphog_handoff.run(**queued)self.start.assert_not_called()- after = REGISTRY.get_sample_value("posthog_review_hog_label_review_total", {"outcome": outcome}) or 0.0+ after = REGISTRY.get_sample_value("posthog_review_hog_stamphog_handoff_total", {"outcome": outcome}) or 0.0assert after - before == 1.0diff --git a/products/review_hog/backend/tests/test_installation_auth.py b/products/review_hog/backend/tests/test_installation_auth.pyindex d89961292abc..682a5787e17e 100644--- a/products/review_hog/backend/tests/test_installation_auth.py+++ b/products/review_hog/backend/tests/test_installation_auth.py@@ -6,12 +6,7 @@ from temporalio.exceptions import ApplicationErrorfrom posthog.models.integration import Integration-from products.review_hog.backend.reviewer.tools.github_client import GitHubAPIError-from products.review_hog.backend.temporal.activities import (- RemoveTriggerLabelInput,- _installation_auth,- _remove_trigger_label,-)+from products.review_hog.backend.temporal.activities import _installation_auth# The true network boundary: first_for_team_repository probes GitHub with an authenticated# GET /repos/{repository} per candidate integration row.@@ -51,31 +46,3 @@ class TestInstallationAuth(BaseTest):_installation_auth(self.team.id, "PostHog/posthog")assert err.value.non_retryable is False---class TestRemoveTriggerLabel:- @patch("products.review_hog.backend.temporal.activities._installation_auth", return_value=("tok", "inst"))- @patch("products.review_hog.backend.temporal.activities.github_api_request")- def test_deletes_the_review_label(self, request: MagicMock, _auth: MagicMock) -> None:- _remove_trigger_label(RemoveTriggerLabelInput(team_id=1, owner="PostHog", repo="posthog", pr_number=7))-- assert [call.args for call in request.call_args_list] == [- ("DELETE", "/repos/PostHog/posthog/issues/7/labels/posthog-review"),- ]-- @patch("products.review_hog.backend.temporal.activities._installation_auth", return_value=("tok", "inst"))- @patch(- "products.review_hog.backend.temporal.activities.github_api_request",- side_effect=GitHubAPIError("not found", status=404),- )- def test_already_removed_label_is_success(self, _request: MagicMock, _auth: MagicMock) -> None:- _remove_trigger_label(RemoveTriggerLabelInput(team_id=1, owner="PostHog", repo="posthog", pr_number=7))-- @patch("products.review_hog.backend.temporal.activities._installation_auth", return_value=("tok", "inst"))- @patch(- "products.review_hog.backend.temporal.activities.github_api_request",- side_effect=GitHubAPIError("server error", status=500),- )- def test_other_github_errors_are_retried(self, _request: MagicMock, _auth: MagicMock) -> None:- with pytest.raises(GitHubAPIError, match="server error"):- _remove_trigger_label(RemoveTriggerLabelInput(team_id=1, owner="PostHog", repo="posthog", pr_number=7))diff --git a/products/review_hog/backend/tests/test_persistence.py b/products/review_hog/backend/tests/test_persistence.pyindex 303078380e28..0a1a6984bdae 100644--- a/products/review_hog/backend/tests/test_persistence.py+++ b/products/review_hog/backend/tests/test_persistence.py@@ -66,7 +66,7 @@ from products.review_hog.backend.reviewer.persistence import ()from products.review_hog.backend.reviewer.review_design import REVIEW_DESIGN_PIPELINE, REVIEW_DESIGN_SINGLE_AGENTfrom products.review_hog.backend.temporal.activities import SandboxStageInput, _prepare_single_agent_prompt-from products.review_hog.backend.temporal.types import TRIGGER_INBOX, TRIGGER_LABEL, TRIGGER_UI+from products.review_hog.backend.temporal.types import TRIGGER_INBOX, TRIGGER_STAMPHOG, TRIGGER_UIfrom products.signals.backend.artefact_attribution import ArtefactAttributionfrom products.signals.backend.artefact_schemas import Commitfrom products.signals.backend.enums import ReportPriority@@ -214,7 +214,7 @@ class TestUpsertReviewReport(BaseTest):repository="o/r",pr_url="u",pr_metadata=_pr_metadata(),- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,lift_tier_on_human_trigger=True,)assert self._routing(report_id) == ("human", "P2", "xhigh")@@ -251,7 +251,7 @@ class TestUpsertReviewReport(BaseTest):repository="o/r",pr_url="u",pr_metadata=_pr_metadata(),- trigger_source=TRIGGER_LABEL,+ trigger_source=TRIGGER_STAMPHOG,lift_tier_on_human_trigger=True,)# The unparseable value is left as-is: the lift is skipped rather than raising or relabeling.@@ -347,7 +347,7 @@ class TestUpsertReviewReport(BaseTest):trigger_source="inbox",)upsert_review_report(- team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata(), trigger_source="label"+ team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata(), trigger_source="stamphog")row = ReviewReport.objects.for_team(self.team.id).get(id=report_id)@@ -355,10 +355,10 @@ class TestUpsertReviewReport(BaseTest):assert row.trigger_source == "inbox"def test_provenance_backfills_only_when_missing(self) -> None:- # The reverse overlap: a label-created report later re-triggered by the inbox flow gains the+ # The reverse overlap: a Stamphog-created report later re-triggered by the inbox flow gains the# missing signal link but keeps its creating trigger.report_id = upsert_review_report(- team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata(), trigger_source="label"+ team_id=self.team.id, repository="o/r", pr_url="u", pr_metadata=_pr_metadata(), trigger_source="stamphog")signal_report_id = str(uuid.uuid4())upsert_review_report(@@ -372,7 +372,7 @@ class TestUpsertReviewReport(BaseTest):row = ReviewReport.objects.for_team(self.team.id).get(id=report_id)assert str(row.signal_report_id) == signal_report_id- assert row.trigger_source == "label"+ assert row.trigger_source == "stamphog"class TestPersistResults(BaseTest):diff --git a/products/review_hog/backend/tests/test_publish_idempotency.py b/products/review_hog/backend/tests/test_publish_idempotency.pyindex 49be26b6b16f..e69e8f03864a 100644--- a/products/review_hog/backend/tests/test_publish_idempotency.py+++ b/products/review_hog/backend/tests/test_publish_idempotency.py@@ -309,10 +309,17 @@ class TestPublishIdempotency(BaseTest):@parameterized.expand([("automatic_draft_with_commands", "automatic", True, True, "Comment `@posthog review` to review", False),- ("automatic_draft_without_commands", "automatic", True, False, "Add the `posthog-review` label to", False),+ (+ "automatic_draft_without_commands",+ "automatic",+ True,+ False,+ "Start a review in PostHog Review to",+ False,+ ),("automatic_ready", "automatic", False, True, None, False),- # A label review also runs for authors without automatic reviews, so it cannot promise one on ready.- ("label_draft", "label", True, True, None, True),+ # A Stamphog handoff also runs for authors without automatic reviews, so it cannot promise one on ready.+ ("stamphog_draft", "stamphog", True, True, None, True),("comment_ready", "comment", False, True, None, True),("ui_ready", "ui", False, True, None, True),("inbox_ready", "inbox", False, True, None, False),diff --git a/products/review_hog/backend/tests/test_review_activity.py b/products/review_hog/backend/tests/test_review_activity.pyindex 689ab44b6d70..1e635490e755 100644--- a/products/review_hog/backend/tests/test_review_activity.py+++ b/products/review_hog/backend/tests/test_review_activity.py@@ -887,20 +887,18 @@ async def test_a_standard_turn_scope_follows_its_trigger_and_run(@pytest.mark.parametrize(- "trigger_source,commands_on,review_mode,expected_hint,note_names_deep",+ "trigger_source,commands_on,review_mode,note_names_deep",[- # The label footer names the Deep command, so the first review note does not repeat it.- pytest.param("label", True, REVIEW_MODE_FLASH, "@posthog review --deep", False, id="label_with_commands"),- pytest.param("label", False, REVIEW_MODE_FLASH, None, False, id="label_without_commands"),- pytest.param("automatic", True, REVIEW_MODE_FLASH, None, True, id="automatic_standard"),- pytest.param("automatic", False, REVIEW_MODE_FLASH, None, False, id="automatic_without_commands"),- pytest.param("comment", True, REVIEW_MODE_FULL, None, False, id="deep_review"),+ pytest.param("stamphog", True, REVIEW_MODE_FLASH, True, id="stamphog_standard"),+ pytest.param("automatic", True, REVIEW_MODE_FLASH, True, id="automatic_standard"),+ pytest.param("automatic", False, REVIEW_MODE_FLASH, False, id="automatic_without_commands"),+ pytest.param("comment", True, REVIEW_MODE_FULL, False, id="deep_review"),],)def test_a_review_points_to_the_review_ui_and_the_comment_commands(- trigger_source: str, commands_on: bool, review_mode: str, expected_hint: str | None, note_names_deep: bool+ trigger_source: str, commands_on: bool, review_mode: str, note_names_deep: bool) -> None:- # The hint advertises `@posthog` commands, so it must not appear where they do not run or where nobody used the label.+ # The note advertises `@posthog` commands, so it must not appear where they do not run.publish = MagicMock(return_value=PublishOutcome(posted=True))with (patch(f"{_MODULE}._installation_auth", return_value=("token", "1")),@@ -922,8 +920,6 @@ def test_a_review_points_to_the_review_ui_and_the_comment_commands())- footer = publish.call_args.kwargs["footer"]- assert (expected_hint in footer) if expected_hint else footer == ""note = publish.call_args.kwargs["first_review_note"]assert "/project/1/code-review?review=rep-1" in noteassert ("@posthog review --deep" in note) is note_names_deepdiff --git a/products/review_hog/backend/tests/test_review_completed_tracking.py b/products/review_hog/backend/tests/test_review_completed_tracking.pyindex d1918158a12e..429850472425 100644--- a/products/review_hog/backend/tests/test_review_completed_tracking.py+++ b/products/review_hog/backend/tests/test_review_completed_tracking.py@@ -52,7 +52,7 @@ from products.review_hog.backend.temporal.activities import (_track_review_failed,_track_review_started,)-from products.review_hog.backend.temporal.types import TRIGGER_INBOX, TRIGGER_LABEL+from products.review_hog.backend.temporal.types import TRIGGER_INBOX, TRIGGER_STAMPHOGfrom products.signals.backend.enums import ReportPriority_PR_URL = "https://github.com/o/r/pull/7"@@ -771,7 +771,7 @@ class TestTrackReviewCompleted(BaseTest):)with patch("products.review_hog.backend.temporal.activities.posthoganalytics.capture") as capture:- _track_review_completed(self._tracking_input(report_id, turn_trigger_source=TRIGGER_LABEL))+ _track_review_completed(self._tracking_input(report_id, turn_trigger_source=TRIGGER_STAMPHOG))_track_review_failed(TrackReviewFailedInput(team_id=self.team.id, report_id=report_id, run_index=1, turn_trigger_source=TRIGGER_INBOX@@ -803,7 +803,7 @@ class TestTrackReviewCompleted(BaseTest):# reads them, so every event names them next to the reviewer arm.assert props["validator_model"] == VALIDATION_MODELassert props["validator_reasoning_effort"] == expected_validator_effort- assert completed.kwargs["properties"]["turn_trigger_source"] == "label"+ assert completed.kwargs["properties"]["turn_trigger_source"] == "stamphog"assert failed.kwargs["properties"]["turn_trigger_source"] == "inbox"assert started.kwargs["properties"]["turn_trigger_source"] == "inbox"# No snapshot for this head, so the draft state is unknown on both events that carry it.diff --git a/products/review_hog/backend/tests/test_temporal_workflow.py b/products/review_hog/backend/tests/test_temporal_workflow.pyindex 5eb2dfc24097..c089fcdd382a 100644--- a/products/review_hog/backend/tests/test_temporal_workflow.py+++ b/products/review_hog/backend/tests/test_temporal_workflow.py@@ -52,7 +52,6 @@ from products.review_hog.backend.temporal.activities import (LoadValidationInput,PublishInput,PublishResult,- RemoveTriggerLabelInput,ResolveActingUserResult,ReviewChunkInput,ReviewMeta,@@ -188,7 +187,6 @@ async def _run_full_review_pr_workflow(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).receipt_calls: list[tuple[str, str | None]] = []# The outcome edit of the PR status comment, as (urgency_threshold, resolved_from, review_url) —@@ -407,10 +405,6 @@ async def _run_full_review_pr_workflow(threshold_calls.append(("publish", input.urgency_threshold))return PublishResult(posted=publish_posts, review_url=_REVIEW_URL if publish_posts else None)- @activity.defn(name="remove_trigger_label_activity")- async def remove_label(input: RemoveTriggerLabelInput) -> None:- remove_label_calls.append(input.pr_number)-@activity.defn(name="append_code_review_artefact_activity")async def append_receipt(input: AppendCodeReviewArtefactInput) -> None:receipt_calls.append((input.outcome, input.review_url))@@ -528,7 +522,6 @@ async def _run_full_review_pr_workflow(validate_chunk,build_body,publish_act,- remove_label,append_receipt,post_status,finalize_status,@@ -588,7 +581,6 @@ async def _run_full_review_pr_workflow("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,"load_user_ids": load_user_ids,"thresholds": threshold_calls,@@ -742,20 +734,13 @@ def test_nudge_stamphog_raises_a_dispatch_error_so_temporal_retries_it():_nudge_stamphog(TurnEndedInput(repository="o/r", pr_number=7, head_sha="sha1"))-async def test_review_pr_workflow_removes_label_trigger_after_completion():- recorded = await _run_full_review_pr_workflow(publish=True, trigger_source="label")- assert recorded["remove_label"] == [7]--@pytest.mark.asyncio@pytest.mark.parametrize("review_mode", ["full", "flash"])-async def test_review_pr_workflow_removes_label_trigger_after_failure(review_mode: str):+async def test_review_pr_workflow_reports_a_failed_turn(review_mode: str):recorded = await _run_full_review_pr_workflow(- publish=True, trigger_source="label", fail_dedup=True, review_mode=review_mode+ publish=True, trigger_source="stamphog", fail_dedup=True, review_mode=review_mode)assert recorded["failed"] is True- assert recorded["remove_label"] == [7]# A Standard turn has no status comment, but its failure still returns the report to rest and# tells the PR. A dead turn must not leave its 👀 behind either.assert recorded["fail_status"] == [(review_mode, True, review_mode == "full")]@@ -786,20 +771,13 @@ async def test_review_pr_workflow_reports_a_failure_only_on_the_last_attempt(async def test_review_pr_workflow_does_not_retry_a_wave_over_the_failure_floor():recorded = await _run_full_review_pr_workflow(publish=True,- trigger_source="label",+ trigger_source="stamphog",fail_review_units=frozenset((p, c) for p in (1, 2, 3) for c in (1, 2)),workflow_max_attempts=2,)assert recorded["failed"] is Trueassert recorded["split"] == [1]assert len(recorded["review"]) == 6- assert recorded["remove_label"] == [7]---async def test_review_pr_workflow_does_not_remove_label_for_other_triggers():- recorded = await _run_full_review_pr_workflow(publish=True, trigger_source="manual")- assert recorded["remove_label"] == []@parameterized.expand(@@ -1022,7 +1000,7 @@ async def test_automatic_reviews_recheck_consent_and_skip_completed_or_closed_pr"trigger_source,reviewed_head,gate_skips,fail_gate,review_design,expected_gate,expected_review",[("automatic", None, True, False, "pipeline", [], True),- ("label", "sha0", True, False, "pipeline", [], True),+ ("stamphog", "sha0", True, False, "pipeline", [], True),("manual", "sha0", True, False, "pipeline", [], True),("automatic", "sha0", True, False, "pipeline", ["sha0"], False),("automatic", "sha0", False, False, "pipeline", ["sha0"], True),@@ -1087,8 +1065,8 @@ async def test_review_pr_workflow_skips_when_author_maps_to_no_user():@parameterized.expand([# (name, trigger_source, review_inbox_prs, input_acting_user_id, expect_ran)- # A label always runs, and the inbox toggle has no say over it.- ("label_ignores_inbox_toggle", "label", False, None, True),+ # A Stamphog handoff always runs, and the inbox toggle has no say over it.+ ("stamphog_ignores_inbox_toggle", "stamphog", False, None, True),# The inbox trigger honors only review_inbox_prs (default off = the budget gate); the# receiver always sets the acting override, so the override must NOT bypass this gate.("inbox_default_off_skips", "inbox", False, 3, False),diff --git a/products/review_hog/frontend/generated/api.schemas.ts b/products/review_hog/frontend/generated/api.schemas.tsindex 32d3acb90a88..c8f610e30549 100644--- a/products/review_hog/frontend/generated/api.schemas.ts+++ b/products/review_hog/frontend/generated/api.schemas.ts@@ -1557,7 +1557,7 @@ export interface ReviewUserSettingsApi {* * `flash` - On everywhere* * `off` - Off everywhere */default_review_mode?: DefaultReviewModeEnumApi- /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: the posthog-review label, an @posthog review comment, and the Review button still review drafts. */+ /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: an @posthog review comment and the Review button still review drafts. */review_drafts?: boolean/** After a Deep review of the user's pull requests is published, run the resolution stage: triage the unresolved review threads, implement the worth-and-safe fixes on the PR branch, and reply on every thread. Off by default. Personal only: no project default applies. */resolve_comments?: boolean@@ -1588,7 +1588,7 @@ export interface PatchedReviewUserSettingsApi {* * `flash` - On everywhere* * `off` - Off everywhere */default_review_mode?: DefaultReviewModeEnumApi- /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: the posthog-review label, an @posthog review comment, and the Review button still review drafts. */+ /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: an @posthog review comment and the Review button still review drafts. */review_drafts?: boolean/** After a Deep review of the user's pull requests is published, run the resolution stage: triage the unresolved review threads, implement the worth-and-safe fixes on the PR branch, and reply on every thread. Off by default. Personal only: no project default applies. */resolve_comments?: booleandiff --git a/products/review_hog/frontend/generated/api.zod.ts b/products/review_hog/frontend/generated/api.zod.tsindex 4bd0238ef7af..602557f27bc3 100644--- a/products/review_hog/frontend/generated/api.zod.ts+++ b/products/review_hog/frontend/generated/api.zod.ts@@ -251,7 +251,7 @@ export const ReviewHogSettingsPartialUpdateBody = /* @__PURE__ */ zod.object({.boolean().optional().describe(- "Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: the posthog-review label, an @posthog review comment, and the Review button still review drafts."+ "Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: an @posthog review comment and the Review button still review drafts."),resolve_comments: zod.boolean()diff --git a/products/review_hog/frontend/settings/DeepArea.tsx b/products/review_hog/frontend/settings/DeepArea.tsxindex 571e5a3f32cd..6b3998396a6f 100644--- a/products/review_hog/frontend/settings/DeepArea.tsx+++ b/products/review_hog/frontend/settings/DeepArea.tsx@@ -7,7 +7,7 @@ export function DeepArea(): JSX.Element {return (<SceneSectiontitle="Deep reviews"- description="Start with the Review button, the posthog-review label, or an Inbox report assigned to you. Uses the settings of whoever starts the review. Costs several times more than Standard."+ description="Start with the Review button, an @posthog review --deep comment, or an Inbox report assigned to you. Uses the settings of whoever starts the review. Costs several times more than Standard."><FullReviewSettingsSection /><ReviewSkillsPanel />diff --git a/products/stamphog/AGENTS.md b/products/stamphog/AGENTS.mdindex 7257fa8af1e3..0d0685df3d1d 100644--- a/products/stamphog/AGENTS.md+++ b/products/stamphog/AGENTS.md@@ -171,8 +171,8 @@ narrow:- These runs bypass the review-mode and author-write-permission gates: the reviewers' toggle isthe gate, and the App's machine user is not a collaborator (the permission lookup would alwaysdeny). `review_mode` keeps governing human PRs only.-- A refused or escalated verdict hands the PR to ReviewHog (`post_verdict` adds the `posthog-review`- label) **only** for these runs. A human author reads their own refusal and decides what comes next.+- A refused or escalated verdict hands the PR to ReviewHog (`post_verdict` sets `request_external_review` on the+ `FinishedReviewRun` it passes to the hooks in `facade/finished_review_hooks.py`) **only** for these runs. A human author reads their own refusal and decides what comes next.A self-driving PR has no such author, and its refusal otherwise sits unread until Inbox triage.In ALL mode an unconditional handoff also fires a second bot review on every PR the repo opens.The condition is the derived `ReviewTrigger`, not the raw provenance flag, so it stays aligned withdiff --git a/products/stamphog/backend/facade/finished_review_hooks.py b/products/stamphog/backend/facade/finished_review_hooks.pyindex e9b15f683324..726d2c442f5b 100644--- a/products/stamphog/backend/facade/finished_review_hooks.py+++ b/products/stamphog/backend/facade/finished_review_hooks.py@@ -30,6 +30,11 @@ class FinishedReviewRun:pr_number: intstatus: ReviewRunStatusverdict: ReviewVerdict+ head_sha: str+ author_login: str+ head_branch: str+ # Not read off `verdict`, because a gate-blocked refusal stores WAIT.+ request_external_review: boolFinishedReviewHook = Callable[[FinishedReviewRun], None]diff --git a/products/stamphog/backend/logic/github_client.py b/products/stamphog/backend/logic/github_client.pyindex b10dec0c5950..5a5b8fa2a7e9 100644--- a/products/stamphog/backend/logic/github_client.py+++ b/products/stamphog/backend/logic/github_client.py@@ -1392,35 +1392,6 @@ class StamphogGitHubClient:status_code=response.status_code,)- def add_pr_label(self, repo: str, number: int, label: str) -> None:- """Add a label to a PR (``POST .../issues/{number}/labels``).-- A 404 (repo not found) or 422 (label does not exist on the repo) is swallowed, so a vendored- stamphog in another repo never raises over a label — e.g. ``posthog-review`` — that isn't set up- there. Any other non-success raises ``StamphogGitHubError``; see ``post_verdict`` for how the- ReviewHog handoff caller treats that as best-effort.- """- path = f"/repos/{repo}/issues/{number}/labels"- response = self._request(- "POST",- path,- endpoint="/repos/{owner}/{repo}/issues/{issue_number}/labels",- json_body={"labels": [label]},- )- if response.status_code in (404, 422):- logger.info(- "stamphog github: reviewhog label unavailable on repo, skipping handoff",- repo=repo,- pr_number=number,- status_code=response.status_code,- )- return- if response.status_code not in (200, 201):- raise StamphogGitHubError(- f"Failed to add label to {repo}#{number}: {response.text[:200]}",- status_code=response.status_code,- )-def create_label(self, repo: str, name: str, *, color: str, description: str) -> bool:"""Create a repository label (``POST /repos/{repo}/labels``). Returns whether GitHub created it.diff --git a/products/stamphog/backend/temporal/activities.py b/products/stamphog/backend/temporal/activities.pyindex 09d12aef3ebf..8043f0692635 100644--- a/products/stamphog/backend/temporal/activities.py+++ b/products/stamphog/backend/temporal/activities.py@@ -111,7 +111,6 @@ from products.stamphog.backend.temporal.constants import (STAMPHOG_OPTIONAL_POLICY_PATHS,STAMPHOG_POLICY_ENTRYPOINT,STAMPHOG_POLICY_PATHS,- STAMPHOG_REVIEWHOG_LABEL,STAMPHOG_SANDBOX_CONTEXT_PATH,STAMPHOG_SANDBOX_ENGINE_DIR,STAMPHOG_SANDBOX_GATEWAY_TOKEN_PATH,@@ -1925,34 +1924,19 @@ def post_verdict(input: StamphogReviewInput) -> dict:return {"verdict": "skipped_superseded"}# Right after the save wins: the GitHub steps below can still fail the activity, and the- # outcome must not wait on them.- _notify_finished_review(run, input.team_id, ReviewRunStatus(run.status))-- # Hand a refused/escalated PR to ReviewHog only AFTER the refusal verdict wins the terminal save- # above — running it before would trigger ReviewHog for a stale refusal that a superseding delivery- # then overrode (a newer run might approve the same head). Adding the ReviewHog trigger label starts- # its review (ReviewHog's label consumer accepts stamphog[bot] as a labeler and strips other bots' labels).- #- # Only self-driving runs hand off. A human PR has an author who reads the refusal and decides what- # to do about it, and in ALL mode the handoff would fire on PRs nobody asked stamphog to look at.- # A self-driving PR has no such author — the refusal sits unread until Inbox triage — so ReviewHog's- # deeper review is the next step rather than a second unrequested opinion.+ # outcome must not wait on them. Running it before the save would hand a stale refusal to+ # ReviewHog after a superseding delivery overrode it (a newer run might approve the same head).#- # This is a secondary, cross-product notification that must never jeopardize the verdict — the- # refusal is already durably saved, so it is single-shot best-effort: catching every exception (not- # just StamphogGitHubError) contains the client's own errors plus the GitHubRateLimitError /- # requests.RequestException the egress layer raises on rate limits and network blips, neither a- # subclass of StamphogGitHubError. The sticky upsert above is idempotent, so a missed handoff is a- # missed handoff, not corruption.- if is_refusal and trigger == ReviewTrigger.SELF_DRIVING.value:- try:- client.add_pr_label(repo, pull_request.pr_number, STAMPHOG_REVIEWHOG_LABEL)- except Exception:- # Format repo/pr into the message — activity.logger is a stdlib LoggerAdapter that- # raises TypeError on arbitrary kwargs, which would escape this best-effort catch.- activity.logger.exception(- f"stamphog: reviewhog handoff failed for {repo}#{pull_request.pr_number}; verdict still posted"- )+ # Only a self-driving refusal asks for an external review. A human PR has an author who reads the+ # refusal and decides what to do about it, and in ALL mode the handoff would fire on PRs nobody+ # asked stamphog to look at. A self-driving PR has no such author — the refusal sits unread until+ # Inbox triage — so ReviewHog's deeper review is the next step rather than a second unrequested opinion.+ _notify_finished_review(+ run,+ input.team_id,+ ReviewRunStatus(run.status),+ request_external_review=is_refusal and trigger == ReviewTrigger.SELF_DRIVING.value,+ )# Close the merge-before-approval race only AFTER this run's APPROVED verdict is durably saved. If# the PR auto-merged the instant GitHub recorded the approval, the closed webhook may run before this@@ -1978,7 +1962,9 @@ def post_verdict(input: StamphogReviewInput) -> dict:return {"verdict": str(parsed.verdict), "waited_on_external_review": _waited_on_external_review(run)}-def _notify_finished_review(run: ReviewRun, team_id: int, status: ReviewRunStatus) -> None:+def _notify_finished_review(+ run: ReviewRun, team_id: int, status: ReviewRunStatus, *, request_external_review: bool = False+) -> None:"""Tell the registered callbacks the outcome the run just saved. Called after the terminal save."""pull_request = run.pull_requestfinished = FinishedReviewRun(@@ -1988,6 +1974,10 @@ def _notify_finished_review(run: ReviewRun, team_id: int, status: ReviewRunStatupr_number=pull_request.pr_number,status=status,verdict=ReviewVerdict(run.verdict),+ head_sha=run.head_sha,+ author_login=pull_request.author_login,+ head_branch=pull_request.head_branch,+ request_external_review=request_external_review,)for hook in get_finished_review_hooks():# A callback belongs to another product, and the outcome is already saved and posted.diff --git a/products/stamphog/backend/temporal/constants.py b/products/stamphog/backend/temporal/constants.pyindex 42a4dad150a0..bbae45a83f2b 100644--- a/products/stamphog/backend/temporal/constants.py+++ b/products/stamphog/backend/temporal/constants.py@@ -38,10 +38,6 @@ STAMPHOG_BOT_EYES_MAX_AGE_SECONDS = 45 * 60STAMPHOG_BOT_REVIEW_POLL_SECONDS = 30STAMPHOG_BOT_REVIEW_MAX_POLLS = 10 # ~300s budget at 30s per poll, matching the engine's wait budget-# The GitHub label Stamphog adds to hand a refused/escalated PR to ReviewHog. ReviewHog's `labeled`-# webhook consumer starts a review for it (stamphog[bot] is the one bot it accepts as a labeler).-# Kept here so the activity references the same scalar ReviewHog gates on.-STAMPHOG_REVIEWHOG_LABEL = "posthog-review"# The owners-yaml resolver package, expected by the engine as a sibling of its own dir# (gates.py resolves `../owners` for the hogli-resolver ownership format). This stays a sibling of# the engine dir although the monorepo source moved to packages/owners-yaml, because downstream reposdiff --git a/products/stamphog/backend/tests/fakes.py b/products/stamphog/backend/tests/fakes.pyindex 4a3bb29c8559..5abcce612d29 100644--- a/products/stamphog/backend/tests/fakes.py+++ b/products/stamphog/backend/tests/fakes.py@@ -108,7 +108,6 @@ _ISSUE_COMMENTS_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/issues/(?P<numbe_COMMENT_PATCH_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/issues/comments/(?P<cid>\d+)$")_DISMISS_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/pulls/(?P<number>\d+)/reviews/(?P<rid>\d+)/dismissals$")_LABEL_DELETE_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/issues/(?P<number>\d+)/labels/(?P<label>[^/]+)$")-_LABEL_ADD_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/issues/(?P<number>\d+)/labels$")_CONTENTS_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/contents/(?P<path>.+)$")_CHECK_RUNS_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/commits/(?P<sha>[^/]+)/check-runs$")_COLLABORATOR_PERMISSION_RE = re.compile(r"^/repos/(?P<repo>[^/]+/[^/]+)/collaborators/(?P<username>[^/]+)/permission$")@@ -172,12 +171,6 @@ class GitHubRecorder:# Test hook: force every reaction POST to return this response (e.g. a 500) to# exercise the client's fail-open path without monkeypatching bound methods.self.reaction_response_override: FakeResponse | None = None- # Test hook: force every label-add POST to return this response (e.g. a 422 for a label that- # does not exist on the repo) to exercise the handoff's best-effort swallow path.- self.add_label_response_override: FakeResponse | None = None- # Test hook: raise this exception from the label-add POST (e.g. GitHubRateLimitError) to- # exercise the best-effort catch for exception types the client does not raise itself.- self.add_label_side_effect: Exception | None = None# Set to make posting a COMMENT review blow up, e.g. a rate limit on the failure notice.self.comment_review_side_effect: Exception | None = Noneself.teams_by_login: dict[str, list[str]] = {}@@ -278,8 +271,6 @@ class GitHubRecorder:return self._record_write("issue_comment_edit", m.group("repo"), 0, json_body)if method == "PUT" and (m := _DISMISS_RE.match(path)):return self._dismiss_review(m.group("repo"), int(m.group("number")), int(m.group("rid")), json_body)- if method == "POST" and (m := _LABEL_ADD_RE.match(path)):- return self._add_label(m.group("repo"), int(m.group("number")), json_body)if method == "DELETE" and (m := _LABEL_DELETE_RE.match(path)):return self._remove_label(m.group("repo"), int(m.group("number")), m.group("label"))@@ -424,19 +415,6 @@ class GitHubRecorder:self.github_writes.append({"kind": "remove_label", "repo": repo, "number": number, "label": label})return FakeResponse(200, json_data=[])- def _add_label(self, repo: str, number: int, body: dict | None) -> FakeResponse:- labels = (body or {}).get("labels", [])- self.github_writes.append({"kind": "add_label", "repo": repo, "number": number, "labels": labels})- # A side effect set by the test simulates the egress layer raising before the response is- # returned — a GitHubRateLimitError (the real raise_if_github_rate_limited is stubbed to a- # no-op in the chain, so the rate-limit path is otherwise unreachable in tests) or a- # requests.RequestException on a network blip. Exercises the handoff's best-effort catch.- if self.add_label_side_effect is not None:- raise self.add_label_side_effect- if self.add_label_response_override is not None:- return self.add_label_response_override- return FakeResponse(200, json_data=[{"name": n} for n in labels])-def _dismiss_review(self, repo: str, number: int, review_id: int, body: dict | None) -> FakeResponse:self.github_writes.append({"kind": "dismiss_review", "repo": repo, "number": number, "review_id": review_id, "body": body or {}}diff --git a/products/stamphog/backend/tests/test_integration.py b/products/stamphog/backend/tests/test_integration.pyindex a8dcc2e804da..a16b69e0997d 100644--- a/products/stamphog/backend/tests/test_integration.py+++ b/products/stamphog/backend/tests/test_integration.py@@ -31,6 +31,7 @@ from products.stamphog.backend.facade.enums import (ReviewRunStatus,ReviewVerdict,)+from products.stamphog.backend.facade.finished_review_hooks import FinishedReviewRunfrom products.stamphog.backend.facade.review_evidence import ReviewEvidence, ReviewEvidenceProvider, ReviewEvidenceStatefrom products.stamphog.backend.logic.channel_resolution import (RoutingContext,@@ -201,8 +202,21 @@ def _make_pr_with_review(return pull_request+def handoff():+ hook = MagicMock()+ with patch(FINISHED_REVIEW_HOOKS, return_value=(hook,)):+ yield hook+++def _external_review_requests(hook: MagicMock) -> list[FinishedReviewRun]:+ return [c.args[0] for c in hook.call_args_list if c.args[0].request_external_review]++@pytest.mark.django_db(databases=PRODUCT_DATABASES)-def test_signed_webhook_drives_review_and_posts_approval(team, stamphog_chain: StamphogChain) -> None:+def test_signed_webhook_drives_review_and_posts_approval(+ team, stamphog_chain: StamphogChain, handoff: MagicMock+) -> None:# Regression guard: the webhook -> capture -> review -> post chain wiring. A signed opened# delivery must create the PR + ReviewRun, run the review activities, and post an APPROVE# review to GitHub pinned to the reviewed head SHA.@@ -293,8 +307,8 @@ def test_signed_webhook_drives_review_and_posts_approval(team, stamphog_chain: Sassert len(additions) == 1assert [r["reaction_id"] for r in removals] == [additions[0]["id"]]- # An APPROVED verdict never hands off to ReviewHog — the posthog-review label is a refusal-only signal.- assert [w for w in recorder.github_writes if w["kind"] == "add_label"] == []+ # An APPROVED verdict never hands off to ReviewHog — the handoff is a refusal-only signal.+ assert _external_review_requests(handoff) == []def _api_file(filename: str) -> dict:@@ -2181,7 +2195,7 @@ def _refused_engine_output() -> str:)@pytest.mark.django_db(databases=PRODUCT_DATABASES)def test_refused_verdict_strips_trigger_label_only_in_label_mode(- team, stamphog_chain: StamphogChain, review_mode: ReviewMode, expect_strip: bool+ team, stamphog_chain: StamphogChain, handoff: MagicMock, review_mode: ReviewMode, expect_strip: bool) -> None:# Action parity: in label-triggered mode a refusal removes the trigger label so the author# explicitly re-requests the next review; in ALL mode labels are never touched.@@ -2214,7 +2228,7 @@ def test_refused_verdict_strips_trigger_label_only_in_label_mode(# Neither mode hands off to ReviewHog: this PR has a human author who reads the refusal, so a# second unrequested bot review is not stamphog's call to make. Only self-driving runs hand off# (test_refused_verdict_hands_off_to_reviewhog_only_when_self_driving).- assert [w for w in stamphog_chain.recorder.github_writes if w["kind"] == "add_label"] == []+ assert _external_review_requests(handoff) == []@pytest.mark.parametrize(@@ -2236,6 +2250,7 @@ def test_refused_verdict_strips_trigger_label_only_in_label_mode(def test_refused_verdict_hands_off_to_reviewhog_only_when_self_driving(team,stamphog_chain: StamphogChain,+ handoff: MagicMock,review_mode: ReviewMode,inbox_review: dict | None,expect_handoff: bool,@@ -2267,46 +2282,23 @@ def test_refused_verdict_hands_off_to_reviewhog_only_when_self_driving(run.refresh_from_db()assert run.verdict == ReviewVerdict.REFUSED- label_adds = [w for w in stamphog_chain.recorder.github_writes if w["kind"] == "add_label"]- expected = [{"kind": "add_label", "repo": REPO, "number": 101, "labels": ["posthog-review"]}]- assert label_adds == (expected if expect_handoff else [])+ requests = [(r.repository, r.pr_number, r.head_sha) for r in _external_review_requests(handoff)]+ assert requests == ([(REPO, 101, head_sha)] if expect_handoff else [])- "fault",- [- # The client swallows a 422 (label missing on the repo) itself; a 500 raises StamphogGitHubError.- pytest.param(422, id="swallows_missing_label"),- pytest.param(500, id="client_raises_on_500"),- # The egress layer raises these directly — not subclasses of StamphogGitHubError, so a narrow- # except would let them escape post_verdict and skip the durable verdict save below.- pytest.param(GitHubRateLimitError("secondary rate limit"), id="rate_limit_does_not_escape"),- pytest.param(requests.ConnectionError("network blip"), id="network_error_does_not_escape"),- ],-)@pytest.mark.django_db(databases=PRODUCT_DATABASES)def test_refused_verdict_lands_even_when_reviewhog_handoff_fails(- team,- stamphog_chain: StamphogChain,- fault: int | Exception,+ team, stamphog_chain: StamphogChain, handoff: MagicMock) -> None:# The ReviewHog handoff is a secondary, cross-product notification that runs AFTER the durable- # terminal save, so the refusal itself is never at risk — it's already committed by the time the- # handoff fires. Left uncaught, though, the exception would fail the activity and trigger a retry,- # re-running already-succeeded side effects (posting the sticky comment, stripping the trigger- # label) even though the verdict is saved; catching it keeps the handoff single-shot best-effort.- # A 422 is swallowed inside the client; a 500 raises StamphogGitHubError; a rate limit raises- # GitHubRateLimitError and a network blip raises requests.RequestException from the egress layer.- # All four must leave the run COMPLETED + REFUSED, not FAILED. The latter two are the regression:- # they are not subclasses of StamphogGitHubError, so only a broad catch at the call site contains- # them. The run carries inbox provenance because only a self-driving refusal reaches the handoff.+ # terminal save, so the refusal itself is never at risk. Left uncaught, though, the hook's exception+ # would fail the activity and trigger a retry, re-running already-succeeded side effects (posting+ # the sticky comment, stripping the trigger label). The run carries inbox provenance because only a+ # self-driving refusal reaches the handoff.repo_config = _repo_config(team.id)head_sha = "sha-refused-handoff"stamphog_chain.recorder.register_pr(REPO, 101, _pr_object(101, "devex-dev", head_sha))- if isinstance(fault, Exception):- stamphog_chain.recorder.add_label_side_effect = fault- else:- stamphog_chain.recorder.add_label_response_override = fakes.FakeResponse(fault, text="handoff failure")+ handoff.side_effect = RuntimeError("handoff failure")pull_request = PullRequest.objects.for_team(team.id).create(team_id=team.id, repo_config=repo_config, pr_number=101, author_login="devex-dev")@@ -2326,11 +2318,13 @@ def test_refused_verdict_lands_even_when_reviewhog_handoff_fails(@pytest.mark.django_db(databases=PRODUCT_DATABASES)-def test_superseded_refusal_does_not_hand_off_to_reviewhog(team, stamphog_chain: StamphogChain) -> None:+def test_superseded_refusal_does_not_hand_off_to_reviewhog(+ team, stamphog_chain: StamphogChain, handoff: MagicMock+) -> None:# The ReviewHog handoff runs AFTER the conditional terminal save, so a refusal that loses the save# to a supersession (a synchronize/re-review delivery landing between the head guard and the save)# must not trigger ReviewHog for the stale refusal — a newer run may approve the same head. The run- # returns skipped_superseded and the posthog-review label is never added. The run carries inbox+ # returns skipped_superseded and the handoff never runs. The run carries inbox# provenance so the supersession is what blocks the handoff, not the self-driving-only condition.repo_config = _repo_config(team.id)head_sha = "sha-refused-superseded"@@ -2359,7 +2353,7 @@ def test_superseded_refusal_does_not_hand_off_to_reviewhog(team, stamphog_chain:result = _run_activity(post_verdict, StamphogReviewInput(review_run_id=str(run.id), team_id=team.id))assert result == {"verdict": "skipped_superseded"}- assert [w for w in stamphog_chain.recorder.github_writes if w["kind"] == "add_label"] == []+ handoff.assert_not_called()@pytest.mark.parametrize(diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex afa4a139043e..409cc43befe2 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -92216,7 +92216,7 @@ export namespace Schemas {* * `flash` - On everywhere* * `off` - Off everywhere */default_review_mode?: DefaultReviewModeEnum;- /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: the posthog-review label, an @posthog review comment, and the Review button still review drafts. */+ /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: an @posthog review comment and the Review button still review drafts. */review_drafts?: boolean;/** After a Deep review of the user's pull requests is published, run the resolution stage: triage the unresolved review threads, implement the worth-and-safe fixes on the PR branch, and reply on every thread. Off by default. Personal only: no project default applies. */resolve_comments?: boolean;@@ -106808,7 +106808,7 @@ export namespace Schemas {* * `flash` - On everywhere* * `off` - Off everywhere */default_review_mode?: DefaultReviewModeEnum;- /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: the posthog-review label, an @posthog review comment, and the Review button still review drafts. */+ /** Give the user's draft pull requests automatic reviews. On by default. When off, a draft gets its first automatic review when it is marked ready for review. Applies to automatic reviews only: an @posthog review comment and the Review button still review drafts. */review_drafts?: boolean;/** After a Deep review of the user's pull requests is published, run the resolution stage: triage the unresolved review threads, implement the worth-and-safe fixes on the PR branch, and reply on every thread. Off by default. Personal only: no project default applies. */resolve_comments?: boolean;