: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(hogli): lint orphan manifest entries (#58645)
Raúl Negrón-Otero28e389f51c84
diff --git a/hogli.yaml b/hogli.yamlindex 2ac6af325605..e5f3ab3528c7 100644--- a/hogli.yaml+++ b/hogli.yaml@@ -767,9 +767,6 @@ tools:bin_script: temporal-recording-rasterizer-workerdescription: Start recording rasterizer Temporal worker (Puppeteer + Chromium)hidden: true- tool:nodejs:- bin_script: nodejs- description: Start nodejs with optional restart looptool:download-mmdb:bin_script: download-mmdbdescription: Download and cache GeoLite2 MaxMind database with retry logic@@ -831,24 +828,6 @@ tools:bin_script: posthog-nodedescription: Start the posthog-node service (old plugin-server)hidden: true- posthog:hobby-installer-linux:- bin_script: hobby-installer-linux- description: Run the hobby-installer installation script for Linux, don't use- it on your MacOS development environment- hidden: true- posthog:hobby-installer:darwin:- bin_script: hobby-installer-darwin- description: Run the hobby-installer installation script for MacOS- hidden: true- posthog:hobby-installer:demo:- bin_script: hobby-installer-demo- description: Run a demo check for the PostHog hobby installation, useful while- developing the installation script- hidden: true- posthog:hobby-installer:development:- bin_script: hobby-installer-development- description: Run the development version for the hobby-installer deployment- hidden: truestart:mcp:server:bin_script: start-mcp-serverdescription: Start the MCP server@@ -856,14 +835,6 @@ tools:start:stripe:app:bin_script: start-stripe-appdescription: Start the Stripe app dev server (requires Stripe CLI)- posthog:hobby:- bin_script: posthog-hobby- description: 'TODO: add description for posthog-hobby'- hidden: true- start:custom:- bin_script: start-custom- description: 'TODO: add description for start-custom'- hidden: truegenerate_personhog_proto:bin_script: generate_personhog_proto.shdescription: 'TODO: add description for generate_personhog_proto.sh'@@ -871,10 +842,6 @@ tools:phrocs:build:cmd: cd tools/phrocs && make builddescription: Build the phrocs binary from source- phrocs:- bin_script: phrocs- description: Run phrocs directly with a custom mprocs-format YAML config- hidden: trueci:wait:for:docker:bin_script: ci-wait-for-dockerdescription: Launch Docker Compose services in CI and later wait for readinessdiff --git a/tools/hogli/src/hogli/cli.py b/tools/hogli/src/hogli/cli.pyindex 67e655c4bb90..04d6259b6ecb 100644--- a/tools/hogli/src/hogli/cli.py+++ b/tools/hogli/src/hogli/cli.py@@ -22,7 +22,7 @@ from hogli.command_types import BinScriptCommand, CompositeCommand, DirectCommanfrom hogli.hooks import post_command_hooks, telemetry_property_hooksfrom hogli.lazy_commands import add_commands_dir_to_path, add_repo_root_to_path, resolve_click_commandfrom hogli.manifest import REPO_ROOT, get_category_for_command, get_manifest, get_services_for_command, load_manifest-from hogli.validate import auto_update_manifest, find_missing_manifest_entries+from hogli.validate import auto_update_manifest, find_missing_manifest_entries, find_orphan_manifest_entries_DEFAULT_HELP = "Developer CLI framework with YAML-based command definitions."@@ -189,16 +189,22 @@ def cli(ctx: click.Context) -> None:@cli.command(name="meta:check", help="Validate manifest against bin scripts (for CI)")def meta_check() -> None:- """Validate that all bin scripts are in the manifest."""+ """Validate that bin scripts and manifest entries stay in sync."""missing = find_missing_manifest_entries()+ orphans = find_orphan_manifest_entries()- if not missing:- click.echo("✓ All bin scripts are in the manifest")+ if not missing and not orphans:+ click.echo("✓ All bin scripts are in the manifest and all manifest entries resolve")return- click.echo(f"✗ Found {len(missing)} bin script(s) not in manifest:")- for script in sorted(missing):- click.echo(f" - {script}")+ if missing:+ click.echo(f"✗ Found {len(missing)} bin script(s) not in manifest:")+ for script in sorted(missing):+ click.echo(f" - {script}")+ if orphans:+ click.echo(f"✗ Found {len(orphans)} manifest entr(ies) with no matching bin script:")+ for cmd in sorted(orphans):+ click.echo(f" - {cmd}")raise SystemExit(1)diff --git a/tools/hogli/src/hogli/validate.py b/tools/hogli/src/hogli/validate.pyindex 55b13ec39e0e..49e336eb4157 100644--- a/tools/hogli/src/hogli/validate.py+++ b/tools/hogli/src/hogli/validate.py@@ -52,6 +52,27 @@ def find_missing_manifest_entries() -> set[str]:return bin_scripts - manifest_scripts+def find_orphan_manifest_entries() -> set[str]:+ """Find manifest entries whose bin_script target does not exist in scripts_dir."""+ manifest = get_manifest()+ scripts_dir = manifest.scripts_dir+ if not scripts_dir.exists():+ return set()+ orphans: set[str] = set()++ for category, commands in manifest.data.items():+ if category == "metadata" or not isinstance(commands, dict):+ continue+ for cmd_name, cmd_config in commands.items():+ if not isinstance(cmd_config, dict):+ continue+ script = cmd_config.get("bin_script")+ if script and not (scripts_dir / script).exists():+ orphans.add(cmd_name)++ return orphans++def generate_missing_entries() -> dict[str, dict]:"""Generate manifest entries for missing bin scripts.diff --git a/tools/hogli/tests/test_validate.py b/tools/hogli/tests/test_validate.pynew file mode 100644index 000000000000..232da2eb668f--- /dev/null+++ b/tools/hogli/tests/test_validate.py@@ -0,0 +1,91 @@+"""Tests for manifest validation utilities."""++from __future__ import annotations++from pathlib import Path+from typing import Any++import pytest+from unittest.mock import patch++from hogli.validate import find_orphan_manifest_entries+++def _make_manifest_stub(scripts_dir: Path, data: dict[str, Any]) -> Any:+ """Build a minimal stand-in for the Manifest singleton with the fields we use."""++ class _ManifestStub:+ def __init__(self) -> None:+ self.scripts_dir = scripts_dir+ self.data = data++ return _ManifestStub()+++class TestFindOrphanManifestEntries:+ @pytest.mark.parametrize(+ "scripts_present,manifest_data,expected",+ [+ (+ ["real-script"],+ {+ "tools": {+ "good": {"bin_script": "real-script"},+ "bad": {"bin_script": "missing-script"},+ }+ },+ {"bad"},+ ),+ (+ ["a", "b"],+ {+ "tools": {+ "a": {"bin_script": "a"},+ "b": {"bin_script": "b"},+ }+ },+ set(),+ ),+ (+ [],+ {+ "metadata": {"categories": []},+ "tools": {"only-orphan": {"bin_script": "ghost"}},+ },+ {"only-orphan"},+ ),+ (+ ["real"],+ {+ "tools": {+ "noop": {"description": "no bin_script field"},+ "good": {"bin_script": "real"},+ }+ },+ set(),+ ),+ ],+ ids=["mixed", "all-present", "all-missing", "skip-entries-without-bin-script"],+ )+ def test_detects_orphans(+ self,+ tmp_path: Path,+ scripts_present: list[str],+ manifest_data: dict[str, Any],+ expected: set[str],+ ) -> None:+ for name in scripts_present:+ (tmp_path / name).write_text("#!/bin/sh\n")++ stub = _make_manifest_stub(tmp_path, manifest_data)+ with patch("hogli.validate.get_manifest", return_value=stub):+ assert find_orphan_manifest_entries() == expected++ def test_returns_empty_when_scripts_dir_missing(self, tmp_path: Path) -> None:+ missing_dir = tmp_path / "does-not-exist"+ stub = _make_manifest_stub(+ missing_dir,+ {"tools": {"a": {"bin_script": "anything"}, "b": {"bin_script": "else"}}},+ )+ with patch("hogli.validate.get_manifest", return_value=stub):+ assert find_orphan_manifest_entries() == set()