Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(engineering-analytics): drop no-op gate runs from duration charts (#71043)

Julian Bez2e2ba14ec7e2
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.md
index d7e95dfad6dc..070fbecc09be 100644
--- a/products/engineering_analytics/SPEC.md
+++ b/products/engineering_analytics/SPEC.md
@@ -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, optionally scoped to a single git `branch` (`head_branch`) or PR-attributed runs excluding the default branch (`run_scope=pull_request`; master/main, same-repo PRs only). p50/p95 are over successful runs only — there is no knob, because cancelled (superseded) and failed runs end early and would bias any duration percentile low.
+- `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`) or PR-attributed runs excluding the default branch (`run_scope=pull_request`; master/main, same-repo PRs only). p50/p95 are over successful runs only — there is no knob, because cancelled (superseded) and failed runs end early and would bias any duration percentile low — and additionally exclude no-op gate runs (benign conclusion, settled in under 10 seconds), falling back to all successful runs for workflows that are legitimately all-fast. Job percentiles keep the plain successful-only population: a seconds-long job (the gate job itself) is a legitimate sample.
- `current_branch_health` — complete current default-branch verdict over a fixed 24-hour window: the detected branch, settled-workflow count, complete failing-workflow count, and a bounded name preview. This is a separate aggregate because `workflow_health` intentionally caps its per-workflow rows and cannot safely prove the fleet is green.
- `pr_lifecycle` — PR header + ordered CI-run timeline (a genuine assembly; `metric_quality = "partial"` until reviews/deploys land).
- `ci_failure_logs` — the thinned failure log lines for a PR's CI, grouped by job. Resolves the PR to its run_ids via the same `pull_requests` attribution as `pr_runs`, then reads the Logs product (`service.name = github-ci-logs`) joined on `run_id`. Reads from Logs, not the warehouse.
diff --git a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
index d0f5b6dedc47..9cec6d08001b 100644
--- a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
+++ b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
@@ -10,11 +10,47 @@ from posthog.hogql import ast
from products.engineering_analytics.backend.facade.contracts import WorkflowHealthRunScope
-# The one duration-percentile population, for runs and jobs alike: successful instances
+# The base duration-percentile population, for runs and jobs alike: successful instances
# only. Cancelled/skipped (superseded) and failed instances end early, so including them
-# answers "how long until CI stopped", not "how long does CI take to pass".
+# answers "how long until CI stopped", not "how long does CI take to pass". Jobs use this
+# as-is — a seconds-long job (the gate job itself) is a legitimate duration sample.
DURATION_PERCENTILE_CONDITION = "status = 'completed' AND conclusion = 'success'"
+# 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 fills
+# with real executions first, then drops them when enough real runs remain (see
+# ``workflow_run_activity``) — duration alone can't tell a gate no-op from an intentionally fast
+# workflow, so an all-fast workflow keeps its history instead of an empty chart. Mirrors ``isNoOpRun``
+# in ``frontend/lib/runHealth.ts`` (keep the two in sync): decisive failures and attention-needing
+# conclusions (``action_required``, ``startup_failure``) are never no-ops — failing in seconds is
+# signal, not noise.
+NO_OP_RUN_MAX_SECONDS = 10
+NO_OP_RUN_FLAG = (
+ # ifNull keeps the flag NULL-free: an in-flight run (NULL duration) and a completed row with a
+ # NULL conclusion (the column is nullable; conclusions can lag the sync) would each turn the AND
+ # into NULL — both must read as real (0), never as no-ops.
+ f"ifNull(r.duration_seconds < {NO_OP_RUN_MAX_SECONDS} "
+ "AND r.conclusion IN ('success', 'skipped', 'neutral', 'completed', 'cancelled'), 0)"
+)
+
+# Run duration percentiles additionally exclude no-op gate runs: a workflow that mostly "succeeds"
+# in seconds without doing real work would otherwise report a seconds-long p50 on every surface.
+RUN_DURATION_PERCENTILE_CONDITION = f"{DURATION_PERCENTILE_CONDITION} AND NOT {NO_OP_RUN_FLAG}"
+
+
+def run_duration_percentile_expr(quantile: float) -> str:
+ """Bare (unaliased) duration percentile over successful non-no-op runs, per aggregate group.
+ Falls back to every successful run when the group has no real samples — duration alone can't
+ tell a gate no-op from an intentionally fast workflow — mirroring the activity endpoint and
+ the frontend ``computeHealthSummary``."""
+ return (
+ f"if(countIf({RUN_DURATION_PERCENTILE_CONDITION}) > 0, "
+ f"quantileIf({quantile})(duration_seconds, {RUN_DURATION_PERCENTILE_CONDITION}), "
+ f"quantileIf({quantile})(duration_seconds, {DURATION_PERCENTILE_CONDITION}))"
+ )
+
+
# The one "failing right now" signal, per workflow: did the latest completed run fail?
# Ordered by (run_started_at, id) so a same-second tie resolves deterministically to the
# later-created run. argMaxIf defaults to 0 (false) over zero matching rows, so consumers must
diff --git a/products/engineering_analytics/backend/logic/queries/workflow_health.py b/products/engineering_analytics/backend/logic/queries/workflow_health.py
index 40671f87057e..857a114a1c01 100644
--- a/products/engineering_analytics/backend/logic/queries/workflow_health.py
+++ b/products/engineering_analytics/backend/logic/queries/workflow_health.py
@@ -6,7 +6,10 @@ a single ``head_branch`` and/or attributed pull-request runs. Rates are over com
runs. Duration percentiles are over successful runs only — cancelled/skipped runs
(common on PR branches, where a new push supersedes in-flight CI) and failed runs
end early and would bias a "how long does CI take" percentile low — so they are
-``None`` for a window with no successful runs.
+``None`` for a window with no successful runs. No-op gate runs are excluded from the
+percentiles too, with an all-successful fallback for legitimately all-fast workflows
+(see ``run_duration_percentile_expr``), so the Workflows table agrees with the
+activity chart and the detail-page KPIs.
The per-bucket history adapts its granularity to the window length (hour / day / week)
so the trend sparkline keeps a readable number of points — per-day buckets are useless
@@ -33,10 +36,10 @@ from products.engineering_analytics.backend.logic.queries._buckets import (
)
from products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource, opt_float
from products.engineering_analytics.backend.logic.queries._workflow_filters import (
- DURATION_PERCENTILE_CONDITION,
LATEST_COMPLETED_RUN_FAILED,
branch_filter_clause,
date_to_filter_clause,
+ run_duration_percentile_expr,
run_scope_filter_clause,
run_started_floor_constant,
)
@@ -53,8 +56,8 @@ _SELECT = f"""
workflow_name,
count() AS run_count,
countIf(status = 'completed' AND conclusion = 'success') / nullIf(countIf(status = 'completed'), 0) AS success_rate,
- quantileIf(0.5)(duration_seconds, {DURATION_PERCENTILE_CONDITION}) AS p50_seconds,
- quantileIf(0.95)(duration_seconds, {DURATION_PERCENTILE_CONDITION}) AS p95_seconds,
+ {run_duration_percentile_expr(0.5)} AS p50_seconds,
+ {run_duration_percentile_expr(0.95)} AS p95_seconds,
max(if(conclusion IN ('failure', 'timed_out'), run_started_at, NULL)) AS last_failure_at,
countIf(status = 'completed') AS completed_count,
{LATEST_COMPLETED_RUN_FAILED} AS latest_failed,
@@ -101,7 +104,7 @@ _BUCKET_SELECT = f"""
_TIME_TO_GREEN_SELECT = f"""
SELECT
__BUCKET_FN__ AS bucket_start,
- quantileIf(0.5)(duration_seconds, {DURATION_PERCENTILE_CONDITION}) AS p50_seconds
+ {run_duration_percentile_expr(0.5)} AS p50_seconds
FROM __RUNS_SOURCE__ AS r
WHERE run_started_at >= {{date_from}} __DATE_TO__ __RUN_SCOPE__
GROUP BY bucket_start
diff --git a/products/engineering_analytics/backend/logic/queries/workflow_run_activity.py b/products/engineering_analytics/backend/logic/queries/workflow_run_activity.py
index c00127e404da..e51c4e729b28 100644
--- a/products/engineering_analytics/backend/logic/queries/workflow_run_activity.py
+++ b/products/engineering_analytics/backend/logic/queries/workflow_run_activity.py
@@ -10,6 +10,15 @@ silently dropped.
The ``run_started_at >= date_from`` filter also excludes runs whose start timestamp didn't parse
(``NULL``), which is intended: a run with no start time can't be placed on the chart's time axis. That
is why ``WorkflowRunActivityPoint.run_started_at`` is non-null while the shared run-detail shape is not.
+
+No-op gate runs (benign conclusion, settled in seconds — see ``NO_OP_RUN_FLAG``) are hidden here, not
+client-side: on a workflow where most runs are no-ops the newest ``_LIMIT`` rows could be pure gate
+runs, and a post-cap filter would leave the chart empty even though real executions exist in the
+window. The query sorts real runs ahead of no-ops so the cap fills with real executions first, and the
+no-ops are then dropped in Python — unless fewer than ``_MIN_REAL_RUNS`` real runs remain, in which
+case everything is kept: duration alone can't tell a gate no-op from an intentionally fast workflow
+(a lightweight guard check), so an all-fast workflow keeps its history instead of an empty chart. The
+run-detail table always shows every run — only the chart hides no-ops.
"""
from datetime import datetime
@@ -19,6 +28,7 @@ from posthog.hogql import ast
from products.engineering_analytics.backend.facade.contracts import WorkflowRunActivity, WorkflowRunActivityPoint
from products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource
from products.engineering_analytics.backend.logic.queries._workflow_filters import (
+ NO_OP_RUN_FLAG,
branch_filter_clause,
date_to_filter_clause,
)
@@ -29,13 +39,18 @@ from products.engineering_analytics.backend.logic.queries._workflow_filters impo
# Revisit this alongside that table cap if it changes materially, so the chart keeps spanning the window.
_LIMIT = 2000
+# Matches the chart's MIN_POINTS: below two real dots the scatter draws nothing anyway, so hiding
+# the no-ops would blank a chart that still has runs to show.
+_MIN_REAL_RUNS = 2
+
_SELECT = f"""
SELECT
- id, conclusion, run_started_at, duration_seconds, head_branch, pr_number, head_sha
+ id, conclusion, run_started_at, duration_seconds, head_branch, pr_number, head_sha,
+ {NO_OP_RUN_FLAG} AS is_noop
FROM __RUNS_SOURCE__ AS r
WHERE repo_owner = {{repo_owner}} AND repo_name = {{repo_name}} AND workflow_name = {{workflow_name}}
AND run_started_at >= {{date_from}} __DATE_TO__ __BRANCH__
- ORDER BY run_started_at DESC, run_attempt DESC
+ ORDER BY is_noop ASC, run_started_at DESC, run_attempt DESC
LIMIT {_LIMIT + 1}
"""
@@ -67,12 +82,21 @@ def query_workflow_run_activity(
)
rows = response.results or []
truncated = len(rows) > _LIMIT
- points = [_to_point(row) for row in rows[:_LIMIT]]
+ capped = rows[:_LIMIT]
+ real = [row for row in capped if not row[7]]
+ # The threshold counts duration-bearing rows only: in-flight runs are kept but can't land on the
+ # scatter, so real rows without durations must not veto the fallback — dropping the no-ops around
+ # a lone completed run plus an in-flight one would leave the chart below MIN_POINTS and blank.
+ plottable_real = sum(1 for row in real if row[3] is not None)
+ chosen = real if plottable_real >= _MIN_REAL_RUNS else capped
+ # The is_noop sort put real runs first — restore the newest-first order the chart contract promises.
+ chosen = sorted(chosen, key=lambda row: row[2], reverse=True)
+ points = [_to_point(row) for row in chosen]
return WorkflowRunActivity(points=points, truncated=truncated, limit=_LIMIT)
def _to_point(row: tuple) -> WorkflowRunActivityPoint:
- run_id, conclusion, run_started_at, duration_seconds, head_branch, pr_number, head_sha = row
+ run_id, conclusion, run_started_at, duration_seconds, head_branch, pr_number, head_sha, _is_noop = row
return WorkflowRunActivityPoint(
run_id=int(run_id),
# Empty string means "no conclusion yet" (still running) — normalize to None for the contract.
diff --git a/products/engineering_analytics/backend/tests/test_logic.py b/products/engineering_analytics/backend/tests/test_logic.py
index 4c7c0038da00..93239a0bec36 100644
--- a/products/engineering_analytics/backend/tests/test_logic.py
+++ b/products/engineering_analytics/backend/tests/test_logic.py
@@ -1010,15 +1010,15 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
assert ci.success_rate == 1.0
assert ci.success_rate_prev == 1.0
- def test_workflow_health_duration_percentiles_exclude_cancelled_and_failed_runs(self) -> None:
+ def test_workflow_health_duration_percentiles_exclude_cancelled_failed_and_noop_runs(self) -> None:
self._create_table(
"github_pull_requests",
_PULL_REQUESTS_COLUMNS,
[_pr_row(90, "alice", "open", 0, _ago(1), head_sha="sha90")],
)
- # Every success shares one duration, so success-only p50/p95 are exactly 100; any leaked
- # cancel (1s) or failure (1000s) in the percentile population moves them off 100.
- conclusions = [("success", 100)] * 2 + [("cancelled", 1)] * 3 + [("failure", 1000)]
+ # Every real success shares one duration, so the percentile population is exactly 100; any
+ # leaked cancel (1s), failure (1000s), or no-op gate success (4s) moves p50/p95 off 100.
+ conclusions = [("success", 100)] * 2 + [("success", 4)] * 3 + [("cancelled", 1)] * 3 + [("failure", 1000)]
self._create_table(
"github_workflow_runs",
_WORKFLOW_RUNS_COLUMNS,
@@ -1034,19 +1034,27 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
head_branch="feature/ci",
)
for index, (conclusion, duration_seconds) in enumerate(conclusions)
+ ]
+ # An all-fast workflow has no real successes — its percentiles fall back to every
+ # successful run instead of reading as missing.
+ + [
+ _run_row(9100, "Guard", "guard-1", "completed", "success", *_ago_with_duration(1, 4)),
+ _run_row(9101, "Guard", "guard-2", "completed", "success", *_ago_with_duration(2, 4)),
],
)
- ci = next(
- item for item in api.list_workflow_health(team=self.team, date_from="-30d") if item.workflow_name == "CI"
- )
+ health = api.list_workflow_health(team=self.team, date_from="-30d")
+ ci = next(item for item in health if item.workflow_name == "CI")
# Counts and rate stay over all/completed runs; only the duration population narrows.
- assert ci.run_count == 6
- assert ci.success_rate == pytest.approx(2 / 6)
+ assert ci.run_count == 9
+ assert ci.success_rate == pytest.approx(5 / 9)
assert ci.p50_seconds == pytest.approx(100)
assert ci.p95_seconds == pytest.approx(100)
+ guard = next(item for item in health if item.workflow_name == "Guard")
+ assert guard.p50_seconds == pytest.approx(4)
+
def test_workflow_health_pull_request_scope_excludes_default_branch_and_unattributed_runs(self) -> None:
self._create_table(
"github_pull_requests",
@@ -1251,6 +1259,9 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
def test_workflow_run_activity_projects_and_windows(self) -> None:
# The chart endpoint returns compact per-run points over the window, newest first, with the
# projection mapped in the right column order and an explicit (untruncated) cap signal.
+ # No-op gate runs (benign conclusion, settled in seconds) are hidden by the endpoint — real
+ # runs fill the cap first — while fast failures and in-flight runs stay, and an all-fast
+ # workflow falls back to showing everything.
self._create_table(
"github_pull_requests",
_PULL_REQUESTS_COLUMNS,
@@ -1260,23 +1271,52 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
"github_workflow_runs",
_WORKFLOW_RUNS_COLUMNS,
[
+ # A fast failure is signal (broken config fails in seconds) — never filtered as no-op.
_run_row(
- 8101, "CI", "sha-a", "completed", "failure", _ago(2), _ago(2), pr_number=80, head_branch="feat"
+ 8101,
+ "CI",
+ "sha-a",
+ "completed",
+ "failure",
+ *_ago_with_duration(2, 4),
+ pr_number=80,
+ head_branch="feat",
),
- _run_row(8102, "CI", "sha-b", "completed", "success", _ago(1), _ago(1)),
- _run_row(8103, "Deploy", "sha-c", "completed", "success", _ago(1), _ago(1)),
+ _run_row(8102, "CI", "sha-b", "completed", "success", *_ago_with_duration(1, 300)),
+ _run_row(8103, "Deploy", "sha-c", "completed", "success", *_ago_with_duration(1, 300)),
# Older than the default -30d window — excluded unless the caller widens it.
- _run_row(8104, "CI", "sha-d", "completed", "success", _ago(60), _ago(60)),
+ _run_row(8104, "CI", "sha-d", "completed", "success", *_ago_with_duration(60, 120)),
+ # A no-op gate run: succeeded in seconds without doing real work — off the chart.
+ _run_row(8105, "CI", "sha-e", "completed", "success", *_ago_with_duration(1, 4)),
+ # Still running: no duration yet, but it must stay (it feeds the in-flight band).
+ _run_row(8106, "CI", "sha-f", "in_progress", None, _ago(3), _ago(3)),
+ # Completed fast but with a NULL conclusion (conclusions can lag the sync) — undecided,
+ # so it must stay; a non-NULL-safe no-op flag would silently drop it.
+ _run_row(8107, "CI", "sha-g", "completed", None, *_ago_with_duration(4, 4)),
+ # A legitimately fast workflow: every run finishes in seconds. Duration alone can't
+ # tell it from a gate no-op, so with no real runs to show the filter must stand down.
+ _run_row(8110, "Guard", "sha-h", "completed", "success", *_ago_with_duration(2, 3)),
+ _run_row(8111, "Guard", "sha-i", "completed", "success", *_ago_with_duration(1, 4)),
+ # A sparse workflow: one real execution, one in flight, one fast no-op. The in-flight
+ # run has no duration to plot, so dropping the no-op would leave the scatter below its
+ # 2-point minimum — the fallback must count duration-bearing runs, not kept rows.
+ _run_row(8120, "Sparse", "sha-j", "completed", "success", *_ago_with_duration(3, 300)),
+ _run_row(8121, "Sparse", "sha-k", "in_progress", None, _ago(2), _ago(2)),
+ _run_row(8122, "Sparse", "sha-l", "completed", "success", *_ago_with_duration(1, 4)),
],
)
activity = api.get_workflow_run_activity(team=self.team, repo="PostHog/posthog", workflow_name="CI")
- assert [p.run_id for p in activity.points] == [8102, 8101] # only CI runs in window, newest first
+ # Only CI runs in window, newest first; the no-op 8105 is excluded, the in-flight 8106 and the
+ # fast-but-undecided 8107 are kept.
+ assert [p.run_id for p in activity.points] == [8102, 8101, 8106, 8107]
assert activity.truncated is False
assert activity.limit == 2000
# Each field maps to the right column — guards a wrong unpack order in _to_point.
- newest, failed = activity.points
+ newest, failed, in_flight, undecided = activity.points
assert (newest.run_id, newest.conclusion, newest.pr_number) == (8102, "success", 0)
assert (failed.conclusion, failed.head_branch, failed.pr_number) == ("failure", "feat", 80)
+ assert (in_flight.conclusion, in_flight.duration_seconds) == (None, None)
+ assert (undecided.conclusion, undecided.duration_seconds) == (None, 4)
# run_started_at is non-null on this endpoint — the window filter excludes unparseable-start runs.
assert all(p.run_started_at is not None for p in activity.points)
@@ -1284,7 +1324,16 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
wide = api.get_workflow_run_activity(
team=self.team, repo="PostHog/posthog", workflow_name="CI", date_from="-90d"
)
- assert [p.run_id for p in wide.points] == [8102, 8101, 8104]
+ assert [p.run_id for p in wide.points] == [8102, 8101, 8106, 8107, 8104]
+
+ # An all-fast workflow keeps its history: with no real runs left to show, hiding the no-ops
+ # would blank the chart, so the filter stands down and both runs come back.
+ guard = api.get_workflow_run_activity(team=self.team, repo="PostHog/posthog", workflow_name="Guard")
+ assert [p.run_id for p in guard.points] == [8111, 8110]
+
+ # One plottable real run isn't enough for the scatter either — the no-op stays visible too.
+ sparse = api.get_workflow_run_activity(team=self.team, repo="PostHog/posthog", workflow_name="Sparse")
+ assert [p.run_id for p in sparse.points] == [8122, 8121, 8120]
def test_repo_run_activity_collapses_workflows_per_commit(self) -> None:
# The repo-health chart folds every workflow run of a default-branch commit into ONE point: the
@@ -1342,9 +1391,11 @@ class TestEndpointsWarehouse(_WarehouseMixin, BaseTest):
"github_workflow_runs",
_WORKFLOW_RUNS_COLUMNS,
[
- _run_row(8501, "CI", "sha-m1", "completed", "success", _ago(2), _ago(2), head_branch="main"),
- _run_row(8502, "CI", "sha-m2", "completed", "failure", _ago(1), _ago(1), head_branch="main"),
- _run_row(8503, "CI", "sha-r1", "completed", "success", _ago(1), _ago(1), head_branch="release"),
+ _run_row(8501, "CI", "sha-m1", "completed", "success", *_ago_with_duration(2, 60), head_branch="main"),
+ _run_row(8502, "CI", "sha-m2", "completed", "failure", *_ago_with_duration(1, 60), head_branch="main"),
+ _run_row(
+ 8503, "CI", "sha-r1", "completed", "success", *_ago_with_duration(1, 60), head_branch="release"
+ ),
],
)
self._create_table(
diff --git a/products/engineering_analytics/frontend/components/RunActivityChart.tsx b/products/engineering_analytics/frontend/components/RunActivityChart.tsx
index 99d126f293a0..f85fc262825a 100644
--- a/products/engineering_analytics/frontend/components/RunActivityChart.tsx
+++ b/products/engineering_analytics/frontend/components/RunActivityChart.tsx
@@ -248,6 +248,8 @@ export function RunActivityChart({
const now = dayjs().valueOf()
// Every run with a start contributes an interval to the band; a still-running run extends to now, but
// only up to MAX_IN_FLIGHT_MS so an abandoned run that never settled doesn't stretch the band by days.
+ // No-op gate runs never reach this component: the workflow activity endpoint hides them server-side
+ // (pre-cap, with an all-fast fallback), and commit rollups deliberately aren't filtered at all.
const intervals: Interval[] = runs
.filter((run): run is ActivityRun & { startedAt: string } => run.startedAt != null)
.map((run) => {
diff --git a/products/engineering_analytics/frontend/lib/runHealth.test.ts b/products/engineering_analytics/frontend/lib/runHealth.test.ts
index b2f64f870126..ce449d82b9fe 100644
--- a/products/engineering_analytics/frontend/lib/runHealth.test.ts
+++ b/products/engineering_analytics/frontend/lib/runHealth.test.ts
@@ -1,4 +1,11 @@
-import { CostableJob, RunCostSummary, computeFleetSummary, computeHealthSummary, summarizeRunCost } from './runHealth'
+import {
+ CostableJob,
+ RunCostSummary,
+ computeFleetSummary,
+ computeHealthSummary,
+ isNoOpRun,
+ summarizeRunCost,
+} from './runHealth'
const at = (hour: number): string => `2026-06-24T${String(hour).padStart(2, '0')}:00:00Z`
@@ -61,6 +68,57 @@ describe('runHealth', () => {
expect(summary.reruns).toBe(1)
})
+ it.each([
+ ['seconds-long success (gate job, rest skipped) → no-op', 'success', 4, true],
+ ['seconds-long skipped run → no-op', 'skipped', 2, true],
+ ['seconds-long cancelled run (superseded) → no-op', 'cancelled', 3, true],
+ ['seconds-long failure is signal, not noise → kept', 'failure', 4, false],
+ ['seconds-long action_required needs attention → kept', 'action_required', 3, false],
+ ['at the threshold → kept', 'success', 10, false],
+ ['still running (no duration yet) → kept', null, null, false],
+ ])('flags no-op runs: %s', (_name, conclusion, durationSeconds, expected) => {
+ expect(isNoOpRun({ conclusion, durationSeconds })).toBe(expected)
+ })
+
+ it('keeps no-op runs in counts and pass rate but out of the duration percentiles', () => {
+ // A workflow dominated by no-op gate runs (e.g. a preview deploy that mostly decides "not
+ // eligible" in ~4s) must not read as having a ~4s median — that hides the real CI duration.
+ const summary = computeHealthSummary([
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(9) },
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(10) },
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(11) },
+ { conclusion: 'success', durationSeconds: 600, startedAt: at(12) },
+ { conclusion: 'success', durationSeconds: 900, startedAt: at(13) },
+ ])
+ expect(summary.medianSeconds).toBe(600)
+ expect(summary.p95Seconds).toBe(900)
+ expect(summary.totalRuns).toBe(5)
+ expect(summary.completedRuns).toBe(5)
+ expect(summary.passRate).toBe(1)
+ })
+
+ it('falls back to every duration when a workflow is legitimately all-fast', () => {
+ // An intentionally quick workflow (a guard check finishing in seconds) has no "real" runs by
+ // the no-op definition — its median must come from what it has, not read as missing.
+ const summary = computeHealthSummary([
+ { conclusion: 'success', durationSeconds: 3, startedAt: at(9) },
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(10) },
+ { conclusion: 'success', durationSeconds: 5, startedAt: at(11) },
+ ])
+ expect(summary.medianSeconds).toBe(4)
+ })
+
+ it('lets a lone real duration win over no-op noise', () => {
+ // With exactly one real execution among gate runs, falling back to all durations would let
+ // the no-ops drown it (~4s median) — the single real sample is the honest answer.
+ const summary = computeHealthSummary([
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(9) },
+ { conclusion: 'success', durationSeconds: 4, startedAt: at(10) },
+ { conclusion: 'success', durationSeconds: 600, startedAt: at(11) },
+ ])
+ expect(summary.medianSeconds).toBe(600)
+ })
+
const fleetRow = (
latestRunFailed: boolean | null,
successRate: number | null = 1,
diff --git a/products/engineering_analytics/frontend/lib/runHealth.ts b/products/engineering_analytics/frontend/lib/runHealth.ts
index f881e708ed99..31ff101240b9 100644
--- a/products/engineering_analytics/frontend/lib/runHealth.ts
+++ b/products/engineering_analytics/frontend/lib/runHealth.ts
@@ -1,4 +1,4 @@
-import { isDecisiveFailure } from './lifecycle'
+import { isDecisiveFailure, isPassingConclusion } from './lifecycle'
/** Minimal run shape; WorkflowRunRow and PrRunRow both satisfy it. */
export interface HealthRun {
@@ -90,6 +90,25 @@ export interface FleetSummary {
estimatedCostUsd: number | null
}
+// A completed run that settled in under this many seconds 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 "succeeds" in seconds with every other job skipped. Those runs are noise on duration surfaces —
+// they pile up at the bottom of the activity scatter and drag duration percentiles toward zero.
+export const NO_OP_RUN_MAX_SECONDS = 10
+
+/** True for no-op runs (see {@link NO_OP_RUN_MAX_SECONDS}): completed fast with a benign conclusion —
+ * the same set `verdictTag` paints as non-warning (passing or cancelled). Everything else is kept
+ * regardless of speed: decisive failures (broken config fails in seconds) and attention-needing
+ * conclusions like action_required or startup_failure are signal, not noise. */
+export function isNoOpRun(run: Pick<HealthRun, 'conclusion' | 'durationSeconds'>): boolean {
+ return (
+ run.conclusion != null &&
+ (isPassingConclusion(run.conclusion) || run.conclusion === 'cancelled') &&
+ run.durationSeconds != null &&
+ run.durationSeconds < NO_OP_RUN_MAX_SECONDS
+ )
+}
+
/** Nearest-rank percentile over an ascending-sorted sample. */
export function percentileSorted(sortedAsc: number[], q: number): number | null {
if (sortedAsc.length === 0) {
@@ -111,10 +130,16 @@ export function computeHealthSummary(runs: HealthRun[]): HealthSummary {
const reruns = runs.filter((run) => (run.runAttempt ?? 1) > 1).length
const passRate = completed.length ? passed / completed.length : null
- const durations = completed
+ // No-op runs stay in the counts and pass rate (they are real runs) but not in the duration
+ // percentiles, so the median/p95 tiles agree with the activity chart, which hides them too. The
+ // all-duration fallback is reserved for ZERO real samples (an intentionally fast workflow, where
+ // "—" would be wrong): even a lone real execution is a more honest median than gate-run noise.
+ const allDurations = completed.map((run) => run.durationSeconds).filter((d): d is number => d != null)
+ const realDurations = completed
+ .filter((run) => !isNoOpRun(run))
.map((run) => run.durationSeconds)
.filter((d): d is number => d != null)
- .sort((a, b) => a - b)
+ const durations = (realDurations.length > 0 ? realDurations : allDurations).sort((a, b) => a - b)
const byStartDesc = [...completed].sort((a, b) => (b.startedAt ?? '').localeCompare(a.startedAt ?? ''))
const latestConclusion = byStartDesc[0]?.conclusion ?? null