: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): exclude failed setup jobs (#102949)
Raúl Negrón-Oteroea80892fe3c1
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.mdindex c79be852ae59..fdb51dcdde42 100644--- a/products/engineering_analytics/SPEC.md+++ b/products/engineering_analytics/SPEC.md@@ -92,7 +92,7 @@ The endpoint catalog is `presentation/views.py`; the agent-facing descriptions l- Capped list contracts that include a sibling aggregate return `{items, truncated, limit}` so they never silently undercount against it.- Span-derived reads (flaky tests, team CI health) report absolute counts, never rates: sub-threshold runs aren't emitted, so denominators are biased.- Test evidence is counted per CI run, never per span or run attempt (one run fans a test across matrix legs, and every attempt re-tests the same commit), and both span-derived reads group the same `run_evidence()` so the grain and the meaning of flaky cannot drift. A test is `confirmed_flake` only on same-commit recovery proof: a re-run attempt going green, or an in-job retry. Unproven failures rank as `suspected_regression` by blast radius.-- A CI setup break is not per-test evidence. `run_evidence()` drops every trial of a run attempt whose errored tests span 3 or more jobs or 3 or more owning teams, so its errors are no test's failure and its passes are no test's recovery. The spans name the attempt, and GitHub's synced `workflow_jobs` rows confirm it: the same attempt must report 3 or more failed jobs there. CI stamps every span attribute the rule reads, so no evidence is dropped on the spans alone, and an unsynced jobs table drops nothing.+- A CI setup break is not per-test evidence. `run_evidence()` drops every trial of a run attempt whose errored tests span 3 or more jobs or 3 or more owning teams, and of a job attempt with 100 or more distinct failed or errored tests, so their failures are no test's failure and their passes are no test's recovery. The spans name the attempt, and GitHub's synced `workflow_jobs` rows confirm it: a run attempt must report 3 or more failed jobs there, a job attempt at least one. CI stamps every span attribute the rule reads, so no evidence is dropped on the spans alone, and an unsynced jobs table drops nothing.- Reads over optional data (e.g. `team_members`) degrade honestly (`has_membership_data: false`), never 500.### Exposed warehouse viewsdiff --git a/products/engineering_analytics/backend/logic/queries/_test_spans.py b/products/engineering_analytics/backend/logic/queries/_test_spans.pyindex d2aae4adc87b..5087320c27ae 100644--- a/products/engineering_analytics/backend/logic/queries/_test_spans.py+++ b/products/engineering_analytics/backend/logic/queries/_test_spans.py@@ -29,6 +29,7 @@ from datetime import datetimefrom posthog.hogql import astfrom posthog.clickhouse.workload import Workload+from posthog.dataclasses import frozenfrom products.engineering_analytics.backend.facade.contracts import UNOWNED_TEAMfrom products.engineering_analytics.backend.logic.merge_queue import source_pr_string_expr@@ -110,6 +111,7 @@ _RUN_EVIDENCE = """max(span_timestamp) AS trial_atFROM (__SPAN_SCAN__)WHERE NOT has({setup_break_run_attempts}, (run_id, toString(attempt)))+ AND NOT has({setup_break_job_attempts}, (run_id, toString(attempt), job_key))GROUP BY runner, nodeid, run_id, job_key, attempt)GROUP BY runner, nodeid, run_id, job_key@@ -121,13 +123,19 @@ _RUN_EVIDENCE = """HAVING failed_in_run OR recovered_in_run OR quarantined_in_run"""-# A CI setup break errors tests in many jobs, or tests of many owning teams, in one run attempt. Those-# errors describe the attempt, not any one test, so run_evidence() drops every trial of that attempt:-# its failures are not failures of a test, and its passes are not recovery proof.+# A CI setup break describes CI, not any one test, so run_evidence() drops every trial it produced: its+# failures are not failures of a test, and its passes are not recovery proof. It has two shapes:+# - a run attempt whose errored tests span many jobs, or tests of many owning teams;+# - a job attempt where many tests failed, such as a whole shard that fails and then passes on a re-run.SETUP_BREAK_MIN_JOBS = 3SETUP_BREAK_MIN_TEAMS = 3+SETUP_BREAK_MIN_JOB_FAILURES = 100-# CI stamps every attribute the rule below reads, and the warehouse is the side of the pair the+# The synthetic bucket _SCAN_TEMPLATE folds every keyless span into (pre-job_key history). It can+# merge failures from several real jobs, so it must never trigger the per-job-attempt exclusion below.+_LEGACY_JOB_KEY = "legacy"++# CI stamps every attribute the rules below read, and the warehouse is the side of the pair the# emitter cannot write, so both must agree before any evidence is dropped._SETUP_BREAK_CANDIDATES = """SELECT run_id, attempt@@ -138,12 +146,22 @@ _SETUP_BREAK_CANDIDATES = """OR uniqIf(owner_team, owner_team != {unowned_team}) >= {setup_break_min_teams}"""-_BROADLY_FAILED_ATTEMPTS = """- SELECT toString(run_id) AS run_id, run_attempt+_SETUP_BREAK_JOB_CANDIDATES = """+ SELECT run_id, attempt, job_key+ FROM (__SPAN_SCAN__)+ WHERE outcome IN ('failed', 'error')+ AND job_key != {legacy_job_key}+ GROUP BY run_id, attempt, job_key+ HAVING uniq(nodeid) >= {setup_break_min_job_failures}+"""++# One failed job is enough for a job attempt: the jobs a run fans out over fail one at a time, and a+# shard that broke is one of them. A run attempt claims many jobs broke, so GitHub has to show as many.+_FAILED_JOB_COUNTS = """+ SELECT toString(run_id) AS run_id, run_attempt, uniqIf(name, conclusion = 'failure') AS failed_jobsFROM __JOBS_SOURCE__WHERE run_id IN {candidate_run_ids}GROUP BY run_id, run_attempt- HAVING uniqIf(name, conclusion = 'failure') >= {setup_break_min_jobs}"""@@ -193,7 +211,7 @@ _SCAN_TEMPLATE = """-- unstamped span from merging every execution of its test into one phantom run.coalesce(nullIf(resource_attributes['ci.run_id'], ''), trace_id) AS run_id,ifNull(accurateCastOrNull(resource_attributes['ci.run_attempt'], 'Int64'), 1) AS attempt,- coalesce(nullIf(attributes['test.job_key'], ''), 'legacy') AS job_key,+ coalesce(nullIf(attributes['test.job_key'], ''), {legacy_job_key}) AS job_key,timestamp AS span_timestamp,timestamp >= {date_from} AS is_currentFROM posthog.trace_spans@@ -219,8 +237,9 @@ def scan_placeholders(date_from: datetime,scan_from: datetime | None = None,date_to: datetime | None = None,- setup_break_run_attempts: Sequence[tuple[str, int]] = (),+ setup_breaks: "SetupBreaks | None" = None,) -> dict[str, ast.Expr]:+ setup_breaks = setup_breaks if setup_breaks is not None else SetupBreaks(run_attempts=(), job_attempts=())placeholders: dict[str, ast.Expr] = {"service_names": ast.Constant(value=CI_SERVICE_NAMES),"signal_outcomes": ast.Constant(value=SIGNAL_OUTCOMES),@@ -230,67 +249,119 @@ def scan_placeholders("scan_from": ast.Constant(value=scan_from if scan_from is not None else date_from),"setup_break_min_jobs": ast.Constant(value=SETUP_BREAK_MIN_JOBS),"setup_break_min_teams": ast.Constant(value=SETUP_BREAK_MIN_TEAMS),- "setup_break_run_attempts": ast.Array(- exprs=[- ast.Tuple(exprs=[ast.Constant(value=run_id), ast.Constant(value=str(attempt))])- for run_id, attempt in setup_break_run_attempts- ]- ),+ "setup_break_min_job_failures": ast.Constant(value=SETUP_BREAK_MIN_JOB_FAILURES),+ "legacy_job_key": ast.Constant(value=_LEGACY_JOB_KEY),+ "setup_break_run_attempts": _attempt_array(setup_breaks.run_attempts),+ "setup_break_job_attempts": _attempt_array(setup_breaks.job_attempts),}if date_to is not None:placeholders["date_to"] = ast.Constant(value=date_to)return placeholders-def query_setup_break_attempts(+@frozen+class SetupBreaks:+ """The CI setup breaks a window holds, keyed the way ``run_evidence()`` excludes them."""++ run_attempts: tuple[tuple[str, int], ...]+ job_attempts: tuple[tuple[str, int, str], ...]+++def _attempt_array(attempts: Sequence[tuple[str | int, ...]]) -> ast.Array:+ # Every part is a string: a Python int would reach ClickHouse as a narrower type than the+ # column it is compared with, and the tuple would never match.+ return ast.Array(+ exprs=[ast.Tuple(exprs=[ast.Constant(value=str(part)) for part in attempt]) for attempt in attempts]+ )+++def query_setup_breaks(*,curated: CuratedGitHubSource,date_from: datetime,scan_from: datetime | None = None,date_to: datetime | None = None,-) -> tuple[tuple[str, int], ...]:- """The ``(run_id, attempt)`` pairs whose CI setup broke, for ``scan_placeholders``.+) -> SetupBreaks:+ """The setup breaks of this window, for ``scan_placeholders``.Two sources have to agree. The spans name the attempts that look broken, and GitHub's synced job- rows say which of those really failed across jobs. An attempt GitHub does not report that way keeps- its trials, so no test's evidence rests on the span attributes alone.+ rows say which of those really failed. An attempt GitHub does not report as failed keeps its trials,+ so no test loses its evidence on the strength of the span attributes alone, and a team whose jobs+ table is unsynced drops nothing."""jobs_source = curated.jobs_source(created_floor=True)if not curated.repository or jobs_source is None:- return ()-- window_start = scan_from if scan_from is not None else date_from- candidates = (- curated.run(- _SETUP_BREAK_CANDIDATES.replace("__SPAN_SCAN__", _scan(bounded=date_to is not None)),- query_type="engineering_analytics.setup_break_candidates",- placeholders=scan_placeholders(- repository=curated.repository, date_from=date_from, scan_from=scan_from, date_to=date_to- ),- workload=Workload.LOGS,- ).results- or []+ return SetupBreaks(run_attempts=(), job_attempts=())++ span_placeholders = scan_placeholders(+ repository=curated.repository, date_from=date_from, scan_from=scan_from, date_to=date_to)+ span_scan = _scan(bounded=date_to is not None)+ run_candidates = [+ (str(run_id), int(attempt))+ for run_id, attempt in _rows(+ curated,+ _SETUP_BREAK_CANDIDATES.replace("__SPAN_SCAN__", span_scan),+ query_type="engineering_analytics.setup_break_run_candidates",+ placeholders=span_placeholders,+ workload=Workload.LOGS,+ )+ ]+ job_candidates = [+ (str(run_id), int(attempt), str(job_key))+ for run_id, attempt, job_key in _rows(+ curated,+ _SETUP_BREAK_JOB_CANDIDATES.replace("__SPAN_SCAN__", span_scan),+ query_type="engineering_analytics.setup_break_job_candidates",+ placeholders=span_placeholders,+ workload=Workload.LOGS,+ )+ ]# An unstamped span falls back to its trace ID, which names no GitHub run.- candidate_run_ids = {int(run_id) for run_id, _attempt in candidates if str(run_id).isdigit()}+ candidate_run_ids = sorted(+ {int(run_id) for run_id, _attempt in run_candidates if run_id.isdigit()}+ | {int(run_id) for run_id, _attempt, _job in job_candidates if run_id.isdigit()}+ )if not candidate_run_ids:- return ()-- confirmed = (- curated.run(- _BROADLY_FAILED_ATTEMPTS.replace("__JOBS_SOURCE__", jobs_source),- query_type="engineering_analytics.setup_break_confirmation",+ return SetupBreaks(run_attempts=(), job_attempts=())++ failed_jobs_by_attempt = {+ (str(run_id), int(attempt)): int(failed_jobs)+ for run_id, attempt, failed_jobs in _rows(+ curated,+ _FAILED_JOB_COUNTS.replace("__JOBS_SOURCE__", jobs_source),+ query_type="engineering_analytics.setup_break_failed_jobs",placeholders={- "candidate_run_ids": ast.Constant(value=sorted(candidate_run_ids)),- "setup_break_min_jobs": ast.Constant(value=SETUP_BREAK_MIN_JOBS),- "job_created_floor": job_created_floor_constant(window_start),+ "candidate_run_ids": ast.Constant(value=candidate_run_ids),+ "job_created_floor": job_created_floor_constant(scan_from if scan_from is not None else date_from),},- ).results- or []+ )+ }+ return SetupBreaks(+ run_attempts=tuple(+ sorted(+ attempt for attempt in run_candidates if failed_jobs_by_attempt.get(attempt, 0) >= SETUP_BREAK_MIN_JOBS+ )+ ),+ job_attempts=tuple(+ sorted(+ candidate+ for candidate in job_candidates+ if failed_jobs_by_attempt.get((candidate[0], candidate[1]), 0) >= 1+ )+ ),)- confirmed_attempts = {(str(run_id), int(attempt)) for run_id, attempt in confirmed}- candidate_attempts = {(str(run_id), int(attempt)) for run_id, attempt in candidates}- return tuple(sorted(candidate_attempts & confirmed_attempts))+++def _rows(+ curated: CuratedGitHubSource,+ sql: str,+ *,+ query_type: str,+ placeholders: dict[str, ast.Expr],+ workload: Workload = Workload.DEFAULT,+) -> list:+ return curated.run(sql, query_type=query_type, placeholders=placeholders, workload=workload).results or []def rerun_recovered_job_attempts(*, scan_from: str) -> str:diff --git a/products/engineering_analytics/backend/logic/queries/flaky_tests.py b/products/engineering_analytics/backend/logic/queries/flaky_tests.pyindex cf8489345499..0974cccc18bb 100644--- a/products/engineering_analytics/backend/logic/queries/flaky_tests.py+++ b/products/engineering_analytics/backend/logic/queries/flaky_tests.py@@ -29,7 +29,7 @@ from products.engineering_analytics.backend.facade.contracts import ()from products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSourcefrom products.engineering_analytics.backend.logic.queries._test_spans import (- query_setup_break_attempts,+ query_setup_breaks,run_evidence,scan_placeholders,selector_from_nodeid,@@ -84,7 +84,7 @@ def query_flaky_tests(repository=repository,date_from=date_from,date_to=date_to,- setup_break_run_attempts=query_setup_break_attempts(curated=curated, date_from=date_from, date_to=date_to),+ setup_breaks=query_setup_breaks(curated=curated, date_from=date_from, date_to=date_to),)placeholders["min_failed_prs"] = ast.Constant(value=min_failed_prs)runner_filter = ""diff --git a/products/engineering_analytics/backend/logic/queries/team_ci_health.py b/products/engineering_analytics/backend/logic/queries/team_ci_health.pyindex fe2eed977afa..75d916527a57 100644--- a/products/engineering_analytics/backend/logic/queries/team_ci_health.py+++ b/products/engineering_analytics/backend/logic/queries/team_ci_health.py@@ -34,7 +34,7 @@ from products.engineering_analytics.backend.facade.contracts import (from products.engineering_analytics.backend.logic._shared import _prior_windowfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSourcefrom products.engineering_analytics.backend.logic.queries._test_spans import (- query_setup_break_attempts,+ query_setup_breaks,run_evidence,scan_placeholders,selector_from_nodeid,@@ -121,7 +121,7 @@ def _window_placeholders(date_from=date_from,scan_from=window.scan_from,date_to=window.resolved_to,- setup_break_run_attempts=query_setup_break_attempts(+ setup_breaks=query_setup_breaks(curated=curated, date_from=date_from, scan_from=window.scan_from, date_to=window.resolved_to),)diff --git a/products/engineering_analytics/backend/presentation/serializers/suite_health.py b/products/engineering_analytics/backend/presentation/serializers/suite_health.pyindex 8021e580f855..8900d4e9102a 100644--- a/products/engineering_analytics/backend/presentation/serializers/suite_health.py+++ b/products/engineering_analytics/backend/presentation/serializers/suite_health.py@@ -146,8 +146,9 @@ class FlakyTestListSerializer(DataclassSerializer):items = FlakyTestItemSerializer(many=True,help_text="Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. "- "A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) "- "excludes every trial of that attempt, not only its failures.",+ "A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a "+ "job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not "+ "only its failures.",)class Meta:diff --git a/products/engineering_analytics/backend/presentation/serializers/teams.py b/products/engineering_analytics/backend/presentation/serializers/teams.pyindex 2bdfcf408814..aab8b54f7aa1 100644--- a/products/engineering_analytics/backend/presentation/serializers/teams.py+++ b/products/engineering_analytics/backend/presentation/serializers/teams.py@@ -73,8 +73,9 @@ class TeamCIHealthListSerializer(DataclassSerializer):many=True,help_text="Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. ""Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break "- "(a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) excludes every "- "trial of that attempt, not only its failures.",+ "(a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt "+ "with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its "+ "failures.",)class Meta:diff --git a/products/engineering_analytics/backend/tests/test_flaky_tests.py b/products/engineering_analytics/backend/tests/test_flaky_tests.pyindex 1efcf158ff57..10e9d8417a33 100644--- a/products/engineering_analytics/backend/tests/test_flaky_tests.py+++ b/products/engineering_analytics/backend/tests/test_flaky_tests.py@@ -2,6 +2,7 @@ from datetime import UTC, datetime, timedeltaimport pytestfrom posthog.test.base import APIBaseTest, ClickhouseTestMixin+from unittest.mock import patchfrom parameterized import parameterizedfrom rest_framework import status@@ -41,6 +42,9 @@ T_JEST_RECOVERY = "products/surveys/frontend/surveyLogic.test.ts::surveyLogic saT_JEST_CROSS_LEG = "frontend/src/scenes/legacy.test.ts::legacy scene renders"T_SETUP_BREAK = "posthog/api/test/test_setup/TestSetup::test_errors_when_setup_breaks"T_SPAN_ONLY_BREAK = "posthog/api/test/test_setup/TestSetup::test_errors_without_a_broken_run"+T_JOB_RERUN = "posthog/api/test/test_shard/TestShard::test_fails_with_its_whole_job"+T_LEGACY_JOB_A = "posthog/api/test/test_legacy_a/TestLegacyA::test_one"+T_LEGACY_JOB_B = "posthog/api/test/test_legacy_b/TestLegacyB::test_two"class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):@@ -165,16 +169,48 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):# The same shape in a run GitHub reports as healthy.*[cls._span(- 50 + shard,+ 70 + shard,f"{T_SPAN_ONLY_BREAK}_{shard}","error",ts=recent,- run="1800",+ run="1900",branch="master",job=f"backend:core:{shard}",)for shard in (1, 2, 3)],+ # One job attempt failed two tests, and its re-run attempt passed both. Two tests is below the+ # default job threshold, so both are flakes here; the threshold test lowers it to two.+ *[+ span+ for index in (1, 2)+ for span in (+ cls._span(+ 50 + index,+ f"{T_JOB_RERUN}_{index}",+ "failed",+ ts=earlier,+ run="1800",+ branch="master",+ job="backend:core:4",+ ),+ cls._span(+ 60 + index,+ f"{T_JOB_RERUN}_{index}",+ "passed",+ ts=recent,+ run="1800",+ attempt="2",+ branch="master",+ job="backend:core:4",+ ),+ )+ ],+ # Two keyless jobs (pre-job_key history) in one run attempt, each failing a different+ # test. Coalesced under the synthetic 'legacy' job_key, their combined nodeid count can+ # cross the job-attempt threshold even though neither real job did.+ cls._span(70, T_LEGACY_JOB_A, "failed", ts=earlier, run="1900", branch="master"),+ cls._span(71, T_LEGACY_JOB_B, "failed", ts=earlier, run="1900", branch="master"),# Main Jest spans share the same evidence model. Recovery only counts within the# stable FOSS/EE + shard job that failed.cls._span(@@ -322,12 +358,14 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):def setUp(self) -> None:super().setUp()- # Run 1700 failed across three jobs on GitHub; run 1800 passed. Only 1700 may drop evidence.+ # Run 1700 failed across three jobs on GitHub and run 1800 failed one; run 1900 passed, so only+ # the first two may drop a trial.connect_github_jobs(self,prefix="flaky",jobs=[(70 + shard, 1700, 1, "failure") for shard in (1, 2, 3)]- + [(80 + shard, 1800, 1, "success") for shard in (1, 2, 3)],+ + [(80, 1800, 1, "failure"), (81, 1800, 2, "success")]+ + [(90 + shard, 1900, 1, "success") for shard in (1, 2, 3)],)def _get(self, **params: str) -> dict:@@ -360,10 +398,32 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):T_JEST_RECOVERY,T_JEST_CROSS_LEG,*(f"{T_SPAN_ONLY_BREAK}_{shard}" for shard in (1, 2, 3)),+ f"{T_JOB_RERUN}_1",+ f"{T_JOB_RERUN}_2",+ T_LEGACY_JOB_A,+ T_LEGACY_JOB_B,}assert data["truncated"] is Falseassert data["limit"] == 50+ def test_a_job_attempt_failing_enough_tests_is_not_flake_proof(self) -> None:+ with patch("products.engineering_analytics.backend.logic.queries._test_spans.SETUP_BREAK_MIN_JOB_FAILURES", 2):+ rows = self._rows()++ assert f"{T_JOB_RERUN}_1" not in rows+ assert f"{T_JOB_RERUN}_2" not in rows+ # A single failing test in a job is still a failure, and its re-run pass is still proof.+ assert rows[T_RERUN_RECOVERY]["classification"] == "confirmed_flake"++ def test_legacy_jobs_do_not_merge_toward_the_job_attempt_threshold(self) -> None:+ # Two real jobs, both keyless, combine to the same 'legacy' bucket. Unlike a real job+ # attempt (asserted above), their combined nodeid count must never trigger exclusion.+ with patch("products.engineering_analytics.backend.logic.queries._test_spans.SETUP_BREAK_MIN_JOB_FAILURES", 2):+ rows = self._rows()++ assert T_LEGACY_JOB_A in rows+ assert T_LEGACY_JOB_B in rows+@parameterized.expand([("recovered_on_rerun_attempt", T_RERUN_RECOVERY, "confirmed_flake"),diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex 00b3a382f868..3685db9b8101 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -674,7 +674,7 @@ export interface FlakyTestItemApi {}export interface FlakyTestListApi {- /** Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) excludes every trial of that attempt, not only its failures. */+ /** Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */items: FlakyTestItemApi[]/** True when more tests qualified than the cap; `items` is the highest-ranked `limit` rows. */truncated: boolean@@ -1831,7 +1831,7 @@ export interface TeamCIHealthItemApi {}export interface TeamCIHealthListApi {- /** Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) excludes every trial of that attempt, not only its failures. */+ /** Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */items: TeamCIHealthItemApi[]/** True when more teams had signal than the cap. */truncated: booleandiff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsxindex a64ec9d5621f..862fc3854733 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeamScene.tsx@@ -160,7 +160,7 @@ export function EngineeringAnalyticsTeamScene(): JSX.Element {/><WindowComparisonCardtitle="Flaky tests"- tooltip="Owned tests one commit was seen both failing and passing in this window. Only tests with that recovery proof count as flaky."+ tooltip="Owned tests one commit was seen both failing and passing in this window. Only tests with that recovery proof count as flaky. A job attempt with 100+ failed or errored tests is a CI setup break, not test proof."value={healthRow?.flakyTestCount}previousValue={healthRow?.flakyTestCountPrior}formatValue={humanFriendlyNumber}@@ -170,7 +170,7 @@ export function EngineeringAnalyticsTeamScene(): JSX.Element {/><WindowComparisonCardtitle="Failed runs"- tooltip="CI runs where at least one test this team owns failed or errored. A run counts once, however many tests failed. Runs where CI setup broke tests across many jobs or teams are left out. Absolute counts, not rates: passing runs are mostly not recorded."+ tooltip="CI runs where at least one test this team owns failed or errored. A run counts once, however many tests failed. CI setup breaks (many jobs or teams, or 100 or more failed or errored tests in one job) are left out. Absolute counts, not rates: passing runs are mostly not recorded."value={healthRow?.failedRunCount}previousValue={healthRow?.failedRunCountPrior}formatValue={humanFriendlyNumber}diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsxindex ec5893aa10ef..29b23d1c294c 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx@@ -66,7 +66,7 @@ export function EngineeringAnalyticsTeams(): JSX.Element {key: 'flakyTestCount',width: 120,align: 'right',- tooltip: `Owned tests one commit was seen both failing and passing in the ${FIXED_WINDOW}. Only tests with that recovery proof count as flaky.`,+ tooltip: `Owned tests one commit was seen both failing and passing in the ${FIXED_WINDOW}. Only tests with that recovery proof count as flaky. A job attempt with 100+ failed or errored tests is a CI setup break, not test proof.`,sorter: (a, b) => a.flakyTestCount - b.flakyTestCount,render: (_, row) => <CountCell value={row.flakyTestCount} />,},diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yamlindex 325badd7f90e..8721ec42d01a 100644--- a/products/engineering_analytics/mcp/tools.yaml+++ b/products/engineering_analytics/mcp/tools.yaml@@ -131,10 +131,10 @@ tools:suspected_regression means only failures were recorded, which is absence of proof, not proof of a realbreak: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, anymaster/main failure, a quarantined failure, or failures on at least min_failed_prs distinct PRs (default 3).- Failures from a CI setup break are not per-test evidence and are left out: a run attempt whose tests errored- in three or more jobs or for three or more owning teams. Counts are absolute, never rates, because fast- passing runs are not emitted. Use selector to run or quarantine the test with its runner; nodeid is only the- stable grouping key.+ A CI setup break excludes every trial of the attempt, not only its failures: a run attempt whose tests+ errored in three or more jobs or for three or more owning teams, or a job attempt with 100 or more distinct+ failed or errored tests. Counts are absolute, never rates, because fast passing runs are not emitted. Use+ selector to run or quarantine the test with its runner; nodeid is only the stable grouping key.feature_flag: engineering-analyticsengineering-analytics-job-aggregates:operation: engineering_analytics_job_aggregates@@ -249,18 +249,18 @@ tools:(a re-run attempt went green, or an in-job retry recovered it), regression_test_count is owned tests thatfailed with no such proof and still hit min_failed_prs distinct PRs or master, and failed_run_count,same_commit_recovery_run_count and quarantined_failed_run_count count distinct CI runs across the team's- owned tests, so one run with many failing tests counts once. Failures from a CI setup break are not per-test- evidence and are left out: a run attempt whose tests errored in three or more jobs or for three or more- owning teams. Each has an equal-length previous-window twin (*_prior) for honest deltas. Use this for "which- team owns the flakiest surfaces right now" and to route a flaky-test or CI Signal to its owning team.- Ownership is stamped on the spans at CI emission time from the repo's ownership map (the distributed- owners.yaml files); spans without a stamp aggregate under the literal team 'unowned' (a nonempty 'unowned'- row means ownership gaps, not a real team), and a re-stamped test lands under its latest owner only. Each- row also carries test_file_count (the daily owners.yaml census denominator, with a window-start twin) and- merged_pr_count (merged PRs by the team's members, bots excluded); teams with census counts but no CI signal- appear with zero signal counts and a null last_seen_at. Teams are organizational owners of code surfaces,- never authors. Read all counts as absolute signal, never rates: fast passing runs are not emitted, so there- is no honest denominator.+ owned tests, so one run with many failing tests counts once. A CI setup break excludes every trial of the+ attempt, not only its failures: a run attempt whose tests errored in three or more jobs or for three or more+ owning teams, or a job attempt with 100 or more distinct failed or errored tests. Each has an equal-length+ previous-window twin (*_prior) for honest deltas. Use this for "which team owns the flakiest surfaces right+ now" and to route a flaky-test or CI Signal to its owning team. Ownership is stamped on the spans at CI+ emission time from the repo's ownership map (the distributed owners.yaml files); spans without a stamp+ aggregate under the literal team 'unowned' (a nonempty 'unowned' row means ownership gaps, not a real team),+ and a re-stamped test lands under its latest owner only. Each row also carries test_file_count (the daily+ owners.yaml census denominator, with a window-start twin) and merged_pr_count (merged PRs by the team's+ members, bots excluded); teams with census counts but no CI signal appear with zero signal counts and a null+ last_seen_at. Teams are organizational owners of code surfaces, never authors. Read all counts as absolute+ signal, never rates: fast passing runs are not emitted, so there is no honest denominator.feature_flag: engineering-analyticsengineering-analytics-team-merge-trend:operation: engineering_analytics_team_merge_trenddiff --git a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.mdindex 6452b42e4c1c..528f5fcdef73 100644--- a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md+++ b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md@@ -55,9 +55,11 @@ to take one failing test or red run to a verdict, switch to the `investigating-cquarantine candidates. **It does not answer "which tests are flaky"**: this queue only sees the main Backend pytestand Frontend Jest suites, and recovery proof only arrives when someone re-runs failed jobs (or a pytest test is hand-marked`@pytest.mark.flaky(reruns=N)`). Counts are absolute signal, never rates: passing runs are mostly not- emitted, so there is no honest denominator. Failures from a CI setup break are left out: a run attempt whose- tests errored in 3 or more jobs or for 3 or more owning teams. A real break that wide is left out too, so when a- whole suite goes red, check `workflow-health` rather than reading an empty queue as healthy.+ emitted, so there is no honest denominator. A CI setup break excludes every trial of the attempt, not only its+ failures: a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt+ with 100 or more distinct failed or errored tests.+ A real break that wide is left out too, so when a whole suite or job goes red, check `workflow-health` rather+ than reading an empty queue as healthy.- **`engineering-analytics-sources`**: the team's connected GitHub sources and repos. With more than one ofeither, call it first and pass the chosen entry's `source_id` **and** `repo` to `pull-requests`,diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.jsonindex 7800b880809e..e56ec49bf25e 100644--- a/services/mcp/schema/generated-tool-definitions.json+++ b/services/mcp/schema/generated-tool-definitions.json@@ -3626,7 +3626,7 @@"feature_flag": "engineering-analytics"},"engineering-analytics-flaky-tests": {- "description": "Pytest and Jest tests worth acting on now, from the per-test CI spans over a window (date_from default -7d, maximum 30 days), ranked by blast radius: master failures first, then how many distinct PRs the test broke. Use this for \"what is this failing test costing us\" and to pick quarantine candidates. It does not measure flake rates. This data sees the main Backend pytest and Frontend Jest suites; package-specific runners are not included. Evidence is counted per CI run, never per span or run attempt: one run fans a test across matrix legs, and re-run attempts re-test the same commit. classification is confirmed_flake only when one commit both failed and passed the test (same_commit_recovery_run_count > 0): a \"Re-run failed jobs\" attempt went green on the same commit, or an in-job pytest retry (tests hand-marked @pytest.mark.flaky(reruns=N)) recovered it. quarantined means a tolerated failure was recorded while the test was masked. suspected_regression means only failures were recorded, which is absence of proof, not proof of a real break: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, any master/main failure, a quarantined failure, or failures on at least min_failed_prs distinct PRs (default 3). Failures from a CI setup break are not per-test evidence and are left out: a run attempt whose tests errored in three or more jobs or for three or more owning teams. Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test with its runner; nodeid is only the stable grouping key.",+ "description": "Pytest and Jest tests worth acting on now, from the per-test CI spans over a window (date_from default -7d, maximum 30 days), ranked by blast radius: master failures first, then how many distinct PRs the test broke. Use this for \"what is this failing test costing us\" and to pick quarantine candidates. It does not measure flake rates. This data sees the main Backend pytest and Frontend Jest suites; package-specific runners are not included. Evidence is counted per CI run, never per span or run attempt: one run fans a test across matrix legs, and re-run attempts re-test the same commit. classification is confirmed_flake only when one commit both failed and passed the test (same_commit_recovery_run_count > 0): a \"Re-run failed jobs\" attempt went green on the same commit, or an in-job pytest retry (tests hand-marked @pytest.mark.flaky(reruns=N)) recovered it. quarantined means a tolerated failure was recorded while the test was masked. suspected_regression means only failures were recorded, which is absence of proof, not proof of a real break: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, any master/main failure, a quarantined failure, or failures on at least min_failed_prs distinct PRs (default 3). A CI setup break excludes every trial of the attempt, not only its failures: a run attempt whose tests errored in three or more jobs or for three or more owning teams, or a job attempt with 100 or more distinct failed or errored tests. Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test with its runner; nodeid is only the stable grouping key.","category": "Engineering analytics","feature": "engineering_analytics","summary": "Active test health queue",@@ -3686,7 +3686,7 @@"feature_flag": "engineering-analytics"},"engineering-analytics-team-ci-health": {- "description": "Per-owning-team rollup of the CI test surfaces each team owns, over a window (date_from default -14d, maximum 30 days). It reads the same per-run evidence as engineering-analytics-flaky-tests and means the same thing by flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window (a re-run attempt went green, or an in-job retry recovered it), regression_test_count is owned tests that failed with no such proof and still hit min_failed_prs distinct PRs or master, and failed_run_count, same_commit_recovery_run_count and quarantined_failed_run_count count distinct CI runs across the team's owned tests, so one run with many failing tests counts once. Failures from a CI setup break are not per-test evidence and are left out: a run attempt whose tests errored in three or more jobs or for three or more owning teams. Each has an equal-length previous-window twin (*_prior) for honest deltas. Use this for \"which team owns the flakiest surfaces right now\" and to route a flaky-test or CI Signal to its owning team. Ownership is stamped on the spans at CI emission time from the repo's ownership map (the distributed owners.yaml files); spans without a stamp aggregate under the literal team 'unowned' (a nonempty 'unowned' row means ownership gaps, not a real team), and a re-stamped test lands under its latest owner only. Each row also carries test_file_count (the daily owners.yaml census denominator, with a window-start twin) and merged_pr_count (merged PRs by the team's members, bots excluded); teams with census counts but no CI signal appear with zero signal counts and a null last_seen_at. Teams are organizational owners of code surfaces, never authors. Read all counts as absolute signal, never rates: fast passing runs are not emitted, so there is no honest denominator.",+ "description": "Per-owning-team rollup of the CI test surfaces each team owns, over a window (date_from default -14d, maximum 30 days). It reads the same per-run evidence as engineering-analytics-flaky-tests and means the same thing by flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window (a re-run attempt went green, or an in-job retry recovered it), regression_test_count is owned tests that failed with no such proof and still hit min_failed_prs distinct PRs or master, and failed_run_count, same_commit_recovery_run_count and quarantined_failed_run_count count distinct CI runs across the team's owned tests, so one run with many failing tests counts once. A CI setup break excludes every trial of the attempt, not only its failures: a run attempt whose tests errored in three or more jobs or for three or more owning teams, or a job attempt with 100 or more distinct failed or errored tests. Each has an equal-length previous-window twin (*_prior) for honest deltas. Use this for \"which team owns the flakiest surfaces right now\" and to route a flaky-test or CI Signal to its owning team. Ownership is stamped on the spans at CI emission time from the repo's ownership map (the distributed owners.yaml files); spans without a stamp aggregate under the literal team 'unowned' (a nonempty 'unowned' row means ownership gaps, not a real team), and a re-stamped test lands under its latest owner only. Each row also carries test_file_count (the daily owners.yaml census denominator, with a window-start twin) and merged_pr_count (merged PRs by the team's members, bots excluded); teams with census counts but no CI signal appear with zero signal counts and a null last_seen_at. Teams are organizational owners of code surfaces, never authors. Read all counts as absolute signal, never rates: fast passing runs are not emitted, so there is no honest denominator.","category": "Engineering analytics","feature": "engineering_analytics","summary": "Team CI health roster",diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.jsonindex 5e8ea23f9c13..904e70c4c7c4 100644--- a/services/mcp/schema/tool-definitions-all.json+++ b/services/mcp/schema/tool-definitions-all.json@@ -3655,7 +3655,7 @@"feature_flag": "engineering-analytics"},"engineering-analytics-flaky-tests": {- "description": "Pytest and Jest tests worth acting on now, from the per-test CI spans over a window (date_from default -7d, maximum 30 days), ranked by blast radius: master failures first, then how many distinct PRs the test broke. Use this for \"what is this failing test costing us\" and to pick quarantine candidates. It does not measure flake rates. This data sees the main Backend pytest and Frontend Jest suites; package-specific runners are not included. Evidence is counted per CI run, never per span or run attempt: one run fans a test across matrix legs, and re-run attempts re-test the same commit. classification is confirmed_flake only when one commit both failed and passed the test (same_commit_recovery_run_count > 0): a \"Re-run failed jobs\" attempt went green on the same commit, or an in-job pytest retry (tests hand-marked @pytest.mark.flaky(reruns=N)) recovered it. quarantined means a tolerated failure was recorded while the test was masked. suspected_regression means only failures were recorded, which is absence of proof, not proof of a real break: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, any master/main failure, a quarantined failure, or failures on at least min_failed_prs distinct PRs (default 3). Failures from a CI setup break are not per-test evidence and are left out: a run attempt whose tests errored in three or more jobs or for three or more owning teams. Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test with its runner; nodeid is only the stable grouping key.",+ "description": "Pytest and Jest tests worth acting on now, from the per-test CI spans over a window (date_from default -7d, maximum 30 days), ranked by blast radius: master failures first, then how many distinct PRs the test broke. Use this for \"what is this failing test costing us\" and to pick quarantine candidates. It does not measure flake rates. This data sees the main Backend pytest and Frontend Jest suites; package-specific runners are not included. Evidence is counted per CI run, never per span or run attempt: one run fans a test across matrix legs, and re-run attempts re-test the same commit. classification is confirmed_flake only when one commit both failed and passed the test (same_commit_recovery_run_count > 0): a \"Re-run failed jobs\" attempt went green on the same commit, or an in-job pytest retry (tests hand-marked @pytest.mark.flaky(reruns=N)) recovered it. quarantined means a tolerated failure was recorded while the test was masked. suspected_regression means only failures were recorded, which is absence of proof, not proof of a real break: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, any master/main failure, a quarantined failure, or failures on at least min_failed_prs distinct PRs (default 3). A CI setup break excludes every trial of the attempt, not only its failures: a run attempt whose tests errored in three or more jobs or for three or more owning teams, or a job attempt with 100 or more distinct failed or errored tests. Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test with its runner; nodeid is only the stable grouping key.","category": "Engineering analytics","feature": "engineering_analytics","summary": "Active test health queue",@@ -3715,7 +3715,7 @@"feature_flag": "engineering-analytics"},"engineering-analytics-team-ci-health": {- "description": "Per-owning-team rollup of the CI test surfaces each team owns, over a window (date_from default -14d, maximum 30 days). It reads the same per-run evidence as engineering-analytics-flaky-tests and means the same thing by flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window (a re-run attempt went green, or an in-job retry recovered it), regression_test_count is owned tests that failed with no such proof and still hit min_failed_prs distinct PRs or master, and failed_run_count, same_commit_recovery_run_count and quarantined_failed_run_count count distinct CI runs across the team's owned tests, so one run with many failing tests counts once. Failures from a CI setup break are not per-test evidence and are left out: a run attempt whose tests errored in three or more jobs or for three or more owning teams. Each has an equal-length previous-window twin (*_prior) for honest deltas. Use this for \"which team owns the flakiest surfaces right now\" and to route a flaky-test or CI Signal to its owning team. Ownership is stamped on the spans at CI emission time from the repo's ownership map (the distributed owners.yaml files); spans without a stamp aggregate under the literal team 'unowned' (a nonempty 'unowned' row means ownership gaps, not a real team), and a re-stamped test lands under its latest owner only. Each row also carries test_file_count (the daily owners.yaml census denominator, with a window-start twin) and merged_pr_count (merged PRs by the team's members, bots excluded); teams with census counts but no CI signal appear with zero signal counts and a null last_seen_at. Teams are organizational owners of code surfaces, never authors. Read all counts as absolute signal, never rates: fast passing runs are not emitted, so there is no honest denominator.",+ "description": "Per-owning-team rollup of the CI test surfaces each team owns, over a window (date_from default -14d, maximum 30 days). It reads the same per-run evidence as engineering-analytics-flaky-tests and means the same thing by flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window (a re-run attempt went green, or an in-job retry recovered it), regression_test_count is owned tests that failed with no such proof and still hit min_failed_prs distinct PRs or master, and failed_run_count, same_commit_recovery_run_count and quarantined_failed_run_count count distinct CI runs across the team's owned tests, so one run with many failing tests counts once. A CI setup break excludes every trial of the attempt, not only its failures: a run attempt whose tests errored in three or more jobs or for three or more owning teams, or a job attempt with 100 or more distinct failed or errored tests. Each has an equal-length previous-window twin (*_prior) for honest deltas. Use this for \"which team owns the flakiest surfaces right now\" and to route a flaky-test or CI Signal to its owning team. Ownership is stamped on the spans at CI emission time from the repo's ownership map (the distributed owners.yaml files); spans without a stamp aggregate under the literal team 'unowned' (a nonempty 'unowned' row means ownership gaps, not a real team), and a re-stamped test lands under its latest owner only. Each row also carries test_file_count (the daily owners.yaml census denominator, with a window-start twin) and merged_pr_count (merged PRs by the team's members, bots excluded); teams with census counts but no CI signal appear with zero signal counts and a null last_seen_at. Teams are organizational owners of code surfaces, never authors. Read all counts as absolute signal, never rates: fast passing runs are not emitted, so there is no honest denominator.","category": "Engineering analytics","feature": "engineering_analytics","summary": "Team CI health roster",diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 89727715417a..8ef85adbe504 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -44688,7 +44688,7 @@ export namespace Schemas {}export interface FlakyTestList {- /** Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) excludes every trial of that attempt, not only its failures. */+ /** Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */items: FlakyTestItem[];/** True when more tests qualified than the cap; `items` is the highest-ranked `limit` rows. */truncated: boolean;@@ -94047,7 +94047,7 @@ export namespace Schemas {}export interface TeamCIHealthList {- /** Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams) excludes every trial of that attempt, not only its failures. */+ /** Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */items: TeamCIHealthItem[];/** True when more teams had signal than the cap. */truncated: boolean;