: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
chore(stamphog): post approval as app with comment plus bare token approval (#70069)
Julian Bezc85193353c7d
diff --git a/.github/workflows/pr-approval-agent.yml b/.github/workflows/pr-approval-agent.ymlindex 8146e2269a22..88f42e6e3188 100644--- a/.github/workflows/pr-approval-agent.yml+++ b/.github/workflows/pr-approval-agent.yml@@ -90,9 +90,14 @@ jobs:- name: Post reviewif: always()env:- # Use GITHUB_TOKEN for approvals so github-actions[bot] is the- # reviewer — its approvals count toward branch protection rules,- # unlike GitHub App bot approvals which show author_association NONE.+ # Approvals are posted twice, on purpose. The Stamphog app+ # (GH_TOKEN) posts the review body as an approval so the+ # human-facing feedback carries the bot's own identity;+ # github-actions[bot] (GH_TOKEN_APPROVE) posts a second,+ # bodyless approval. We keep both while we confirm which+ # identity's approval actually counts toward branch protection+ # — GitHub App bot approvals have shown author_association NONE.+ # If the github-actions[bot] one proves redundant, drop it.GH_TOKEN_APPROVE: ${{ github.token }}GH_TOKEN: ${{ steps.app-token.outputs.token }}# Derived from the token step so the sticky-comment author@@ -117,11 +122,24 @@ jobs:fiif [ "$VERDICT" = "APPROVED" ]; then- GH_TOKEN="$GH_TOKEN_APPROVE" gh api \+ # Stamphog app approval, carrying the review body. Best-effort:+ # the step runs under `set -e`, so a failure here (e.g. the App+ # install missing Pull-requests write, or a transient error)+ # would otherwise abort before the github-actions[bot] approval+ # below — the identity currently known to unblock PRs. Keep it+ # non-fatal and surface the failure as a warning instead.+ gh api \-X POST "repos/$REPO/pulls/$PR/reviews" \"${SHA_ARGS[@]}" \-f event=APPROVE \- -f body="$REASONING"+ -f body="$REASONING" \+ || echo "::warning::stamphog app approval failed to post; continuing with the github-actions[bot] approval"+ # Bodyless github-actions[bot] approval — kept alongside the+ # app approval until we've confirmed which one unblocks PRs.+ GH_TOKEN="$GH_TOKEN_APPROVE" gh api \+ -X POST "repos/$REPO/pulls/$PR/reviews" \+ "${SHA_ARGS[@]}" \+ -f event=APPROVEelse# Non-approve verdicts share ONE sticky comment, updated in# place, instead of a fresh COMMENT review per run. Review@@ -346,7 +364,7 @@ jobs:steps:- name: Dismiss stale bot approvalsenv:- # Same identity (github-actions[bot]) that posted the approval.+ # github.token can dismiss both bot identities' approvals.GH_TOKEN: ${{ github.token }}PR: ${{ github.event.pull_request.number }}REPO: ${{ github.repository }}@@ -354,11 +372,13 @@ jobs:run: |set -euo pipefail- # Only dismiss APPROVED reviews made by github-actions[bot] —- # human reviews and non-approval reviews are untouched.+ # Dismiss APPROVED reviews from either Stamphog identity —+ # github-actions[bot] (bodyless approval) and stamphog[bot]+ # (the app approval carrying the review body). Human reviews+ # and non-approval reviews are untouched.mapfile -t REVIEW_IDS < <(gh api "repos/$REPO/pulls/$PR/reviews" --paginate \- --jq '.[] | select(.user.login == "github-actions[bot]" and .state == "APPROVED") | .id'+ --jq '.[] | select((.user.login == "github-actions[bot]" or .user.login == "stamphog[bot]") and .state == "APPROVED") | .id')for id in "${REVIEW_IDS[@]}"; dodiff --git a/tools/pr-approval-agent/README.md b/tools/pr-approval-agent/README.mdindex 69ec85bcae8b..921a2e7f383e 100644--- a/tools/pr-approval-agent/README.md+++ b/tools/pr-approval-agent/README.md@@ -139,6 +139,9 @@ Final verdict → GitHub review (approve) or sticky comment (everything else)The bot never posts request-changes.Approvals are posted as real PR reviews (they must count toward branch protection).+An approval is posted twice on purpose: the Stamphog app (`stamphog[bot]`) posts the review body as an approval, and `github-actions[bot]` posts a second, bodyless approval.+We keep both while confirming which identity's approval actually satisfies branch protection — GitHub App bot approvals have shown `author_association: NONE`.+If the `github-actions[bot]` one proves redundant, it can be dropped.Every other verdict (REFUSED, ESCALATE, WAIT, ERROR) goes into a single sticky comment that is updated in place on each run, with a counter of how many verdicts the comment has carried (failure notes append without bumping it) — repeated refusals don't stack up as separate review comments on the PR.## Tiersdiff --git a/tools/pr-approval-agent/dismiss_check.py b/tools/pr-approval-agent/dismiss_check.pyindex 52b49fd579ad..1416300a80ff 100644--- a/tools/pr-approval-agent/dismiss_check.py+++ b/tools/pr-approval-agent/dismiss_check.py@@ -36,7 +36,10 @@ from pathlib import Pathfrom gates import is_trivial_at_dismiss_time-BOT_LOGIN = "github-actions[bot]"+# Both identities Stamphog approves under: github-actions[bot] posts a+# bodyless approval, stamphog[bot] (the app) posts the approval carrying the+# review body. Either counts as a prior bot approval for the delta check.+BOT_LOGINS = {"github-actions[bot]", "stamphog[bot]"}class Reason(StrEnum):@@ -136,14 +139,14 @@ def select_last_bot_approval(reviews: list[dict]) -> str | None:excluded; ties are broken by `submitted_at`."""bot_approvals = sorted(- (r for r in reviews if r.get("user", {}).get("login") == BOT_LOGIN and r.get("state") == "APPROVED"),+ (r for r in reviews if r.get("user", {}).get("login") in BOT_LOGINS and r.get("state") == "APPROVED"),key=lambda r: r.get("submitted_at", ""),)return bot_approvals[-1].get("commit_id") if bot_approvals else Nonedef find_last_approved_sha(repo: str, pr_number: int) -> str | None:- """Commit SHA of the most recent github-actions[bot] APPROVED review."""+ """Commit SHA of the most recent Stamphog-bot APPROVED review."""reviews = json.loads(_run("gh", "api", f"repos/{repo}/pulls/{pr_number}/reviews", "--paginate"))return select_last_bot_approval(reviews)diff --git a/tools/pr-approval-agent/test_dismiss_check.py b/tools/pr-approval-agent/test_dismiss_check.pyindex 0b5010e76fd0..bec4834293b8 100644--- a/tools/pr-approval-agent/test_dismiss_check.py+++ b/tools/pr-approval-agent/test_dismiss_check.py@@ -448,6 +448,13 @@ def test_select_last_bot_approval_ignores_bot_non_approval_states() -> None:assert select_last_bot_approval(reviews) == "sha-approved"+def test_select_last_bot_approval_recognizes_app_identity() -> None:+ # The Stamphog app posts the body-carrying approval as stamphog[bot]; it+ # must count as a prior bot approval so dismiss-on-push can find its SHA.+ reviews = [_review("stamphog[bot]", "APPROVED", "sha-app", "2026-01-01T00:00:00Z")]+ assert select_last_bot_approval(reviews) == "sha-app"++# ── main() error path ────────────────────────────────────────────