: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): shrink this repository's policy to an overlay (#118375)
Julian Bez555d65c91dcd
diff --git a/.stamphog/README.md b/.stamphog/README.mdindex cecebe47e0cc..8bdd67697332 100644--- a/.stamphog/README.md+++ b/.stamphog/README.md@@ -7,31 +7,29 @@ What each file contains and how per-folder overrides resolve: [the engine's "Pol## What this repository configures-`policy.yml` keeps the shipped defaults for `size_gate`, `tiers`, `overrides`, `familiarity` and `ownership`.-It overrides `deny` and `allow`, and the differences are:+`policy.yml` declares only what differs from the shipped default, which the engine merges it onto:-- `deny_exceptions` lifts `auth` and `billing` for `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. It lifts `workflows_delivery` for the CDP and Messaging API test directories.-- `infra_cicd` also matches `.github/pr-deploy`. Of the workflows, it keeps only the ones that CODEOWNERS assigns to `team-security`, so those stay denied for every author.+- `infra_cicd` replaces its `paths` list. It also matches `.github/pr-deploy`, and of the workflows it keeps only the ones that CODEOWNERS assigns to `team-security`, so those stay denied for every author.- `ci_workflows` is an extra, owner-only category. It matches every file under `.github/workflows/` and `.depot/workflows/`, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-devex`.-- `stamphog_policy` also matches `packages/owners-yaml/`, `owners.yaml` and `product.yaml`, because those are gate inputs here.+- `stamphog_policy` extends its paths with `packages/owners-yaml/`, `owners.yaml` and `product.yaml`, because those are gate inputs here.- `devex_guardrails` is an extra category. It matches the semgrep rules, ratchet baselines, invariant tests and lint code that guard the house patterns, so an edit to a guard always gets a human review.- `agent_steering` is an extra, owner-only category. It matches the root `AGENTS.md`, the PR template, the `writing-pr-descriptions` skill, `.claude/settings.json`, `.claude/hooks/` and `.mcp.json`, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-devex`.- `workflows_delivery` is an extra, owner-only category. It matches the CDP, Workflows and Messaging API, models and plugin-server worker code, and its `exempt_author_teams` lets stamphog approve there only for authors on `team-workflows`.-- `allow` also lists `.github/CODEOWNERS`.-- Every `rationale` records the false positives that shaped the rule in this repository.+- `deny_exceptions` lifts `auth` and `billing` for `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. It lifts `workflows_delivery` for the CDP and Messaging API test directories.+- `allow` extends its path patterns with `.github/CODEOWNERS`.The repository uses the shipped default `review-guidance.md`.`steering.md` tells the reviewer to refuse a diff that adds a suppression or an exemption for one of those guards.A path rule cannot see these, because the marker sits in product code or in a busy file.-`ownership` declares one `hogli-resolver` source at the repo root, so stamphog reads the same merged view the reviewer auto-assigner builds.+`ownership` comes from the shipped default, which declares one `hogli-resolver` source at the repo root, so stamphog reads the same merged view the reviewer auto-assigner builds.-`overrides` grants folders a ceiling of 50 files and 1000 lines.+`overrides` comes from the shipped default and 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).## Proposing a changeOpen 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.+The loader also hard-fails if that self-governance entry is missing or loses a shipped pattern, so it cannot be dropped silently.diff --git a/.stamphog/policy.yml b/.stamphog/policy.ymlindex 3c511fefcb44..1af1f95c29bd 100644--- a/.stamphog/policy.yml+++ b/.stamphog/policy.yml@@ -1,71 +1,12 @@-# Stamphog merge-gate policy - see .stamphog/README.md for how changes are-# proposed and reviewed. Keep pattern scalars single-quoted so regex-# backslashes survive YAML parsing.-version: 1+# Stamphog merge-gate policy for this repository. The engine merges this file onto its shipped+# default (products/stamphog/packages/pr-approval-agent/defaults/policy.yml), so it declares only+# what differs: mappings merge key by key, a declared list replaces the default's list, and an+# extend_<list> key appends to it. See .stamphog/README.md for what each difference is for. Keep+# pattern scalars single-quoted so regex backslashes survive YAML parsing.deny:- auth:- description: 'Authentication and authorization surfaces.'- rationale: "Only file paths hard-deny; titles surface as scrutiny flags. Past participles (authenticated/authorized) live in titles-only because as path patterns they hard-deny the wrong things (web analytics' authorized_urls.py is domain config, not the auth system). session/token/permission are path-only with tighter compounds because they match too broadly in titles and non-auth paths (SessionAnalysisWarning, tokenizer, permission helpers)."- match:- any:- - 'auth'- - 'login'- - 'signup'- - 'oauth'- - 'saml'- - 'sso'- - 'oidc'- - 'credential'- - 'password'- - '2fa'- - 'mfa'- - 'authentication'- - 'authenticate'- - 'authorize'- - 'authorization'- - 'two[_-]?factor'- titles:- - 'authenticated'- - 'authorized'- paths:- - 'session_auth'- - 'session_token'- - 'auth/session'- - 'auth/token'- - 'permission'- crypto_secrets:- description: 'Cryptography, secrets, and key material.'- rationale: 'key/secret/cert/signing are too broad for titles (key matches keyboard, hotkey, localStorage key), so they are path-only with compound patterns.'- match:- any:- - 'crypto'- - 'encrypt'- - 'decrypt'- - 'vault'- paths:- - 'secret'- - 'api[_-]?key'- - 'secret[_-]?key'- - 'private[_-]?key'- - 'signing[_-]?key'- - 'certificate'- - '\.env'- - '\.pem'- migrations:- description: 'Database and schema migrations.'- rationale: 'The migrations/ substring is load-bearing - it also catches rust *_migrations/ dirs applied by sqlx at deploy.'- match:- paths:- - 'migrations/'- - 'schema_change'infra_cicd:- description: 'Infrastructure, CI, and deployment artifacts.'rationale: 'routing and bare deploy are excluded on purpose: every historical match was app-level (DRF routers, message-routing tests, deploy-timing docs), never infrastructure. Narrow deploy literals (bin/deploy, deploy.sh, .github/pr-deploy) cover real deployment artifacts without the false positives.'match:- any:- - 'terraform'- - 'kubernetes'- - 'helm'paths:- 'k8s'- 'dockerfile'@@ -87,55 +28,12 @@ deny:- '\.depot/workflows'exempt_author_teams:- 'team-devex'- billing:- description: 'Payments and billing.'- rationale: 'subscription is excluded on purpose: in this repo it means scheduled insight/report deliveries, not payments. Real billing surfaces still match via the other words.'- match:- any:- - 'billing'- - 'payment'- - 'stripe'- - 'invoice'- - 'pricing'- public_api:- description: 'Public API contracts and schemas.'- rationale: 'Changes to the published API surface need human review.'- match:- any:- - 'openapi'- - 'api_schema'- - 'swagger'- - 'public_api'- deps_toolchain:- description: 'Dependency lockfiles and toolchain/build files.'- rationale: "All path-only literal filenames. Manifests deliberately don't hard-deny: without a lockfile change they cannot pull in third-party code, and manifest scripts/hooks are guarded by the reviewer prompt and kept out of the T0 fast path. requirements.txt stays (pins installed code directly). .nvmrc/.tool-versions stay (they change the runtime for every CI job). Makefile/Dockerfile stay (they execute)."- # NOTE: partially code-sourced. The lockfile-name path patterns are derived- # in the loader from DEPENDENCY_ECOSYSTEMS (re.escape over every ecosystem's- # lockfiles) and spliced in ahead of the literals below - do not copy them- # here. Only the non-derived literal patterns live in this file.- match:- paths:- - 'requirements[-\w]*\.(txt|in)'- - 'Makefile'- - 'Dockerfile'- - '\.tool-versions'- - '\.nvmrc'stamphog_policy:- description: "Stamphog's own policy files, engine, and gate inputs."- rationale: "Changes to the merge gate's own policy or engine always require human review - the gate cannot be trusted to approve edits to itself. Ownership sources (CODEOWNERS, owners.yaml, product.yaml owners) are gate inputs: an ownership edit changes which team the reviewer treats as owning future PRs, and owners.yaml/product.yaml would otherwise ride the .yaml allow-list to a T0 auto-approve (Jul 2026 review finding)."match:- paths:- - '\.stamphog/'- - 'AGENT_APPROVALS\.md'- - 'pr-approval-agent/'- # Kept next to the location-agnostic pattern above. The engine that- # validates this file ships in the server image, so a deploy that still- # runs the previous engine needs this exact literal.- - 'tools/pr-approval-agent/'+ extend_paths:- 'packages/owners-yaml/'# Transitional: branches that predate the move still carry the resolver here.- 'tools/owners/'- - 'CODEOWNERS'- '(?:^|/)owners\.yaml$'- '(?:^|/)product\.yaml$'devex_guardrails:@@ -202,82 +100,5 @@ deny_exceptions:- 'products/cdp/backend/api/test/'- 'products/messaging/backend/api/test/'allow:- path_patterns:- - 'docs/'- - 'README'- - 'CHANGELOG'- - 'LICENSE'- - 'CONTRIBUTING'+ extend_path_patterns:- '.github/CODEOWNERS'- - '.gitignore'- - '.editorconfig'- - 'generated/'- - '__snapshots__/'- extensions_only:- - '.cfg'- - '.csv'- - '.gif'- - '.ico'- - '.ini'- - '.jpeg'- - '.jpg'- - '.json'- - '.lock'- - '.md'- - '.mdx'- - '.png'- - '.rst'- - '.snap'- - '.svg'- - '.toml'- - '.txt'- - '.webp'- - '.yaml'- - '.yml'-size_gate:- max_lines: 800- max_files: 30-tiers:- t1_subclasses:- T1a-trivial:- max_lines: 20- max_files: 3- breadth: 'single-area'- T1b-small:- max_lines: 100- max_files: 5- breadth: 'not-cross-cutting'- T1c-medium:- max_lines: 300- max_files: 15- breadth: 'not-cross-cutting'-overrides:- 'size_gate.max_files':- ceiling: 50- 'size_gate.max_lines':- ceiling: 1000-# Author-familiarity signal - judgment layer only, never a gate. Non-delegable-# (absent from `overrides`). STRONG = blame overlap ≥ min_blame_overlap_pct;-# MODERATE = both of its keys satisfied; else NONE.-# Rationale: calibrated against 120 days of refused/escalated verdict outcomes-# (Jul 2026 backtest). Blame overlap was the only metric that rose monotonically-# with the human rubber-stamp rate; prior-PR counts, previously-modified-file-# fractions, and recency were flat at every cutoff, so STRONG is blame-only and-# MODERATE is advisory. Tuning these is a YAML-only diff.-familiarity:- strong:- min_blame_overlap_pct: 70- moderate:- min_prior_prs: 5- max_days_since_touch: 180-# Ownership sources feeding the reviewer's team context - advisory only, never a-# gate. The hogli-resolver source delegates to the shared hogli OwnersResolver,-# which walks the distributed owners.yaml / product.yaml files from the repo root-# (the `path` locator) and merges nearest-file-wins, so stamphog reads the same-# view the reviewer auto-assigner builds. Sources are read from the master-# checkout (the workflow pins ref: master), so a PR editing them cannot influence-# its own review. Locators must stay repo-relative (no absolute paths, no '..').-ownership:- sources:- - path: .- format: hogli-resolverdiff --git a/products/stamphog/packages/pr-approval-agent/test_policy.py b/products/stamphog/packages/pr-approval-agent/test_policy.pyindex f065f01d906d..e54a1e93d217 100644--- a/products/stamphog/packages/pr-approval-agent/test_policy.py+++ b/products/stamphog/packages/pr-approval-agent/test_policy.py@@ -196,11 +196,11 @@ OLD_ALLOW_PATH_PATTERNS = ["CHANGELOG","LICENSE","CONTRIBUTING",- ".github/CODEOWNERS",".gitignore",".editorconfig","generated/","__snapshots__/",+ ".github/CODEOWNERS",]OLD_MAX_LINES = 800OLD_MAX_FILES = 30