Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(stamphog): rewrite the readmes for a first-time reader (#101733)

Julian Bez231cce1e4a31
diff --git a/.agents/skills/merging-prs/SKILL.md b/.agents/skills/merging-prs/SKILL.md
index eec19dce18ad..895ddc36b780 100644
--- a/.agents/skills/merging-prs/SKILL.md
+++ b/.agents/skills/merging-prs/SKILL.md
@@ -35,7 +35,7 @@ gh pr view <n> --json state,isDraft,mergeable,reviewDecision,statusCheckRollup,b
- **Draft** → it can't be merged. Ask the developer to confirm, then `gh pr ready <n>` before continuing. Don't un-draft silently.
- **Failing required checks** (`statusCheckRollup`) → the queue will just reject it. Report which checks are red and stop; fix them first. **Pending** checks are fine — the queue waits for them. To work out _why_ a check is red, use `/debugging-ci-failures`.
- **Merge conflicts** (`mergeable == "CONFLICTING"`) → report and stop; merge `master` in first.
-- **Missing approval** (`reviewDecision == "REVIEW_REQUIRED"`, or a stamphog approval was dismissed) → apply the `stamphog` label yourself: `gh pr edit <n> --add-label stamphog`. That triggers the automated review-and-approve flow ([tools/pr-approval-agent/README.md](../../../tools/pr-approval-agent/README.md)); on an `APPROVED` verdict the Stamphog app posts the approval that satisfies the required review. Re-applying the label is always safe and is the intended retry path — it gets stripped on a `REFUSED`/`ESCALATE` verdict, and after addressing that feedback you re-apply it to request a fresh review. Read the reason first: every verdict is its own review from the Stamphog app, opening with whether it approved. Re-applying the label without changing anything just repeats the same verdict. It stays sticky across ordinary pushes (non-trivial deltas re-review automatically), and it never works on bot-authored PRs.
+- **Missing approval** (`reviewDecision == "REVIEW_REQUIRED"`, or a stamphog approval was dismissed) → apply the `stamphog` label yourself: `gh pr edit <n> --add-label stamphog`. That triggers the automated review-and-approve flow ([the engine README](../../../products/stamphog/packages/pr-approval-agent/README.md)); on an `APPROVED` verdict the Stamphog app posts the approval that satisfies the required review. Re-applying the label is always safe and is the intended retry path — it gets stripped on a `REFUSED`/`ESCALATE` verdict, and after addressing that feedback you re-apply it to request a fresh review. Read the reason first: every verdict is its own review from the Stamphog app, opening with whether it approved. Re-applying the label without changing anything just repeats the same verdict. It stays sticky across ordinary pushes (non-trivial deltas re-review automatically), and it never works on bot-authored PRs.
- **Part of a stack** (`baseRefName != "master"`, or the PR appears in `gh api repos/$REPO/stacks`) → the queue handles stacks natively: enqueueing a PR enqueues it **and every unmerged layer below it**, tests them together, and merges them atomically. After explicit user approval, comment `/trunk merge` on the **top** PR to merge the whole stack, or on the highest layer you want landed to merge just the bottom part. Run this preflight on every layer being merged, not only the one you comment on. `/stacking-prs` covers restack mechanics and the post-merge `gh stack sync --prune`.
## 2. Enqueue
diff --git a/.stamphog/README.md b/.stamphog/README.md
index e61121e3db9a..315c76d82acc 100644
--- a/.stamphog/README.md
+++ b/.stamphog/README.md
@@ -1,58 +1,39 @@
# .stamphog
-Declarative policy for the stamphog PR-approval merge gate (`products/stamphog/packages/pr-approval-agent/`).
-The engine loads these files from the checked-out working tree at run time.
-Engine and policy are vendored into other repos (see the note in the engine's README), so format changes here need those copies re-synced too.
+The PostHog monorepo's own stamphog configuration.
-## What lives here
+How the hosted product reads this directory: [`products/stamphog/README.md`](../products/stamphog/README.md#customize-the-review-for-your-repository).
+What each file contains and how per-folder overrides resolve: [the engine's "Policy files" section](../products/stamphog/packages/pr-approval-agent/README.md#policy-files).
-- `policy.yml` - the global machine policy: deny categories, allow-list, size gate, tier thresholds, dismiss-time triviality rules, the folder delegation contract, and the ownership source (the `hogli-resolver` input that feeds the reviewer's advisory team context via the shared hogli resolver). Trusted data. Each rule's `rationale` records why the rule became what it is (which false positives drove an exclusion, and when) - historical justification like a commit message, not a claim about the present.
-- `review-guidance.md` - the trusted review-norms prose injected into the reviewer's system prompt. Ordinary repo-formatted markdown. Editing it changes the production prompt directly, so update deliberately - the `stamphog_policy` deny guarantees a human reviews every change.
+## What this repository configures
-## Proposing a policy change
+`policy.yml` keeps the shipped defaults for `size_gate`, `tiers`, `overrides`, `familiarity` and `ownership`.
+It overrides `deny` and `allow`, and the differences are:
-Open a PR that edits these files.
-Stamphog can never auto-approve it: the `stamphog_policy` deny category matches `.stamphog/**`, any `AGENT_APPROVALS.md`, and any `pr-approval-agent/**`, so every change to the gate's own policy or engine routes to a human reviewer.
-The loader also hard-fails if that self-governance entry is ever missing, so it cannot be dropped silently.
-
-## Per-folder overrides (`AGENT_APPROVALS.md`)
-
-A folder may carry an `AGENT_APPROVALS.md` with a `stamphog:` frontmatter block plus advisory prose.
-Resolution:
+- `auth` and `billing` exempt `products/warehouse_sources/backend/temporal/data_imports/sources/`, because connector code does OAuth and talks to the Stripe API without touching PostHog's auth system or its billing.
+- `infra_cicd` also matches `.github/pr-deploy`.
+- `stamphog_policy` also matches `products/stamphog/backend/logic/policy_defaults/`, `tools/owners/`, `owners.yaml` and `product.yaml`, because those are gate inputs here.
+- `allow` also lists `.github/CODEOWNERS`.
+- Every `rationale` records the false positives that shaped the rule in this repository.
-- Every `AGENT_APPROVALS.md` at or above a changed file governs it: guidance accumulates outermost first, and a child file adds to its ancestors rather than replacing them.
-- For the delegated `size_gate.max_files` and `size_gate.max_lines`, the nearest file on the chain with a valid grant wins for its files (within the contract ceilings). Each key resolves on its own: a folder that grants only one key leaves its files to the nearest ancestor grant of the other key, or to the global pool when no ancestor grants it. Files whose chain grants nothing belong to the global pool.
-- The frontmatter is a positive allow-list: only keys named in the `overrides` contract in `policy.yml` are read, within their ceilings. Anything else (unknown key, out-of-bounds value, unparseable frontmatter) invalidates the whole file - frontmatter and prose. An invalid file contributes nothing itself, but it does not cancel its ancestors: files under it still ride an ancestor's grant, or fall to the global pool if the chain grants nothing. Rationale: an author who can write an invalid file could equally delete it, so treating invalid as absent grants no extra power, and every `AGENT_APPROVALS.md` edit is human-reviewed via the `stamphog_policy` deny anyway.
-- The prose is untrusted advisory guidance. It is sanitized, length-capped, and injected inside the reviewer prompt's untrusted region; it can never override the deny rules or the refusal criteria.
+`review-guidance.md` replaces the default norms.
+It differs from the default in six lines:
-### Mixed PRs get mixed leniency
+- Ownership is read from `owners.yaml` and `product.yaml` rather than CODEOWNERS, in two places.
+- Risky territory names event ingestion paths, where the default names data ingestion or write paths.
+- The opt-in signal is described as the stamphog label, where the default describes the repository's review settings and the label in label mode.
+- The incidental-keyword example is a warehouse connector fix.
+- The philosophy line says "We move fast" rather than "Move fast".
-Each scope's files are counted against that scope's own ceiling, so a grant covers exactly the files that resolve to it (the nearest valid grant of that key on their chain) and nothing else.
-Example: a PR changing 30 files under `products/visual_review/` (ceiling 50) plus 19 files elsewhere (global ceiling 20) passes, because each budget fits.
-Add a 21st global file and the PR is denied for the global budget, no matter how much headroom the folder still has.
-Files whose chain grants nothing (no folder file, prose-only, or only invalid grants) count against the global budget, so splitting files across pseudo-scopes can never inflate the allowance.
-Lines follow the same rule: a scope's substantive lines are counted against that scope's own line ceiling, and the global pool's lines against the global line ceiling.
-The two ceilings are budgeted separately, so a folder that raises only the line ceiling still counts its files against the one global file budget.
-That keeps a one-key grant from opening a second budget for the key it never asked for.
+There is no `steering.md`.
-### The roof bounds the whole PR
+`ownership` declares one `hogli-resolver` source at the repo root, so stamphog reads the same merged view the reviewer auto-assigner builds.
-Per-scope budgets alone would let a PR's total grow with the number of scopes it touches.
-A folder granting 1000 lines next to the 800-line global pool would allow 1800, and every further granting folder would add its own budget on top.
-So each ceiling also carries a roof over the whole PR: the most generous ceiling in play for that key.
-A PR touching `products/desktop/` gets a 1000-line roof, whatever else it touches.
+`overrides` grants folders a ceiling of 50 files and 1000 lines.
+Two folders currently take it up: [`products/desktop/`](../products/desktop/AGENT_APPROVALS.md) and [`products/visual_review/`](../products/visual_review/AGENT_APPROVALS.md).
-The roof needs no separate number in `policy.yml`.
-Every grant is validated at or under the contract ceiling, and the global pool is always a scope, so the roof stays between the global default and the contract ceiling.
-With no grant in play it equals the global default, which is the single global total the gate applied before the ceilings became delegable.
+## Proposing a change
-The roof takes no headroom away from a scope.
-The per-scope budgets still hold, so the extra lines a folder's grant unlocks are only spendable inside that folder.
-
-## Delegation contract
-
-The set of keys a folder file may override lives under `overrides` in `policy.yml` (currently `size_gate.max_files`, ceiling 50, and `size_gate.max_lines`, ceiling 1000).
-A ceiling therefore bounds two things: the largest value a folder may grant, and the highest a PR's roof can ever go for that key.
-It is not the limit every PR gets. A PR whose files reach no grant keeps the lower global roof.
-The loader rejects a ceiling under its own global default, which would otherwise bound nothing.
-deny, allow, dismiss, and tiers are non-delegable by construction - they are absent from the contract and cannot be granted from a folder file.
+Open a PR that edits these files.
+Stamphog can never auto-approve it: the `stamphog_policy` deny category matches `.stamphog/**`, any `AGENT_APPROVALS.md`, and the engine itself, so every change routes to a human reviewer.
+The loader also hard-fails if that self-governance entry is ever missing, so it cannot be dropped silently.
diff --git a/products/stamphog/AGENTS.md b/products/stamphog/AGENTS.md
index edbc0a1fca08..07bbb9331fd1 100644
--- a/products/stamphog/AGENTS.md
+++ b/products/stamphog/AGENTS.md
@@ -1,6 +1,7 @@
# stamphog — invariants for agents
-Read [README.md](README.md) for the product shape first. This file is the contract: the
+Read [README.md](README.md) for the product shape first, and [docs/digest.md](docs/digest.md) for
+the digest design. This file is the contract: the
invariants below were each earned through a real review finding — do not relax one without
understanding what it closes, and hold new code to all of them.
diff --git a/products/stamphog/README.md b/products/stamphog/README.md
index 76e1d1e3e499..ece9ef63e930 100644
--- a/products/stamphog/README.md
+++ b/products/stamphog/README.md
@@ -1,56 +1,156 @@
# Stamphog
-Approve-first PR review: an LLM reviewer that runs deterministic gates plus a scoped review over a pull request and, when the policy allows it, posts an actual GitHub **approval** — not just comments. Repos opt in per-repo; everything else stays untouched.
+Stamphog is an approve-first pull request reviewer.
+It runs deterministic gates and a scoped LLM review over a PR and, when the policy allows it, posts a real GitHub approval instead of comments.
+Repositories opt in one at a time, and nothing else is touched.
-## The engine
+The review itself is done by the engine in [`packages/pr-approval-agent/`](packages/pr-approval-agent/).
+This product decides which PRs are reviewed, runs the engine in a sandbox, and puts the verdict on GitHub.
-The review engine lives in [`packages/pr-approval-agent/`](packages/pr-approval-agent/).
-A GitHub App delivers webhooks here, and reviews run in an isolated Modal sandbox with per-run minted credentials: `review_local.py` consumes a pre-fetched context, with no GitHub token inside the sandbox.
-`review_pr.py` in the same directory is the manual entrypoint for reviewing a PR from your own checkout, which fetches over the network instead.
+## What a PR author sees
-Hosted flow: webhook → Celery (`backend/tasks/tasks.py`) → Temporal (`backend/temporal/workflow.py`) → sandboxed engine → verdict posted back (`post_verdict`). The workflow dismisses stale approvals _first_, waits out other in-flight reviewer bots, then reviews.
+A repository either reviews every PR or waits for its trigger label, depending on its review mode.
+The engine returns one of five verdicts, and `post_verdict` puts it on the PR.
-There is one non-webhook entry: **self-driving inbox PRs**. When a self-driving Inbox implementation run opens its (bot-authored, draft) PR, review_hog's inbox receiver calls the `queue_inbox_pr_review` facade — gated by the assigned reviewers' per-user `stamphog_review_inbox_prs` toggles on ReviewHog's settings (any opted-in reviewer is enough) — and the initial review runs while the PR is still a draft so the verdict is ready at Inbox triage time. Later pushes re-review through the normal webhook path via a positively identified carve-out (task linkage through the tasks facade, toggle re-checked through `facade/inbox_hooks.py`); every other bot author stays refused at every layer. See AGENTS.md § the self-driving carve-out.
+| Verdict | Where it lands | Trigger label in label mode |
+| -------- | ------------------------------------------ | --------------------------- |
+| APPROVED | A real GitHub review by `stamphog[bot]` | Kept |
+| REFUSED | A GitHub comment review by `stamphog[bot]` | Removed |
+| ESCALATE | A GitHub comment review by `stamphog[bot]` | Removed |
+| WAIT | A GitHub comment review by `stamphog[bot]` | Kept, retries |
+| ERROR | A GitHub comment review by `stamphog[bot]` | Kept, retries |
+| Gated | A GitHub comment review by `stamphog[bot]` | Removed |
-## The digest
+Gated means a deterministic gate denied the PR before any review, such as the deny-list or the size ceiling.
+The engine reports it as `REFUSED`; the product stores the run as gated with the verdict `WAIT`, and still removes the trigger label because a human has to take it from here.
-On top of reviews, a repo can enable a daily Slack digest of its merged PRs (`backend/logic/digest_runs.py`, scheduled from `backend/tasks/digest.py`). Only stamphog-approved merges are digested, so the digest needs reviews enabled for the repo.
+The bot never posts request-changes.
+Approvals are posted as real reviews so they count toward branch protection, once, as the Stamphog app (`stamphog[bot]`), carrying the review body.
+Every other verdict is posted once per run as a comment review on the same surface, so approvals and non-approvals for one head never disagree across two lists.
+A run that produced no verdict posts a short failure notice the same way, unless a newer run already holds the same head.
+The engine reports `APPROVED` and `REFUSED`, and the API exposes them lowercase as `approved` and `refused`.
-A merge fans out to every audience it belongs to (`backend/logic/audiences.py`): every team owning a file it changed, read back from the ownership the review already resolved, plus a per-repo audience when a repo declares its own channel under `digest:` in `.stamphog/policy.yml`. A team hears about code it owns, not about everywhere its members touched, so a merge nobody owns in a repo that declares nothing reaches nobody — that is an ownership gap, and `hogli owners:unowned` is where it gets fixed. A slug that is not a live GitHub team reaches nobody in the same way, because there is no `#<slug>` channel to name-match and no registry entry to redirect it, and `hogli owners:lint --live` is the check that catches one. Renaming an audience in the ownership files does not move the rows already captured under the old key, and a branch opened before the rename keeps producing that key until it rebases, so those rows route nowhere and expire after the seven-day claim window. A `PullRequestAudience` row per audience is what the daily run claims, so one channel failing to post never strands the merge for another. Files a generator wrote do not count toward a team's stake in a merge, and a team that owns nothing else is not an audience at all: `hogli build:openapi` rewrites a product's generated API types whenever any shared serializer changes anywhere in the repo, so owning one says nothing about whether that team was touched.
+The trigger label only exists in label-triggered mode, and only a substantive non-approval removes it.
+So the label can be re-applied once the feedback is addressed.
+A verdict that says nothing about the PR keeps the label, and the next push retries.
+`WAIT` means a reviewer bot still had a review in flight, or the `Migration risk` check had not reported yet.
+`ERROR` means the run failed before it could judge the PR, because the LLM backend was unreachable or the reviewer hit a non-retryable analysis failure such as its turn limit.
+A transient failure must not silently drop labels across every queued PR.
-Routing is config, and it lives in the repositories rather than in this database (`backend/logic/channel_resolution.py`). Nothing is stored: a run resolves, posts, and records where it went, so changing a declaration moves the next morning's digest. The order is proximity. A `repo:` audience takes the channel that repo declared. A team slug takes the root `owners.yaml` registry of the repo the merge came from, and a repo that carries a registry answers for its own merges completely, including by omission — a registry lists the teams whose derived name is wrong, so a missing slug means the derived name is right. A repo carrying no registry inherits one, which is what lets `charts` route `team-data-stack` to `#group-data-stack` because the monorepo says so. Otherwise the slug name-matches a Slack channel, and the app joins one it was never invited to, so a team's digest starts without anyone wiring it up. Channels shared outside the workspace are skipped, and `notifications: false` on a registry entry is how a team opts out. The registry is asked where _automation_ posts (`notifications`), which falls back to the team's own `slack` channel, so a team that wants bots somewhere quieter says so once and every producer follows.
+Each run is stored as a `ReviewRun` row with its evidence bundle.
+Runs are listed in the Stamphog runs page in the PostHog app (`/stamphog/runs`), and the same data is available through the stamphog API and its MCP tools (review runs, repo configs, digest runs).
-Two repos declaring one team is a scope, not a conflict. Each answers for the merges that came from it, so one audience can resolve to two channels in a run and the digest partitions between them. No merge is posted twice and no declaration is discarded.
+## Connect a repository
-Summaries are written where the diff is. The reviewer emits a `change_summary` alongside its verdict, which is stamped onto the merged PR; the daily run condenses those rather than guessing from PR titles, and for an owning team it also sees which of the changed files are theirs, so a repo-wide sweep that grazed two of them can be dropped as noise. That summary is one sentence about the whole change, and on a merge more than one team owns files in, one clause per owning team after it, each opening with that team's handle. The digest hands its model the sentence and the clause addressed to its own audience, and nothing else, so another team's clause is not there to be picked rather than forbidden. A team that owns part of a merge and got no clause of its own is dropped before the model reads anything, because the reviewer had the diff and found nothing to say about that team's files. A team that owns one file of a change of eight or more never reaches the summarizer: that merge is dropped from the team's digest in code (`GRAZE_CHANGED_FILES` in `backend/logic/digest.py`). The prompt asked for that judgment first and the model kept a merge it had been told to drop, which is no surprise — the prompt carries the title, the reviewed sentence and the paths, never the diff, so nothing in it says what the one file does. The team that owns the rest of the merge still hears about it. The author's own PR body never reaches the prompt, and a PR stamphog never summarized contributes only its title. The reviewed sentence already says what changed, and carrying the body handed one contributor two thousand characters of a prompt whose empty answer consumes the whole batch. What remains is fenced so it cannot close its own tag and continue as instructions.
+1. Install the Stamphog GitHub App on your GitHub organization.
+2. Open Stamphog in the PostHog app and select **Connect a repository**. The install callback syncs the repositories the installation can reach.
+3. Turn on **Enabled** for each repository you want reviewed. A connected repository reviews nothing until you do.
+4. Pick a **review mode**: "All PRs" reviews every pull request, "Label-triggered" reviews only PRs carrying the trigger label. Set the trigger label name next to the mode.
+5. Turn on **Digest enabled** if you want the daily Slack digest of merged PRs. The project needs a connected Slack integration first, or the digest run stops silently before posting.
-The daily run asks the model twice. The first call picks the merges worth posting and writes one line each for the thread. The second writes the channel headline and is shown only what the first call kept, so a headline cannot name a change the thread has no line for. One call did both jobs before, and a prompt rule forbidding that did not hold: the headline reached the channel naming merges the model had chosen to leave out, accurate and unlinkable. A failed second call costs the headline and nothing else, because the first call's lines are already the digest. The headline is written every time. The rule that let it return nothing on a routine day predates the split, and the changes it now sees have already cleared the bar, so its only remaining effect was on a single-change digest, where the renderer promoted that change's line and the channel said the same sentence as the thread.
+Connecting a repository and the digest toggle need the `editor` level on the `stamphog` resource.
+The gating fields, which are enabled, review mode and trigger label, need `manager`, because they decide whether a pull request is reviewed at all.
-Both calls run on Sonnet with adaptive thinking, the selection call at medium effort and the headline at low.
-Neither call sees the diff or the PR body, so the work is to carry every condition the reviewed text states, such as a flag or a change that does nothing until later work ships, and to add no consequence the text does not state.
-A smaller model got both wrong often enough that readers acted on lines that were not true, and both prompts state the two rules.
-The headline sees each kept change's reviewed text and thread line, and its title only when the team owns the whole merge.
-A title describes the whole pull request, so for a merge the team owns only part of, it is another team's news.
+## Customize the review for your repository
-How many changes a digest carries is decided by the bar and by nothing else. There is no target count and no editorial cap, so a quiet day shows none and a heavy one shows what it earns. The bar is four named rules — `contract`, `assumption`, `decision`, `customer` — and the summarizer has to name the one that admits each merge it keeps. A merge kept without a valid rule is dropped in code rather than trusted, because an unnamed bar gets rationalized away: on a real day of twenty-six connector fixes the same model kept twenty-one of them without the rules and none to two with them. The same trick carries the team's own perspective. A team that owns part of a merge was told what the merge was about, which is the other team's news, so the model has to say whether each line it keeps is about the team's own files or about the pull request overall, and a line about the whole pull request is dropped for a team that owns only part of it. A team owning every changed file, and a repo that declared its own channel, are asked for no such claim. Repair overrides all four. Making a broken integration work is maintenance, and only changing what a working one does is news. The one limit is Slack's own block ceiling, which the deterministic fallback rails far below because that path judges nothing.
+Customization is optional.
+A repository with no `.stamphog/` directory reviews under the hosted defaults in [`backend/logic/policy_defaults/`](backend/logic/policy_defaults/).
-A run consumes every merge it claims, whatever the summarizer decided about it. Handing the leftovers back put the same merges in front of the same prompt every morning, where the same text produced the same answer, so a busy team's batch grew for a week and then aged out unseen. Merges above the per-run claim ceiling are the one exception: they are never claimed, so the next run picks them up.
+The three `.stamphog/` files are read from the repository's **default branch**, never from the PR head, so a PR cannot rewrite the policy that gates it.
+After the sandbox clones the PR head, the server overwrites the checkout's `.stamphog/` with the default-branch versions.
+A file the repository does not carry is wiped from the checkout as well, so a planted PR-head copy cannot take its place.
-A digest posts as two messages (`backend/logic/slack_digest.py`). The channel gets one lead, best available first: the model's headline, otherwise the first change's own line when the headline call failed or answered with something unpostable, and the scope line ("3 of 11 Stamphog-approved merges") when neither is available. Promoting a change line keeps the channel saying something that shipped instead of a bare count, and it is the line the thread already carries, so a reader who wants the diff is one message away. Only a judged run may promote one: the deterministic fallback's lines are unreviewed PR titles, and the promoted line has to clear the same no-link rule the headline does, because the channel lead is the one piece of digest text posted without a link attached to it. The per-change lines go in a thread under that lead, so a team spends one line of its channel and opens the rest by choice. Neither message promises the reader every merge of the day: the thread leads with whose judgment picked its contents, and the footer marks the digest as beta and asks for a reaction or a reply, which is where feedback on the digest itself lands. A failed thread reply never fails the run — the lead is already posted and the run's PRs are consumed on that basis, so treating it as a failure would post the same lead again the next day.
+`AGENT_APPROVALS.md` is the exception: it sits in arbitrary folders, so the engine reads it from the checkout, which is the PR head.
+That is why its frontmatter is a bounded positive allow-list, and why the `stamphog_policy` deny routes every edit to one to a human reviewer.
-## Stacked PRs
+| File | Required | Default when absent | How it combines with the default |
+| -------------------- | -------- | ------------------------- | -------------------------------------------------------------------------------------------- |
+| `policy.yml` | No | The hosted default policy | Section overlay: each top-level section you declare replaces the default's section wholesale |
+| `review-guidance.md` | No | The hosted default norms | Replaces the default prose wholesale |
+| `steering.md` | No | Nothing is added | Passed through as-is, because no default exists |
+| `AGENT_APPROVALS.md` | No | No folder overrides | Read from the PR's own tree, not overlaid |
-A stacked PR targets its parent's branch, not the repo's default branch, and depends on parent code that hasn't merged yet.
-The sandbox clones and checks out the PR head for every review, so the reviewer's Read/Grep/Glob already see the post-stack tree and parent symbols resolve.
-The engine is told the checkout is the head (`head_checkout=True`) so it never builds the Action's separate head worktree, and the prompt flags the PR as stacked (`PRData.stacked`, keyed on the repo's actual default branch).
-The diff stays scoped `base...head`.
-When the parent merges and GitHub retargets the child onto the default branch, the diff changes without a push: the webhook path retracts the standing approval and queues a fresh run, and `post_verdict` rechecks the live base (ref and SHA) against the reviewed one before posting.
-Engine details: [`packages/pr-approval-agent/README.md`](packages/pr-approval-agent/README.md#stacked-prs-graphite--git-stacks).
+What each file contains, and how per-folder overrides resolve: [the engine's "Policy files" section](packages/pr-approval-agent/README.md#policy-files).
-## Configuration
+The overlay means a repository can declare only the sections it wants to change.
+A repository that only wants a bigger size gate writes five lines:
-Per-repo settings live on `StamphogRepoConfig` (synced via the GitHub App install flow, managed in the Stamphog scene): review on/off, review mode (auto vs trigger label), digest on/off. Review policy (gates, deny-lists, tiers, ownership) is read from `.stamphog/policy.yml` on the repo's **default branch** — never from the PR head — layered over hosted defaults in [`backend/logic/policy_defaults/`](backend/logic/policy_defaults/).
+```yaml
+version: 1
+size_gate:
+ max_lines: 1000
+ max_files: 40
+```
-## Security model, in one paragraph
+Everything else, including every deny category, still comes from the hosted default.
+A global limit may not exceed the matching ceiling under `overrides`, so a repository that wants to go past the shipped ceilings declares both sections.
+The merged document is validated by the engine's strict loader inside the sandbox, so required sections and the `stamphog_policy` self-governance deny cannot be dropped by omission.
-The sandbox runs an LLM over untrusted PR content, so it holds no long-lived secrets: it gets a per-run `phe_` scoped token from the Go ai-gateway (pinned to `product=aio_stamphog`, capped at $5 and one hour, revoked when the sandbox is destroyed), egress is fenced to an explicit domain allowlist, posted bodies are scrubbed and markdown-image-neutralized, and approvals are governed by a strict supersession protocol so no approval survives events it shouldn't (pushes, re-reviews, repo disable). Details and invariants: [AGENTS.md](AGENTS.md).
+A `policy.yml` that is present but unusable, such as malformed YAML or a non-mapping root, fails the run closed.
+The repository declared something, so reviewing under pure defaults would be wrong.
+
+### The `digest:` key
+
+`policy.yml` may also carry a `digest:` section.
+It names a Slack channel that receives all of the repository's merged-PR digests, as one more audience next to the owning teams, so a merge can appear in the repository channel and in a team channel:
+
+```yaml
+digest:
+ channel: '#my-team'
+```
+
+This key belongs to this product, not to the engine, which ignores it.
+It is read from the default branch too, so a PR cannot redirect its own digest.
+
+## Daily digest
+
+A repository with the digest turned on gets a daily Slack summary of its merged PRs (`backend/logic/digest_runs.py`, scheduled from `backend/tasks/digest.py`).
+Only stamphog-approved merges are digested, so the digest needs reviews enabled for the repository.
+A merge fans out to every audience it belongs to, and each audience resolves to a channel in this order:
+
+- A `repo:` audience takes the channel that repository declared under `digest:`.
+- A team slug takes the root `owners.yaml` registry of the repository the merge came from.
+- A repository carrying no registry inherits the first non-empty registry among the team's connected repositories, in repository name order.
+- Otherwise the slug name-matches a Slack channel, and the app joins it.
+- A registry-derived or name-matched channel that is shared outside the workspace is skipped. A channel the repository declared under `digest:` is posted to even when shared, because someone chose it on purpose. `notifications: false` on a registry entry opts a team out.
+
+Why the digest works this way: [`docs/digest.md`](docs/digest.md).
+
+## How it runs
+
+Hosted flow: webhook → Celery (`backend/tasks/tasks.py`) → Temporal (`backend/temporal/workflow.py`) → sandboxed engine → verdict posted back (`post_verdict`).
+The workflow dismisses stale approvals first, waits out other in-flight reviewer bots, then reviews.
+
+Reviews run in an isolated Modal sandbox with per-run minted credentials.
+The sandbox clones the repository, checks out the PR head, and runs `review_local.py` against a pre-fetched context, with no GitHub token inside the sandbox.
+
+**Stacked PRs.** A stacked PR targets its parent's branch and depends on parent code that has not merged yet.
+The sandbox checkout is already the PR head, so the reviewer's Read, Grep and Glob see the post-stack tree and parent symbols resolve.
+The sandbox fetches the base SHA explicitly during the clone, and the diff stays scoped `base...head`.
+When the parent merges and GitHub retargets the child onto the default branch, the diff changes without a push, so no `synchronize` event fires and the normal push-dismiss path is skipped.
+The webhook path therefore retracts the standing approval on a base retarget (`_retract_approvals_on_base_retarget`) and queues a fresh run, and `post_verdict` rechecks the live base ref and SHA against the reviewed ones before posting.
+One limitation stays: a parent branch force-push or rebase without restacking the child emits no child PR event, so the child's approval is only revalidated once the child is restacked or pushed.
+How the engine handles a stacked checkout: [`packages/pr-approval-agent/README.md`](packages/pr-approval-agent/README.md#stacked-prs-graphite--git-stacks).
+
+**Self-driving inbox PRs** are the one non-webhook entry.
+When a self-driving Inbox implementation run opens its bot-authored draft PR, review_hog's inbox receiver calls the `queue_inbox_pr_review` facade, gated by the assigned reviewers' per-user `stamphog_review_inbox_prs` toggles, and the initial review runs while the PR is still a draft so the verdict is ready at Inbox triage time.
+Later pushes re-review through the normal webhook path via a positively identified carve-out, and every other bot author stays refused at every layer.
+See [AGENTS.md](AGENTS.md) for the carve-out's invariants.
+
+## Security model
+
+The sandbox runs an LLM over untrusted PR content, so it holds no long-lived secrets.
+It gets a per-run `phe_` scoped token from the Go ai-gateway, pinned to `product=aio_stamphog`, capped at $5 and one hour, and revoked when the sandbox is destroyed.
+Egress is fenced to an explicit domain allowlist.
+Posted bodies are scrubbed and markdown-image-neutralized.
+Approvals are governed by a strict supersession protocol, so no approval survives a re-review or a push that changes the PR's diff.
+A push that leaves the PR's own unified diff byte-identical, such as a base merge that touches none of its files, keeps the approval standing.
+Disabling a repository stops new runs and retracts a standing approval on the next head change, not at the moment of disabling.
+Details and invariants: [AGENTS.md](AGENTS.md).
+
+## Where to read more
+
+- [AGENTS.md](AGENTS.md) - the invariants that keep approvals and the sandbox sound.
+- [`packages/pr-approval-agent/README.md`](packages/pr-approval-agent/README.md) - the engine: gates, tiers, policy file formats, evidence bundle.
+- [`docs/digest.md`](docs/digest.md) - the digest design note.
+- [`.stamphog/README.md`](../../.stamphog/README.md) - what the PostHog monorepo itself configures.
diff --git a/products/stamphog/docs/digest.md b/products/stamphog/docs/digest.md
new file mode 100644
index 000000000000..7152bd91f91d
--- /dev/null
+++ b/products/stamphog/docs/digest.md
@@ -0,0 +1,108 @@
+# Digest design
+
+Design note for the daily merged-PR digest.
+Read [the product README](../README.md) first for what the digest does and how to turn it on.
+
+## Routing
+
+A merge fans out to every audience it belongs to (`backend/logic/audiences.py`).
+That is every team owning a file it changed, read back from the ownership the review already resolved.
+It also includes a per-repo audience when a repo declares its own channel under `digest:` in `.stamphog/policy.yml`.
+A team hears about code it owns, not about everywhere its members touched.
+So a merge nobody owns, in a repo that declares nothing, reaches nobody.
+That is an ownership gap, and `hogli owners:unowned` is where it gets fixed.
+A slug that is no longer a live GitHub team is not checked at run time.
+If a same-named Slack channel or a registry entry still exists, the digest keeps posting there; only when neither exists does the audience reach nobody.
+`hogli owners:lint --live` is the check that catches a stale slug.
+Renaming an audience in the ownership files does not move the rows already captured under the old key.
+A branch opened before the rename keeps producing that key until it rebases, so those rows route nowhere and expire after the seven-day claim window.
+A `PullRequestAudience` row per audience is what the daily run claims, so one channel failing to post never strands the merge for another.
+Generated frontend API types under `products/<name>/frontend/generated/` do not count toward a team's stake in a merge, and a team that owns nothing else is not an audience at all.
+Generated files anywhere else still count, because only that one directory shape is rewritten by a change made elsewhere.
+`hogli build:openapi` rewrites a product's generated API types whenever any shared serializer changes anywhere in the repo, so owning one says nothing about whether that team was touched.
+
+Routing is config, and it lives in the repositories rather than in this database (`backend/logic/channel_resolution.py`).
+Nothing is stored: a run resolves, posts, and records where it went, so changing a declaration moves the next morning's digest.
+The order is proximity.
+A `repo:` audience takes the channel that repo declared.
+A team slug takes the root `owners.yaml` registry of the repo the merge came from.
+A repo that carries a registry answers for its own merges completely, including by omission: a registry lists the teams whose derived name is wrong, so a missing slug means the derived name is right.
+A repo carrying no registry inherits one, which is what lets `charts` route `team-data-stack` to `#group-data-stack` because the monorepo says so.
+Otherwise the slug name-matches a Slack channel, and the app joins one it was never invited to, so a team's digest starts without anyone wiring it up.
+A registry-derived or name-matched channel that is shared outside the workspace is skipped, because nobody chose it for the audience on purpose.
+A channel the repository declared under `digest:` is posted to even when shared.
+`notifications: false` on a registry entry is how a team opts out.
+The registry is asked where automation posts (`notifications`), which falls back to the team's own `slack` channel.
+A team that wants bots somewhere quieter says so once and every producer follows.
+
+## Two repos, one team
+
+Two repos declaring one team is a scope, not a conflict.
+Each answers for the merges that came from it.
+So one audience can resolve to two channels in a run, and the digest partitions between them.
+No merge is posted twice and no declaration is discarded.
+
+## Summaries and the graze rule
+
+Summaries are written where the diff is.
+The reviewer emits a `change_summary` alongside its verdict, which is stamped onto the merged PR.
+The daily run condenses those rather than guessing from PR titles.
+For an owning team it also sees which of the changed files are theirs, so a repo-wide sweep that grazed two of them can be dropped as noise.
+That summary is one sentence about the whole change.
+On a merge more than one team owns files in, one clause per owning team follows it, each opening with that team's handle.
+The digest hands its model the sentence and the clause addressed to its own audience, and nothing else, so another team's clause is not there to be picked rather than forbidden.
+A team that owns part of a merge and got no clause of its own is dropped before the model reads anything, because the reviewer had the diff and found nothing to say about that team's files.
+A team that owns one file of a change of eight or more never reaches the summarizer: that merge is dropped from the team's digest in code (`GRAZE_CHANGED_FILES` in `backend/logic/digest.py`).
+The rule is deterministic because the prompt carries the title, the reviewed sentence and the paths, never the diff, so nothing in it says what the one file does.
+The team that owns the rest of the merge still hears about it.
+The author's own PR body never reaches the prompt, and a PR stamphog never summarized contributes only its title.
+The reviewed sentence already says what changed, and a long body crowds out the rest of the prompt.
+What remains is fenced so it cannot close its own tag and continue as instructions.
+
+## Two model calls
+
+The daily run asks the model twice.
+The first call picks the merges worth posting and writes one line each for the thread.
+The second writes the channel headline and is shown only what the first call kept, so a headline cannot name a change the thread has no line for.
+A failed second call costs the headline and nothing else, because the first call's lines are already the digest.
+The headline is written every time, because the changes it sees have already cleared the bar.
+
+Both calls run on Sonnet with adaptive thinking, the selection call at medium effort and the headline at low.
+Neither call sees the diff or the PR body.
+So the work is to carry every condition the reviewed text states, such as a flag or a change that does nothing until later work ships, and to add no consequence the text does not state.
+A smaller model got both wrong often enough that readers acted on lines that were not true, and both prompts state the two rules.
+The headline sees each kept change's reviewed text and thread line, and its title only when the team owns the whole merge.
+A title describes the whole pull request, so for a merge the team owns only part of, it is another team's news.
+
+## The bar
+
+How many changes a digest carries is decided by the bar and by nothing else.
+There is no target count and no editorial cap, so a quiet day shows none and a heavy one shows what it earns.
+The bar is four named rules, `contract`, `assumption`, `decision` and `customer`, and the summarizer has to name the one that admits each merge it keeps.
+A merge kept without a valid rule is dropped in code rather than trusted, because an unnamed bar gets rationalized away.
+On a real day of twenty-six connector fixes, the same model kept twenty-one of them without the rules and none to two with them.
+The same trick carries the team's own perspective.
+A team that owns part of a merge was told what the merge was about, which is the other team's news.
+So the model has to say whether each line it keeps is about the team's own files or about the pull request overall, and a line about the whole pull request is dropped for a team that owns only part of it.
+A team owning every changed file, and a repo that declared its own channel, are asked for no such claim.
+Repair overrides all four.
+Making a broken integration work is maintenance, and only changing what a working one does is news.
+The one limit is Slack's own block ceiling, which the deterministic fallback rails far below because that path judges nothing.
+
+## Consumption
+
+A run consumes every merge it claims, whatever the summarizer decided about it.
+Unconsumed leftovers would put the same merges in front of the same prompt every morning, where the same text produces the same answer, so a busy team's batch would grow for a week and then age out unseen.
+Merges above the per-run claim ceiling are the one exception: they are never claimed, so the next run picks them up.
+
+## Posting
+
+A digest posts as two messages (`backend/logic/slack_digest.py`).
+The channel gets one lead, best available first: the model's headline, otherwise the first change's own line when the headline call failed or answered with something unpostable, and the scope line ("3 of 11 Stamphog-approved merges") when neither is available.
+Promoting a change line keeps the channel saying something that shipped instead of a bare count, and it is the line the thread already carries, so a reader who wants the diff is one message away.
+Only a judged run may promote one: the deterministic fallback's lines are unreviewed PR titles.
+The promoted line has to clear the same no-link rule the headline does, because the channel lead is the one piece of digest text posted without a link attached to it.
+The per-change lines go in a thread under that lead, so a team spends one line of its channel and opens the rest by choice.
+Neither message promises the reader every merge of the day: the thread leads with whose judgment picked its contents, and the footer marks the digest as beta and asks for a reaction or a reply, which is where feedback on the digest itself lands.
+A failed thread reply never fails the run.
+The lead is already posted and the run's PRs are consumed on that basis, so treating it as a failure would post the same lead again the next day.
diff --git a/products/stamphog/packages/pr-approval-agent/README.md b/products/stamphog/packages/pr-approval-agent/README.md
index 2243ab904a27..d516289220f0 100644
--- a/products/stamphog/packages/pr-approval-agent/README.md
+++ b/products/stamphog/packages/pr-approval-agent/README.md
@@ -1,35 +1,44 @@
# PR approval agent
-AI-assisted PR approval for PostHog.
-Deterministic safety gates first, then Claude reviews for showstoppers.
-
-> [!NOTE]
-> This directory (together with `.stamphog/`) is vendored into other repos — e.g. [MLHog](https://github.com/PostHog/MLHog/tree/master/tools/pr-approval-agent) — each documenting its intentional local changes in its own copy of this README. Vendored copies live at `tools/pr-approval-agent/` with `tools/owners` beside them, which is also where this repo's review sandbox writes the engine; only the source of truth sits here. When you change the engine or policy format here, those copies stay stale until someone re-syncs them, so give the owning teams a heads-up (or re-sync yourself: diff, re-copy, re-apply their documented local changes).
-> A policy that declares a `hogli-resolver` ownership source additionally needs the sibling `tools/owners` package vendored.
-> The legacy `gh-codeowners` / `ph-product` ownership formats were removed together with the `CODEOWNERS-soft` migration, so a vendored copy whose policy still declares them must migrate to `hogli-resolver` (adopting `owners.yaml` + `tools/owners`) as part of the re-sync — or skip the re-sync and keep its previous engine until it's ready. The policy loader rejects unknown formats loudly at startup, so a missed migration fails closed rather than silently skipping the ownership source.
-
-## Usage
-
-Reviews run in the hosted stamphog product ([`products/stamphog/`](../../products/stamphog/)): a GitHub App delivers the PR webhook, and the engine runs in an isolated sandbox through `review_local.py`.
-A repo either reviews every PR or waits for its trigger label, per its `review_mode`.
-On approval a trigger label stays so it's visible which PRs were stamphog'd.
-Only a substantive non-approval (`REFUSE`/`ESCALATE`) removes the label, so it
-can be re-applied once the feedback is addressed; every other outcome —
-including a crashed run that produced no verdict — keeps the label and retries
-on the next push.
-If the review agent can't reach its LLM backend (credentials, credit, or
-outage) it returns `ERROR` and **keeps** the label — a transient infra failure
-must not silently drop labels across every queued PR. The review retries on the
-next push, or re-apply the label once the backend recovers.
-`WAIT` also keeps the label. It means either that an allowlisted reviewer bot
-still had a review in flight (👀 reaction) after the polling budget, or that the
-`Migration risk` check had not reported yet — neither is a verdict on the PR, so
-the next push retries automatically.
-
-### Local review
+A Python package that reviews one pull request and returns a verdict.
+It runs deterministic safety gates over the changed files, classifies the PR into a tier, then lets a Claude Agent SDK reviewer look for showstoppers.
+
+The package reads its policy from the `.stamphog/` directory of the checked-out tree it runs in.
+It writes nothing to GitHub.
+The verdict is the output, and the caller decides what to do with it.
+
+Two entrypoints:
+
+- `review_pr.py` fetches the PR itself with the `gh` CLI and reviews it from the current checkout.
+- `review_local.py` reviews from a pre-fetched context JSON, with a checkout that is already at the PR head (`head_checkout=True`).
+
+The stamphog product in [`products/stamphog/`](../../../stamphog/) runs `review_local.py` in a sandbox.
+
+## Verdicts
+
+| Verdict | Meaning |
+| -------- | ------------------------------------------------------------------------------------------------------------------ |
+| APPROVED | The gates passed and the reviewer found no showstoppers |
+| REFUSED | A gate denied the PR (deny-list, size, bot author, pending migration check) or the reviewer found a concrete issue |
+| ESCALATE | Only a human can rule out a showstopper |
+| WAIT | No verdict yet: a reviewer bot or a CI check is pending |
+| ERROR | The run could not produce a verdict |
+
+These are the values of `Pipeline.final_verdict`, which both entrypoints return.
+The nested LLM reviewer answers with `APPROVE` and `REFUSE`, and the pipeline maps those onto the names above.
+
+`WAIT` means either that an allowlisted reviewer bot still had a review in flight (👀 reaction) after the polling budget, or that the `Migration risk` check had not reported yet.
+Neither is a verdict on the PR, so the caller can retry unchanged.
+`ERROR` means the run failed before it could judge the PR: the LLM backend was unreachable through credentials, credit or an outage, the reviewer hit a non-retryable analysis failure such as its turn limit, or `review_pr.py` could not create the worktree for a stacked PR.
+It is never a judgment on the PR.
+
+How a verdict reaches GitHub, and what happens to a trigger label, is the caller's concern.
+For the hosted product see [`products/stamphog/README.md`](../../README.md#what-a-pr-author-sees).
+
+## Local review
```bash
-# run from anywhere inside the posthog repo
+# run from the repository root
uv run products/stamphog/packages/pr-approval-agent/review_pr.py 46594
# dry run (gates only, no LLM calls)
@@ -42,15 +51,13 @@ uv run products/stamphog/packages/pr-approval-agent/review_pr.py 46594 --output-
uv run products/stamphog/packages/pr-approval-agent/review_pr.py 46594 -v
```
-`review_pr.py` is the manual entrypoint: it fetches everything over the network with `gh` and reviews a PR from your own checkout.
-The hosted runtime never uses it, running `review_local.py` against a pre-fetched context instead, with no GitHub token inside the sandbox.
-Requires `gh` CLI authenticated and `ANTHROPIC_API_KEY` in your environment.
-Uses PEP 723 inline metadata so `uv run` handles dependencies automatically.
+`review_pr.py` requires the `gh` CLI authenticated and `ANTHROPIC_API_KEY` in your environment.
+It uses PEP 723 inline metadata, so `uv run` handles dependencies automatically.
## How it works
```text
-"stamphog" label added to PR
+review requested
│
▼
Prerequisites (hard gate)
@@ -61,7 +68,7 @@ Prerequisites (hard gate)
Deny-list (hard gate)
- Checks file paths against sensitive categories
- Any match → gates DENY
- - PR-title keywords never deny on their own — they surface as scrutiny
+ - PR-title keywords never deny on their own. They surface as scrutiny
flags the LLM must verify against the diff (REFUSE if the change
behaviorally touches the flagged domain, judge normally if incidental)
│
@@ -72,7 +79,7 @@ Size ceiling (hard gate)
denied-yet-merged-unchanged PRs sits at 500-750 substantive lines, and past
~800 the merged-unchanged rate collapses, so escalation is genuinely right)
- A folder's AGENT_APPROVALS.md can raise either ceiling for its own files,
- within the `overrides` contract in policy.yml (see .stamphog/README.md)
+ within the `overrides` contract in policy.yml (see "Policy files" below)
- The whole PR still has to fit the most generous ceiling in play, so
per-scope budgets never sum. With no folder grant that roof is the global
ceiling above, so the gate keeps measuring the PR size these limits were
@@ -82,7 +89,7 @@ Size ceiling (hard gate)
`.lock`-extension files (e.g. `yarn.lock`), tests (test dirs and
.test/.spec/_test files), and generated/ artifacts
(regenerated-artifact extensions only: .ts/.tsx/.js/.jsx/.json/.md/.snap/.pyi/.txt)
- don't count toward the ceiling — they inflate diffs without adding review
+ don't count toward the ceiling, because they inflate diffs without adding review
surface. Note: `pnpm-lock.yaml` and `package-lock.json` are not `.lock`-extension
files and do count toward the ceiling. All files still count toward tier
classification and still appear in the diff the LLM reads.
@@ -96,15 +103,15 @@ Tier classification
▼
Wait for in-flight bot reviews (skipped when gates already denied)
- Reviewer bots (greptile, hex-security, codex) put 👀 on the PR while
- reviewing and swap it for a verdict reaction minutes later; stamphog is
+ reviewing and swap it for a verdict reaction minutes later; the review is
triggered at the same moment, so an 👀 at fetch time is a race, not a
lasting state
- Polls until allowlisted-bot 👀 reactions clear (up to 5 min); if one
- remains, verdict is WAIT — label kept, next push retries
- - Bot 👀 older than ~45 min is a crashed reviewer, not an in-flight one —
+ remains, the verdict is WAIT
+ - Bot 👀 older than ~45 min is a crashed reviewer, not an in-flight one:
ignored, so a wedged bot can't stall every review (reactions never
expire and humans can't remove another app's reaction)
- - Human 👀 reactions are not waited on — the LLM refuses over them instead
+ - Human 👀 reactions are not waited on; the LLM refuses over them instead
- If the wait refetched the PR, classification and gates re-run on the
fresh data before the LLM sees it
│
@@ -114,160 +121,247 @@ LLM Review
- Explores the repo via git diff, reads source files if needed
- Looks for showstoppers: production breakage, security, missed deps
- Receives the PR description (untrusted) and verifies the diff matches the
- author's stated intent — undisclosed sensitive behavior gets extra scrutiny
+ author's stated intent. Undisclosed sensitive behavior gets extra scrutiny
- Reads the discussion-comment timeline (untrusted, newest first, capped)
alongside inline comments; an un-withdrawn maintainer hold blocks approval
- Gets a trusted one-line `Assurance:` digest (current-head approvals,
unresolved inline comments, discussion count) so review state is at a glance
- Reads other reviewers' signals as context (not a gate): top-level review
states (annotated current-head vs older-commit), inline comments (tagged
- resolved/outdated), and reactions (👍/👎/👀) on the PR and comments —
+ resolved/outdated), and reactions (👍/👎/👀) on the PR and comments,
filtered to org members and an allowlist of reviewer bots (installed
apps like inkeep react for non-review reasons), never the PR author
- - An 👀 reaction signals an in-flight review — the LLM refuses rather than
+ - An 👀 reaction signals an in-flight review, so the LLM refuses rather than
approving over someone who is mid-review (bot 👀 races are waited out
before the LLM runs; see above)
- - Stamphog's own prior reviews (stamphog[bot] refusals, github-actions[bot]
- approvals) and its own inline comments are excluded from the prompt — they
- describe an earlier snapshot of the PR and are never independent review
- signal. Quoted stamphog verdicts in other reviewers' comments are treated
- as history, not tampering
+ - Stamphog's own prior reviews and its own inline comments are excluded from
+ the prompt, because they describe an earlier snapshot of the PR and are never
+ independent review signal. Quoted stamphog verdicts in other reviewers'
+ comments are treated as history, not tampering
- For changes entering risky territory (migrations, billing, auth, and
- similar; the full list lives in `.stamphog/review-guidance.md`), expects
+ similar; the full list lives in the review guidance file), expects
independent assurance over the risky part on the current head: a
substantive reviewer pass, or an owning-team / STRONG-familiarity author;
escalates otherwise. Outside risky territory no independent review is
required, regardless of size tier. We move fast and fix forward, and the
LLM's own reading suffices for contained, reversible changes
- - Gates are authoritative — LLM can tighten but never loosen
+ - Gates are authoritative: the LLM can tighten but never loosen
│
▼
-Final verdict → GitHub review (approve) or sticky comment (everything else)
+Final verdict returned to the caller
```
-The bot never posts request-changes.
-Approvals are posted as real PR reviews (they must count toward branch protection).
-An approval is posted once, as the Stamphog app (`stamphog[bot]`), carrying the review body.
-This identity was confirmed to satisfy branch protection, so the earlier bodyless `github-actions[bot]` fallback approval has been dropped and every stamphog action now runs under the app token.
-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.
+## Policy files
+
+The engine reads four files from the checked-out tree.
+The repo root is resolved from the package's own location, never from the working directory, so the policy always comes from the same tree the engine reviews.
+
+### `policy.yml`
+
+Required, at `.stamphog/policy.yml`.
+The machine policy, loaded and validated by a strict loader: a malformed or incomplete file hard-fails at load rather than reviewing under a half-loaded policy.
+
+Top-level sections:
+
+| Section | What it declares |
+| ------------- | -------------------------------------------------------------------- |
+| `version` | The policy schema version |
+| `deny` | The T2 categories and the title/path patterns that match them |
+| `allow` | The path patterns and extensions that make a PR eligible for T0 |
+| `size_gate` | The global `max_lines` and `max_files` ceilings |
+| `tiers` | The T1 sub-class thresholds |
+| `overrides` | The keys a folder file may override, and each key's ceiling |
+| `familiarity` | The author-familiarity bands, a judgment input and never a gate |
+| `ownership` | The ownership sources that feed the reviewer's advisory team context |
+
+A rule may carry a `rationale`.
+It records why the rule became what it is, which false positives drove an exclusion and when.
+Treat it as historical justification like a commit message, not as a claim about the present.
+
+The `deny` section must keep a `stamphog_policy` category matching the policy files and the engine itself.
+The loader hard-fails when the category or one of its required path patterns is missing.
+It checks the pattern sources only, so a policy that keeps the patterns but hollows them out, for example with a blanket `exempt_path_prefixes`, still loads.
+That is one more reason every edit to a policy file is a human-reviewed change.
+
+The loader rejects unknown top-level keys.
+The two exceptions are `digest` and `dismiss`, which a hosting server may declare and parse itself; the engine allows them and never reads them.
+
+### `review-guidance.md`
+
+The trusted review-norms prose, injected into the reviewer's system prompt.
+Ordinary markdown.
+Editing it changes the reviewer's behavior directly, so update it deliberately.
+
+### `steering.md`
+
+Optional, and there is no default.
+When present, it is appended to the review guidance under a "Repository-specific steering" section, so a repository can add its own advisory norms without replacing the whole guidance file.
+An absent file leaves the prompt unchanged.
+
+### `AGENT_APPROVALS.md`
+
+A folder anywhere in the tree may carry an `AGENT_APPROVALS.md` with a `stamphog:` frontmatter block plus advisory prose.
+
+Resolution:
+
+- Every `AGENT_APPROVALS.md` at or above a changed file governs it.
+ Guidance accumulates outermost first, and a child file adds to its ancestors rather than replacing them.
+- For a delegated key, the nearest file on the chain with a valid grant wins for its files, within the contract ceiling.
+ Each key resolves on its own.
+ A folder that grants only one key leaves its files to the nearest ancestor grant of the other key, or to the global pool when no ancestor grants it.
+ Files whose chain grants nothing belong to the global pool.
+- The frontmatter is a positive allow-list.
+ Only keys named in the `overrides` contract in `policy.yml` are read, within their ceilings.
+ Anything else invalidates the whole file, frontmatter and prose: an unknown key, an out-of-bounds value, or unparseable frontmatter.
+ An invalid file contributes nothing itself, but it does not cancel its ancestors.
+ Files under it still ride an ancestor's grant, or fall to the global pool if the chain grants nothing.
+ Treating invalid as absent grants no extra power, because an author who can write an invalid file could equally delete it.
+- The prose is untrusted advisory guidance.
+ It is sanitized, length-capped, and injected inside the reviewer prompt's untrusted region.
+ It can never override the deny rules or the refusal criteria.
+
+#### Mixed PRs get mixed leniency
+
+Each scope's files are counted against that scope's own ceiling.
+A grant covers exactly the files that resolve to it, which is the nearest valid grant of that key on their chain, and nothing else.
+
+Example: with a folder ceiling of 50 files and a global ceiling of 20, a PR changing 30 files under that folder plus 19 files elsewhere passes, because each budget fits.
+Add a 21st global file and the PR is denied for the global budget, however much headroom the folder still has.
+
+Files whose chain grants nothing count against the global budget, so splitting files across pseudo-scopes can never inflate the allowance.
+That covers a missing folder file, a prose-only file, and a file with only invalid grants.
+Lines follow the same rule: a scope's substantive lines count against that scope's own line ceiling, and the global pool's lines against the global line ceiling.
+The two ceilings are budgeted separately.
+A folder that raises only the line ceiling still counts its files against the one global file budget, which keeps a one-key grant from opening a second budget for the key it never asked for.
+
+#### The roof bounds the whole PR
+
+Per-scope budgets alone would let a PR's total grow with the number of scopes it touches.
+A folder granting 1000 lines next to an 800-line global pool would allow 1800, and every further granting folder would add its own budget on top.
+So each ceiling also carries a roof over the whole PR: the most generous ceiling in play for that key.
+A PR touching a folder that grants 1000 lines gets a 1000-line roof, whatever else it touches.
+
+The roof needs no separate number in `policy.yml`.
+Every grant is validated at or under the contract ceiling, and the global pool is always a scope, so the roof stays between the global default and the contract ceiling.
+With no grant in play it equals the global default.
+
+The roof takes no headroom away from a scope.
+The per-scope budgets still hold, so the extra lines a folder's grant unlocks are only spendable inside that folder.
+
+#### Delegation contract
+
+The `overrides` section of `policy.yml` names the delegable keys and each key's ceiling.
+Today the engine delegates `size_gate.max_files` and `size_gate.max_lines`.
+
+A ceiling bounds two things: the largest value a folder may grant, and the highest a PR's roof can ever go for that key.
+It is not the limit every PR gets.
+A PR whose files reach no grant keeps the lower global roof.
+The loader rejects a ceiling under its own global default, which would otherwise bound nothing.
+
+`deny`, `allow`, `dismiss` and `tiers` are non-delegable by construction.
+They are absent from the contract and cannot be granted from a folder file.
## Stacked PRs (Graphite / git stacks)
A stacked PR targets its parent branch, not the repo's default branch, and depends on code the parent introduces but hasn't merged yet.
`PRData.stacked` (`base_ref != default_branch`, so repos whose trunk is `main` work too) drives the handling; the reviewer prompt tells the agent it is looking at a stacked PR.
-Two parts make stamphog correct on these:
-
-- **Exploration sees the post-stack tree.**
- The LLM reviewer's `Read`/`Grep`/`Glob` must run over a tree that already contains the parent PRs' code, so symbols from a not-yet-merged parent resolve and aren't flagged as broken imports.
- The diff itself is still computed `base_sha...head_sha`, so the review is scoped to exactly this PR's changes.
- How the head tree is materialized differs per runtime:
- - **Action:** the workflow checks out master (hardcoded, so a PR can't swap the review script), so the reviewer explores a detached **worktree at the PR head** created just for stacked PRs.
- If the worktree cannot be created, stamphog returns `ERROR` and retains the label rather than reviewing against the wrong source tree.
- Symbolic links the PR adds or repoints (relative to the default branch's tree, which already carries trusted ones like `CLAUDE.md`) fail closed, so a PR path cannot resolve outside the worktree.
- - **Hosted:** the sandbox clones and checks out the PR head for every review, so nothing extra is needed — `review_local.py` runs the pipeline with `head_checkout=True` and no worktree is created.
- - **Security (both runtimes):** the explored tree is PR-authored content.
- The reviewer runs the Agent SDK with `setting_sources=[]` (isolation mode) plus `strict_mcp_config`, so it does **not** load `.claude/settings.json` hooks (command execution), `CLAUDE.md` (injected instructions), or `.mcp.json` from the tree.
- Those files are still readable as untrusted _content_ under the anti-injection notice — never as configuration.
- The diff scratch file is created with `mkstemp` under an unpredictable name, so a tracked symlink in the tree cannot redirect the write.
-
-- **Base retarget dismisses the stale approval.**
- When a stack's parent merges, the child PR is retargeted from the parent branch onto master, changing its effective diff **without a push** — so no `synchronize` fires and the normal push-dismiss path is skipped.
- Under the master ruleset (`dismiss_stale_reviews_on_push=false`), a prior bot approval would silently carry onto the new base.
- The Action listens for the `edited` event and, when the base changed, dismisses the bot approval and re-reviews against the new base (if the label is still present); the approval step also rechecks the live base and head SHAs right before posting.
- The hosted runtime does the same from the webhook (`_retract_approvals_on_base_retarget`, then a fresh run) and `post_verdict` rechecks the live base ref and SHA against the reviewed ones.
-
-The base commit of a stacked PR is its parent branch tip, which the Action's master checkout doesn't fetch by default — `github.ensure_commits` and the `decide-delta` job both fetch the base branch so `git diff base_sha...head_sha` and the dismiss-time merge classification resolve it.
-The hosted sandbox fetches the base SHA explicitly during the clone.
-
-Known limitation (both runtimes): a parent branch force-push or rebase without restacking the child emits no child PR event, so the child's approval is only revalidated once the child is restacked or pushed.
-## Tiers
+**Exploration sees the post-stack tree.**
+The LLM reviewer's `Read`/`Grep`/`Glob` must run over a tree that already contains the parent PRs' code, so symbols from a not-yet-merged parent resolve and aren't flagged as broken imports.
+The diff itself is still computed `base_sha...head_sha`, so the review is scoped to exactly this PR's changes.
+How the head tree is materialized differs per entrypoint:
-### T0 — deterministic
+- `review_local.py` runs the pipeline with `head_checkout=True`, because the checkout is already at the PR head. No worktree is created.
+- `review_pr.py` reviews from the current checkout, which is not the PR head, so it creates a detached **worktree at the PR head** for stacked PRs.
+ If the worktree cannot be created, the verdict is `ERROR` rather than a review against the wrong source tree.
+ Symbolic links the PR adds or repoints fail closed, so a PR path cannot resolve outside the worktree.
-Lowest risk. LLM still reviews but with a lighter bar. PR touches only safe paths:
+**The explored tree is PR-authored content.**
+The reviewer runs the Agent SDK with `setting_sources=[]` (isolation mode) plus `strict_mcp_config`, so it does **not** load `.claude/settings.json` hooks (command execution), `CLAUDE.md` (injected instructions), or `.mcp.json` from the tree.
+Those files are still readable as untrusted _content_ under the anti-injection notice, never as configuration.
+The diff scratch file is created with `mkstemp` under an unpredictable name, so a tracked symlink in the tree cannot redirect the write.
-- Allow-listed extensions: `.md`, `.mdx`, `.txt`, `.rst`, `.json`, `.yaml`, `.yml`, `.toml`, `.ini`, `.cfg`, `.csv`, `.svg`, `.png`, `.jpg`, `.jpeg`, `.gif`, `.ico`, `.webp`, `.snap`, `.lock`
-- Allow-listed paths: `docs/`, `README`, `CHANGELOG`, `LICENSE`, `CONTRIBUTING`, `.github/CODEOWNERS`, `.gitignore`, `.editorconfig`, `generated/`, `__snapshots__/`
-- Test-only PRs (all changed files are test files)
+The base commit of a stacked PR is its parent branch tip, which the checkout does not necessarily carry.
+`github.ensure_commits` fetches it for `review_pr.py`, and `review_local.py` expects the caller to have fetched it during the clone.
-### T1 — agent-reviewed
+## Tiers
+
+### T0 - deterministic
+
+Lowest risk. The LLM still reviews but with a lighter bar. The PR touches only safe paths: allow-listed extensions, allow-listed paths, or test files only.
+The extension and path lists live under `allow:` in `policy.yml`.
-Sub-classified by risk to calibrate scrutiny:
+### T1 - agent-reviewed
+
+Sub-classified by risk to calibrate scrutiny, from `tiers:` in `policy.yml`:
| Sub-tier | Lines | Files | Breadth |
| ----------- | ----------- | ----- | ----------------- |
| T1a-trivial | ≤20 | ≤3 | single-area |
| T1b-small | ≤100 | ≤5 | not cross-cutting |
| T1c-medium | ≤300 | ≤15 | not cross-cutting |
-| T1d-complex | >300 or >15 | — | any |
-
-### T2 — never AI-approved
-
-Deny-listed categories where even a small diff can have high blast radius:
-
-| Category | Patterns |
-| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
-| **auth** | auth, authentication, authenticate, authenticated, authorize, authorization, authorized, login, signup, oauth, saml, sso, oidc, credential, … |
-| **crypto_secrets** | crypto, encrypt, decrypt, secret, key, cert, signing, .env, vault |
-| **migrations** | migrations/, migrate, backfill, schema_change |
-| **infra_cicd** | terraform, k8s, helm, dockerfile, .github/workflows, .github/pr-deploy, bin/deploy, deploy.sh, iam, cloudflare, etc. |
-| **billing** | billing, payment, stripe, invoice, pricing |
-| **public_api** | openapi, api_schema, swagger, public_api |
-| **deps_toolchain** | lockfiles (pnpm-lock, uv.lock, Cargo.lock, go.sum, …), requirements.txt, Makefile, Dockerfile, .nvmrc |
-
-Notably absent, on purpose (calibrated against ~440 deny-listed PRs over 120 days):
-`subscription` (means scheduled insight deliveries here, not payments),
-`routing` (every match was app-level DRF routing, never infra), and the bare word `deploy`
-(matches deploy-timing docs and unrelated code); narrow literals `bin/deploy`, `deploy.sh`,
-and `.github/pr-deploy` cover real deployment artifacts instead.
-Dependency _manifests_ (package.json, pyproject.toml, tsconfig, Cargo.toml,
-go.mod) don't hard-deny either: without a lockfile change they can't pull in
-third-party code (CI installs are frozen-lockfile). Three guards cover the
-residual risk that manifest scripts/hooks execute in CI: a deterministic scan
-of the manifest's diff hard-denies edits to known scripts/lifecycle/build
-keys (see `manifest_risk.py` — fails closed if the diff can't be read),
-manifest PRs are kept out of the T0 fast path, and the reviewer prompt must
-REFUSE on execution-bearing changes the scan can't name.
-Manifest/lockfile pairing is per-ecosystem, from the `DEPENDENCY_ECOSYSTEMS`
-table in `gates.py` (the single source the deny patterns and helpers derive
-from): a Cargo.lock bump hard-denies on its own but doesn't silence the
-scripts guard on an unrelated package.json edit in the same PR.
-Data warehouse connector sources (`products/warehouse_sources/.../sources/`)
-are exempt from the **auth** and **billing** categories — connector code
-legitimately does OAuth and talks to the Stripe API without touching
-PostHog's auth system or its billing.
-
-The **migrations** deny-list is bypassed when the `Migration risk` check on the head commit concludes `success` (all migrations classified Safe). The check is published by `analyze_migration_risk` in `ci-backend.yml` and is the same signal humans see in the PR's Checks tab. See `migration_risk.py` for how stamphog reads it.
-
-If the check hasn't reported yet when stamphog runs, the hosted runtime returns `WAIT` rather than a verdict: the deny-list only matched because the engine could not tell a safe migration from a risky one, and a refusal would cost a trigger-label strip, and a ReviewHog handoff on a self-driving PR, over a race with CI. The label is kept and the next push reviews against the now-classified head commit.
+| T1d-complex | >300 or >15 | - | any |
+
+### T2 - never AI-approved
+
+Deny-listed categories where even a small diff can have high blast radius.
+The patterns for each category, and the `rationale` behind them, live under `deny:` in `policy.yml`.
+The categories the shipped policy defines:
+
+| Category | What it covers |
+| ------------------- | ---------------------------------------------------- |
+| **auth** | Authentication and authorization surfaces |
+| **crypto_secrets** | Cryptography, secrets, and key material |
+| **migrations** | Database and schema migrations |
+| **infra_cicd** | Infrastructure, CI, and deployment artifacts |
+| **billing** | Payments and billing |
+| **public_api** | Public API contracts and schemas |
+| **deps_toolchain** | Dependency lockfiles and toolchain/build files |
+| **stamphog_policy** | Stamphog's own policy files, engine, and gate inputs |
+
+Some words are absent on purpose, calibrated against deny-listed PRs over 120 days.
+`subscription` means scheduled insight deliveries in the PostHog monorepo, not payments.
+`routing` only ever matched app-level DRF routing, never infrastructure.
+The bare word `deploy` matches deploy-timing docs and unrelated code, so narrow literals like `bin/deploy` and `deploy.sh` cover real deployment artifacts instead.
+
+Dependency _manifests_ (package.json, pyproject.toml, tsconfig, Cargo.toml, go.mod) don't hard-deny either: without a lockfile change they can't pull in third-party code, because CI installs are frozen-lockfile.
+Three guards cover the residual risk that manifest scripts or hooks execute in CI.
+A deterministic scan of the manifest's diff hard-denies edits to known scripts, lifecycle and build keys (see `manifest_risk.py`, which fails closed if the diff can't be read).
+Manifest PRs are kept out of the T0 fast path.
+And the reviewer prompt must REFUSE on execution-bearing changes the scan can't name.
+
+Manifest and lockfile pairing is per-ecosystem, from the `DEPENDENCY_ECOSYSTEMS` table in `gates.py`, which is the single source the deny patterns and helpers derive from.
+So a Cargo.lock bump hard-denies on its own but doesn't silence the scripts guard on an unrelated package.json edit in the same PR.
+
+A deny category may carry `exempt_path_prefixes`, for code that legitimately looks like a sensitive domain without touching one.
+
+The **migrations** deny-list is bypassed when the `Migration risk` check on the head commit concludes `success` (all migrations classified Safe).
+The check is the same signal humans see in the PR's Checks tab.
+See `migration_risk.py` for how the engine reads it.
+
+If the check hasn't reported yet, `review_local.py` returns `WAIT` rather than a verdict, because its caller can retry on the next push.
+`review_pr.py` has no such caller and returns `REFUSED` instead.
+The deny-list only matched because the engine could not tell a safe migration from a risky one, so a refusal would be a verdict on a race with CI rather than on the PR.
+A retry against the now-classified head commit reviews it properly.
### Ownership
-Ownership context for the LLM (not a hard gate). The sources are declared in
-`.stamphog/policy.yml` under `ownership:` and read from the master checkout: a
-`hogli-resolver` source that resolves ownership through the shared hogli
-resolver over the distributed `owners.yaml` / `product.yaml` files. A file's
-owning teams are the union across all sources, so stamphog sees the same merged
-view the reviewer auto-assigner builds. Cross-team typo/test/comment fixes are
-fine, as are small well-tested behavioral fixes (T1a/T1b) with no outstanding
-reviewer concerns; API contract, data model, and larger behavioral changes get
-escalated.
+Ownership context for the LLM, not a hard gate.
+The sources are declared in `policy.yml` under `ownership:` and read from the checked-out tree: a `hogli-resolver` source that resolves ownership through the shared hogli resolver over the distributed `owners.yaml` / `product.yaml` files.
+A file's owning teams are the union across all sources.
+Cross-team typo, test and comment fixes are fine, as are small well-tested behavioral fixes (T1a/T1b) with no outstanding reviewer concerns.
+API contract, data model, and larger behavioral changes get escalated.
## Versioning
`version.py` holds `STAMPHOG_VERSION` (semver, pre-releases like `2.0.0b1`).
-It is stamped onto the `stamphog_review_completed` event (alongside the
-checkout commit sha), the LLM trace properties, the evidence bundle, and the
-verdict comment's mechanics table — so verdict quality and reviewer behavior
-can be segmented by version in LLM analytics. Bump it in the same PR as any
-behavior-affecting change to the engine, the prompt scaffold, or the review
-guidance. Policy data edits don't need a bump; they're tracked by the policy
-sha shown next to the version.
+It is stamped onto the `stamphog_review_completed` event (alongside the checkout commit sha), the LLM trace properties, the evidence bundle, and the verdict comment's mechanics table, so verdict quality and reviewer behavior can be segmented by version in LLM analytics.
+Bump it in the same PR as any behavior-affecting change to the engine, the prompt scaffold, or the review guidance.
+Policy data edits don't need a bump; they're tracked by the policy sha shown next to the version.
## Evidence bundle
-Every run produces a JSON evidence bundle (`--output-json` locally, uploaded as artifact in CI) containing:
+Every run produces a JSON evidence bundle (`--output-json` on `review_pr.py`) containing:
- Stamphog version and PR metadata (number, author, title)
- Classification (tier, sub-tier, breadth, commit type, deny categories, ownership)
@@ -275,26 +369,27 @@ Every run produces a JSON evidence bundle (`--output-json` locally, uploaded as
- Reviewer output (verdict, reasoning, risk, issues)
- Final verdict
-The hosted runtime persists it on the `ReviewRun` row, readable through the stamphog API.
-
## Architecture
-- `review_pr.py` — pipeline orchestrator (fetch → classify → gates → LLM)
-- `gates.py` — deterministic classification and deny-list logic
-- `github.py` — GitHub data fetching via `gh` CLI
-- `reviewer.py` — Claude Agent SDK reviewer (showstoppers prompt)
-- `review_local.py` — offline entrypoint the hosted sandbox runs, consuming a pre-fetched context
+- `review_pr.py` - pipeline orchestrator (fetch → classify → gates → LLM), and the `gh`-fetching entrypoint
+- `review_local.py` - the entrypoint that reviews from a pre-fetched context JSON
+- `policy.py` - policy loader, resolver, and the untrusted-text sanitizer
+- `gates.py` - deterministic classification and deny-list logic
+- `github.py` - GitHub data fetching via `gh` CLI
+- `reviewer.py` - Claude Agent SDK reviewer (showstoppers prompt)
## Empirical basis
Tier thresholds and deny categories calibrated against 356 PRs that received quick human approval (stamp) in the PostHog repo over ~90 days:
-- 126 tiny (1-10 lines), 102 small (11-50 lines) — most quick approvals are small
-- 284/356 single-area — narrow scope dominates
+- 126 tiny (1-10 lines), 102 small (11-50 lines) - most quick approvals are small
+- 284/356 single-area - narrow scope dominates
- Top profiles: frontend-only (122), python-only (57), python+test (28), config-only (21), test-only (16)
-- 184 `fix`, 101 `chore` — fixes and chores are the modal commit types
+- 184 `fix`, 101 `chore` - fixes and chores are the modal commit types
- Frontend-only cluster: median 9 lines/1 file, 0% has tests
- Python+test cluster: median 73 lines/2.5 files, 100% has tests
- Python-only cluster: median 13 lines/1 file, 3% has tests
-Key insight: size alone is not a safe proxy. Small PRs touching CI workflows, auth, or SAML should never be auto-approved regardless of size. The deny-list exists precisely for this.
+Key insight: size alone is not a safe proxy.
+Small PRs touching CI workflows, auth, or SAML should never be auto-approved regardless of size.
+The deny-list exists precisely for this.