: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(devex): run whole-repo pytest guards outside test selection (#84370)
Julian Bezde8e4e600c43
diff --git a/.agents/skills/django-startup-time/SKILL.md b/.agents/skills/django-startup-time/SKILL.mdindex 31e7bbbe21ae..ed8a0f6a216b 100644--- a/.agents/skills/django-startup-time/SKILL.md+++ b/.agents/skills/django-startup-time/SKILL.md@@ -12,7 +12,7 @@ description: >Full background — the four mechanisms (lazy router, model registration, receiver wiring, boot GC window), the regression guards, how to add code without regressing them, how to measure, and the detailed trap write-ups: **[docs/internal/django-startup-time.md](../../../docs/internal/django-startup-time.md)**. That doc is the single source of detail; this skill is the trigger and the checklist.-The guards live in `posthog/test/test_startup_import_budget.py`. **When one fails, defer the import — don't remove an entry to dodge it.** Conversely, when you deliberately defer a significant heavy lib off setup, **add it to `FORBIDDEN_AT_SETUP`** (after confirming it's absent from a bare `django.setup()`). New imports nobody has named yet are caught by `test_no_new_heavy_imports_at_setup`: any package not in `posthog/test/setup_import_baseline.txt` costing ≥100ms at setup fails the build — defer it; baseline only what every process genuinely needs at setup.+The guards live in `posthog/test/repo_invariants/test_startup_import_budget.py`. **When one fails, defer the import — don't remove an entry to dodge it.** Conversely, when you deliberately defer a significant heavy lib off setup, **add it to `FORBIDDEN_AT_SETUP`** (after confirming it's absent from a bare `django.setup()`). New imports nobody has named yet are caught by `test_no_new_heavy_imports_at_setup`: any package not in `posthog/test/repo_invariants/setup_import_baseline.txt` costing ≥100ms at setup fails the build — defer it; baseline only what every process genuinely needs at setup.## Defaults when adding backend codediff --git a/.agents/skills/writing-dataclasses/SKILL.md b/.agents/skills/writing-dataclasses/SKILL.mdindex 43f36f682d4b..9cd41b70dce1 100644--- a/.agents/skills/writing-dataclasses/SKILL.md+++ b/.agents/skills/writing-dataclasses/SKILL.md@@ -37,7 +37,7 @@ class RunAccumulator: ...- `kw_only=True` is what actually prevents swaps at construction: `BillingPeriod(start=a, end=b)`, never `BillingPeriod(a, b)`. Don't override it without a reason.- `slots=True` blocks `functools.cached_property` and ad-hoc attributes; override with `slots=False` rather than dropping `@frozen`.-- A bare `@dataclass` with no explicit `frozen=` fails the ratchet in `posthog/test/test_dataclass_defaults.py` and is flagged by the advisory `prefer-frozen-dataclasses` semgrep rule. `@dataclass(frozen=False)` passes; the ratchet asks for a stated choice, not immutability. If you only _moved_ an existing bare `@dataclass`, regenerate the baseline with `python posthog/test/test_dataclass_defaults.py` instead of decorating it.+- A bare `@dataclass` with no explicit `frozen=` fails the ratchet in `posthog/test/repo_invariants/test_dataclass_defaults.py` and is flagged by the advisory `prefer-frozen-dataclasses` semgrep rule. `@dataclass(frozen=False)` passes; the ratchet asks for a stated choice, not immutability. If you only _moved_ an existing bare `@dataclass`, regenerate the baseline with `python posthog/test/repo_invariants/test_dataclass_defaults.py` instead of decorating it.- Don't add `frozen=False` to a bare `@dataclass` you didn't otherwise touch. The ratchet counts per file against a baseline; an unchanged count passes, and the edit is churn in someone else's file.- Facade contracts (`products/<name>/backend/facade/contracts.py`) are frozen dataclasses too, usually `pydantic.dataclasses.dataclass(frozen=True)` so they validate on construction. See [products/architecture.md](../../../products/architecture.md).@@ -73,6 +73,6 @@ Three carve-outs, in priority order:## What enforces this-- `posthog/test/test_dataclass_defaults.py` (blocking ratchet): new bare `@dataclass` without `frozen=`.+- `posthog/test/repo_invariants/test_dataclass_defaults.py` (blocking ratchet): new bare `@dataclass` without `frozen=`.- `.semgrep/rules/devex/prefer-frozen-dataclasses.yaml` and `tuple-return-prefer-dataclass.yaml` (advisory).- Everything else is review.diff --git a/.agents/skills/writing-tests/SKILL.md b/.agents/skills/writing-tests/SKILL.mdindex 7b2e5db958ea..b28412ae9edf 100644--- a/.agents/skills/writing-tests/SKILL.md+++ b/.agents/skills/writing-tests/SKILL.md@@ -114,6 +114,7 @@ Escalating to the next rung is the last resort, not the default.Don't mock your own internal helpers (that's how change-detector tests are born).- **Person/group/cohort data:** use the helpers in `posthog/test/persons.py` (`create_person`, `create_group`, `create_group_type_mapping`, `add_cohort_members`, etc.) — never `Person.objects.create()` or similar ORM calls directly.See [`posthog/test/AGENTS.md`](../../posthog/test/AGENTS.md) for the full API reference and rationale.+- **Whole-repo guards go in `posthog/test/repo_invariants/`.** If a test's input is the entire repo — it walks `apps.get_models()`, inspects `sys.modules` after a cold `django.setup()`, enumerates every route or signal receiver, or `rglob`s the tree against a baseline — any file anywhere can break it and diff-based test selection can't select it. That directory runs unconditionally in the `repo-checks` CI job on every backend PR (products-only and drafts included) with no Postgres/ClickHouse, and the Core shards skip it. Tests with a bounded input stay next to the code they cover.### Frontend (Jest)diff --git a/.claude/commands/conventions.md b/.claude/commands/conventions.mdindex 9066bd2780f2..ad174ed30e7d 100644--- a/.claude/commands/conventions.md+++ b/.claude/commands/conventions.md@@ -96,7 +96,7 @@ Hence the explicit separation between the data and view layers.- Consume results with dot notation (`result.field`), never by unpacking into positional locals- Name dataclasses after the domain concept (`BillingPeriod`), never `*Info`/`*Data`/`*Tuple`- Mark secret fields with `field(repr=False)`-- A bare `@dataclass` without an explicit `frozen=` choice fails the `posthog/test/test_dataclass_defaults.py` ratchet and is flagged by the `prefer-frozen-dataclasses` semgrep rule+- A bare `@dataclass` without an explicit `frozen=` choice fails the `posthog/test/repo_invariants/test_dataclass_defaults.py` ratchet and is flagged by the `prefer-frozen-dataclasses` semgrep rule### Loggingdiff --git a/.cursor/rules/django-python.mdc b/.cursor/rules/django-python.mdcindex 5bbe86aca0a1..b58577553e8d 100644--- a/.cursor/rules/django-python.mdc+++ b/.cursor/rules/django-python.mdc@@ -107,7 +107,7 @@ Dataclasses- Use @frozen from posthog.dataclasses (frozen=True, kw_only=True, slots=True by default; every flag overridable, e.g. @frozen(slots=False) for functools.cached_property).- Consume results with dot notation (result.field), never by unpacking into positional locals (a, b = result.a, result.b).- Name dataclasses after the domain concept (BillingPeriod), never *Info/*Data/*Tuple; mark secret fields with field(repr=False).- - A bare @dataclass without an explicit frozen= choice fails the posthog/test/test_dataclass_defaults.py ratchet and is flagged by the prefer-frozen-dataclasses semgrep rule.+ - A bare @dataclass without an explicit frozen= choice fails the posthog/test/repo_invariants/test_dataclass_defaults.py ratchet and is flagged by the prefer-frozen-dataclasses semgrep rule.Running commands- Use `uv sync` instead of `pip install -r ...`, and `uv add PACKAGE` instead of `pip install PACKAGE`. If there is an import error, first activate the venv at `.flox/cache/venv/` or alternatively `.venv/`.diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex 4dee84300abf..82196e1de322 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -755,7 +755,8 @@ jobs:# Partition selected files by the Django segment that owns them.# Mirrors the positional path arguments in the Run Core / Run Temporal pytest invocations:- # Core (POE off): posthog ee/ (minus posthog/temporal, posthog/dags)+ # Core (POE off): posthog ee/ (minus posthog/temporal, posthog/dags,+ # posthog/test/repo_invariants)# Core POE on: posthog/clickhouse, posthog/queries, posthog/api/test/test_insight*,# posthog/api/test/dashboards/test_dashboard.py, ee/clickhouse/# Temporal: posthog/temporal, products/{batch_exports,tasks}/backend/temporal,@@ -776,7 +777,7 @@ jobs:poe+=("$f")core+=("$f");;- posthog/dags/*|common/hogvm/python/test/*)+ posthog/dags/*|common/hogvm/python/test/*|posthog/test/repo_invariants/*)# Explicitly --ignore'd by the Core invocation; nothing to do.;;posthog/*|ee/*)@@ -1045,6 +1046,19 @@ jobs:run: tach check --dependencies --interfaces- name: Check product facade enforcement (import-linter)run: lint-imports+ # These guards take the whole repo as input (import graph after+ # django.setup(), signal registries, repo-wide AST scans), so diff-based+ # test selection can't pick them and the Django matrix skips them on+ # products-only diffs and drafts. They need no service containers.+ # Branches that predate the directory still carry the guards at their+ # old paths, so fall back to those rather than failing on a missing arg.+ - name: Run repo invariants (whole-repo pytest guards)+ run: |+ if [ -d posthog/test/repo_invariants ]; then+ pytest -p no:cacheprovider posthog/test/repo_invariants+ else+ pytest -p no:cacheprovider posthog/test/test_startup_import_budget.py posthog/test/test_dataclass_defaults.py+ fi# Block deleting historical migration files (see safe-django-migrations.md).# GITHUB_ACTIONS=false suppresses the command's PR annotations on the shadow.- name: Check deleted migrations@@ -1982,6 +1996,7 @@ jobs:--ignore=posthog/temporal \--ignore=posthog/dags \--ignore=common/hogvm/python/test \+ --ignore=posthog/test/repo_invariants \"${full_ignores[@]}" \--splits ${{ matrix.concurrency }} --group ${{ matrix.group }} \--durations=1000 --durations-min=1.0 \diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex 8c22979c1761..cec4f74ddf24 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -701,7 +701,8 @@ jobs:# Partition selected files by the Django segment that owns them.# Mirrors the positional path arguments in the Run Core / Run Temporal pytest invocations:- # Core (POE off): posthog ee/ (minus posthog/temporal, posthog/dags)+ # Core (POE off): posthog ee/ (minus posthog/temporal, posthog/dags,+ # posthog/test/repo_invariants)# Core POE on: posthog/clickhouse, posthog/queries, posthog/api/test/test_insight*,# posthog/api/test/dashboards/test_dashboard.py, ee/clickhouse/# Temporal: posthog/temporal, products/{batch_exports,tasks}/backend/temporal,@@ -722,7 +723,7 @@ jobs:poe+=("$f")core+=("$f");;- posthog/dags/*|common/hogvm/python/test/*)+ posthog/dags/*|common/hogvm/python/test/*|posthog/test/repo_invariants/*)# Explicitly --ignore'd by the Core invocation; nothing to do.;;posthog/*|ee/*)@@ -1261,6 +1262,20 @@ jobs:- name: Check product facade enforcement (import-linter)run: lint-imports+ # These guards take the whole repo as input (import graph after+ # django.setup(), signal registries, repo-wide AST scans), so diff-based+ # test selection can't pick them and the Django matrix skips them on+ # products-only diffs and drafts. They need no service containers.+ # Branches that predate the directory still carry the guards at their+ # old paths, so fall back to those rather than failing on a missing arg.+ - name: Run repo invariants (whole-repo pytest guards)+ run: |+ if [ -d posthog/test/repo_invariants ]; then+ pytest -p no:cacheprovider posthog/test/repo_invariants+ else+ pytest -p no:cacheprovider posthog/test/test_startup_import_budget.py posthog/test/test_dataclass_defaults.py+ fi+# Deterministic = a static check above failed after setup completed.# A retry can't fix it, so this signals the cancellation gate to stop the run.- name: Flag deterministic failure@@ -3092,6 +3107,7 @@ jobs:--ignore=posthog/temporal \--ignore=posthog/dags \--ignore=common/hogvm/python/test \+ --ignore=posthog/test/repo_invariants \"${full_ignores[@]}" \--splits ${{ matrix.concurrency }} --group ${{ matrix.group }} \--durations=1000 --durations-min=1.0 --store-durations \diff --git a/.semgrep/rules/devex/prefer-frozen-dataclasses.yaml b/.semgrep/rules/devex/prefer-frozen-dataclasses.yamlindex 38699992b23d..70dbf3dccc53 100644--- a/.semgrep/rules/devex/prefer-frozen-dataclasses.yaml+++ b/.semgrep/rules/devex/prefer-frozen-dataclasses.yaml@@ -15,7 +15,7 @@ rules:end: datetimeIf mutability is intentional, say so explicitly with `@dataclass(frozen=False, ...)`.- The `posthog/test/test_dataclass_defaults.py` ratchet blocks new undeclared uses;+ The `posthog/test/repo_invariants/test_dataclass_defaults.py` ratchet blocks new undeclared uses;existing ones are grandfathered in its baseline and migrated over time.Informational, not blocking. For a genuine exception, add`# nosemgrep: prefer-frozen-dataclasses -- <reason>` on the class line.diff --git a/AGENTS.md b/AGENTS.mdindex 69cda6f08288..2bbe8af42ac0 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -200,7 +200,7 @@ See [.agents/security.md](.agents/security.md) for security guidelines — least- Python: Write as if mypy `--strict` is enabled — annotate all function signatures (arguments + return types), avoid `Any`, use `TYPE_CHECKING` imports for type-only references. When a change is type-risky, run mypy the way CI does — `uv run mypy --cache-fine-grained .`, repo-wide, never a file subset (it follows imports, so a subset misses reverse-dependency breakage); `hogli ci:preflight` reminds you, and CI blocks on the same command. The config isn't fully strict yet, but new code should be- Python imports: keep imports at module level — not inside functions, methods, or conditionals. Inline imports hide dependencies from static analysis, slow hot paths with repeated lookups, and mask circular-import problems instead of fixing them; ruff's `PLC0415` enforces this. Defer an import only to (1) break a true unavoidable circular import (fix the structure first if you can), (2) reference types under `TYPE_CHECKING`, or (3) keep a heavy/optional dependency off the import path so it loads only when its code runs. For (3), add a justified `# noqa: PLC0415` on the import line (e.g. `# noqa: PLC0415 — keeps the heavy dep off the import path`) — never blanket-suppress the rule-- Python dataclasses: invoke `/writing-dataclasses` before adding or changing a dataclass, returning or passing several values, or passing a dataclass through layers. House decorator is `@frozen` from `posthog.dataclasses`; a bare `@dataclass` without an explicit `frozen=` fails the ratchet in `posthog/test/test_dataclass_defaults.py`+- Python dataclasses: invoke `/writing-dataclasses` before adding or changing a dataclass, returning or passing several values, or passing a dataclass through layers. House decorator is `@frozen` from `posthog.dataclasses`; a bare `@dataclass` without an explicit `frozen=` fails the ratchet in `posthog/test/repo_invariants/test_dataclass_defaults.py`- Frontend: for any frontend work — the main app (`frontend/src/`) **or** a product frontend (`products/*/frontend/`) — follow [frontend/src/AGENTS.md](frontend/src/AGENTS.md): reuse existing Lemon/quill components instead of hand-rolling tables/badges/labels, import generated `*Api` types instead of handwriting them, and run typecheck/typegen at the right moments. Product frontends share the same components and generated types, so the same rules apply there- Frontend: TypeScript required, explicit return types- Frontend: If there is a kea logic file, write all business logic there, avoid React hooks at all costs.diff --git a/docs/internal/django-startup-time.md b/docs/internal/django-startup-time.mdindex 4d0e7440bd21..0204b6cfdeba 100644--- a/docs/internal/django-startup-time.md+++ b/docs/internal/django-startup-time.md@@ -64,12 +64,14 @@ The same applies to the celery task graph: `posthog/tasks/__init__.py` eagerly i## The regression guard-`posthog/test/test_startup_import_budget.py` boots a bare `django.setup()` in a clean subprocess and asserts three things, one per mechanism:+`posthog/test/repo_invariants/test_startup_import_budget.py` boots a bare `django.setup()` in a clean subprocess and asserts three things, one per mechanism:1. No `FORBIDDEN_AT_SETUP` heavy module (the lazy router aggregator, the generated `posthog.schema`, the query-runner layer, the AI core, `chdb`, `scipy`, …) is in `sys.modules`.2. Every model registers at app-population — importing the router adds none.3. No signal receiver connects _only_ when the router is built.+It runs in the `repo-checks` CI job on every backend-touching PR regardless of test selection, because a products-only diff skips the Django suite entirely.+**When a guard fails, fix the import — do not widen the list.**Defer the offending import, add the missing `models/__init__` import, or wire the receiver at `ready()`.Removing an entry to make the test pass re-opens the door the guard exists to keep shut.@@ -80,7 +82,7 @@ Confirm the module is absent from a bare `django.setup()` first, then add it.**The forward-looking guard: new heavy imports.**`FORBIDDEN_AT_SETUP` only catches modules someone already named; `test_no_new_heavy_imports_at_setup` catches the heavy import nobody has named yet.-It captures `python -X importtime` over a bare setup (GC disabled, so a migrating gen2 pause can't masquerade as a module's cost), aggregates self-time by top-level package for third-party (SDKs split across submodules; the package total is the meaningful number) and per-module for first-party, and fails when a name **not** in `posthog/test/setup_import_baseline.txt` costs ≥100ms.+It captures `python -X importtime` over a bare setup (GC disabled, so a migrating gen2 pause can't masquerade as a module's cost), aggregates self-time by top-level package for third-party (SDKs split across submodules; the package total is the meaningful number) and per-module for first-party, and fails when a name **not** in `posthog/test/repo_invariants/setup_import_baseline.txt` costs ≥100ms.There are deliberately no per-entry time budgets — absolute timings flake in CI — time is only the materiality gate for _new arrivals_: known names are never timed, and a new arrival is deterministic (the PR that adds the import, adds it).Two captures are taken and the per-name minimum used, because a cold first boot pays page-cache misses that can double a package's apparent cost.When it fires: defer the import (the failure message carries the playbook); baseline a package only when every process genuinely needs it during setup, with a justifying comment.diff --git a/docs/published/handbook/engineering/conventions/backend-coding.md b/docs/published/handbook/engineering/conventions/backend-coding.mdindex 3eb9087c6315..4834aaaece16 100644--- a/docs/published/handbook/engineering/conventions/backend-coding.md+++ b/docs/published/handbook/engineering/conventions/backend-coding.md@@ -166,7 +166,7 @@ Don't unpack them back into positional locals (`a, b = result.a, result.b`), whiName dataclasses after the domain concept (`ClickHouseCredentials`, `BillingPeriod`), never `*Info`/`*Data`/`*Tuple`; use a `*Result` suffix only when the function's outcome genuinely is the concept.Mark secret fields with `field(repr=False)` so they stay out of logs and tracebacks.-Enforcement: a new bare `@dataclass` without an explicit `frozen=` choice fails the ratchet in `posthog/test/test_dataclass_defaults.py` (existing uses are grandfathered in its baseline) and is flagged inline by the `prefer-frozen-dataclasses` semgrep rule.+Enforcement: a new bare `@dataclass` without an explicit `frozen=` choice fails the ratchet in `posthog/test/repo_invariants/test_dataclass_defaults.py` (existing uses are grandfathered in its baseline) and is flagged inline by the `prefer-frozen-dataclasses` semgrep rule.### Querying ClickHousediff --git a/posthog/test/repo_invariants/README.md b/posthog/test/repo_invariants/README.mdnew file mode 100644index 000000000000..c3d3f33b2148--- /dev/null+++ b/posthog/test/repo_invariants/README.md@@ -0,0 +1,15 @@+# Repo invariants++Tests here take the whole repo as input: the import graph after `django.setup()`,+`apps.get_models()`, signal receiver registries, repo-wide AST scans against a+baseline. Any file anywhere can break them, and diff-based test selection has no+way to pick them from a diff.++So CI runs this directory unconditionally on every backend-touching PR, including+products-only diffs and drafts, as a step of the `repo-checks` job in+`.github/workflows/ci-backend.yml`. There is no Postgres or ClickHouse in that+job, and the Core Django shards skip this directory.++Rules: no database or ClickHouse fixtures. A test whose input is a bounded set of+files belongs next to the code it covers, not here. Regenerate baselines with the+commands the tests print when they fail.diff --git a/posthog/test/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtsimilarity index 100%rename from posthog/test/dataclass_frozen_baseline.txtrename to posthog/test/repo_invariants/dataclass_frozen_baseline.txtdiff --git a/posthog/test/setup_import_baseline.txt b/posthog/test/repo_invariants/setup_import_baseline.txtsimilarity index 100%rename from posthog/test/setup_import_baseline.txtrename to posthog/test/repo_invariants/setup_import_baseline.txtdiff --git a/posthog/test/setup_receivers_baseline.txt b/posthog/test/repo_invariants/setup_receivers_baseline.txtsimilarity index 99%rename from posthog/test/setup_receivers_baseline.txtrename to posthog/test/repo_invariants/setup_receivers_baseline.txtindex f343a7d5b529..459febb8e3bb 100644--- a/posthog/test/setup_receivers_baseline.txt+++ b/posthog/test/repo_invariants/setup_receivers_baseline.txt@@ -1,6 +1,6 @@# First-party signal receivers connected after a bare django.setup(), as signal:module.qualname.# Maintained by test_setup_receivers_match_baseline — regenerate with:-# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/test_startup_import_budget.py -k receivers_match+# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/repo_invariants/test_startup_import_budget.py -k receivers_match# A receiver disappearing from this set means it connects in NO process (silent audit/cache loss):# restore its AppConfig.ready() wiring instead of deleting the line.model_activity:posthog.models.activity_logging.signal_handlers.handle_experiment_holdout_changediff --git a/posthog/test/test_dataclass_defaults.py b/posthog/test/repo_invariants/test_dataclass_defaults.pysimilarity index 94%rename from posthog/test/test_dataclass_defaults.pyrename to posthog/test/repo_invariants/test_dataclass_defaults.pyindex f802987e42af..64253f340ea6 100644--- a/posthog/test/test_dataclass_defaults.py+++ b/posthog/test/repo_invariants/test_dataclass_defaults.py@@ -6,15 +6,15 @@ deliberate. Existing bare @dataclass uses are grandfathered in the baseline.Regenerate the baseline (only to ratchet DOWN or after moving code):- python posthog/test/test_dataclass_defaults.py+ python posthog/test/repo_invariants/test_dataclass_defaults.py"""import astfrom pathlib import Path-REPO_ROOT = Path(__file__).parents[2]+REPO_ROOT = Path(__file__).parents[3]BASELINE_PATH = Path(__file__).parent / "dataclass_frozen_baseline.txt"-SCANNED_ROOTS = ("posthog", "ee", "products", "dags", "common")+SCANNED_ROOTS = ("posthog", "ee", "products", "common")SKIPPED_DIRS = {"node_modules", ".venv", "venv", "__pycache__", ".git", ".mypy_cache"}@@ -92,7 +92,7 @@ def test_no_new_undeclared_dataclasses() -> None:"New @dataclass without an explicit frozen= choice. Prefer @frozen from ""posthog.dataclasses (frozen, kw_only, slots by default; every flag overridable), ""or pass frozen= explicitly if mutability is intentional. If you only moved "- "existing code, regenerate the baseline: python posthog/test/test_dataclass_defaults.py\n"+ "existing code, regenerate the baseline: python posthog/test/repo_invariants/test_dataclass_defaults.py\n"+ "\n".join(regressions))diff --git a/posthog/test/test_startup_import_budget.py b/posthog/test/repo_invariants/test_startup_import_budget.pysimilarity index 98%rename from posthog/test/test_startup_import_budget.pyrename to posthog/test/repo_invariants/test_startup_import_budget.pyindex d48c0907eaa7..95c0367c91a1 100644--- a/posthog/test/test_startup_import_budget.py+++ b/posthog/test/repo_invariants/test_startup_import_budget.py@@ -211,7 +211,7 @@ def test_signal_receivers_connect_at_setup_not_via_router() -> None:# a hand-curated "one representative per relocation" list proved both fiddly and incomplete (several# ready()-wired receivers were never pinned). A receiver missing from the live set is silent audit/cache# loss; an unexpected one is a new wiring to record deliberately. Regenerate the file with:-# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/test_startup_import_budget.py -k receivers_match+# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/repo_invariants/test_startup_import_budget.py -k receivers_match# Known granularity limit: receivers created in a loop share one qualname (e.g. the org-cache# _connect_invalidation closures), so the set can't see one of their senders being dropped —# Django stores sender identity as id(), which is not stable enough to snapshot.@@ -270,7 +270,7 @@ def test_setup_receivers_match_baseline() -> None:header = ("# First-party signal receivers connected after a bare django.setup(), as signal:module.qualname.\n""# Maintained by test_setup_receivers_match_baseline — regenerate with:\n"- "# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/test_startup_import_budget.py -k receivers_match\n"+ "# UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/repo_invariants/test_startup_import_budget.py -k receivers_match\n""# A receiver disappearing from this set means it connects in NO process (silent audit/cache loss):\n""# restore its AppConfig.ready() wiring instead of deleting the line.\n")@@ -291,7 +291,7 @@ def test_setup_receivers_match_baseline() -> None:f"These receivers connect at django.setup() but are not in setup_receivers_baseline.txt: {unexpected}. ""If the new wiring is deliberate (receiver in an import-light module, imported from the owning ""AppConfig.ready() — see docs/internal/django-startup-time.md), record it: "- "UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/test_startup_import_budget.py -k receivers_match"+ "UPDATE_SETUP_RECEIVERS_BASELINE=1 pytest posthog/test/repo_invariants/test_startup_import_budget.py -k receivers_match")@@ -339,7 +339,7 @@ def test_mcp_tool_registry_loads_cold_without_import_cycle() -> None:# unbounded cycle growth in a long-lived process. This boots through manage.py and asserts both# ends of the window.def test_boot_gc_window_reenables_and_freezes() -> None:- manage_py = Path(__file__).parents[2] / "manage.py"+ manage_py = Path(__file__).parents[3] / "manage.py"probe = ("import gc; ""assert gc.isenabled(), 'GC left disabled after boot'; "diff --git a/products/review_hog/backend/receivers.py b/products/review_hog/backend/receivers.pyindex 9b22f0114ca6..cde3dff83cd1 100644--- a/products/review_hog/backend/receivers.py+++ b/products/review_hog/backend/receivers.py@@ -52,7 +52,7 @@ from products.signals.backend.report_generation.resolve_reviewers import resolvefrom products.stamphog.backend.facade.inbox_hooks import register_inbox_acting_reviewer_resolver# This module loads during django.setup() (AppConfig.ready() wires the receiver), and-# posthog/test/test_startup_import_budget.py forbids temporalio/modal/openai/anthropic at setup —+# posthog/test/repo_invariants/test_startup_import_budget.py forbids temporalio/modal/openai/anthropic at setup —# the temporal client and the stamphog task module reach all four, so those two imports stay# function-local in _start_review / _start_stamphog_review per the budget test's own prescription.