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.

7.6 KB
Raw Blame
# 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:
    infra_cicd:
        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:
            paths:
                - 'k8s'
                - 'dockerfile'
                - 'docker-compose'
                - '\.(github|depot)/workflows/(ci-security|codeql|auto-assign-reviewers)'
                - '\.github/pr-deploy'
                - 'iam'
                - 'cloudflare'
                - 'cdn'
                - 'waf'
                - '(?:^|/)bin/deploy'
                - 'deploy\.sh'
    ci_workflows:
        description: 'GitHub Actions and Depot CI workflows.'
        rationale: 'Owner-only: stamphog approves team-devex changes here and refuses everyone else. team-devex owns the workflows in .github/owners.yaml and edits them daily, so a hard deny sent every routine CI fix to a second devex engineer. infra_cicd also matches the workflows that CODEOWNERS assigns to team-security, and it exempts nobody, so those stay denied for every author.'
        match:
            paths:
                - '\.github/workflows'
                - '\.depot/workflows'
        exempt_author_teams:
            - 'team-devex'
    stamphog_policy:
        match:
            extend_paths:
                - 'packages/owners-yaml/'
                # Transitional: branches that predate the move still carry the resolver here.
                - 'tools/owners/'
                - '(?:^|/)owners\.yaml$'
                - '(?:^|/)product\.yaml$'
    devex_guardrails:
        description: 'The guards that keep the house patterns for API codegen, egress, ingress, product isolation, migrations, URLs and startup imports.'
        rationale: 'These files define what CI blocks, so a small edit can turn a guard off. Most are .yaml, .md, .txt or test files, and without this category they ride the allow-list or the test-only rule to a T0 auto-approve. Busy files stay out on purpose, because most edits to them are routine: tach.toml, pyproject.toml, lib/api.ts, model_crossing_uses_baseline.txt and the setup receivers baseline. owners.yaml routes those to team-devex instead.'
        match:
            paths:
                - '^\.github/scripts/migration-deletion-allowlist\.txt$'
                - '^\.semgrep/rules/devex/'
                - '^\.semgrep/rules/security/prefer-codegen-api\.'
                - '^frontend/src/lib/api-ratchet-baseline\.txt$'
                - '^posthog/(egress|ingress)/agents\.md$'
                - '^posthog/egress/(limiter|observability|transport)/'
                - '^posthog/ingress/(dispatch|observability|verify)/'
                - '^posthog/ingress/views\.py$'
                - '^posthog/management/migration_analysis/'
                - '^posthog/migration_helpers/'
                - '^posthog/product_urls\.py$'
                - '^posthog/settings/nextgensquash\.py$'
                - '^posthog/test/repo_invariants/(dataclass_secret_field_exemptions\.txt|setup_import_baseline\.txt)$'
                - '^posthog/test/repo_invariants/test_(admin_url_conf|dataclass_secret_fields|generated_files_are_registered|migration_dependencies_share_a_database|migration_run_before|model_crossing_uses|model_enum_defaults|squash_partial_fallback|startup_import_budget)\.py$'
                - '^products/(architecture\.md|isolation_baseline\.txt|readme\.md)$'
                - '^docs/internal/django-startup-time\.md$'
                - '^docs/published/handbook/engineering/type-system\.md$'
                - '^tools/hogli-commands/hogli_commands/(api_ratchet|projections|tach_lint)\.py$'
                - '^tools/hogli-commands/hogli_commands/product_structure\.yaml$'
                - '^tools/hogli-commands/hogli_commands/product/'
    agent_steering:
        description: 'The root agent instructions, the PR authoring guidance, and the agent config that runs in every session.'
        rationale: 'Owner-only: stamphog approves team-devex changes here and refuses everyone else. One edit changes how every agent-written PR reads, and the files are .md, so without this category they ride the allow-list to a T0 auto-approve. A change from outside team-devex now needs a human approval, which is where the owner discussion happens. .claude/settings.json and .mcp.json are .json and ride the same allow-list, but their hooks and MCP servers run commands in every agent session, so they belong here too. Other skills under .agents/skills stay out on purpose, because product teams own several and edit their own. Paths are anchored, so a nested AGENTS.md stays with its folder owner.'
        match:
            paths:
                - '^agents\.md$'
                - '^claude\.md$'
                - '^\.agents/(agent-automation|architecture|ci|code-style|feature-usage-tracking)\.md$'
                - '^\.github/pull_request_template\.md$'
                - '^\.agents/skills/writing-pr-descriptions/'
                - '^\.claude/settings\.json$'
                - '^\.claude/hooks/'
                - '^\.mcp\.json$'
        exempt_author_teams:
            - 'team-devex'
    workflows_delivery:
        description: 'CDP, Workflows and Messaging code that decides which customer configurations exist and what gets delivered.'
        rationale: "Owner-only: stamphog approves team-workflows' own changes here and refuses everyone else's. Another team's change here breaks a customer silently: the API and models decide which of a tenant's rows get listed and updated, and the plugin-server worker decides what gets delivered. Teams usually edit these paths to carve out an exception for their own rows, their tests still pass, and existing customer configurations stop appearing or stop being delivered. Product frontends stay out, because a mistake there is visible. As in CODEOWNERS, only the API test directories and `*.test.ts` files stay out. Nothing else under the worker does: the template, legacy-plugin, legacy-webhook and segment directories hold live delivery code and mutable registries."
        match:
            paths:
                - '^products/cdp/backend/(api|models)/'
                - '^products/workflows/backend/(facade|presentation|models)/'
                - '^products/messaging/backend/(api|models)/'
                - '^nodejs/src/cdp/[\s\S]*(?<!\.test\.ts)\Z'
        exempt_author_teams:
            - 'team-workflows'
deny_exceptions:
    # Connector code does OAuth and talks to the Stripe API without touching PostHog's auth system
    # or its billing.
    auth:
        - path_prefixes:
              - 'products/warehouse_sources/backend/temporal/data_imports/sources/'
              - 'products/warehouse_sources/sources/'
    billing:
        - path_prefixes:
              - 'products/warehouse_sources/backend/temporal/data_imports/sources/'
              - 'products/warehouse_sources/sources/'
    workflows_delivery:
        - path_prefixes:
              - 'products/cdp/backend/api/test/'
              - 'products/messaging/backend/api/test/'
allow:
    extend_path_patterns:
        - '.github/CODEOWNERS'