: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
fix(eng-analytics): partition CI verdicts and gate runs (#95097)
Raúl Negrón-Oteroccebba99e66c
diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex d56743075396..b4b98e9d8dc4 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -340,6 +340,8 @@ class WorkflowRunDetail:# This is the only PR attribution a default-branch push has, since its `pull_requests`# association is empty by then, so consumers read `pr_number` first and fall back to this (SPEC §6).commit_pr_number: int | None+ # A merge-queue gate attempt landing `pr_number`. Counts as CI; not as a push the author made.+ is_merge_queue: bool@dataclass(frozen=True)@@ -829,6 +831,9 @@ class CIStatusRollup:passing: intfailing: intpending: int+ # Completed without a verdict (cancelled, skipped, neutral, action_required). The four counts+ # partition `runs`, so an all-cancelled PR is not mistaken for a passing one.+ inconclusive: int# The workflow names behind `failing`, sorted — what the UI names under the CI tag.failing_workflows: list[str] = field(default_factory=list)@@ -1531,7 +1536,7 @@ class RunFailureLogs:class WorkflowJobAggregate:"""Per-job aggregates for one workflow over a window, one row per de-sharded job name(matrix ``(G/N)`` suffix stripped; unexpanded ``${{ matrix.* }}`` templates collapsed).- ``failure_rate`` is over completed jobs; ``p50_seconds``/``p95_seconds`` are over+ ``failure_rate`` is decisive failures over conclusive jobs; ``p50_seconds``/``p95_seconds`` are oversuccessful jobs only (cancelled and failed instances end early and would bias aduration percentile low); cost is None when every instance ran on an unknown tier."""diff --git a/products/engineering_analytics/backend/logic/merge_queue.py b/products/engineering_analytics/backend/logic/merge_queue.pyindex f1bf88ebdc15..2e59c1b311a6 100644--- a/products/engineering_analytics/backend/logic/merge_queue.py+++ b/products/engineering_analytics/backend/logic/merge_queue.py@@ -78,6 +78,17 @@ def looks_like_merge_queue_branch_expr(branch_column: str) -> str:return f"{_source_pr_string(branch_column)} != ''"+def in_merge_queue_namespace_expr(branch_column: str) -> str:+ """HogQL predicate on the queue's branch namespace, for spend totals only.++ Wider than ``_SOURCE_PR_PATTERN``: a batched or otherwise unresolvable gate branch still sits+ here. A false positive can only misplace a sum, so the shape needs no corroboration. Anything+ that decides what a row *is* must use ``merge_queue_branch_expr``.+ """+ branch = f"ifNull({branch_column}, '')"+ return f"(startsWith({branch}, 'trunk-merge/') OR startsWith({branch}, 'gh-readonly-queue/'))"++def source_pr_string_expr(branch_column: str, *, queue_actor_column: str) -> str:"""HogQL: the PR number a corroborated gate branch is landing, as a string; '' otherwise.diff --git a/products/engineering_analytics/backend/logic/queries/_curated.py b/products/engineering_analytics/backend/logic/queries/_curated.pyindex f6ded46b1890..b4937aceb562 100644--- a/products/engineering_analytics/backend/logic/queries/_curated.py+++ b/products/engineering_analytics/backend/logic/queries/_curated.py@@ -377,6 +377,11 @@ class CuratedGitHubSource:-- s IS NULL: run_started_at parses to NULL on a bad/missing timestamp, and argMax-- over an all-NULL group returns NULL — count those as pending, not vanished.countIf(s IS NULL OR s != 'completed') AS pending,+ -- Completes the partition, so an all-cancelled PR is not read as passing.+ countIf(+ s = 'completed'+ AND ifNull(c, '') NOT IN ('success', {DECISIVE_FAILURE_CONCLUSIONS_SQL})+ ) AS inconclusive,-- The names behind `failing`, sorted for a stable order — the UI shows what is-- failing under the CI tag instead of a bare count.arraySort(groupArrayIf(workflow_name, s = 'completed' AND c IN ({DECISIVE_FAILURE_CONCLUSIONS_SQL}))) AS failing_workflowsdiff --git a/products/engineering_analytics/backend/logic/queries/_run_detail.py b/products/engineering_analytics/backend/logic/queries/_run_detail.pyindex c01152d94307..4f18eabdba22 100644--- a/products/engineering_analytics/backend/logic/queries/_run_detail.py+++ b/products/engineering_analytics/backend/logic/queries/_run_detail.py@@ -13,7 +13,7 @@ from products.engineering_analytics.backend.facade.contracts import RepoRef, WorRUN_DETAIL_COLUMNS = """id, workflow_name, head_sha, head_branch, status, conclusion,run_started_at, updated_at, duration_seconds, run_attempt, pr_number, commit_pr_number,- repo_owner, repo_name+ repo_owner, repo_name, is_merge_queue"""@@ -33,6 +33,7 @@ def to_run_detail(row: tuple[Any, ...]) -> WorkflowRunDetail:commit_pr_number,repo_owner,repo_name,+ is_merge_queue,) = rowreturn WorkflowRunDetail(repo=RepoRef(provider="github", owner=repo_owner, name=repo_name),@@ -50,4 +51,5 @@ def to_run_detail(row: tuple[Any, ...]) -> WorkflowRunDetail:run_attempt=int(run_attempt) if run_attempt is not None else 1,pr_number=int(pr_number) if pr_number is not None else 0,commit_pr_number=int(commit_pr_number) if commit_pr_number is not None else None,+ is_merge_queue=bool(is_merge_queue),)diff --git a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py b/products/engineering_analytics/backend/logic/queries/_workflow_filters.pyindex 5e498d7885de..01700aa4e003 100644--- a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py+++ b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py@@ -17,20 +17,11 @@ from products.engineering_analytics.backend.facade.contracts import WorkflowHeal# bounded by the repo's shape (workflows, job names, a PR's runs) rather than by a page size take it whole.UNPAGED_SCAN_LIMIT = MAX_SELECT_RETURNED_ROWS-# Trunk's merge-queue batch branches. Trunk-specific and hardcoded like KNOWN_BOT_HANDLES;-# defined once here so every surface breaks queue spend out with the same key.-MERGE_QUEUE_BRANCH_PREFIX = "trunk-merge/"---def merge_queue_branch_predicate(branch_sql: str) -> str:- """True when the branch expression names a merge-queue batch branch."""- return f"startsWith({branch_sql}, '{MERGE_QUEUE_BRANCH_PREFIX}')"--# Mirrors DECISIVE_FAILURE_CONCLUSIONS in frontend/lib/lifecycle.ts (keep the two in sync).DECISIVE_FAILURE_CONCLUSIONS = ("failure", "timed_out", "startup_failure", "stale")DECISIVE_FAILURE_CONCLUSIONS_SQL = ", ".join(f"'{conclusion}'" for conclusion in DECISIVE_FAILURE_CONCLUSIONS)SUCCESSFUL_RUN_CONDITION = "status = 'completed' AND conclusion = 'success'"+FAILED_RUN_CONDITION = f"status = 'completed' AND conclusion IN ({DECISIVE_FAILURE_CONCLUSIONS_SQL})"CONCLUSIVE_RUN_CONDITION = f"status = 'completed' AND conclusion IN ('success', {DECISIVE_FAILURE_CONCLUSIONS_SQL})"# Duration percentiles use successful instances because cancelled, skipped, and failed instances@@ -47,6 +38,12 @@ def success_rate_expr(scope: str | None = None) -> str:return f"countIf({SUCCESSFUL_RUN_CONDITION}{guard}) / nullIf(countIf({CONCLUSIVE_RUN_CONDITION}{guard}), 0)"+def failure_rate_expr(scope: str | None = None) -> str:+ """The complement of ``success_rate_expr`` over the same denominator."""+ guard = f" AND {scope}" if scope else ""+ return f"countIf({FAILED_RUN_CONDITION}{guard}) / nullIf(countIf({CONCLUSIVE_RUN_CONDITION}{guard}), 0)"++# A run that settled in under this many seconds with a benign conclusion did no real CI work — the# common shape is a gate job deciding the rest of the workflow should be skipped (path filters,# eligibility checks). The run-activity chart query sorts these AFTER real runs so its row cap fillsdiff --git a/products/engineering_analytics/backend/logic/queries/job_aggregates.py b/products/engineering_analytics/backend/logic/queries/job_aggregates.pyindex b40f597e199b..62b1bd81942d 100644--- a/products/engineering_analytics/backend/logic/queries/job_aggregates.py+++ b/products/engineering_analytics/backend/logic/queries/job_aggregates.py@@ -25,12 +25,17 @@ from products.engineering_analytics.backend.logic.queries._workflow_filters impobranch_filter_clause,cost_run_scope_filter_clause,date_to_filter_clause,+ failure_rate_expr,run_scope_filter_clause,run_windowed_job_created_floor_constant,)_LIMIT = 200+# A skipped job is stamped started_at = created_at, so it never queued. `conclusion` is Nullable and+# NULL != 'skipped' is NULL, which quantileIf drops; the ifNull keeps still-running jobs in the sample.+_QUEUED_JOB_CONDITION = "ifNull(conclusion, '') != 'skipped'"+# De-shard + de-template in SQL so grouping happens server-side over millions of job rows.# Mirrors jobGroups.stripShardSuffix / collapseTemplates on the frontend and# master_failures.strip_shard_suffix in Python — keep the three in sync.@@ -52,10 +57,11 @@ _AGGREGATE_SELECT = f"""count() AS job_count,uniq(name) AS shard_count,uniq(run_id) AS runs_in,- quantile(0.5)(queue_seconds) AS queue_p50_seconds,+ quantileIf(0.5)(queue_seconds, {_QUEUED_JOB_CONDITION}) AS queue_p50_seconds,quantileIf(0.5)(duration_seconds, {DURATION_PERCENTILE_CONDITION}) AS p50_seconds,quantileIf(0.95)(duration_seconds, {DURATION_PERCENTILE_CONDITION}) AS p95_seconds,- countIf(conclusion IN ('failure', 'timed_out')) / nullIf(countIf(status = 'completed'), 0) AS failure_rate,+ -- Jobs without a verdict (skipped, cancelled, neutral) stay in job_count but not in the rate.+ {failure_rate_expr()} AS failure_rate,countIf(run_attempt > 1) AS retry_job_countFROM __JOBS_SOURCE__ AS j-- NOT is_rerun_copy: "Re-run failed jobs" re-lists every already-passed job under the new attemptdiff --git a/products/engineering_analytics/backend/logic/queries/pr_cost.py b/products/engineering_analytics/backend/logic/queries/pr_cost.pyindex 2435dc4fe24f..f72467ee0645 100644--- a/products/engineering_analytics/backend/logic/queries/pr_cost.py+++ b/products/engineering_analytics/backend/logic/queries/pr_cost.py@@ -39,6 +39,7 @@ from products.engineering_analytics.backend.logic.cost import (render_is_billable_job,runner_tier_descriptor,)+from products.engineering_analytics.backend.logic.merge_queue import in_merge_queue_namespace_exprfrom products.engineering_analytics.backend.logic.queries._buckets import (Granularity,bucket_expr,@@ -50,7 +51,6 @@ from products.engineering_analytics.backend.logic.queries._workflow_filters impobranch_filter_clause,cost_run_scope_filter_clause,date_to_filter_clause,- merge_queue_branch_predicate,run_windowed_job_created_floor_constant,window_pair_predicates,)@@ -437,11 +437,11 @@ def query_workflow_window_costs_with_prev(if date_to is not None:date_to_clause = "AND c.run_started_at <= {date_to}"placeholders["date_to"] = ast.Constant(value=date_to)- # The prefix predicate deliberately counts all queue-shaped spend, including branch shapes+ # The namespace predicate deliberately counts all queue spend, including branch shapes# logic/merge_queue.py cannot resolve to a PR (e.g. trunk-merge/gr-*). The per-PR landing stats# in merge_queue_overview.py use the narrower corroborated population; the two answer different# questions, so don't unify them casually.- queue = merge_queue_branch_predicate("c.head_branch")+ queue = in_merge_queue_namespace_expr("c.head_branch")queue_agg = (f"sumIf(ifNull(c.billable_seconds, 0), {queue} AND {windows.current}) AS queue_billable_seconds, "f"sumIf(ifNull(c.billable_seconds, 0), {queue} AND {windows.previous}) AS queue_billable_seconds_prev"diff --git a/products/engineering_analytics/backend/logic/queries/pull_request_list.py b/products/engineering_analytics/backend/logic/queries/pull_request_list.pyindex 0411303f3de1..a28e058723ca 100644--- a/products/engineering_analytics/backend/logic/queries/pull_request_list.py+++ b/products/engineering_analytics/backend/logic/queries/pull_request_list.py@@ -54,6 +54,7 @@ _SELECT = f"""coalesce(ci.passing, 0) AS passing,coalesce(ci.failing, 0) AS failing,coalesce(ci.pending, 0) AS pending,+ coalesce(ci.inconclusive, 0) AS inconclusive,ci.failing_workflows AS failing_workflows,coalesce(rp.pushes, 0) AS pushes,coalesce(rp.rerun_cycles, 0) AS rerun_cycles@@ -195,6 +196,7 @@ def _map_row(passing,failing,pending,+ inconclusive,failing_workflows,pushes,rerun_cycles,@@ -224,6 +226,7 @@ def _map_row(passing=passing,failing=failing,pending=pending,+ inconclusive=inconclusive,failing_workflows=list(failing_workflows or []),),pushes=pushes,diff --git a/products/engineering_analytics/backend/presentation/serializers/pull_requests.py b/products/engineering_analytics/backend/presentation/serializers/pull_requests.pyindex 143e8ef44363..8681e79ed987 100644--- a/products/engineering_analytics/backend/presentation/serializers/pull_requests.py+++ b/products/engineering_analytics/backend/presentation/serializers/pull_requests.py@@ -202,6 +202,11 @@ class CIStatusRollupSerializer(DataclassSerializer):"passing": {"help_text": "Latest runs that completed with conclusion 'success'."},"failing": {"help_text": "Latest runs that ended in failure, timeout, startup failure, or staleness."},"pending": {"help_text": "Latest runs not yet completed (queued or in progress)."},+ "inconclusive": {+ "help_text": "Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, "+ "neutral, or action required. Together with the three counts above this covers every run, so "+ "a PR whose CI was entirely cancelled is not readable as passing."+ },"failing_workflows": {"help_text": "The workflow names behind `failing`, sorted - names what is failing instead of ""leaving a bare count."diff --git a/products/engineering_analytics/backend/presentation/serializers/workflows.py b/products/engineering_analytics/backend/presentation/serializers/workflows.pyindex 68bb5aa15439..69fcc984a6ac 100644--- a/products/engineering_analytics/backend/presentation/serializers/workflows.py+++ b/products/engineering_analytics/backend/presentation/serializers/workflows.py@@ -69,6 +69,10 @@ class WorkflowRunDetailSerializer(DataclassSerializer):"first and fall back to this.","allow_null": True,},+ "is_merge_queue": {+ "help_text": "True when a merge queue pushed this run to gate pr_number, rather than the author "+ "pushing it. Count it when measuring CI; drop it when counting what the author did."+ },}@@ -713,8 +717,8 @@ class WorkflowJobAggregateSerializer(DataclassSerializer):"allow_null": True,},"failure_rate": {- "help_text": "Decisive failures ('failure', 'timed_out') over completed instances (0-1). Null if "- "none completed.",+ "help_text": "Decisive failures over job instances with a pass-or-fail verdict (0-1). Skipped, "+ "cancelled, neutral, and action-required instances are excluded. Null if none reached a verdict.","allow_null": True,},"retry_job_count": {"help_text": "Job instances that ran on a 2nd+ run attempt - retry pressure."},diff --git a/products/engineering_analytics/backend/tests/test_ci_failure_logs.py b/products/engineering_analytics/backend/tests/test_ci_failure_logs.pyindex a1af650af357..e3d03e9197cf 100644--- a/products/engineering_analytics/backend/tests/test_ci_failure_logs.py+++ b/products/engineering_analytics/backend/tests/test_ci_failure_logs.py@@ -21,6 +21,7 @@ def _run(run_id: int) -> WorkflowRunDetail:run_attempt=1,pr_number=5,commit_pr_number=None,+ is_merge_queue=False,)diff --git a/products/engineering_analytics/backend/tests/test_logic_pull_requests.py b/products/engineering_analytics/backend/tests/test_logic_pull_requests.pyindex 058c697af46d..1d7a1b3e40f6 100644--- a/products/engineering_analytics/backend/tests/test_logic_pull_requests.py+++ b/products/engineering_analytics/backend/tests/test_logic_pull_requests.py@@ -10,7 +10,12 @@ from django.utils import timezonefrom parameterized import parameterizedfrom products.engineering_analytics.backend.facade import api-from products.engineering_analytics.backend.facade.contracts import MetricQuality, PRLifecycleEventKind, PRState+from products.engineering_analytics.backend.facade.contracts import (+ CIStatusRollup,+ MetricQuality,+ PRLifecycleEventKind,+ PRState,+)from products.engineering_analytics.backend.logic.views.source_schema import (ISSUE_EVENTS_COLUMNS,PULL_REQUESTS_COLUMNS,@@ -171,10 +176,11 @@ class TestPullRequestEndpointMapping(BaseTest):None,None,["bug", "p1"],- 3,+ 4,2,1,0,+ 1,["E2E CI"],5,2,@@ -198,7 +204,13 @@ class TestPullRequestEndpointMapping(BaseTest):assert item.labels == ["bug", "p1"]assert item.open_to_merge_seconds is Noneassert item.ready_to_merge_seconds is None- assert (item.ci.runs, item.ci.passing, item.ci.failing, item.ci.pending) == (3, 2, 1, 0)+ assert (item.ci.runs, item.ci.passing, item.ci.failing, item.ci.pending, item.ci.inconclusive) == (+ 4,+ 2,+ 1,+ 0,+ 1,+ )assert item.ci.failing_workflows == ["E2E CI"]assert (item.pushes, item.rerun_cycles) == (5, 2)assert item.estimated_cost_usd is None@@ -229,6 +241,7 @@ class TestPullRequestEndpointMapping(BaseTest):0,0,0,+ 0,list[str](),0,0,@@ -505,11 +518,43 @@ class TestPullRequestEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):_run_row(9300, "CI", "shaA", "completed", "success", _ago(2), _ago(2), pr_number=70),_run_row(9301, "CI", "shaB", "completed", "failure", _ago(1), _ago(1), pr_number=70),_run_row(9302, "CI", "shaC", "completed", "success", _ago(1), _ago(1), pr_number=71),+ # The queue's gate attempt is credited to PR 70 through its branch and flagged, so the+ # detail page can keep it as CI without counting its rebase SHA as a push.+ _run_row(+ 9303,+ "CI",+ "shaQ",+ "completed",+ "success",+ _ago(1),+ _ago(1),+ pr_number=9001,+ head_branch="trunk-merge/pr-70/7c1c3f4e-2d0a-4b7e-9e1f-0a5b6c7d8e9f",+ actor="trunk-io[bot]",+ ),],)runs = api.list_pr_runs(team=self.team, pr_number=70, repo="PostHog/posthog")- assert {r.id for r in runs} == {9300, 9301} # only PR 70's runs- assert {r.head_sha for r in runs} == {"shaA", "shaB"} # across two commits+ assert {r.id: r.is_merge_queue for r in runs} == {9300: False, 9301: False, 9303: True}+ assert {r.head_sha for r in runs} == {"shaA", "shaB", "shaQ"} # across every commit++ def test_pull_request_list_rollup_partitions_runs_without_a_verdict(self) -> None:+ self._create_table(+ "github_pull_requests",+ PULL_REQUESTS_COLUMNS,+ [_pr_row(80, "alice", "open", 0, _ago(1), head_sha="sha80")],+ )+ self._create_table(+ "github_workflow_runs",+ WORKFLOW_RUNS_COLUMNS,+ [+ _run_row(9400, "CI", "sha80", "completed", "cancelled", _ago(1), _ago(1), pr_number=80),+ _run_row(9401, "Lint", "sha80", "completed", "skipped", _ago(1), _ago(1), pr_number=80),+ _run_row(9402, "Deploy", "sha80", "completed", None, _ago(1), _ago(1), pr_number=80),+ ],+ )+ [item] = api.list_pull_requests(team=self.team).items+ assert item.ci == CIStatusRollup(runs=3, passing=0, failing=0, pending=0, inconclusive=3)def test_pr_cost_aggregates_billable_jobs_across_runs(self) -> None:# PR cost sums the jobs of all the PR's runs (across commits), counting only billable Linuxdiff --git a/products/engineering_analytics/backend/tests/test_logic_workflows.py b/products/engineering_analytics/backend/tests/test_logic_workflows.pyindex 8bde45324185..ece9e3ee303a 100644--- a/products/engineering_analytics/backend/tests/test_logic_workflows.py+++ b/products/engineering_analytics/backend/tests/test_logic_workflows.py@@ -1172,6 +1172,47 @@ class TestWorkflowEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):e2e = next(j for j in jobs if j.name == "e2e")assert e2e.runner_provider == "github_hosted" and e2e.estimated_cost_usd is None+ def test_job_aggregates_rate_and_queue_time_use_verdicts(self) -> None:+ self._create_table(+ "github_pull_requests",+ PULL_REQUESTS_COLUMNS,+ [_pr_row(64, "alice", "open", 0, _ago(1), head_sha="sha64")],+ )+ self._create_table(+ "github_workflow_runs",+ WORKFLOW_RUNS_COLUMNS,+ [_run_row(9700, "CI", "sha64", "completed", "failure", _ago(1), _ago(1), pr_number=64)],+ )+ started, completed = _ago_with_duration(1, 120)++ def queued_for(seconds: int) -> str:+ return _ago_offset_with_duration(1, -seconds, 0)[0]++ self._create_table(+ "github_workflow_jobs",+ WORKFLOW_JOBS_COLUMNS,+ [+ {+ **_job_row(97000, 9700, "build (1/4)", "success", started=started, completed=completed),+ "created_at": queued_for(60),+ },+ {+ **_job_row(97001, 9700, "build (2/4)", "failure", started=started, completed=completed),+ "created_at": queued_for(120),+ },+ {+ **_job_row(97002, 9700, "build (3/4)", "cancelled", started=started, completed=completed),+ "created_at": queued_for(180),+ },+ # GitHub stamps a skipped job started_at = created_at: no queue time and no verdict.+ _job_row(97003, 9700, "build (4/4)", "skipped", started=started, completed=started),+ ],+ )+ [build] = api.list_job_aggregates(team=self.team, workflow_name="CI")+ assert (build.job_name, build.job_count) == ("build", 4)+ assert build.failure_rate == 0.5 # one failure over the two jobs with a verdict+ assert build.queue_p50_seconds == 120 # the skipped job's zero-second queue is not a sample+def test_workflow_run_detail_handles_null_timestamps(self) -> None:# A queued/barely-started run lands with empty timestamps; the mapper must yield None, not raise# a contract validation error (regression guard for nullable run_started_at/updated_at).diff --git a/products/engineering_analytics/backend/tests/test_presentation.py b/products/engineering_analytics/backend/tests/test_presentation.pyindex 59eafa54f22e..0d33a8debd0e 100644--- a/products/engineering_analytics/backend/tests/test_presentation.py+++ b/products/engineering_analytics/backend/tests/test_presentation.py@@ -90,7 +90,7 @@ def _pr_list_item() -> contracts.PullRequestListItem:open_to_merge_seconds=None,ready_to_merge_seconds=None,labels=["bug"],- ci=contracts.CIStatusRollup(runs=3, passing=2, failing=1, pending=0),+ ci=contracts.CIStatusRollup(runs=3, passing=2, failing=1, pending=0, inconclusive=0),pushes=4,rerun_cycles=1,estimated_cost_usd=None,@@ -210,6 +210,7 @@ def _workflow_run() -> contracts.WorkflowRunDetail:run_attempt=2,pr_number=42,commit_pr_number=None,+ is_merge_queue=False,)diff --git a/products/engineering_analytics/frontend/components/CIStatusTag.tsx b/products/engineering_analytics/frontend/components/CIStatusTag.tsxindex 8b1f4607de5f..1e0eec3bc55b 100644--- a/products/engineering_analytics/frontend/components/CIStatusTag.tsx+++ b/products/engineering_analytics/frontend/components/CIStatusTag.tsx@@ -1,4 +1,4 @@-import { IconCheck, IconClock, IconX } from '@posthog/icons'+import { IconCheck, IconClock, IconMinus, IconX } from '@posthog/icons'import { LemonTag, Tooltip } from '@posthog/lemon-ui'import { CIRollup } from '../lib/ci'@@ -12,20 +12,23 @@ function Count({ count, icon, className }: { count: number; icon: JSX.Element; c)}-// Just the run tallies — passed / failed / still-running — as colored icon counts. At row height the marks-// carry the state, so there's no word label; the tooltip has the detail. "No CI" is the one case with no marks.+// The run tallies as colored icon counts; the tooltip carries the words. Every run lands in exactly one+// count, so an all-cancelled PR shows a mark instead of an empty cell. "No CI" is the one case with no marks.export function CIStatusTag({ rollup }: { rollup: CIRollup }): JSX.Element {if (rollup.runs === 0) {return <LemonTag type="muted">No CI</LemonTag>}return (<Tooltip- title={`${rollup.passing} passed, ${rollup.failing} failed, ${rollup.pending} still running. Workflow-level status for the PR's latest commit, not per-check.`}+ title={`${rollup.passing} passed, ${rollup.failing} failed, ${rollup.pending} still running, ${rollup.inconclusive} with no verdict. Workflow-level status for the PR's latest commit, not per-check.`}><span className="flex items-center gap-1.5">{rollup.passing > 0 && <Count count={rollup.passing} icon={<IconCheck />} className="text-success" />}{rollup.failing > 0 && <Count count={rollup.failing} icon={<IconX />} className="text-danger" />}{rollup.pending > 0 && <Count count={rollup.pending} icon={<IconClock />} className="text-secondary" />}+ {rollup.inconclusive > 0 && (+ <Count count={rollup.inconclusive} icon={<IconMinus />} className="text-muted" />+ )}</span></Tooltip>)diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex 71c73d1dad09..87f9d6e24cd0 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -606,7 +606,7 @@ export interface WorkflowJobAggregateApi {*/p95_seconds: number | null/**- * Decisive failures ('failure', 'timed_out') over completed instances (0-1). Null if none completed.+ * Decisive failures over job instances with a pass-or-fail verdict (0-1). Skipped, cancelled, neutral, and action-required instances are excluded. Null if none reached a verdict.* @nullable*/failure_rate: number | null@@ -862,6 +862,8 @@ export interface WorkflowRunDetailApi {* @nullable*/commit_pr_number: number | null+ /** True when a merge queue pushed this run to gate pr_number, rather than the author pushing it. Count it when measuring CI; drop it when counting what the author did. */+ is_merge_queue: boolean}/**@@ -996,6 +998,8 @@ export interface CIStatusRollupApi {failing: number/** Latest runs not yet completed (queued or in progress). */pending: number+ /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */+ inconclusive: number/** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */failing_workflows?: string[]}diff --git a/products/engineering_analytics/frontend/lib/ci.test.ts b/products/engineering_analytics/frontend/lib/ci.test.tsnew file mode 100644index 000000000000..cac4f9165d13--- /dev/null+++ b/products/engineering_analytics/frontend/lib/ci.test.ts@@ -0,0 +1,15 @@+import { ciStatusOf } from './ci'++describe('ci', () => {+ it.each([+ ['no runs', { runs: 0, passing: 0, failing: 0, pending: 0, inconclusive: 0 }, 'none'],+ ['a failure', { runs: 3, passing: 2, failing: 1, pending: 0, inconclusive: 0 }, 'failing'],+ ['failure beats pending', { runs: 5, passing: 2, failing: 1, pending: 2, inconclusive: 0 }, 'failing'],+ ['unsettled run', { runs: 3, passing: 1, failing: 0, pending: 2, inconclusive: 0 }, 'running'],+ ['all green', { runs: 3, passing: 3, failing: 0, pending: 0, inconclusive: 0 }, 'passing'],+ ['a cancelled run beside passes', { runs: 3, passing: 2, failing: 0, pending: 0, inconclusive: 1 }, 'passing'],+ ['every run cancelled', { runs: 3, passing: 0, failing: 0, pending: 0, inconclusive: 3 }, 'inconclusive'],+ ])('ciStatusOf derives %s', (_label, rollup, expected) => {+ expect(ciStatusOf(rollup)).toBe(expected)+ })+})diff --git a/products/engineering_analytics/frontend/lib/ci.ts b/products/engineering_analytics/frontend/lib/ci.tsindex bed19ab944e5..e5da183fcd80 100644--- a/products/engineering_analytics/frontend/lib/ci.ts+++ b/products/engineering_analytics/frontend/lib/ci.ts@@ -2,16 +2,17 @@// head_sha, NOT per-check). An incomplete run is "running", never a pass/fail. Shared by the logic's// selectors and the CI badge so the two never drift.-export type CIStatus = 'passing' | 'failing' | 'running' | 'none'+export type CIStatus = 'passing' | 'failing' | 'running' | 'inconclusive' | 'none'export interface CIRollup {runs: numberpassing: numberfailing: numberpending: number+ inconclusive: number}-export function ciStatusOf(rollup: Pick<CIRollup, 'runs' | 'failing' | 'pending'>): CIStatus {+export function ciStatusOf(rollup: CIRollup): CIStatus {if (rollup.runs === 0) {return 'none'}@@ -21,5 +22,9 @@ export function ciStatusOf(rollup: Pick<CIRollup, 'runs' | 'failing' | 'pending'if (rollup.pending > 0) {return 'running'}- return 'passing'+ if (rollup.passing > 0) {+ return 'passing'+ }+ // Every run was cancelled or skipped, which is not green.+ return 'inconclusive'}diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsxindex 4029de216e82..78beb45ad91c 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsPullRequests.tsx@@ -252,6 +252,11 @@ export function EngineeringAnalyticsPullRequests(): JSX.Element {{ value: 'passing', label: 'CI: passing', labelInMenu: 'Passing' },{ value: 'failing', label: 'CI: failing', labelInMenu: 'Failing' },{ value: 'running', label: 'CI: running', labelInMenu: 'Running' },+ {+ value: 'inconclusive',+ label: 'CI: no verdict',+ labelInMenu: 'No verdict',+ },{ value: 'none', label: 'CI: none', labelInMenu: 'No CI' },]}/>diff --git a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsxindex a333fe334f56..63e835b42dd1 100644--- a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx@@ -141,7 +141,14 @@ const PULL_REQUESTS: PullRequestListApi = {{author: { handle: 'jane-dev', display_name: 'Jane Dev', avatar_url: '', is_bot: false },repo: { provider: 'github', owner: 'PostHog', name: 'posthog' },- ci: { runs: 6, passing: 4, failing: 2, pending: 0, failing_workflows: ['Backend CI', 'E2E - Playwright'] },+ ci: {+ runs: 6,+ passing: 4,+ failing: 2,+ pending: 0,+ inconclusive: 0,+ failing_workflows: ['Backend CI', 'E2E - Playwright'],+ },push_history: [{head_sha: 'aaa111',@@ -182,7 +189,7 @@ const PULL_REQUESTS: PullRequestListApi = {{author: { handle: 'sam-eng', display_name: 'Sam Eng', avatar_url: '', is_bot: false },repo: { provider: 'github', owner: 'PostHog', name: 'posthog' },- ci: { runs: 5, passing: 5, failing: 0, pending: 0 },+ ci: { runs: 5, passing: 5, failing: 0, pending: 0, inconclusive: 0 },push_history: [{head_sha: 'ddd444',diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsxindex 1c2ea113ba0f..0c68581ad0a9 100644--- a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.stories.tsx@@ -44,6 +44,7 @@ function run(run_attempt: runAttempt,pr_number: prNumber,commit_pr_number: prNumber === 0 ? 4788 : null,+ is_merge_queue: headBranch === GATE_BRANCH,}}diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.tsindex 65b38e61f789..276792844b6c 100644--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts@@ -92,6 +92,7 @@ function makePr(overrides: Partial<PullRequestRow> = {}): PullRequestRow {passing: 0,failing: 0,pending: 0,+ inconclusive: 0,failingWorkflows: [],pushes: 0,pushHistory: [],@@ -106,7 +107,7 @@ function apiPr(overrides: Partial<PullRequestListItemApi> = {}): PullRequestListreturn {author: { handle: 'alice', display_name: 'alice', avatar_url: 'https://a/avatar', is_bot: false },repo: { provider: 'github', owner: 'posthog', name: 'posthog' },- ci: { runs: 0, passing: 0, failing: 0, pending: 0 },+ ci: { runs: 0, passing: 0, failing: 0, pending: 0, inconclusive: 0 },number: 1,title: 'feat: x',state: 'open',@@ -126,13 +127,18 @@ function apiPr(overrides: Partial<PullRequestListItemApi> = {}): PullRequestListconst CARDS: CICardSummaryApi = { open_prs: 18, repos: 10, stuck: 6, failing_ci: 4 }const PRS: PullRequestListItemApi[] = [- apiPr({ number: 101, ci: { runs: 3, passing: 2, failing: 1, pending: 0 }, pushes: 7, rerun_cycles: 2 }),+ apiPr({+ number: 101,+ ci: { runs: 3, passing: 2, failing: 1, pending: 0, inconclusive: 0 },+ pushes: 7,+ rerun_cycles: 2,+ }),apiPr({number: 102,title: 'fix: y',author: { handle: 'bob', display_name: 'bob', avatar_url: 'https://b/avatar', is_bot: false },repo: { provider: 'github', owner: 'posthog', name: 'posthog-js' },- ci: { runs: 5, passing: 5, failing: 0, pending: 0 },+ ci: { runs: 5, passing: 5, failing: 0, pending: 0, inconclusive: 0 },state: 'merged',created_at: '2026-05-20T00:00:00Z',merged_at: '2026-05-21T00:00:00Z',@@ -221,16 +227,6 @@ describe('engineeringAnalyticsLogic', () => {resumeKeaLoadersErrors()})- it.each([- ['no runs', { runs: 0, failing: 0, pending: 0 }, 'none'],- ['a failure', { runs: 3, failing: 1, pending: 0 }, 'failing'],- ['failure beats pending', { runs: 5, failing: 1, pending: 2 }, 'failing'],- ['unsettled run', { runs: 3, failing: 0, pending: 2 }, 'running'],- ['all green', { runs: 3, failing: 0, pending: 0 }, 'passing'],- ])('ciStatusOf derives %s', (_label, rollup, expected) => {- expect(ciStatusOf(rollup)).toBe(expected)- })-it('filters by state, author, repo, ci status, and search', () => {const rows = [makePr({ number: 1, state: 'open', authorHandle: 'alice', runs: 2, failing: 1 }),@@ -654,6 +650,7 @@ describe('engineeringAnalyticsLogic', () => {run_attempt: 1,pr_number: 10,commit_pr_number: null,+ is_merge_queue: false,...overrides,})const groups = groupRunsByCommit([diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.tsindex a2aca23c1e71..a0153f3ac2d9 100644--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts@@ -70,6 +70,8 @@ export interface PullRequestRow {passing: numberfailing: numberpending: number+ /** Runs that settled without a verdict: cancelled, skipped, neutral, action required. */+ inconclusive: number/** Workflow names behind `failing`, sorted. */failingWorkflows: string[]/** Distinct head SHAs across the PR's workflow runs. Fork PRs unattributed. */@@ -216,6 +218,7 @@ export function toPullRequestRow(it: PullRequestListItemApi): PullRequestRow {passing: it.ci.passing,failing: it.ci.failing,pending: it.ci.pending,+ inconclusive: it.ci.inconclusive,failingWorkflows: it.ci.failing_workflows ?? [],pushes: it.pushes ?? 0,pushHistory: it.push_history ?? [],diff --git a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.tsindex 9a5708eb4ee0..4f1ff3080f85 100644--- a/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts+++ b/products/engineering_analytics/frontend/scenes/pullRequestDetailLogic.ts@@ -164,6 +164,7 @@ export function groupRunsByCommit(prRuns: WorkflowRunDetailApi[]): PrCommitRuns[// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface pullRequestDetailLogicValues {+ authoredRuns: WorkflowRunDetailApi[]breadcrumbs: Breadcrumb[]commitGroups: PrCommitRuns[]expandedRunKeys: string[]@@ -330,8 +331,9 @@ export interface pullRequestDetailLogicMeta {filteredRuns: PrRunRow[],runJobs: Record<string, WorkflowJobApi[]>) => Record<string, string>- pushes: (prRuns: WorkflowRunDetailApi[]) => number- rerunCycles: (prRuns: WorkflowRunDetailApi[]) => number+ authoredRuns: (prRuns: WorkflowRunDetailApi[]) => WorkflowRunDetailApi[]+ pushes: (authoredRuns: WorkflowRunDetailApi[]) => number+ rerunCycles: (authoredRuns: WorkflowRunDetailApi[]) => numberbreadcrumbs: (repoOwner: string, repoName: string, number: number) => Breadcrumb[]}}@@ -613,14 +615,20 @@ export const pullRequestDetailLogic = kea<pullRequestDetailLogicType>([return labels},],- // Both match the backend definitions (`pushes`, `rerun_cycles`).- pushes: [+ // Drops merge-queue gate attempts, whose head SHAs the author never pushed. Mirrors the+ // backend's `runs_by_pr` rollup, so push counts agree between the PR list and this page.+ authoredRuns: [(s) => [s.prRuns],- (prRuns: WorkflowRunDetailApi[]): number => new Set(prRuns.map((run) => run.head_sha)).size,+ (prRuns: WorkflowRunDetailApi[]): WorkflowRunDetailApi[] => prRuns.filter((run) => !run.is_merge_queue),+ ],+ pushes: [+ (s) => [s.authoredRuns],+ (authoredRuns: WorkflowRunDetailApi[]): number => new Set(authoredRuns.map((run) => run.head_sha)).size,],rerunCycles: [- (s) => [s.prRuns],- (prRuns: WorkflowRunDetailApi[]): number => prRuns.filter((run) => (run.run_attempt ?? 1) > 1).length,+ (s) => [s.authoredRuns],+ (authoredRuns: WorkflowRunDetailApi[]): number =>+ authoredRuns.filter((run) => (run.run_attempt ?? 1) > 1).length,],breadcrumbs: [(_, p) => [p.repoOwner, p.repoName, p.number],diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0219e4fcb6b3..8511cad64aa1 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -15635,6 +15635,8 @@ export namespace Schemas {failing: number;/** Latest runs not yet completed (queued or in progress). */pending: number;+ /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */+ inconclusive: number;/** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */failing_workflows?: string[];}@@ -92779,7 +92781,7 @@ export namespace Schemas {*/p95_seconds: number | null;/**- * Decisive failures ('failure', 'timed_out') over completed instances (0-1). Null if none completed.+ * Decisive failures over job instances with a pass-or-fail verdict (0-1). Skipped, cancelled, neutral, and action-required instances are excluded. Null if none reached a verdict.* @nullable*/failure_rate: number | null;@@ -92871,6 +92873,8 @@ export namespace Schemas {* @nullable*/commit_pr_number: number | null;+ /** True when a merge queue pushed this run to gate pr_number, rather than the author pushing it. Count it when measuring CI; drop it when counting what the author did. */+ is_merge_queue: boolean;}export interface WorkflowRunnerCost {