: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): isolation-seal maturity report and honest interface config (#64520)
Julian Bez7bb847752f61
diff --git a/products/legal_documents/package.json b/products/legal_documents/package.jsonindex 0785c9d9af63..749148722916 100644--- a/products/legal_documents/package.json+++ b/products/legal_documents/package.json@@ -1,8 +1,7 @@{"name": "@posthog/products-legal-documents","scripts": {- "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests -v --tb=short",- "backend:contract-check": "echo 'Contract files unchanged'"+ "backend:test": "pytest -c ../../pytest.ini --rootdir ../.. backend/tests -v --tb=short"},"dependencies": {"kea": "catalog:",diff --git a/products/legal_documents/turbo.json b/products/legal_documents/turbo.jsonindex 34a16b3d30ce..4016ec3a8bde 100644--- a/products/legal_documents/turbo.json+++ b/products/legal_documents/turbo.json@@ -1,10 +1,4 @@{"extends": ["//"],- "tasks": {- "backend:contract-check": {- "inputs": ["backend/facade/**", "backend/presentation/**"],- "outputs": [],- "cache": true- }- }+ "tasks": {}}diff --git a/tach.toml b/tach.tomlindex f44db1e77b95..e0cbb807420b 100644--- a/tach.toml+++ b/tach.toml@@ -690,7 +690,7 @@ expose = ["backend\\.routes.*",]from = [- "products\\.(error_tracking|experiments|mcp_analytics|mcp_store|metrics|notifications|tracing|user_interviews|visual_review)",+ "products\\.(error_tracking|experiments|mcp_analytics|mcp_store|metrics|notifications|streamlit_apps|tracing|user_interviews|visual_review)",]# TODO: Experiments-specific temporary interface@@ -761,6 +761,28 @@ from = ["products.mcp_store",]+# legal_documents has a non-standard public surface, so it gets a dedicated block rather than+# joining the canonical alternation above: posthog/urls registers its pandadoc webhook+# (presentation.webhook), and core's OrganizationAdmin lists its LegalDocumentInline (admin+# block below — a Django inline must be named in its parent admin's `inlines`).+[[interfaces]]+expose = [+ "backend\\.facade.*",+ "backend\\.presentation.*",+ "backend\\.routes.*",+]+from = [+ "products.legal_documents",+]++[[interfaces]]+expose = [+ "backend\\.admin.*",+]+from = [+ "products.legal_documents",+]+# error_tracking exposes its ClickHouse DDL (sql / embedding / indexed_embedding) to# core's ClickHouse schema + frozen migrations, and its models / remote_config to core# model-class consumers (product_intent, remote_config, team deletion) and test fixtures.diff --git a/tools/hogli-commands/hogli_commands/product/ast_helpers.py b/tools/hogli-commands/hogli_commands/product/ast_helpers.pyindex 027e640293bd..4315d6f09856 100644--- a/tools/hogli-commands/hogli_commands/product/ast_helpers.py+++ b/tools/hogli-commands/hogli_commands/product/ast_helpers.py@@ -217,36 +217,6 @@ def find_direct_orm_queries(path: Path) -> list[str]:return locations-def get_cross_product_internal_imports(product_dir: Path, product_name: str) -> list[str]:- """- Find imports from other products' internals (non-facade) within this product's own files.- Handles both `from X import Y` and `import X` styles.- Returns list of 'relpath: module' strings.- """-- def _is_cross_product_violation(module: str) -> bool:- if module.startswith(f"products.{product_name}"):- return False- if module.startswith("products.") and ".backend." in module:- return "facade" not in module.split(".")- return False-- violations: list[str] = []- for py_file in product_dir.rglob("*.py"):- tree = ast_parse_safe(py_file)- if not tree:- continue- rel = str(py_file.relative_to(product_dir))- for node in ast.walk(tree):- if isinstance(node, ast.ImportFrom) and node.module and _is_cross_product_violation(node.module):- violations.append(f"{rel}: {node.module}")- elif isinstance(node, ast.Import):- for alias in node.names:- if _is_cross_product_violation(alias.name):- violations.append(f"{rel}: {alias.name}")- return violations--def view_facade_usage(views_path: Path) -> tuple[bool, bool]:"""Returns (imports_facade, imports_models_directly).diff --git a/tools/hogli-commands/hogli_commands/product/checks.py b/tools/hogli-commands/hogli_commands/product/checks.pyindex 7977292d46db..1707dfc7f4b6 100644--- a/tools/hogli-commands/hogli_commands/product/checks.py+++ b/tools/hogli-commands/hogli_commands/product/checks.py@@ -11,13 +11,25 @@ from __future__ import annotationsimport reimport jsonimport shlex-import tomllibfrom abc import ABC, abstractmethodfrom collections.abc import Iteratorfrom dataclasses import dataclass, fieldfrom pathlib import Path-from .paths import REPO_ROOT, TACH_TOML, get_tach_block+from .isolation import (+ IsolationStatus,+ compute_isolation_status,+ has_contract_check_script,+ has_legacy_interface_leaks,+ has_narrowed_turbo_inputs,+ has_real_facade,+ has_tach_interface,+ is_isolated_product,+ iter_interface_blocks as _iter_interface_blocks,+ names_from_pattern as _names_from_pattern,+ pattern_targets_public_surface as _pattern_targets_public_surface,+)+from .paths import TACH_TOML, get_tach_block# ---------------------------------------------------------------------------# Utilities@@ -36,19 +48,6 @@ def check_file_exists(backend_dir: Path, path: str) -> bool:return False-def _iter_interface_blocks(tach_content: str) -> Iterator[tuple[list[str], list[str]]]:- """Yield (expose_patterns, from_patterns) for every [[interfaces]] block."""- for match in re.finditer(r"\[\[interfaces\]\]\s*\n(.*?)(?=\[\[|\Z)", tach_content, re.DOTALL):- block = match.group(1)- expose_match = re.search(r"expose\s*=\s*\[(.*?)\]", block, re.DOTALL)- from_match = re.search(r"from\s*=\s*\[(.*?)\]", block, re.DOTALL)- if not expose_match or not from_match:- continue- expose_patterns = re.findall(r'"(.*?)"', expose_match.group(1))- from_patterns = re.findall(r'"(.*?)"', from_match.group(1))- yield expose_patterns, from_patterns--def _iter_module_blocks(tach_content: str) -> Iterator[tuple[str, list[str]]]:"""Yield (path, depends_on) for every [[modules]] block."""for match in re.finditer(r"\[\[modules\]\]\s*\n(.*?)(?=\[\[|\Z)", tach_content, re.DOTALL):@@ -62,66 +61,6 @@ def _iter_module_blocks(tach_content: str) -> Iterator[tuple[str, list[str]]]:yield path, depends_on-def _pattern_targets_public_surface(pattern: str) -> bool:- """True if a tach expose pattern targets a product's public surface.-- Public surface is backend.facade, backend.presentation, or backend.routes —- the last being the product-local route registration entry point that core- imports to assemble the API router. It is a public composition hook, not an- internal leak, so it does not mark a product as un-isolatable.-- Strips backslashes first so it works on both the on-disk TOML form (`\\.`,- two literal backslashes) and Python-string fixtures (single backslash).- """- normalized = pattern.replace("\\", "")- return (- normalized.startswith("backend.facade")- or normalized.startswith("backend.presentation")- or normalized.startswith("backend.routes")- )---def count_presentation_allowlist_entries(name: str, pyproject_text: str | None = None) -> int:- """Count deferred presentation-wave entries for a product in import-linter's ignore_imports.-- Each pair allows the product's own presentation to bypass its facade — work owed to a- presentation-wave PR (see the isolating-product-facade-contracts skill).- """- if pyproject_text is None:- pyproject = REPO_ROOT / "pyproject.toml"- if not pyproject.exists():- return 0- pyproject_text = pyproject.read_text()- try:- contracts = tomllib.loads(pyproject_text)["tool"]["importlinter"]["contracts"]- except (tomllib.TOMLDecodeError, KeyError):- return 0- prefix = f"products.{name}.backend.presentation"- return sum(1 for contract in contracts for entry in contract.get("ignore_imports", []) if entry.startswith(prefix))---def has_legacy_interface_leaks(tach_content: str, module_path: str) -> bool:- """Check if a product has legacy interface leak blocks in tach.toml.-- These are products where core (posthog/ee) still imports internals directly,- so they can't safely be tested in isolation via contract-check.-- Detected structurally: an [[interfaces]] block whose `from` is exactly this- module and whose `expose` includes any non-facade/non-presentation pattern.- """- for expose_patterns, from_patterns in _iter_interface_blocks(tach_content):- normalized_from = [p.replace("\\", "") for p in from_patterns]- if normalized_from != [module_path]:- continue- if any(not _pattern_targets_public_surface(p) for p in expose_patterns):- return True- return False---def is_isolated_product(backend_dir: Path) -> bool:- return (backend_dir / "facade" / "contracts.py").exists() or (backend_dir / "facade" / "contracts").exists()--# ---------------------------------------------------------------------------# Canonical facade alternation validation (global, not per-product)# ---------------------------------------------------------------------------@@ -153,26 +92,6 @@ def _is_canonical_facade_expose(expose_patterns: list[str]) -> bool:return any(_targets_facade_or_presentation(p) for p in expose_patterns)-def _names_from_pattern(pattern: str) -> set[str]:- """Extract product short names from a tach `from` pattern.-- Handles three forms:- - "products.experiments" -> {"experiments"}- - "products\\.experiments" -> {"experiments"}- - "products\\.(experiments|mcp_store|...)" -> {"experiments", "mcp_store", ...}- """- # Normalize backslashes — tach regex uses `\.` which appears as `\\.` when- # read as raw TOML source.- normalized = pattern.replace("\\", "")- m = re.match(r"^products\.\(([^)]+)\)$", normalized)- if m:- return {n.strip() for n in m.group(1).split("|") if n.strip()}- m = re.match(r"^products\.([A-Za-z0-9_]+)$", normalized)- if m:- return {m.group(1)}- return set()--def validate_facade_alternation(tach_content: str, products_dir: Path) -> list[str]:"""Validate the canonical facade `[[interfaces]]` block(s).@@ -424,6 +343,24 @@ def _parse_pytest_paths(script: str) -> list[str]:return paths+def _contract_check_withheld_note(status: IsolationStatus) -> str | None:+ """Why the contract-check skip is correctly withheld for an isolated product.++ Surfaced on a passing single-product lint so a reader sees the decision, not just+ its silent absence. Returns None when there's nothing meaningful to explain.+ """+ if status.deferred_count > 0 and status.has_legacy_leaks:+ return f"legacy interface leaks + {status.deferred_count} presentation bypass(es) still open"+ if status.deferred_count > 0:+ plural = "bypass" if status.deferred_count == 1 else "bypasses"+ return f"{status.deferred_count} presentation {plural} still open (internal seal incomplete)"+ if status.has_legacy_leaks:+ return "legacy interface leak block present (external seal incomplete)"+ if not status.has_real_facade:+ return "facade/api.py is a re-export, not real functions"+ return None++class PackageJsonScriptsCheck(ProductCheck):label = "package.json scripts"@@ -443,21 +380,13 @@ class PackageJsonScriptsCheck(ProductCheck):result = CheckResult()# --- presence checks (legacy leaks exempt from contract-check) ---- from .ast_helpers import has_any_function_defs-- module_path = f"products.{ctx.name}"- tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""- has_leaks = has_legacy_interface_leaks(tach_content, module_path)-- facade_api = ctx.backend_dir / "facade" / "api.py"- has_real_facade = facade_api.exists() and has_any_function_defs(facade_api)# While a product has deferred presentation-wave ignore_imports entries, its# views still bypass the facade and reach internals directly. The skip only# re-runs the full suite on facade/presentation changes, so an internals# change flowing to HTTP through such a view would be hidden. The skip is the# reward for finishing — it can't be enabled until the wave empties them.- deferred = count_presentation_allowlist_entries(ctx.name)- needs_contract_check = ctx.is_isolated and not has_leaks and has_real_facade and deferred == 0+ status = compute_isolation_status(ctx.name, ctx.product_dir, ctx.backend_dir, is_isolated=ctx.is_isolated)+ needs_contract_check = status.eligible_for_isolated_testsrequired = ["backend:test"] + (["backend:contract-check"] if needs_contract_check else [])for script in required:if script not in scripts:@@ -468,16 +397,15 @@ class PackageJsonScriptsCheck(ProductCheck):)# --- absence check: must NOT have contract-check when not safe for isolation ---- must_not_have_contract_check = not ctx.is_isolated or has_leaks or not has_real_facade or deferred > 0- if must_not_have_contract_check and "backend:contract-check" in scripts:- if has_leaks:+ if not needs_contract_check and "backend:contract-check" in scripts:+ if status.has_legacy_leaks:reason = "has legacy interface leaks (core imports internals directly)"- elif deferred > 0:- plural = "entry" if deferred == 1 else "entries"+ elif status.deferred_count > 0:+ plural = "entry" if status.deferred_count == 1 else "entries"reason = (- f"has {deferred} deferred presentation-wave ignore_imports {plural} — its presentation "- "still bypasses the facade, so finish the presentation wave (empty the ignore_imports TODO "- "section) before opting into the skip"+ f"has {status.deferred_count} deferred presentation-wave ignore_imports {plural} — its "+ "presentation still bypasses the facade, so finish the presentation wave (empty the "+ "ignore_imports TODO section) before opting into the skip")else:reason = "non-isolated product must not have 'backend:contract-check' script"@@ -488,6 +416,12 @@ class PackageJsonScriptsCheck(ProductCheck):"the full Django test suite to be skipped when this product changes")+ # --- surface the withholding decision (single-product view only; keep the CI sweep quiet) ---+ if ctx.detailed and ctx.is_isolated and not needs_contract_check and "backend:contract-check" not in scripts:+ note = _contract_check_withheld_note(status)+ if note:+ result.lines.append(f"ℹ contract-check skip withheld — {note}")+# --- content checks on backend:test ---test_script = scripts.get("backend:test", "")if test_script:@@ -656,28 +590,16 @@ class TachCheck(ProductCheck):],)- if ctx.is_isolated and "interfaces" not in tach_block:- # Check global [[interfaces]] blocks — the product name may appear- # literally or as part of a regex pattern in a from = [...] field.- tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""- product_short = ctx.name- has_global_interface = bool(- re.search(- rf"\[\[interfaces\]\].*?from\s*=\s*\[.*?{re.escape(product_short)}",- tach_content,- re.DOTALL,- )+ tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""+ if ctx.is_isolated and not has_tach_interface(ctx.name, tach_content):+ return CheckResult(+ lines=["✗ missing interfaces declaration"],+ issues=[+ f"Isolated product missing interface definition in tach.toml — "+ f'add a [[interfaces]] block with from = ["{module_path}"]'+ ],)- if not has_global_interface:- return CheckResult(- lines=["✗ missing interfaces declaration"],- issues=[- f"Isolated product missing interface definition in tach.toml — "- f'add a [[interfaces]] block with from = ["{module_path}"]'- ],- )- tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""if has_legacy_interface_leaks(tach_content, module_path):return CheckResult(lines=["⚠ has legacy interface leaks — core bypasses facade (not tested in isolation)"])@@ -694,58 +616,16 @@ class IsolationChainCheck(ProductCheck):label = "isolation chain"- def _has_contract_check_script(self, product_dir: Path) -> bool:- package_json = product_dir / "package.json"- if not package_json.exists():- return False- try:- scripts = json.loads(package_json.read_text()).get("scripts", {})- except json.JSONDecodeError:- return False- return "backend:contract-check" in scripts-- def _has_narrowed_turbo_inputs(self, product_dir: Path) -> bool:- turbo_json = product_dir / "turbo.json"- if not turbo_json.exists():- return False- try:- tasks = json.loads(turbo_json.read_text()).get("tasks", {})- except json.JSONDecodeError:- return False- contract_task = tasks.get("backend:contract-check")- if not contract_task:- return False- inputs = contract_task.get("inputs", [])- return any("facade" in i or "presentation" in i for i in inputs)-- def _has_tach_interfaces(self, name: str) -> bool:- module_path = f"products.{name}"- block = get_tach_block(module_path)- if not block:- return False- if "interfaces" in block and "interfaces = []" not in block:- return True- tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""- return bool(- re.search(- rf"\[\[interfaces\]\].*?from\s*=\s*\[.*?{re.escape(name)}",- tach_content,- re.DOTALL,- )- )-def run(self, ctx: CheckContext) -> CheckResult:- from .ast_helpers import has_any_function_defs-facade_api = ctx.backend_dir / "facade" / "api.py"- has_real_facade = facade_api.exists() and has_any_function_defs(facade_api)- has_tach = self._has_tach_interfaces(ctx.name)- has_script = self._has_contract_check_script(ctx.product_dir)- has_narrowed = self._has_narrowed_turbo_inputs(ctx.product_dir)+ real_facade = has_real_facade(ctx.backend_dir)+ has_tach = has_tach_interface(ctx.name)+ has_script = has_contract_check_script(ctx.product_dir)+ has_narrowed = has_narrowed_turbo_inputs(ctx.product_dir)result = CheckResult()- if has_script and not has_real_facade:+ if has_script and not real_facade:result.issues.append("has 'backend:contract-check' but facade/api.py has no function definitions — ""re-exporting from logic is not a facade. turbo-discover classifies this product "@@ -763,14 +643,14 @@ class IsolationChainCheck(ProductCheck):"'backend:contract-check' script — dead config, remove the turbo.json override")- if has_narrowed and not has_real_facade:+ if has_narrowed and not real_facade:result.issues.append("turbo.json narrows contract-check inputs to facade/presentation but ""facade/api.py has no function definitions — internal changes won't trigger ""Django suite even though the facade boundary isn't real")- if not has_script and facade_api.exists() and not has_real_facade:+ if not has_script and facade_api.exists() and not real_facade:result.warnings.append("facade/api.py exists but has no function definitions — ""a real facade should convert models to contracts, not just re-export"diff --git a/tools/hogli-commands/hogli_commands/product/isolation.py b/tools/hogli-commands/hogli_commands/product/isolation.pynew file mode 100644index 000000000000..a7b99c2b2486--- /dev/null+++ b/tools/hogli-commands/hogli_commands/product/isolation.py@@ -0,0 +1,254 @@+"""Shared isolation-seal predicates — single source of truth for both consumers.++The lint gate (checks.py) and the maturity report (maturity.py) both need to answer+"how isolated is this product, really?". Keeping that logic here means the gate and the+report can't drift apart.++Isolation has two independent seals:++ - external: nobody outside the product imports its internals. Enforced by tach's+ [[interfaces]] block — the product only exposes facade + presentation.views + routes.+ - internal: the product's own presentation reaches models/logic only through the facade.+ Enforced by import-linter, and only fully sealed once its ignore_imports allowlist for+ this product is empty (no deferred presentation-wave bypasses).++When both seals hold and the facade is real, the product earns isolated tests — the+backend:contract-check skip that keeps its Django suite off unrelated CI shards. That skip+is the reward for finishing, which is why it can't turn on while either seal is incomplete.+"""++from __future__ import annotations++import re+import json+import tomllib+from collections.abc import Iterator+from dataclasses import dataclass+from pathlib import Path++from .ast_helpers import has_any_function_defs+from .paths import REPO_ROOT, TACH_TOML, get_tach_block++# ---------------------------------------------------------------------------+# tach.toml parsing+# ---------------------------------------------------------------------------+++def iter_interface_blocks(tach_content: str) -> Iterator[tuple[list[str], list[str]]]:+ """Yield (expose_patterns, from_patterns) for every [[interfaces]] block."""+ for match in re.finditer(r"\[\[interfaces\]\]\s*\n(.*?)(?=\[\[|\Z)", tach_content, re.DOTALL):+ block = match.group(1)+ expose_match = re.search(r"expose\s*=\s*\[(.*?)\]", block, re.DOTALL)+ from_match = re.search(r"from\s*=\s*\[(.*?)\]", block, re.DOTALL)+ if not expose_match or not from_match:+ continue+ expose_patterns = re.findall(r'"(.*?)"', expose_match.group(1))+ from_patterns = re.findall(r'"(.*?)"', from_match.group(1))+ yield expose_patterns, from_patterns+++def pattern_targets_public_surface(pattern: str) -> bool:+ """True if a tach expose pattern targets a product's public surface.++ Public surface is backend.facade, backend.presentation, or backend.routes —+ the last being the product-local route registration entry point that core+ imports to assemble the API router. It is a public composition hook, not an+ internal leak, so it does not mark a product as un-isolatable.++ Strips backslashes first so it works on both the on-disk TOML form (`\\.`,+ two literal backslashes) and Python-string fixtures (single backslash).+ """+ normalized = pattern.replace("\\", "")+ return (+ normalized.startswith("backend.facade")+ or normalized.startswith("backend.presentation")+ or normalized.startswith("backend.routes")+ )+++def names_from_pattern(pattern: str) -> set[str]:+ """Extract product short names from a tach `from` pattern.++ Handles three forms:+ - "products.experiments" -> {"experiments"}+ - "products\\.experiments" -> {"experiments"}+ - "products\\.(experiments|mcp_store|...)" -> {"experiments", "mcp_store", ...}+ """+ normalized = pattern.replace("\\", "")+ m = re.match(r"^products\.\(([^)]+)\)$", normalized)+ if m:+ return {n.strip() for n in m.group(1).split("|") if n.strip()}+ m = re.match(r"^products\.([A-Za-z0-9_]+)$", normalized)+ if m:+ return {m.group(1)}+ return set()+++# ---------------------------------------------------------------------------+# Low-level seal signals+# ---------------------------------------------------------------------------+++def is_isolated_product(backend_dir: Path) -> bool:+ """A product is in the strict isolation regime once it has a contracts module."""+ return (backend_dir / "facade" / "contracts.py").exists() or (backend_dir / "facade" / "contracts").exists()+++def has_real_facade(backend_dir: Path) -> bool:+ """A real facade defines functions; a re-export shim from logic does not count."""+ facade_api = backend_dir / "facade" / "api.py"+ return facade_api.exists() and has_any_function_defs(facade_api)+++def has_tach_interface(name: str, tach_content: str | None = None) -> bool:+ """True if the product is named in a tach [[interfaces]] block (inline or global).++ Names are matched structurally against each block's `from` list. A loose regex+ over the whole file false-positives on any product whose name appears later (e.g.+ in its own [[modules]] block), which made nearly every product read as sealed.+ """+ block = get_tach_block(f"products.{name}")+ if block and "interfaces" in block and "interfaces = []" not in block:+ return True+ content = tach_content if tach_content is not None else (TACH_TOML.read_text() if TACH_TOML.exists() else "")+ return any(+ name in names_from_pattern(pattern)+ for _expose, from_patterns in iter_interface_blocks(content)+ for pattern in from_patterns+ )+++def has_legacy_interface_leaks(tach_content: str, module_path: str) -> bool:+ """Check if a product has legacy interface leak blocks in tach.toml.++ These are products where core (posthog/ee) still imports internals directly,+ so they can't safely be tested in isolation via contract-check.++ Detected structurally: an [[interfaces]] block whose `from` is exactly this+ module and whose `expose` includes any non-facade/non-presentation pattern.+ """+ for expose_patterns, from_patterns in iter_interface_blocks(tach_content):+ normalized_from = [p.replace("\\", "") for p in from_patterns]+ if normalized_from != [module_path]:+ continue+ if any(not pattern_targets_public_surface(p) for p in expose_patterns):+ return True+ return False+++def presentation_bypass_entries(name: str, pyproject_text: str | None = None) -> list[str]:+ """import-linter ignore_imports entries that still let this product's presentation+ reach its own internals directly — the deferred presentation-wave worklist.++ Each entry is one view -> internal edge to remove before the product is internally+ sealed (see the isolating-product-facade-contracts skill).+ """+ if pyproject_text is None:+ pyproject = REPO_ROOT / "pyproject.toml"+ if not pyproject.exists():+ return []+ pyproject_text = pyproject.read_text()+ try:+ contracts = tomllib.loads(pyproject_text)["tool"]["importlinter"]["contracts"]+ except (tomllib.TOMLDecodeError, KeyError):+ return []+ prefix = f"products.{name}.backend.presentation"+ return [entry for contract in contracts for entry in contract.get("ignore_imports", []) if entry.startswith(prefix)]+++def has_contract_check_script(product_dir: Path) -> bool:+ package_json = product_dir / "package.json"+ if not package_json.exists():+ return False+ try:+ scripts = json.loads(package_json.read_text()).get("scripts", {})+ except json.JSONDecodeError:+ return False+ return "backend:contract-check" in scripts+++def has_narrowed_turbo_inputs(product_dir: Path) -> bool:+ turbo_json = product_dir / "turbo.json"+ if not turbo_json.exists():+ return False+ try:+ tasks = json.loads(turbo_json.read_text()).get("tasks", {})+ except json.JSONDecodeError:+ return False+ contract_task = tasks.get("backend:contract-check")+ if not contract_task:+ return False+ inputs = contract_task.get("inputs", [])+ return any("facade" in i or "presentation" in i for i in inputs)+++# ---------------------------------------------------------------------------+# High-level status — the synthesis both lint and maturity read+# ---------------------------------------------------------------------------+++@dataclass(frozen=True)+class IsolationStatus:+ name: str+ is_isolated: bool # has facade/contracts.py — in the strict regime+ has_real_facade: bool+ has_tach_interface: bool+ has_legacy_leaks: bool+ bypass_entries: tuple[str, ...] # presentation -> internals deferrals still open (the worklist)+ has_contract_check_script: bool+ has_narrowed_turbo: bool++ @property+ def deferred_count(self) -> int:+ return len(self.bypass_entries)++ @property+ def externally_sealed(self) -> bool:+ """External consumers can only reach the public surface: interface on, no leak block."""+ return self.has_tach_interface and not self.has_legacy_leaks++ @property+ def internally_sealed(self) -> bool:+ """Presentation reaches internals only through the facade — no open bypasses."""+ return self.is_isolated and self.deferred_count == 0++ @property+ def eligible_for_isolated_tests(self) -> bool:+ """Prerequisites for the contract-check skip, mirroring the lint gate's package.json+ check exactly. Deliberately does NOT include `has_tach_interface` — the external+ boundary is required too, but it's enforced separately (TachCheck demands the+ interface; IsolationChainCheck blocks a script without it). Callers that gate a+ "ready" *display* should additionally require `externally_sealed`."""+ return self.is_isolated and self.has_real_facade and not self.has_legacy_leaks and self.deferred_count == 0++ @property+ def isolated_tests_enabled(self) -> bool:+ """The skip is physically wired up right now (script present + turbo narrowed)."""+ return self.has_contract_check_script and self.has_narrowed_turbo+++def compute_isolation_status(+ name: str,+ product_dir: Path,+ backend_dir: Path,+ *,+ is_isolated: bool | None = None,+ tach_content: str | None = None,+ pyproject_text: str | None = None,+) -> IsolationStatus:+ """Compute the full isolation seal status for one product."""+ if is_isolated is None:+ is_isolated = is_isolated_product(backend_dir)+ if tach_content is None:+ tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""+ module_path = f"products.{name}"+ return IsolationStatus(+ name=name,+ is_isolated=is_isolated,+ has_real_facade=has_real_facade(backend_dir),+ has_tach_interface=has_tach_interface(name, tach_content),+ has_legacy_leaks=has_legacy_interface_leaks(tach_content, module_path),+ bypass_entries=tuple(presentation_bypass_entries(name, pyproject_text)),+ has_contract_check_script=has_contract_check_script(product_dir),+ has_narrowed_turbo=has_narrowed_turbo_inputs(product_dir),+ )diff --git a/tools/hogli-commands/hogli_commands/product/maturity.py b/tools/hogli-commands/hogli_commands/product/maturity.pyindex fe02ef5bff14..1865dd3ceacb 100644--- a/tools/hogli-commands/hogli_commands/product/maturity.py+++ b/tools/hogli-commands/hogli_commands/product/maturity.py@@ -19,13 +19,13 @@ from __future__ import annotationsimport reimport jsonimport textwrap+import warningsimport subprocessfrom dataclasses import dataclass, fieldfrom pathlib import Pathfrom .ast_helpers import (find_direct_orm_queries,- get_cross_product_internal_imports,get_frozen_dataclass_names,get_model_names,get_orm_bound_serializer_names,@@ -34,6 +34,13 @@ from .ast_helpers import (imports_any,view_facade_usage,)+from .isolation import (+ IsolationStatus,+ compute_isolation_status,+ has_legacy_interface_leaks,+ has_tach_interface,+ presentation_bypass_entries,+)from .paths import PRODUCTS_DIR, REPO_ROOT, TACH_TOML, find_views_path, get_tach_blockfrom .product_yaml import load_all_product_yamls, load_product_yamlfrom .ts_helpers import codegen_adoption, codegen_call_sites@@ -111,6 +118,8 @@ class ProductScore:display_name: str = ""owners: list[str] = field(default_factory=list)dimensions: list[DimensionScore] = field(default_factory=list)+ # External-vs-internal seal synthesis. None for products with no backend.+ isolation: IsolationStatus | None = None@propertydef overall(self) -> int | None:@@ -369,7 +378,24 @@ def score_facade(backend_dir: Path) -> DimensionScore:# ----------------------------------------------------------------------------def score_presentation(backend_dir: Path) -> DimensionScore:+def _format_bypass(entry: str) -> str:+ """Make an import-linter ignore_imports entry readable as a per-view worklist item.++ "products.x.backend.presentation.views.external -> products.x.backend.models"+ becomes "presentation.views.external → backend.models".+ """+ sides = entry.split(" -> ")+ if len(sides) != 2:+ return entry++ def strip(side: str) -> str:+ m = re.match(r"products\.[^.]+\.backend\.(.+)", side.strip())+ return m.group(1) if m else side.strip()++ return f"{strip(sides[0])} → backend.{strip(sides[1])}"+++def score_presentation(name: str, backend_dir: Path, pyproject_text: str | None = None) -> DimensionScore:"""Views through facade, serializers on contracts.Points breakdown (100 total):@@ -377,6 +403,11 @@ def score_presentation(backend_dir: Path) -> DimensionScore:views use facade: 25no direct ORM in views: 25serializers not ORM-bound: 25++ The "views use facade" 25 is decided by import-linter ground truth when the+ product is isolated: any open presentation-wave bypass means presentation still+ reaches internals directly, so the points are withheld regardless of what the+ AST heuristic sees. The deferral list doubles as the per-view worklist."""views_path, correct_location = find_views_path(backend_dir)@@ -419,7 +450,19 @@ def score_presentation(backend_dir: Path) -> DimensionScore:facade_api = backend_dir / "facade" / "api.py"real_facade = facade_api.exists() and has_any_function_defs(facade_api)- if uses_facade and real_facade:+ # Ground truth wins over the AST heuristic: each open import-linter deferral is a+ # view that still bypasses the facade, so the product is not internally sealed.+ bypass_entries = presentation_bypass_entries(name, pyproject_text)++ if bypass_entries:+ parts.append(f"{len(bypass_entries)} facade bypass(es)")+ next_steps.append(+ "Presentation still reaches internals directly. Thin each view below to "+ "parse → facade → serialize, then delete its line from the import-linter "+ "ignore_imports TODO section in pyproject.toml — that empties the internal seal."+ )+ evidence.append(("facade bypasses (import-linter deferrals)", [_format_bypass(e) for e in bypass_entries]))+ elif uses_facade and real_facade:score += 25parts.append("uses facade")elif uses_facade:@@ -483,13 +526,18 @@ def score_presentation(backend_dir: Path) -> DimensionScore:# ----------------------------------------------------------------------------def _build_inbound_violation_map() -> dict[str, list[str]] | None:- """Build a map of product_name -> inbound violation locations for ALL products.+def _build_cross_import_maps() -> tuple[dict[str, list[str]], dict[str, list[str]]] | None:+ """One rg pass over the repo, distributed into inbound and outbound maps.- Single rg pass across the repo, then distributes results. Much faster than- running rg per-product. Each value is a list of `relpath:line module` strings- so callers can show concrete evidence. Returns None if the scan fails (rg- missing or timeout).+ Both halves care about the same thing — `import products.<x>.backend.<…>` lines —+ so they share a single scan instead of re-walking every product's files per product.++ inbound[target] = external code (core or another product) importing that product's+ non-facade internals — the real isolation failure.+ outbound[source] = that product's own files importing ANOTHER product's internals.++ Each value is a list of `relpath:line module` strings for evidence. Returns None if+ rg is unavailable or times out."""try:result = subprocess.run(@@ -501,7 +549,8 @@ def _build_inbound_violation_map() -> dict[str, list[str]] | None:except (subprocess.TimeoutExpired, FileNotFoundError):return None- locations: dict[str, list[str]] = {}+ inbound: dict[str, list[str]] = {}+ outbound: dict[str, list[str]] = {}for line in result.stdout.strip().split("\n"):if not line:continue@@ -516,47 +565,53 @@ def _build_inbound_violation_map() -> dict[str, list[str]] | None:line_num = line[colon_idx + 1 : colon2_idx]import_text = line[colon2_idx + 1 :].strip()- # Extract which product is being imported (handles both from/import style)+ # Which product is being imported? (handles both from/import style)match = re.search(r"products\.(\w+)\.backend\.\w+", import_text)if not match:continue- product_name = match.group(1)-- # Skip files inside the product itself- if f"products/{product_name}/" in file_path:- continue- if "/migrations/" in file_path:- continue- # Django admin's project-wide registry has to import each product's- # admin classes and the models they reference — there's no facade- # equivalent for `admin.site.register`.- if "/posthog/admin/" in file_path or file_path.startswith("posthog/admin/"):- continue- if ".backend.facade" in import_text:- continue- if ".backend.presentation" in import_text:- continue+ imported = match.group(1)+ module = match.group(0)try:rel_path = str(Path(file_path).relative_to(REPO_ROOT))except ValueError:rel_path = file_path- locations.setdefault(product_name, []).append(f"{rel_path}:{line_num} {match.group(0)}")+ evidence = f"{rel_path}:{line_num} {module}"- return locations+ # Which product owns the importing file? Empty when it lives in core (ee/, posthog/).+ src = re.match(r"products/(\w+)/", rel_path)+ source = src.group(1) if src else ""+ is_facade = ".backend.facade" in import_text+ is_presentation = ".backend.presentation" in import_text-def _inbound_violations(name: str, inbound_map: dict[str, list[str]] | None = None) -> list[str] | None:- """Return inbound violation locations for a single product. None means scan failed."""- if inbound_map is not None:- return inbound_map.get(name, [])- built = _build_inbound_violation_map()- if built is None:- return None- return built.get(name, [])+ # inbound: someone outside `imported` reaching past its facade/presentation surface.+ # Django admin's project-wide registry must import each product's admin classes and+ # the models they reference — there's no facade equivalent for `admin.site.register`.+ in_admin = "/posthog/admin/" in file_path or rel_path.startswith("posthog/admin/")+ if (+ source != imported+ and not is_facade+ and not is_presentation+ and "/migrations/" not in file_path+ and not in_admin+ ):+ inbound.setdefault(imported, []).append(evidence)++ # outbound: `source` reaching into another product's non-facade internals.+ if source and source != imported and not is_facade:+ outbound.setdefault(source, []).append(evidence)+ return inbound, outbound-def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[str]] | None = None) -> DimensionScore:++def score_boundaries(+ name: str,+ product_dir: Path,+ inbound_map: dict[str, list[str]] | None = None,+ outbound_map: dict[str, list[str]] | None = None,+ tach_content: str | None = None,+) -> DimensionScore:"""Tach interfaces + cross-product import hygiene.Points breakdown (100 total):@@ -569,6 +624,8 @@ def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[sif not _has_python_files(product_dir):return DimensionScore("boundaries", 0, "no Python files", applicable=False)+ content = tach_content if tach_content is not None else (TACH_TOML.read_text() if TACH_TOML.exists() else "")+score = 0parts = []next_steps: list[str] = []@@ -579,18 +636,7 @@ def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[sblock = get_tach_block(module_path)if block:- has_inline_interfaces = "interfaces" in block and "interfaces = []" not in block- has_global_interfaces = False- if not has_inline_interfaces:- tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""- has_global_interfaces = bool(- re.search(- rf"\[\[interfaces\]\].*?from\s*=\s*\[.*?{re.escape(name)}",- tach_content,- re.DOTALL,- )- )- if has_inline_interfaces or has_global_interfaces:+ if has_tach_interface(name, content):score += 10parts.append("tach + interfaces")else:@@ -624,8 +670,14 @@ def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[s)# Outbound: this product importing other products' internals- outbound = get_cross_product_internal_imports(product_dir, name)- if not outbound:+ outbound = outbound_map.get(name, []) if outbound_map is not None else None+ if outbound is None:+ parts.append("outbound scan failed")+ next_steps.append(+ "Outbound scan failed — `rg` is missing or timed out. Install ripgrep and re-run "+ "`hogli product:maturity` for an accurate outbound count."+ )+ elif not outbound:score += 15parts.append("outbound clean")else:@@ -635,10 +687,10 @@ def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[sf"Replace the {len(outbound)} outbound import(s) of other products' internals listed "f"below with calls to those products' facades.")- evidence.append(("outbound violations", outbound))+ evidence.append(("outbound violations", _cap(outbound, 25)))# Inbound: other code importing this product's non-facade internals- inbound = _inbound_violations(name, inbound_map)+ inbound = inbound_map.get(name, []) if inbound_map is not None else Noneif inbound is None:parts.append("inbound scan failed")next_steps.append(@@ -660,6 +712,19 @@ def score_boundaries(name: str, product_dir: Path, inbound_map: dict[str, list[s# Cap evidence so the report doesn't explode for products with hundreds of violationsevidence.append(("inbound violations", _cap(inbound, 25)))+ # A declared legacy-leak interface (e.g. backend.admin exposed to core) is an external+ # bypass the inbound scan deliberately exempts. Without docking it here, a leaky product+ # still scores a near-perfect boundary while the seal capstone says the boundary is open.+ if has_legacy_interface_leaks(content, module_path):+ score -= min(score, 30)+ parts.append("legacy interface leak")+ next_steps.append(+ "A dedicated legacy-leak [[interfaces]] block exposes non-facade internals to core "+ "(e.g. backend.admin). The external boundary stays open until that coupling is removed "+ "or accepted as permanent; contract-check stays off either way."+ )+ evidence.append(("legacy interface leak", [f"{module_path}: non-facade surface exposed to core in tach.toml"]))+skills = ["/isolating-product-facade-contracts"] if next_steps else []return DimensionScore("boundaries", score, ", ".join(parts), next_steps=next_steps, skills=skills, evidence=evidence@@ -747,12 +812,29 @@ def score_product(*,assigned_counts: dict[str, int] | None = None,inbound_map: dict[str, list[str]] | None = None,+ outbound_map: dict[str, list[str]] | None = None,+ maps_resolved: bool = False,+ tach_content: str | None = None,+ pyproject_text: str | None = None,product_yamls: dict[str, dict] | None = None,) -> ProductScore:- """Compute all dimension scores for a single product."""+ """Compute all dimension scores for a single product.++ `tach_content`/`pyproject_text` let the --all caller read those repo files once and+ thread them in; a single-product run leaves them None and the helpers read on demand.++ The --all caller scans cross-product imports once and passes the maps with+ `maps_resolved=True` (a map may be None, meaning the scan failed — boundaries scoring+ then shows "scan failed" rather than awarding clean points). A single-product run+ leaves it False, so the scan runs once here.+ """if assigned_counts is None:assigned_counts = _load_model_assignments()+ if not maps_resolved:+ built = _build_cross_import_maps()+ inbound_map, outbound_map = built if built is not None else (None, None)+meta = (product_yamls or {}).get(name) or load_product_yaml(name)product_dir = PRODUCTS_DIR / namebackend_dir = product_dir / "backend"@@ -768,10 +850,14 @@ def score_product(ps.dimensions = [score_models(name, backend_dir, assigned_counts),score_facade(backend_dir),- score_presentation(backend_dir),- score_boundaries(name, product_dir, inbound_map),+ score_presentation(name, backend_dir, pyproject_text),+ score_boundaries(name, product_dir, inbound_map, outbound_map, tach_content),score_codegen(product_dir),]+ if backend_dir.exists():+ ps.isolation = compute_isolation_status(+ name, product_dir, backend_dir, tach_content=tach_content, pyproject_text=pyproject_text+ )return ps@@ -785,15 +871,29 @@ def score_all_products() -> list[ProductScore]:assigned_counts = _load_model_assignments()product_yamls = load_all_product_yamls()- inbound_map = _build_inbound_violation_map()- if inbound_map is None:- import warnings-- warnings.warn("inbound violation scan failed (rg unavailable or timeout)", stacklevel=2)- inbound_map = {}+ # Read the two repo-level files once and thread them through, instead of letting each+ # of the ~65 products re-read and re-parse them inside the per-product scorers.+ tach_content = TACH_TOML.read_text() if TACH_TOML.exists() else ""+ pyproject_path = REPO_ROOT / "pyproject.toml"+ pyproject_text = pyproject_path.read_text() if pyproject_path.exists() else ""+ maps = _build_cross_import_maps()+ if maps is None:+ warnings.warn("cross-product import scan failed (rg unavailable or timeout)", stacklevel=2)+ # On failure both maps stay None, so boundaries scoring reports "scan failed" instead of+ # awarding clean points — and the scan is not re-run per product.+ inbound_map, outbound_map = maps if maps is not None else (None, None)scores = [- score_product(name, assigned_counts=assigned_counts, inbound_map=inbound_map, product_yamls=product_yamls)+ score_product(+ name,+ assigned_counts=assigned_counts,+ inbound_map=inbound_map,+ outbound_map=outbound_map,+ maps_resolved=True,+ tach_content=tach_content,+ pyproject_text=pyproject_text,+ product_yamls=product_yamls,+ )for name in product_dirs]scores.sort(key=lambda s: s.overall or -1, reverse=True)@@ -837,6 +937,89 @@ def _dim_line(dim: DimensionScore, connector: str = "\u251c\u2500") -> str:return f" {connector} {dim.name:14s} {dim.score:3d} {_bar(dim.score)} {dim.detail}"+def _isolated_tests_state(status: IsolationStatus) -> tuple[str, str]:+ """(state, reason) for the isolated-tests certificate \u2014 the contract-check skip."""+ if status.isolated_tests_enabled:+ return "ON", "contract-check skip live \u2014 Django suite stays off unrelated CI shards"+ # Eligibility deliberately excludes the tach interface (see IsolationStatus), but the skip+ # is unsound without the external boundary, so READY also requires it.+ if status.eligible_for_isolated_tests and status.externally_sealed:+ missing = []+ if not status.has_contract_check_script:+ missing.append("add backend:contract-check")+ if not status.has_narrowed_turbo:+ missing.append("narrow turbo.json inputs")+ return "READY", f"{' + '.join(missing)} to turn the skip on"+ blockers: list[str] = []+ if not status.is_isolated:+ blockers.append("add a facade (contracts.py + api.py)")+ elif not status.has_real_facade:+ blockers.append("make facade/api.py real (define functions, not re-exports)")+ if status.has_legacy_leaks:+ blockers.append("remove the legacy interface leak block from tach.toml")+ if status.deferred_count > 0:+ blockers.append(f"empty the {status.deferred_count} presentation bypass(es)")+ if not status.has_tach_interface:+ blockers.append("add the tach [[interfaces]] block")+ return "OFF", "; ".join(blockers) if blockers else "prerequisites incomplete"+++def _isolation_capstone(status: IsolationStatus) -> list[str]:+ """Render the external-vs-internal seal synthesis: the headline an agent acts on.++ Maps the two seals onto the isolated-tests certificate. The boundary protects+ external consumers (tach); the seal stops the product's own presentation bypassing+ its facade (import-linter). Both done + a real facade earns the contract-check skip.+ """+ if status.externally_sealed:+ ext_state, ext_detail = "sealed", "tach [[interfaces]] on, no legacy leaks"+ elif not status.has_tach_interface:+ ext_state, ext_detail = "open", "no tach [[interfaces]] block \u2014 external code can reach internals"+ else:+ ext_state, ext_detail = "open", "legacy interface leak block present \u2014 core still imports internals"++ if not status.is_isolated:+ int_state, int_detail = "n/a", "no facade yet \u2014 product not isolated"+ elif status.internally_sealed:+ int_state, int_detail = "sealed", "presentation reaches internals only through the facade"+ else:+ int_state, int_detail = (+ f"{status.deferred_count} open",+ "presentation still reaches internals directly (see presentation dimension)",+ )++ tests_state, tests_detail = _isolated_tests_state(status)++ rows = [+ ("external boundary", ext_state, ext_detail),+ ("internal seal", int_state, int_detail),+ ("isolated tests", tests_state, tests_detail),+ ]+ lines = [" isolation seal"]+ for label, state, detail in rows:+ lines.append(f" {label:18s} {state:10s} {detail}")+ return lines+++SEAL_LEGEND = "seal: on=tests live ready=eligible, not wired int:N=N internal bypasses open ext\u2717=external boundary open \u2014=not isolated"+++def _seal_token(status: IsolationStatus | None) -> str:+ """Compact seal state for the --all grid. Each token names the remaining blocker."""+ if status is None or not status.is_isolated:+ return "\u2014"+ if status.isolated_tests_enabled:+ return "on"+ if not status.externally_sealed:+ return "ext\u2717"+ if status.deferred_count > 0:+ # externally sealed but internally unsealed \u2014 looks done, isn't+ return f"int:{status.deferred_count}"+ if status.eligible_for_isolated_tests:+ return "ready"+ return "partial"++def generate_report(scores: list[ProductScore]) -> str:"""Generate a heatmap grid report for all products."""lines: list[str] = []@@ -863,15 +1046,17 @@ def generate_report(scores: list[ProductScore]) -> str:name_w = max(max_name, 20)# Header+ lines.append(SEAL_LEGEND)+ lines.append("")dim_header = " ".join(f"{_DIM_SHORT[d]:>{_MINI_WIDTH}s}" for d in _DIM_ORDER)- lines.append(f"{'':>{name_w}s} score {dim_header}")+ lines.append(f"{'':>{name_w}s} score {dim_header} seal")lines.append("")# Rowsfor ps in scored:dim_map = ps.dimension_mapmini_bars = " ".join(_mini_bar(dim_map[d]) if d in dim_map else "\u00b7" * _MINI_WIDTH for d in _DIM_ORDER)- lines.append(f"{ps.product:>{name_w}s} {ps.overall:>3d} {mini_bars}")+ lines.append(f"{ps.product:>{name_w}s} {ps.overall:>3d} {mini_bars} {_seal_token(ps.isolation)}")# Owner rollupowner_scores: dict[str, list[int]] = {}@@ -907,6 +1092,10 @@ def generate_detail(ps: ProductScore) -> str:lines.append(f"{name}{owner_str} {score_str}")lines.append("")+ if ps.isolation is not None:+ lines.extend(_isolation_capstone(ps.isolation))+ lines.append("")+applicable = list(ps.dimensions)target_line_width = 100for i, dim in enumerate(applicable):diff --git a/tools/hogli-commands/hogli_commands/tests/test_checks.py b/tools/hogli-commands/hogli_commands/tests/test_checks.pyindex 73af418b0b97..74967d346d5a 100644--- a/tools/hogli-commands/hogli_commands/tests/test_checks.py+++ b/tools/hogli-commands/hogli_commands/tests/test_checks.py@@ -228,9 +228,9 @@ class TestAbsenceChecks:self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:"""An isolated product still owing presentation-wave work can't opt into the skip."""- import hogli_commands.product.checks as checks_module+ import hogli_commands.product.isolation as isolation_module- monkeypatch.setattr(checks_module, "count_presentation_allowlist_entries", lambda *_a, **_k: 2)+ monkeypatch.setattr(isolation_module, "presentation_bypass_entries", lambda *_a, **_k: ["e1", "e2"])ctx = _make_product(tmp_path,scripts={@@ -1086,13 +1086,13 @@ ignore_imports = [("wizard", 0),],)-def test_count_presentation_allowlist_entries(name: str, expected: int) -> None:- from hogli_commands.product.checks import count_presentation_allowlist_entries+def test_presentation_bypass_entries(name: str, expected: int) -> None:+ from hogli_commands.product.isolation import presentation_bypass_entries- assert count_presentation_allowlist_entries(name, _IGNORE_IMPORTS_PYPROJECT) == expected+ assert len(presentation_bypass_entries(name, _IGNORE_IMPORTS_PYPROJECT)) == expected-def test_count_presentation_allowlist_entries_handles_broken_toml() -> None:- from hogli_commands.product.checks import count_presentation_allowlist_entries+def test_presentation_bypass_entries_handles_broken_toml() -> None:+ from hogli_commands.product.isolation import presentation_bypass_entries- assert count_presentation_allowlist_entries("logs", "not = [valid") == 0+ assert presentation_bypass_entries("logs", "not = [valid") == []