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.

feat(engineering_analytics): add branch filter and failure tracking to workflow health (#65432)

Julian Bez41a92a8bdad7
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.md
index 34dacb1d5e6e..ea5f6ca1fdcf 100644
--- a/products/engineering_analytics/SPEC.md
+++ b/products/engineering_analytics/SPEC.md
@@ -131,7 +131,7 @@ Types named in the README but not yet modeled (reviewers, deploys, file paths) w
Two curated `build_query()` SELECTs over the existing warehouse data — columns mapped from JSON we already store, **no new ingestion, no global view registration**. Column names encode caveats so a misread is defined out of existence (`open_to_merge_seconds`, never `cycle_time`).
- pull-requests builder — `number`, `title`, `author_handle`, `is_bot`, `repo_owner` / `repo_name` (from `base.repo.full_name`), `labels`, `state`, `is_draft`, `created_at`, `merged_at`, `closed_at`, `head_sha`, `open_to_merge_seconds` (coarse — see §7).
-- workflow-runs builder — `workflow_name`, `head_sha`, `conclusion`, `status`, `run_started_at`, `updated_at`, `duration_seconds`, `repo_owner` / `repo_name`.
+- workflow-runs builder — `workflow_name`, `head_sha`, `head_branch`, `conclusion`, `status`, `run_started_at`, `updated_at`, `duration_seconds`, `repo_owner` / `repo_name`.
A PR's current CI status is the head-SHA join between the two (the `ci_rollup` CTE in `_curated`); defined once.
@@ -141,7 +141,7 @@ A PR's current CI status is the head-SHA join between the two (the `ci_rollup` C
- `ci_cards` — open-PR backlog counts (open / repos / stuck >7d / failing CI).
- `pull_requests` — PR list with head-SHA CI rollup; `date_from` recency window. Capped (newest first) and returned as `{items, truncated, limit}` so the page never silently under-counts against `ci_cards`.
-- `workflow_health` — per-workflow run count, success rate, p50/p95 duration, last failure over a `date_from`/`date_to` window.
+- `workflow_health` — per-workflow run count, success rate, p50/p95 duration, last failure over a `date_from`/`date_to` window, optionally scoped to a single git `branch` (`head_branch`).
- `pr_lifecycle` — PR header + ordered CI-run timeline (a genuine assembly; `metric_quality = "partial"` until reviews/deploys land).
**UI:** a read-only scene on the same endpoints via the generated API client — a PR list (CI status, CI duration, age), the count cards (open / stuck >7d / failing CI), and a workflow-health view. Read-only; **no saved views or stateful filters in this phase** (persisted/stateful surfaces are a later, separate decision). Columns that need deferred data — time-in-review, reviewers/approvals, per-check counts, DORA — are out until the event substrate lands (§9).
diff --git a/products/engineering_analytics/backend/facade/api.py b/products/engineering_analytics/backend/facade/api.py
index 851e0a9693ca..f02516f8cc8c 100644
--- a/products/engineering_analytics/backend/facade/api.py
+++ b/products/engineering_analytics/backend/facade/api.py
@@ -5,7 +5,8 @@ runtime PR/CI analytics. Public functions take a team plus PostHog-convention
parameters and return canonical contract types.
``repo`` is an optional ``owner/name`` filter, applied against the curated repo
-identity (mapped from ``base.repo.full_name``). ``date_from`` / ``date_to`` accept
+identity (mapped from ``base.repo.full_name``). ``branch`` is an optional exact
+``head_branch`` filter for workflow health. ``date_from`` / ``date_to`` accept
relative strings (``-30d``) or ISO8601 and are resolved against the team timezone.
``source_id`` selects a specific connected GitHub source when the team has more than
one; it defaults to the oldest connected source. ``user_access_control`` enforces the
@@ -81,11 +82,15 @@ def list_workflow_health(
team: Team,
date_from: str | None = None,
date_to: str | None = None,
+ branch: str | None = None,
source_id: str | None = None,
user_access_control: "UserAccessControl | None" = None,
) -> list[WorkflowHealthItem]:
return logic.build_workflow_health(
- curated=_authorized_source(team, source_id, user_access_control), date_from=date_from, date_to=date_to
+ curated=_authorized_source(team, source_id, user_access_control),
+ date_from=date_from,
+ date_to=date_to,
+ branch=branch,
)
diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.py
index cae0b7ce06d7..6b8cb121cf0a 100644
--- a/products/engineering_analytics/backend/facade/contracts.py
+++ b/products/engineering_analytics/backend/facade/contracts.py
@@ -226,12 +226,17 @@ class CICardSummary:
@dataclass(frozen=True)
class WorkflowHealthDay:
- """One day of a workflow's run history; days without runs are zero-filled."""
+ """One day of a workflow's run history; days without runs are zero-filled.
+ ``failures`` is decisive failures only (failure / timed_out), matching the CI
+ rollup — skipped, cancelled, and action_required runs are neither successes nor
+ failures, so they must not be treated as non-passing.
+ """
day: date
run_count: int
completed: int
successes: int
+ failures: int
@dataclass(frozen=True)
diff --git a/products/engineering_analytics/backend/logic/__init__.py b/products/engineering_analytics/backend/logic/__init__.py
index 880918157f03..c9bf5d84d479 100644
--- a/products/engineering_analytics/backend/logic/__init__.py
+++ b/products/engineering_analytics/backend/logic/__init__.py
@@ -63,14 +63,18 @@ def build_pull_request_list(*, curated: CuratedGitHubSource, date_from: str | No
def build_workflow_health(
- *, curated: CuratedGitHubSource, date_from: str | None = None, date_to: str | None = None
+ *,
+ curated: CuratedGitHubSource,
+ date_from: str | None = None,
+ date_to: str | None = None,
+ branch: str | None = None,
) -> list[WorkflowHealthItem]:
parsed_from = _parse_date(curated.team, date_from or _DEFAULT_WINDOW)
parsed_to = _parse_date(curated.team, date_to) if date_to else None
span_days = ((parsed_to or datetime.now(tz=parsed_from.tzinfo)) - parsed_from).days
if span_days > _MAX_WINDOW_DAYS:
raise ValueError(f"date window spans {span_days} days; the maximum is {_MAX_WINDOW_DAYS}")
- return query_workflow_health(curated=curated, date_from=parsed_from, date_to=parsed_to)
+ return query_workflow_health(curated=curated, date_from=parsed_from, date_to=parsed_to, branch=branch)
def _parse_date(team: Team, value: str) -> datetime:
diff --git a/products/engineering_analytics/backend/logic/queries/workflow_health.py b/products/engineering_analytics/backend/logic/queries/workflow_health.py
index 3ce8264a440d..9e174320fb37 100644
--- a/products/engineering_analytics/backend/logic/queries/workflow_health.py
+++ b/products/engineering_analytics/backend/logic/queries/workflow_health.py
@@ -1,9 +1,9 @@
"""Curated query: per-workflow CI health over a window.
Run counts, success rate, and duration percentiles per ``workflow_name`` for runs
-started within ``[date_from, date_to]`` (``date_to`` optional). Rates and
-percentiles are over completed runs only, so they are ``None`` for a window with
-no completed runs.
+started within ``[date_from, date_to]`` (``date_to`` optional), optionally scoped to
+a single ``head_branch``. Rates and percentiles are over completed runs only, so they
+are ``None`` for a window with no completed runs.
"""
import math
@@ -27,9 +27,9 @@ _SELECT = f"""
countIf(status = 'completed' AND conclusion = 'success') / nullIf(countIf(status = 'completed'), 0) AS success_rate,
quantileIf(0.5)(duration_seconds, status = 'completed') AS p50_seconds,
quantileIf(0.95)(duration_seconds, status = 'completed') AS p95_seconds,
- max(if(conclusion = 'failure', run_started_at, NULL)) AS last_failure_at
+ max(if(conclusion IN ('failure', 'timed_out'), run_started_at, NULL)) AS last_failure_at
FROM __RUNS_SOURCE__ AS r
- WHERE run_started_at >= {{date_from}} __DATE_TO__
+ WHERE run_started_at >= {{date_from}} __DATE_TO__ __BRANCH__
GROUP BY repo_owner, repo_name, workflow_name
ORDER BY run_count DESC
LIMIT {_LIMIT}
@@ -43,9 +43,10 @@ _DAILY_SELECT = f"""
toDate(run_started_at) AS day,
count() AS run_count,
countIf(status = 'completed') AS completed,
- countIf(status = 'completed' AND conclusion = 'success') AS successes
+ countIf(status = 'completed' AND conclusion = 'success') AS successes,
+ countIf(status = 'completed' AND conclusion IN ('failure', 'timed_out')) AS failures
FROM __RUNS_SOURCE__ AS r
- WHERE run_started_at >= {{date_from}} __DATE_TO__
+ WHERE run_started_at >= {{date_from}} __DATE_TO__ __BRANCH__
GROUP BY repo_owner, repo_name, workflow_name, day
LIMIT {_DAILY_LIMIT}
"""
@@ -56,33 +57,48 @@ def query_workflow_health(
curated: CuratedGitHubSource,
date_from: datetime,
date_to: datetime | None,
+ branch: str | None = None,
) -> list[WorkflowHealthItem]:
date_to_clause = "AND run_started_at <= {date_to}" if date_to is not None else ""
+ # An empty/whitespace branch is "no filter", not a literal match on ''.
+ branch = branch.strip() if branch else None
+ branch_clause = "AND head_branch = {branch}" if branch else ""
placeholders: dict[str, ast.Expr] = {"date_from": ast.Constant(value=date_from)}
if date_to is not None:
placeholders["date_to"] = ast.Constant(value=date_to)
+ if branch:
+ placeholders["branch"] = ast.Constant(value=branch)
runs_source = curated.run_source()
- sql = _SELECT.replace("__RUNS_SOURCE__", runs_source).replace("__DATE_TO__", date_to_clause)
+
+ def fill(template: str) -> str:
+ return (
+ template.replace("__RUNS_SOURCE__", runs_source)
+ .replace("__DATE_TO__", date_to_clause)
+ .replace("__BRANCH__", branch_clause)
+ )
+
response = curated.run(
- sql,
+ fill(_SELECT),
query_type="engineering_analytics.workflow_health",
placeholders=placeholders,
)
if not response.results:
return []
- daily_sql = _DAILY_SELECT.replace("__RUNS_SOURCE__", runs_source).replace("__DATE_TO__", date_to_clause)
+ daily_sql = fill(_DAILY_SELECT)
daily_response = curated.run(
daily_sql,
query_type="engineering_analytics.workflow_health_daily",
placeholders=placeholders,
)
days_by_workflow: dict[tuple[str, str, str], dict[date, WorkflowHealthDay]] = {}
- for repo_owner, repo_name, workflow_name, day, run_count, completed, successes in daily_response.results or []:
+ for repo_owner, repo_name, workflow_name, day, run_count, completed, successes, failures in (
+ daily_response.results or []
+ ):
day = day.date() if isinstance(day, datetime) else day
days_by_workflow.setdefault((repo_owner, repo_name, workflow_name), {})[day] = WorkflowHealthDay(
- day=day, run_count=run_count, completed=completed, successes=successes
+ day=day, run_count=run_count, completed=completed, successes=successes, failures=failures
)
window_days = _window_days(date_from, date_to)
@@ -97,7 +113,7 @@ def query_workflow_health(
last_failure_at=last_failure_at,
daily=[
days_by_workflow.get((repo_owner, repo_name, workflow_name), {}).get(
- day, WorkflowHealthDay(day=day, run_count=0, completed=0, successes=0)
+ day, WorkflowHealthDay(day=day, run_count=0, completed=0, successes=0, failures=0)
)
for day in window_days
],
diff --git a/products/engineering_analytics/backend/logic/views/source_schema.py b/products/engineering_analytics/backend/logic/views/source_schema.py
index 478c1199878d..9ffe477fb70c 100644
--- a/products/engineering_analytics/backend/logic/views/source_schema.py
+++ b/products/engineering_analytics/backend/logic/views/source_schema.py
@@ -40,6 +40,7 @@ WORKFLOW_RUNS_COLUMNS: dict[str, dict[str, str]] = {
"id": {"clickhouse": "Nullable(Int64)", "hogql": "IntegerDatabaseField"},
"name": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
"head_sha": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
+ "head_branch": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
"status": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
"conclusion": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
"created_at": {"clickhouse": "Nullable(String)", "hogql": "StringDatabaseField"},
diff --git a/products/engineering_analytics/backend/logic/views/workflow_runs.py b/products/engineering_analytics/backend/logic/views/workflow_runs.py
index 50c48fa9a49d..f4a34bfac571 100644
--- a/products/engineering_analytics/backend/logic/views/workflow_runs.py
+++ b/products/engineering_analytics/backend/logic/views/workflow_runs.py
@@ -37,6 +37,7 @@ def build_query(table_name: str) -> str:
id,
workflow_name,
head_sha,
+ head_branch,
status,
conclusion,
run_started_at,
@@ -52,6 +53,7 @@ def build_query(table_name: str) -> str:
id,
name AS workflow_name,
head_sha,
+ head_branch,
status,
conclusion,
run_attempt,
diff --git a/products/engineering_analytics/backend/presentation/serializers.py b/products/engineering_analytics/backend/presentation/serializers.py
index 21cbedbc74b2..8d84d13639a6 100644
--- a/products/engineering_analytics/backend/presentation/serializers.py
+++ b/products/engineering_analytics/backend/presentation/serializers.py
@@ -186,6 +186,10 @@ class WorkflowHealthDaySerializer(DataclassSerializer):
"run_count": {"help_text": "Runs started that day."},
"completed": {"help_text": "Runs that completed that day."},
"successes": {"help_text": "Completed runs with conclusion 'success' that day."},
+ "failures": {
+ "help_text": "Completed runs that failed that day (conclusion 'failure' or 'timed_out'); "
+ "excludes skipped, cancelled, and action_required runs."
+ },
}
@@ -213,7 +217,7 @@ class WorkflowHealthItemSerializer(DataclassSerializer):
"allow_null": True,
},
"last_failure_at": {
- "help_text": "When the most recent run with conclusion 'failure' started, or null.",
+ "help_text": "When the most recent failing run (conclusion 'failure' or 'timed_out') started, or null.",
"allow_null": True,
},
}
diff --git a/products/engineering_analytics/backend/presentation/views.py b/products/engineering_analytics/backend/presentation/views.py
index 1a972a393f98..461f911537a5 100644
--- a/products/engineering_analytics/backend/presentation/views.py
+++ b/products/engineering_analytics/backend/presentation/views.py
@@ -56,6 +56,15 @@ _DATE_TO = OpenApiParameter(
description="Window end: relative or ISO8601. Defaults to now.",
)
+_BRANCH = OpenApiParameter(
+ name="branch",
+ type=OpenApiTypes.STR,
+ location=OpenApiParameter.QUERY,
+ required=False,
+ description="Optional exact git branch (head_branch) to scope workflow health to, e.g. 'main'. "
+ "Omit or leave blank to aggregate across all branches.",
+)
+
_SOURCE_ID = OpenApiParameter(
name="source_id",
type=OpenApiTypes.UUID,
@@ -153,7 +162,7 @@ class EngineeringAnalyticsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSe
@extend_schema(
operation_id="engineering_analytics_workflow_health",
- parameters=[_DATE_FROM, _DATE_TO, _SOURCE_ID],
+ parameters=[_DATE_FROM, _DATE_TO, _BRANCH, _SOURCE_ID],
responses={
200: WorkflowHealthItemSerializer(many=True),
400: OpenApiResponse(
@@ -163,8 +172,8 @@ class EngineeringAnalyticsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSe
description=(
"Per-workflow CI health over a window (default last 30 days, maximum 366 days): run count, success "
"rate, p50/p95 duration over completed runs, last failure time, and a zero-filled daily run history. "
- "Use this for 'is CI getting slower' and 'which workflow is the long pole'; compare two windows to "
- "get a trend."
+ "Optionally scope to a single git branch via `branch`. Use this for 'is CI getting slower' and "
+ "'which workflow is the long pole'; compare two windows to get a trend."
),
)
@action(detail=False, methods=["get"], pagination_class=None)
@@ -174,6 +183,7 @@ class EngineeringAnalyticsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSe
team=self.team,
date_from=request.query_params.get("date_from") or None,
date_to=request.query_params.get("date_to") or None,
+ branch=request.query_params.get("branch") or None,
source_id=request.query_params.get("source_id") or None,
user_access_control=self.user_access_control,
)
diff --git a/products/engineering_analytics/backend/tests/test_logic.py b/products/engineering_analytics/backend/tests/test_logic.py
index 3bf28bcb80d4..b606b63baa0b 100644
--- a/products/engineering_analytics/backend/tests/test_logic.py
+++ b/products/engineering_analytics/backend/tests/test_logic.py
@@ -296,8 +296,9 @@ class TestEndpointMapping(BaseTest):
# No completed runs: success_rate is NULL and quantileIf returns NaN — both map to None.
("PostHog", "posthog", "Deploy", 2, None, float("nan"), float("nan"), None),
]
- # Must be inside the -30d window, which is relative to now.
- daily_rows = [("PostHog", "posthog", "CI", datetime.now(tz=UTC).date() - timedelta(days=1), 10, 8, 7)]
+ # Must be inside the -30d window, which is relative to now. Columns:
+ # owner, name, workflow, day, run_count, completed, successes, failures.
+ daily_rows = [("PostHog", "posthog", "CI", datetime.now(tz=UTC).date() - timedelta(days=1), 10, 8, 7, 1)]
with mock.patch(_RUN_QUERY, side_effect=[_resp(rows), _resp(daily_rows)]):
items = api.list_workflow_health(team=self.team, date_from="-30d", date_to=None)
@@ -306,7 +307,7 @@ class TestEndpointMapping(BaseTest):
# The daily series spans the whole window, zero-filled except the day with runs.
assert len(items[0].daily) >= 30
seeded_day = next(entry for entry in items[0].daily if entry.run_count > 0)
- assert (seeded_day.completed, seeded_day.successes) == (8, 7)
+ assert (seeded_day.completed, seeded_day.successes, seeded_day.failures) == (8, 7, 1)
assert all(entry.run_count == 0 for entry in items[1].daily)
assert items[0].p50_seconds == 120.0 and items[0].p95_seconds == 600.0
assert items[1].success_rate is None
@@ -564,6 +565,82 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
assert ci.success_rate == 0.5 # 1 success of 2 completed
assert ci.last_failure_at is not None
+ def test_workflow_health_daily_failures_exclude_non_failures(self) -> None:
+ # The daily failure count is decisive failures only — skipped / cancelled / action_required
+ # runs are completed but neither successes nor failures, so they must not inflate the trend.
+ self._create_table(
+ "github_pull_requests",
+ _PULL_REQUESTS_COLUMNS,
+ [_pr_row(30, "alice", "open", 0, _ago(1), head_sha="sha30")],
+ )
+ self._create_table(
+ "github_workflow_runs",
+ _WORKFLOW_RUNS_COLUMNS,
+ [
+ _run_row(6001, "CI", "sha-a", "completed", "success", _ago(1), _ago(1)),
+ _run_row(6002, "CI", "sha-b", "completed", "failure", _ago(1), _ago(1)),
+ _run_row(6003, "CI", "sha-c", "completed", "timed_out", _ago(1), _ago(1)),
+ _run_row(6004, "CI", "sha-d", "completed", "skipped", _ago(1), _ago(1)),
+ _run_row(6005, "CI", "sha-e", "completed", "cancelled", _ago(1), _ago(1)),
+ _run_row(6006, "CI", "sha-f", "completed", "action_required", _ago(1), _ago(1)),
+ ],
+ )
+ ci = next(i for i in api.list_workflow_health(team=self.team) if i.workflow_name == "CI")
+ day = next(entry for entry in ci.daily if entry.run_count > 0)
+ # 6 completed, 1 success, 2 failures (failure + timed_out) — skipped/cancelled/action_required are neither.
+ assert (day.completed, day.successes, day.failures) == (6, 1, 2)
+
+ def test_workflow_health_last_failure_includes_timed_out(self) -> None:
+ # last_failure_at must agree with the failure definition used by the trend: a workflow whose
+ # only decisive failure is a timeout still has a "last failure".
+ self._create_table(
+ "github_pull_requests",
+ _PULL_REQUESTS_COLUMNS,
+ [_pr_row(31, "alice", "open", 0, _ago(1), head_sha="sha31")],
+ )
+ self._create_table(
+ "github_workflow_runs",
+ _WORKFLOW_RUNS_COLUMNS,
+ [
+ _run_row(6101, "CI", "sha-g", "completed", "success", _ago(2), _ago(2)),
+ _run_row(6102, "CI", "sha-h", "completed", "timed_out", _ago(1), _ago(1)),
+ ],
+ )
+ ci = next(i for i in api.list_workflow_health(team=self.team) if i.workflow_name == "CI")
+ assert ci.last_failure_at is not None
+
+ def test_workflow_health_branch_filter(self) -> None:
+ self._create_table(
+ "github_pull_requests",
+ _PULL_REQUESTS_COLUMNS,
+ [_pr_row(20, "alice", "open", 0, _ago(1), head_sha="sha20")],
+ )
+ self._create_table(
+ "github_workflow_runs",
+ _WORKFLOW_RUNS_COLUMNS,
+ [
+ _run_row(5001, "CI", "sha-m1", "completed", "success", _ago(2), _ago(2), head_branch="main"),
+ _run_row(5002, "CI", "sha-m2", "completed", "failure", _ago(1), _ago(1), head_branch="main"),
+ _run_row(5003, "CI", "sha-f1", "completed", "success", _ago(1), _ago(1), head_branch="feature/x"),
+ ],
+ )
+ # Unfiltered: every branch's runs aggregate together.
+ assert next(i for i in api.list_workflow_health(team=self.team) if i.workflow_name == "CI").run_count == 3
+
+ # Scoped to a branch: only that branch's runs count, and rates recompute over them.
+ main_only = next(i for i in api.list_workflow_health(team=self.team, branch="main") if i.workflow_name == "CI")
+ assert main_only.run_count == 2
+ assert main_only.success_rate == 0.5
+
+ # A blank branch is treated as "no filter", not a literal match on ''.
+ assert (
+ next(i for i in api.list_workflow_health(team=self.team, branch=" ") if i.workflow_name == "CI").run_count
+ == 3
+ )
+
+ # A branch with no runs yields no rows.
+ assert api.list_workflow_health(team=self.team, branch="nope") == []
+
def test_pull_request_list_rollup_is_repo_qualified(self) -> None:
# PR numbers restart per repo. Two repos share PR #10; the per-PR push / re-run rollup must
# attribute each repo's runs to its own PR, not merge them on number alone. (The head-SHA CI
diff --git a/products/engineering_analytics/backend/tests/test_presentation.py b/products/engineering_analytics/backend/tests/test_presentation.py
index 41d2eae9a3b5..6f298340899e 100644
--- a/products/engineering_analytics/backend/tests/test_presentation.py
+++ b/products/engineering_analytics/backend/tests/test_presentation.py
@@ -64,7 +64,7 @@ def _workflow_health() -> contracts.WorkflowHealthItem:
p50_seconds=120.0,
p95_seconds=600.0,
last_failure_at=datetime(2026, 1, 20, tzinfo=UTC),
- daily=[contracts.WorkflowHealthDay(day=date(2026, 1, 20), run_count=10, completed=8, successes=7)],
+ daily=[contracts.WorkflowHealthDay(day=date(2026, 1, 20), run_count=10, completed=8, successes=7, failures=1)],
)
@@ -151,6 +151,13 @@ class TestEngineeringAnalyticsAPI(APIBaseTest):
assert response.status_code == status.HTTP_200_OK
assert response.json()[0]["workflow_name"] == "CI"
+ def test_workflow_health_passes_branch_through(self) -> None:
+ with mock.patch(f"{_VIEWS}.list_workflow_health", return_value=[]) as list_health:
+ response = self.client.get(self._url("workflow_health"), {"branch": "main"})
+
+ assert response.status_code == status.HTTP_200_OK
+ assert list_health.call_args.kwargs["branch"] == "main"
+
def test_pr_lifecycle_serializes(self) -> None:
with mock.patch(f"{_VIEWS}.get_pr_lifecycle", return_value=_pr_lifecycle()) as get:
response = self.client.get(self._url("pr_lifecycle"), {"pr_number": "10", "repo": "PostHog/posthog"})
diff --git a/products/engineering_analytics/backend/tests/test_views.py b/products/engineering_analytics/backend/tests/test_views.py
index bebfb3975870..7f67face7e7c 100644
--- a/products/engineering_analytics/backend/tests/test_views.py
+++ b/products/engineering_analytics/backend/tests/test_views.py
@@ -139,11 +139,13 @@ def _run_row(
full_name: str = "PostHog/posthog",
run_attempt: int = 1,
pr_number: int | None = None,
+ head_branch: str = "main",
) -> dict[str, Any]:
return {
"id": run_id,
"name": name,
"head_sha": head_sha,
+ "head_branch": head_branch,
"status": status,
"conclusion": conclusion,
"created_at": run_started_at,
@@ -281,7 +283,7 @@ class TestEngineeringAnalyticsViews(ClickhouseTestMixin, BaseTest):
# skip without it.
repo_json = '{"full_name": "PostHog/posthog"}'
raw = (
- "(SELECT 1 AS id, 'CI' AS name, 'sha1' AS head_sha, 'completed' AS status, "
+ "(SELECT 1 AS id, 'CI' AS name, 'sha1' AS head_sha, 'main' AS head_branch, 'completed' AS status, "
"'success' AS conclusion, 1 AS run_attempt, nullIf('', '') AS pull_requests, "
f"'{repo_json}' AS repository, "
"'2026-01-20 10:00:00' AS run_started_at, '2026-01-20 10:30:00' AS updated_at, "
diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.ts
index f40c3e6cb2f6..763e67dbec76 100644
--- a/products/engineering_analytics/frontend/generated/api.schemas.ts
+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts
@@ -233,6 +233,8 @@ export interface WorkflowHealthDayApi {
completed: number
/** Completed runs with conclusion 'success' that day. */
successes: number
+ /** Completed runs that failed that day (conclusion 'failure' or 'timed_out'); excludes skipped, cancelled, and action_required runs. */
+ failures: number
}
export interface WorkflowHealthItemApi {
@@ -260,7 +262,7 @@ export interface WorkflowHealthItemApi {
*/
p95_seconds: number | null
/**
- * When the most recent run with conclusion 'failure' started, or null.
+ * When the most recent failing run (conclusion 'failure' or 'timed_out') started, or null.
* @nullable
*/
last_failure_at: string | null
@@ -300,6 +302,10 @@ export type EngineeringAnalyticsPullRequestsParams = {
}
export type EngineeringAnalyticsWorkflowHealthParams = {
+ /**
+ * Optional exact git branch (head_branch) to scope workflow health to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
+ */
+ branch?: string
/**
* Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
*/
diff --git a/products/engineering_analytics/frontend/generated/api.ts b/products/engineering_analytics/frontend/generated/api.ts
index 991483a5e2bd..f2230ff7bfe4 100644
--- a/products/engineering_analytics/frontend/generated/api.ts
+++ b/products/engineering_analytics/frontend/generated/api.ts
@@ -153,7 +153,7 @@ export const getEngineeringAnalyticsWorkflowHealthUrl = (
}
/**
- * Per-workflow CI health over a window (default last 30 days, maximum 366 days): run count, success rate, p50/p95 duration over completed runs, last failure time, and a zero-filled daily run history. Use this for 'is CI getting slower' and 'which workflow is the long pole'; compare two windows to get a trend.
+ * Per-workflow CI health over a window (default last 30 days, maximum 366 days): run count, success rate, p50/p95 duration over completed runs, last failure time, and a zero-filled daily run history. Optionally scope to a single git branch via `branch`. Use this for 'is CI getting slower' and 'which workflow is the long pole'; compare two windows to get a trend.
*/
export const engineeringAnalyticsWorkflowHealth = async (
projectId: string,
diff --git a/products/engineering_analytics/frontend/generated/api.zod.schemas.ts b/products/engineering_analytics/frontend/generated/api.zod.schemas.ts
index 7b519f483d20..907defe5f00f 100644
--- a/products/engineering_analytics/frontend/generated/api.zod.schemas.ts
+++ b/products/engineering_analytics/frontend/generated/api.zod.schemas.ts
@@ -358,6 +358,11 @@ export const WorkflowHealthDayApi = zod.object({
run_count: zod.number().describe('Runs started that day.'),
completed: zod.number().describe('Runs that completed that day.'),
successes: zod.number().describe("Completed runs with conclusion 'success' that day."),
+ failures: zod
+ .number()
+ .describe(
+ "Completed runs that failed that day (conclusion 'failure' or 'timed_out'); excludes skipped, cancelled, and action_required runs."
+ ),
})
export type WorkflowHealthDayApi = zod.input<typeof WorkflowHealthDayApi>
@@ -378,6 +383,11 @@ export const WorkflowHealthItemApi = zod.object({
run_count: zod.number().describe('Runs started that day.'),
completed: zod.number().describe('Runs that completed that day.'),
successes: zod.number().describe("Completed runs with conclusion 'success' that day."),
+ failures: zod
+ .number()
+ .describe(
+ "Completed runs that failed that day (conclusion 'failure' or 'timed_out'); excludes skipped, cancelled, and action_required runs."
+ ),
})
)
.describe('Daily run history across the whole window, oldest first, zero-filled.'),
@@ -398,7 +408,7 @@ export const WorkflowHealthItemApi = zod.object({
last_failure_at: zod.iso
.datetime({ offset: true })
.nullable()
- .describe("When the most recent run with conclusion 'failure' started, or null."),
+ .describe("When the most recent failing run (conclusion 'failure' or 'timed_out') started, or null."),
})
export type WorkflowHealthItemApi = zod.input<typeof WorkflowHealthItemApi>
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
index 204622b6424c..70360befb3f4 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
@@ -1,6 +1,6 @@
import { useActions, useValues } from 'kea'
-import { LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'
+import { LemonInput, LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { Sparkline } from 'lib/components/Sparkline'
@@ -59,8 +59,10 @@ export function EngineeringAnalyticsWorkflows(): JSX.Element {
workflowHealthLoadError,
workflowDateFrom,
workflowDateTo,
+ branchInput,
+ appliedBranch,
} = useValues(engineeringAnalyticsLogic)
- const { setWorkflowDateRange, refresh } = useActions(engineeringAnalyticsLogic)
+ const { setWorkflowDateRange, setBranchFilter, applyBranchFilter, refresh } = useActions(engineeringAnalyticsLogic)
if (notConnected) {
return <ConnectGitHubSource />
@@ -117,7 +119,7 @@ export function EngineeringAnalyticsWorkflows(): JSX.Element {
<Sparkline
className="h-8"
type="bar"
- name="Non-passing"
+ name="Failing"
data={values}
labels={labels}
maximumIndicator={false}
@@ -168,6 +170,17 @@ export function EngineeringAnalyticsWorkflows(): JSX.Element {
onChange={setWorkflowDateRange}
dateOptions={WORKFLOW_DATE_OPTIONS}
/>
+ <LemonInput
+ type="search"
+ size="small"
+ className="w-56"
+ placeholder="Branch: all (e.g. main)"
+ value={branchInput}
+ onChange={setBranchFilter}
+ onPressEnter={applyBranchFilter}
+ onBlur={applyBranchFilter}
+ data-attr="engineering-analytics-branch-filter"
+ />
</div>
<LemonTable
data-attr="engineering-analytics-workflow-table"
@@ -178,12 +191,17 @@ export function EngineeringAnalyticsWorkflows(): JSX.Element {
loading={workflowHealthLoading}
useURLForSorting={false}
pagination={{ pageSize: 50 }}
- emptyState="No workflow runs in this window."
+ emptyState={
+ appliedBranch
+ ? `No workflow runs on '${appliedBranch}' in this window.`
+ : 'No workflow runs in this window.'
+ }
nouns={['workflow', 'workflows']}
/>
<div className="text-xs text-tertiary">
Success rate and durations are computed over completed runs only — a run that hasn't settled is
- excluded, not counted as a failure. Window: {windowLabel}.
+ excluded, not counted as a failure. Window: {windowLabel}
+ {appliedBranch ? ` · branch: ${appliedBranch}` : ''}.
</div>
</div>
)
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
index 0af6dcbcc791..2127b693414c 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
@@ -110,7 +110,7 @@ const PRS: PullRequestListItemApi[] = [
const WORKFLOWS: WorkflowHealthItemApi[] = [
{
repo: { provider: 'github', owner: 'posthog', name: 'posthog' },
- daily: [{ day: '2026-05-30', run_count: 100, completed: 95, successes: 90 }],
+ daily: [{ day: '2026-05-30', run_count: 100, completed: 95, successes: 90, failures: 4 }],
workflow_name: 'CI',
run_count: 100,
success_rate: 0.95,
@@ -254,7 +254,7 @@ describe('engineeringAnalyticsLogic', () => {
expect(logic.values.workflowHealth).toHaveLength(1)
expect(logic.values.workflowHealth[0].successRate).toBe(0.95)
expect(logic.values.workflowHealth[0].daily).toEqual([
- { day: '2026-05-30', runCount: 100, completed: 95, successes: 90 },
+ { day: '2026-05-30', runCount: 100, completed: 95, successes: 90, failures: 4 },
])
// Default state filter is "open", so only the open PR survives.
expect(logic.values.filteredPullRequests).toHaveLength(1)
@@ -278,6 +278,43 @@ describe('engineeringAnalyticsLogic', () => {
expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '2026-01-01', date_to: '2026-03-01' })
})
+ it('filters workflow health by branch server-side, only reloading on a real change', async () => {
+ logic = engineeringAnalyticsLogic()
+ logic.mount()
+ await expectLogic(logic).toDispatchActions(['loadWorkflowHealthSuccess'])
+ expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-30d' })
+
+ // Typing only stages the value — no reload until applied.
+ logic.actions.setBranchFilter('main')
+ expect(logic.values.branchInput).toBe('main')
+ expect(logic.values.appliedBranch).toBe('')
+
+ // Applying promotes it and reloads with the branch param (trimmed).
+ logic.actions.setBranchFilter(' main ')
+ logic.actions.applyBranchFilter()
+ await expectLogic(logic).toDispatchActions(['loadWorkflowHealth', 'loadWorkflowHealthSuccess'])
+ expect(logic.values.appliedBranch).toBe('main')
+ expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-30d', branch: 'main' })
+
+ // Re-applying an unchanged value (e.g. a blur with no edit) does not reload.
+ mockWorkflowHealth.mockClear()
+ logic.actions.applyBranchFilter()
+ await expectLogic(logic).toNotHaveDispatchedActions(['loadWorkflowHealth'])
+ expect(mockWorkflowHealth).not.toHaveBeenCalled()
+
+ // The applied branch persists across a date-range reload.
+ logic.actions.setWorkflowDateRange('-90d', null)
+ await expectLogic(logic).toDispatchActions(['loadWorkflowHealthSuccess'])
+ expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-90d', branch: 'main' })
+
+ // Clearing the box (e.g. the search × button, which only fires onChange('')) applies
+ // immediately — no Enter/blur needed — and drops the filter.
+ logic.actions.setBranchFilter('')
+ await expectLogic(logic).toDispatchActions(['loadWorkflowHealthSuccess'])
+ expect(logic.values.appliedBranch).toBe('')
+ expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-90d' })
+ })
+
it('exposes source options and the multi-source flag only when more than one source exists', async () => {
mockSources.mockResolvedValue(SOURCES)
logic = engineeringAnalyticsLogic()
@@ -344,9 +381,21 @@ describe('engineeringAnalyticsLogic', () => {
})
it.each([
- ['a bad day spikes', { completed: 25, successes: 22 }, 0.12, 'Jun 5 · 3 of 25 non-passing'],
- ['an all-green day stays flat', { completed: 25, successes: 25 }, 0, 'Jun 5 · 0 of 25 non-passing'],
- ['a day with nothing completed stays flat', { completed: 0, successes: 0 }, 0, 'Jun 5 · no completed runs'],
+ ['a bad day spikes', { completed: 25, successes: 22, failures: 3 }, 0.12, 'Jun 5 · 3 of 25 failed'],
+ ['an all-green day stays flat', { completed: 25, successes: 25, failures: 0 }, 0, 'Jun 5 · 0 of 25 failed'],
+ // Skipped/cancelled/action_required runs are completed but not failures — they must not spike the bar.
+ [
+ 'skipped/cancelled runs are not failures',
+ { completed: 25, successes: 20, failures: 0 },
+ 0,
+ 'Jun 5 · 0 of 25 failed',
+ ],
+ [
+ 'a day with nothing completed stays flat',
+ { completed: 0, successes: 0, failures: 0 },
+ 0,
+ 'Jun 5 · no completed runs',
+ ],
])('workflowTrendSeries: %s', (_label, counts, value, label) => {
const series = workflowTrendSeries([{ day: '2026-06-05', runCount: 30, ...counts }])
expect(series).toEqual({ values: [value], labels: [label] })
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
index 3550d4481553..ebde642bd335 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
@@ -77,6 +77,8 @@ export interface WorkflowHealthDay {
runCount: number
completed: number
successes: number
+ /** Decisive failures only (failure / timed_out); excludes skipped, cancelled, action_required. */
+ failures: number
}
export interface WorkflowHealthRow {
@@ -94,16 +96,16 @@ export interface WorkflowHealthRow {
}
/**
- * Daily series for the trend sparkline. Bar height is the non-pass rate over runs
- * that completed that day, so healthy rows stay flat and bad days spike.
+ * Daily series for the trend sparkline. Bar height is the failure rate (decisive
+ * failures over runs that completed that day), so healthy rows stay flat and bad days
+ * spike. Skipped, cancelled, and action_required runs are not failures — counting them
+ * as non-passing made green workflows look broken.
*/
export function workflowTrendSeries(daily: WorkflowHealthDay[]): { values: number[]; labels: string[] } {
- const values = daily.map((d) => (d.completed > 0 ? (d.completed - d.successes) / d.completed : 0))
+ const values = daily.map((d) => (d.completed > 0 ? d.failures / d.completed : 0))
const labels = daily.map((d) => {
const date = dayjs(d.day).format('MMM D')
- return d.completed > 0
- ? `${date} · ${d.completed - d.successes} of ${d.completed} non-passing`
- : `${date} · no completed runs`
+ return d.completed > 0 ? `${date} · ${d.failures} of ${d.completed} failed` : `${date} · no completed runs`
})
return { values, labels }
}
@@ -212,6 +214,11 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
setSearch: (search: string) => ({ search }),
setStuckOnly: (stuckOnly: boolean) => ({ stuckOnly }),
setWorkflowDateRange: (dateFrom: string | null, dateTo: string | null) => ({ dateFrom, dateTo }),
+ // Branch is filtered server-side (it's aggregated away in workflow health), so typing only
+ // stages the value in branchInput; applyBranchFilter promotes it to appliedBranch and reloads.
+ setBranchFilter: (branch: string) => ({ branch }),
+ applyBranchFilter: true,
+ setAppliedBranch: (branch: string) => ({ branch }),
applyCardFilter: (card: CardFilter) => ({ card }),
setSourceId: (sourceId: string | null) => ({ sourceId }),
setCostLensEnabled: (enabled: boolean) => ({ enabled }),
@@ -279,6 +286,7 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
const items = await engineeringAnalyticsWorkflowHealth(projectId(), {
date_from: values.workflowDateFrom ?? undefined,
date_to: values.workflowDateTo ?? undefined,
+ branch: values.appliedBranch || undefined,
source_id: values.sourceId ?? undefined,
})
return items.map(
@@ -296,6 +304,9 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
runCount: d.run_count,
completed: d.completed,
successes: d.successes,
+ // Defensive ?? 0: a new frontend can briefly hit an older backend whose
+ // response predates this field — degrade to 0, don't compute NaN bars.
+ failures: d.failures ?? 0,
})),
})
)
@@ -334,6 +345,11 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
{ setWorkflowDateRange: (_, { dateFrom }) => dateFrom },
],
workflowDateTo: [null as string | null, { setWorkflowDateRange: (_, { dateTo }) => dateTo }],
+ // Exact git branch to scope workflow health to; '' means all branches. branchInput is the
+ // staged text in the box; appliedBranch is what the loader sends. Server-side filter, so
+ // appliedBranch persists across date reloads (e.g. "main on last 30d" → "main on last 90d").
+ branchInput: ['', { setBranchFilter: (_, { branch }) => branch }],
+ appliedBranch: ['', { setAppliedBranch: (_, { branch }) => branch }],
// Leaving the open backlog (e.g. switching to Merged) exits the stuck lens — stuck implies open.
stuckOnly: [
DEFAULT_FILTERS.stuckOnly,
@@ -474,6 +490,25 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
setWorkflowDateRange: () => {
actions.loadWorkflowHealth()
},
+ setBranchFilter: ({ branch }) => {
+ // The search input's built-in clear (×) only fires onChange(''), never Enter/blur, so
+ // clearing it would otherwise leave the table scoped to the old branch. Apply on empty
+ // so the × resets to all-branches immediately.
+ if (branch.trim() === '') {
+ actions.applyBranchFilter()
+ }
+ },
+ applyBranchFilter: () => {
+ const next = values.branchInput.trim()
+ // Skip the reload when the box is unchanged (e.g. a focus/blur with no edit).
+ if (next === values.appliedBranch) {
+ return
+ }
+ actions.setAppliedBranch(next)
+ },
+ setAppliedBranch: () => {
+ actions.loadWorkflowHealth()
+ },
applyCardFilter: ({ card }) => {
// Clicking the already-active card toggles back to the plain open view.
const target: CardFilter = values.activeCard === card ? 'open' : card
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 31b09428ed68..b060ba080017 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -50494,6 +50494,8 @@ export namespace Schemas {
completed: number;
/** Completed runs with conclusion 'success' that day. */
successes: number;
+ /** Completed runs that failed that day (conclusion 'failure' or 'timed_out'); excludes skipped, cancelled, and action_required runs. */
+ failures: number;
}
export interface WorkflowHealthItem {
@@ -50521,7 +50523,7 @@ export namespace Schemas {
*/
p95_seconds: number | null;
/**
- * When the most recent run with conclusion 'failure' started, or null.
+ * When the most recent failing run (conclusion 'failure' or 'timed_out') started, or null.
* @nullable
*/
last_failure_at: string | null;
@@ -58402,6 +58404,10 @@ export namespace Schemas {
};
export type EngineeringAnalyticsWorkflowHealthParams = {
+ /**
+ * Optional exact git branch (head_branch) to scope workflow health to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
+ */
+ branch?: string;
/**
* Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
*/
diff --git a/services/mcp/src/generated/engineering_analytics/api.ts b/services/mcp/src/generated/engineering_analytics/api.ts
index 4013a8faab4d..61f70033172e 100644
--- a/services/mcp/src/generated/engineering_analytics/api.ts
+++ b/services/mcp/src/generated/engineering_analytics/api.ts
@@ -68,7 +68,7 @@ export const EngineeringAnalyticsSourcesParams = /* @__PURE__ */ zod.object({
})
/**
- * Per-workflow CI health over a window (default last 30 days, maximum 366 days): run count, success rate, p50/p95 duration over completed runs, last failure time, and a zero-filled daily run history. Use this for 'is CI getting slower' and 'which workflow is the long pole'; compare two windows to get a trend.
+ * Per-workflow CI health over a window (default last 30 days, maximum 366 days): run count, success rate, p50/p95 duration over completed runs, last failure time, and a zero-filled daily run history. Optionally scope to a single git branch via `branch`. Use this for 'is CI getting slower' and 'which workflow is the long pole'; compare two windows to get a trend.
*/
export const EngineeringAnalyticsWorkflowHealthParams = /* @__PURE__ */ zod.object({
project_id: zod
@@ -79,6 +79,12 @@ export const EngineeringAnalyticsWorkflowHealthParams = /* @__PURE__ */ zod.obje
})
export const EngineeringAnalyticsWorkflowHealthQueryParams = /* @__PURE__ */ zod.object({
+ branch: zod
+ .string()
+ .optional()
+ .describe(
+ "Optional exact git branch (head_branch) to scope workflow health to, e.g. 'main'. Omit or leave blank to aggregate across all branches."
+ ),
date_from: zod.string().optional().describe("Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d."),
date_to: zod.string().optional().describe('Window end: relative or ISO8601. Defaults to now.'),
source_id: zod
diff --git a/services/mcp/src/tools/generated/engineering_analytics.ts b/services/mcp/src/tools/generated/engineering_analytics.ts
index c41eb19baccd..a87b97dc385e 100644
--- a/services/mcp/src/tools/generated/engineering_analytics.ts
+++ b/services/mcp/src/tools/generated/engineering_analytics.ts
@@ -97,6 +97,7 @@ const workflowHealth = (): ToolBase<typeof WorkflowHealthSchema, WithPostHogUrl<
method: 'GET',
path: `/api/projects/${encodeURIComponent(String(projectId))}/engineering_analytics/workflow_health/`,
query: {
+ branch: params.branch,
date_from: params.date_from,
date_to: params.date_to,
source_id: params.source_id,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json
index f09cb5d85b56..1bd95eedaae7 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/workflow-health.json
@@ -1,6 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
+ "branch": {
+ "description": "Optional exact git branch (head_branch) to scope workflow health to, e.g. 'main'. Omit or leave blank to aggregate across all branches.",
+ "type": "string"
+ },
"date_from": {
"description": "Window start — relative ('-30d', '-8w') or ISO8601. Defaults to -30d.",
"type": "string"