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.

fix(devex): stop product:maturity calling leaky facades ready (#115916)

Julian Beza62ec60ae5f5
diff --git a/tools/hogli-commands/hogli_commands/product/maturity.py b/tools/hogli-commands/hogli_commands/product/maturity.py
index 2416ee3f598b..2d7e641fcd51 100644
--- a/tools/hogli-commands/hogli_commands/product/maturity.py
+++ b/tools/hogli-commands/hogli_commands/product/maturity.py
@@ -924,10 +924,40 @@ 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 _blocking_facade_classes(status: IsolationStatus) -> list[str]:
+ """Classes the facade hands out that withhold the skip on a Sealed product (product:lint gates on the same two lists)."""
+ return sorted({c.class_name for c in (*status.facade_leaks, *status.unapproved_wiring)})
+
+
+def _class_list(names: set[str]) -> str:
+ shown = sorted(names)
+ return ", ".join(shown[:5]) + (f" +{len(shown) - 5} more" if len(shown) > 5 else "")
+
+
+def _blocked_reason(status: IsolationStatus) -> str:
+ """Each list needs a different move: a leak can go to contracts or a wiring location, wiring is already there."""
+ reasons = []
+ leaks = {c.class_name for c in status.facade_leaks}
+ if leaks:
+ reasons.append(
+ f"facade hands out {len(leaks)} non-contract class(es) ({_class_list(leaks)}): "
+ "convert them to contracts or move them to a wiring location"
+ )
+ wiring = {c.class_name for c in status.unapproved_wiring}
+ if wiring:
+ reasons.append(
+ f"{len(wiring)} wiring class(es) have no confirmed approved interface ({_class_list(wiring)}): "
+ "return contracts from a facade function, register a plain function, or use an approved base"
+ )
+ return "; ".join(reasons) + " (see product:lint)"
+
+
def _isolated_tests_state(status: IsolationStatus) -> tuple[str, str]:
"""(state, reason) for the isolated-tests certificate \u2014 the contract-check skip."""
if status.test_skip_configured:
return "ON", "contract-check skip live \u2014 Django suite stays off unrelated CI shards"
+ if status.is_sealed and _blocking_facade_classes(status):
+ return "BLOCKED", _blocked_reason(status)
if status.is_sealed:
missing = []
if not status.has_contract_check_script:
@@ -997,7 +1027,7 @@ def _isolation_capstone(status: IsolationStatus) -> list[str]:
return lines
-SEAL_LEGEND = "seal: on=tests live ready=eligible, not wired int:N=N internal bypasses open ext\u2717=external boundary open \u2014=Lenient (no facade contracts)"
+SEAL_LEGEND = "seal: on=tests live ready=eligible, not wired cls:N=facade hands out N non-contract classes int:N=N internal bypasses open ext\u2717=external boundary open \u2014=Lenient (no facade contracts)"
def _seal_token(status: IsolationStatus | None) -> str:
@@ -1011,6 +1041,9 @@ def _seal_token(status: IsolationStatus | None) -> str:
if status.deferred_count > 0:
# externally sealed but internally unsealed \u2014 looks done, isn't
return f"int:{status.deferred_count}"
+ blocking = _blocking_facade_classes(status)
+ if status.is_sealed and blocking:
+ return f"cls:{len(blocking)}"
if status.is_sealed:
return "ready"
return "partial"
diff --git a/tools/hogli-commands/hogli_commands/tests/test_maturity.py b/tools/hogli-commands/hogli_commands/tests/test_maturity.py
index cf5867ca3445..d1608f5f2acb 100644
--- a/tools/hogli-commands/hogli_commands/tests/test_maturity.py
+++ b/tools/hogli-commands/hogli_commands/tests/test_maturity.py
@@ -4,7 +4,9 @@ from pathlib import Path
import pytest
-from hogli_commands.product.maturity import _count_tach_depends_on, score_facade
+from hogli_commands.product.isolation import FacadeClassImport, IsolationStatus, UnapprovedWiringClass
+from hogli_commands.product.maturity import _count_tach_depends_on, _isolated_tests_state, _seal_token, score_facade
+from hogli_commands.product.wiring_interfaces import WiringVerdict
class TestCountTachDependsOn:
@@ -42,3 +44,42 @@ class TestScoreFacade:
(presentation / "views.py").write_text("from products.demo.backend.facade import api\n")
assert score_facade(tmp_path).score == 100
+
+
+class TestSealState:
+ @pytest.mark.parametrize(
+ "facade_leaks, unapproved_wiring, expected_token, expected_state",
+ [
+ ((), (), "ready", "READY"),
+ ((FacadeClassImport("models.py", "Thing", "backend/models.py"),), (), "cls:1", "BLOCKED"),
+ (
+ (),
+ (UnapprovedWiringClass("tasks.py", "Job", "backend/tasks.py", WiringVerdict.UNAPPROVED),),
+ "cls:1",
+ "BLOCKED",
+ ),
+ ],
+ ids=["clean_facade", "facade_hands_out_model", "unapproved_wiring_class"],
+ )
+ def test_sealed_product_is_ready_only_without_blocking_classes(
+ self,
+ facade_leaks: tuple[FacadeClassImport, ...],
+ unapproved_wiring: tuple[UnapprovedWiringClass, ...],
+ expected_token: str,
+ expected_state: str,
+ ) -> None:
+ status = IsolationStatus(
+ name="demo",
+ has_facade_contracts=True,
+ has_real_facade=True,
+ has_tach_interface=True,
+ has_legacy_leaks=False,
+ bypass_entries=(),
+ has_contract_check_script=False,
+ has_narrowed_turbo=False,
+ facade_leaks=facade_leaks,
+ unapproved_wiring=unapproved_wiring,
+ )
+
+ assert _seal_token(status) == expected_token
+ assert _isolated_tests_state(status)[0] == expected_state