Skip to content

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

feat(eng-analytics): same-commit re-run recovery as flake proof (#72916)

Raúl Negrón-Otero6316cbb1b8a9
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index 5f69716a1cc7..d85d6c2e615f 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -34,7 +34,9 @@
# - report-test-timings: canonical emits per-test OTLP spans from the uploaded JUnit. The shadow
# strips artifact uploads (above) and posts no telemetry, so the whole job is depot-exempt —
# changes confined to it (script deps, the reporter's availability guard, emission secret
-# plumbing such as dual-project tokens) need no depot bump.
+# plumbing such as dual-project tokens, re-run attempt handling — including the
+# attempt-suffixed junit artifact names canonical uploads so the reporter can pair re-run
+# recoveries with attempt-1 failures) need no depot bump.
# - OpenAPI types: the check-openapi-types job is folded into check-migrations as a
# check-only step (drift still fails the run); only its auto-commit side effect is dropped
# - events_json variants: the shadow never doubles the matrix (no RUN_NEW_EVENTS_SCHEMA
diff --git a/.github/scripts/report_test_timings.py b/.github/scripts/report_test_timings.py
index 0790bc39707e..864b6cb2efc0 100644
--- a/.github/scripts/report_test_timings.py
+++ b/.github/scripts/report_test_timings.py
@@ -25,6 +25,13 @@ Trace ID is deterministic per (run_id, run_attempt, job) so each job in each
workflow attempt gets its own trace. Failures and errors mark spans
Status.ERROR.
+On a re-run attempt (GITHUB_RUN_ATTEMPT > 1) only the artifacts that attempt
+uploaded (suffixed `-attempt<N>` by the workflow) are emitted, so shards the
+attempt did not re-execute are never re-reported under the new attempt. Passes
+of tests that failed in an earlier attempt of the same job are kept regardless
+of duration: one commit failing then passing is the same-commit recovery proof
+the flaky-test queue (engineering_analytics) classifies on.
+
This script must NEVER fail the workflow: any unexpected error is logged and
the process exits 0. The workflow job is also `continue-on-error: true` as a
second belt for setup and artifact-download failures.
@@ -33,6 +40,7 @@ second belt for setup and artifact-download failures.
from __future__ import annotations
import os
+import re
import sys
import json
import hashlib
@@ -87,6 +95,9 @@ class ArtifactInfo:
segment: str
group: int | None
total: int | None
+ # Which workflow run attempt uploaded the artifact (from the `-attempt<N>` name suffix); 1
+ # when unsuffixed, i.e. every artifact predating re-run-aware uploads.
+ attempt: int = 1
@dataclass(frozen=True)
@@ -117,6 +128,21 @@ def split_artifact_name(name_parts: list[str]) -> tuple[str, str]:
return "-".join(name_parts), "-".join(name_parts)
+_ATTEMPT_SUFFIX = re.compile(r"-attempt(\d+)$")
+
+
+def split_attempt_suffix(artifact_dir_name: str) -> tuple[str, int]:
+ """`junit-results-backend-core-29-attempt2` → ("junit-results-backend-core-29", 2).
+
+ Re-run shards upload under an attempt-suffixed name so attempt 1's artifact survives
+ (a same-name upload in a later attempt silently supersedes the earlier artifact).
+ """
+ match = _ATTEMPT_SUFFIX.search(artifact_dir_name)
+ if match is None:
+ return artifact_dir_name, 1
+ return artifact_dir_name[: match.start()], int(match.group(1))
+
+
def derive_suite_segment_and_group(artifact_dir_name: str) -> tuple[str, str, int | None]:
"""Parse `junit-results-backend-core-29` → ("backend", "core", 29).
@@ -133,10 +159,13 @@ def derive_suite_segment_and_group(artifact_dir_name: str) -> tuple[str, str, in
def collect_artifact_infos(artifacts_root: Path) -> list[ArtifactInfo]:
artifact_dirs = sorted(d for d in artifacts_root.iterdir() if d.is_dir()) or [artifacts_root]
- parsed = [(d, *derive_suite_segment_and_group(d.name)) for d in artifact_dirs]
+ parsed: list[tuple[Path, str, str, int | None, int]] = []
+ for d in artifact_dirs:
+ base_name, attempt = split_attempt_suffix(d.name)
+ parsed.append((d, *derive_suite_segment_and_group(base_name), attempt))
groups_by_shard_key: dict[tuple[str, str], set[int]] = {}
- for _, suite, segment, group in parsed:
+ for _, suite, segment, group, _attempt in parsed:
if group is not None:
groups_by_shard_key.setdefault((suite, segment), set()).add(group)
@@ -146,8 +175,10 @@ def collect_artifact_infos(artifacts_root: Path) -> list[ArtifactInfo]:
}
return [
- ArtifactInfo(path=d, suite=suite, segment=segment, group=group, total=shard_totals.get((suite, segment)))
- for d, suite, segment, group in parsed
+ ArtifactInfo(
+ path=d, suite=suite, segment=segment, group=group, total=shard_totals.get((suite, segment)), attempt=attempt
+ )
+ for d, suite, segment, group, attempt in parsed
]
@@ -329,17 +360,33 @@ def collect_shards(artifacts_root: Path) -> list[Shard]:
# ---------- threshold filter ----------
-def should_emit(test: TestCase, min_duration_seconds: float) -> bool:
- """Emit signal-bearing testcases: failures, errors, xfails, reruns, or above the duration threshold."""
+def should_emit(test: TestCase, min_duration_seconds: float, prior_failed: frozenset[str] = frozenset()) -> bool:
+ """Emit signal-bearing testcases: failures, errors, xfails, reruns, or above the duration threshold.
+
+ ``prior_failed`` (re-run attempts only) holds the nodeids that failed in an earlier attempt of
+ the same job: their passes are the same-commit recovery proof and are kept however fast.
+ """
if test.outcome in ("failed", "error", "xfailed"):
return True
if test.attempts > 1:
return True
+ if test.outcome == "passed" and test.nodeid in prior_failed:
+ return True
return test.duration_seconds >= min_duration_seconds
-def filter_shards(shards: list[Shard], min_duration_seconds: float) -> list[Shard]:
+def filter_shards(
+ shards: list[Shard],
+ min_duration_seconds: float,
+ prior_failed_by_job: dict[str, frozenset[str]] | None = None,
+) -> list[Shard]:
"""Prune sub-threshold passing tests; preserve shard wall-time bounds and order."""
+ prior_failed_by_job = prior_failed_by_job or {}
+
+ def kept_tests(shard: Shard) -> list[TestCase]:
+ prior_failed = prior_failed_by_job.get(job_trace_key(shard.info), frozenset())
+ return [t for t in shard.tests if should_emit(t, min_duration_seconds, prior_failed)]
+
return [
Shard(
info=s.info,
@@ -348,13 +395,46 @@ def filter_shards(shards: list[Shard], min_duration_seconds: float) -> list[Shar
end=s.end,
testcase_seconds=s.testcase_seconds,
overhead_seconds=s.overhead_seconds,
- tests=[t for t in s.tests if should_emit(t, min_duration_seconds)],
+ tests=kept_tests(s),
setup_seconds=s.setup_seconds,
)
for s in shards
]
+# ---------- re-run attempts ----------
+
+
+def current_run_attempt() -> int:
+ """The workflow run attempt this emit runs under; 1 outside CI or on malformed input."""
+ try:
+ return max(1, int(os.environ.get("GITHUB_RUN_ATTEMPT", "1") or "1"))
+ except ValueError:
+ return 1
+
+
+# ci-backend.yml greps for this function name to decide whether the checked-out script may emit
+# on a re-run attempt; keep the name in sync with that probe if it ever changes.
+def partition_run_attempt(shards: list[Shard], run_attempt: int) -> tuple[list[Shard], dict[str, frozenset[str]]]:
+ """Split parsed shards for a re-run attempt: the shards this attempt executed, plus the
+ nodeids that failed in earlier attempts keyed by job.
+
+ Emitting only the current attempt's shards keeps an attempt from re-reporting shards it
+ never ran (each run attempt's resource attributes stamp every span it emits). The per-job
+ keying scopes recovery proof to the same matrix leg: a pass in a different leg runs a
+ different config and proves nothing about the failure.
+ """
+ current = [s for s in shards if s.info.attempt == run_attempt]
+ prior_failed: dict[str, set[str]] = {}
+ for shard in shards:
+ if shard.info.attempt >= run_attempt:
+ continue
+ for test in shard.tests:
+ if test.outcome in ("failed", "error"):
+ prior_failed.setdefault(job_trace_key(shard.info), set()).add(test.nodeid)
+ return current, {key: frozenset(nodeids) for key, nodeids in prior_failed.items()}
+
+
# ---------- workflow context ----------
@@ -595,8 +675,19 @@ def main(argv: list[str] | None = None) -> int:
logger.exception("failed to collect shards")
return 0
+ run_attempt = current_run_attempt()
+ prior_failed_by_job: dict[str, frozenset[str]] = {}
+ if run_attempt > 1:
+ shards, prior_failed_by_job = partition_run_attempt(shards, run_attempt)
+ logger.info(
+ "re-run attempt %d: emitting %d re-executed shards (%d jobs carry earlier-attempt failures)",
+ run_attempt,
+ len(shards),
+ len(prior_failed_by_job),
+ )
+
pre_filter = sum(len(s.tests) for s in shards)
- shards = filter_shards(shards, args.min_duration_seconds)
+ shards = filter_shards(shards, args.min_duration_seconds, prior_failed_by_job)
post_filter = sum(len(s.tests) for s in shards)
logger.info(
"collected %d shards, %d testcases (%d after %.2fs threshold filter)",
diff --git a/.github/scripts/test_report_test_timings.py b/.github/scripts/test_report_test_timings.py
index f8f147374c12..e6ee849b3d37 100644
--- a/.github/scripts/test_report_test_timings.py
+++ b/.github/scripts/test_report_test_timings.py
@@ -84,6 +84,21 @@ def test_derive_suite_segment_and_group(dir_name: str, expected: tuple[str, str,
assert report_test_timings.derive_suite_segment_and_group(dir_name) == expected
+ "dir_name,expected",
+ [
+ # A suffix folded into the segment would mis-key the shard and break recovery pairing.
+ ("junit-results-backend-core-29-attempt2", ("junit-results-backend-core-29", 2)),
+ ("junit-results-backend-core-29-attempt10", ("junit-results-backend-core-29", 10)),
+ ("junit-results-backend-core-29", ("junit-results-backend-core-29", 1)),
+ # No digits is not an attempt suffix: a segment could legitimately end in a word.
+ ("junit-results-backend-core-attempt", ("junit-results-backend-core-attempt", 1)),
+ ],
+)
+def test_split_attempt_suffix(dir_name: str, expected: tuple[str, int]) -> None:
+ assert report_test_timings.split_attempt_suffix(dir_name) == expected
+
+
# ---------- shard parsing end-to-end ----------
@@ -313,6 +328,61 @@ def test_filter_shards_preserves_parse_time_test_windows(tmp_path: Path) -> None
assert filtered[0].tests[2].start == datetime(2026, 5, 4, 10, 0, 2, 300000, tzinfo=UTC)
+# ---------- re-run attempts ----------
+
+
+def test_rerun_attempt_emits_only_reexecuted_shards_and_same_leg_recovery_passes(tmp_path: Path) -> None:
+ _write_shard_xml(
+ tmp_path / "junit-results-backend-core-1",
+ filename="junit-core.xml",
+ timestamp="2026-05-04T10:00:00",
+ time="1.0",
+ body="""\
+ <testcase classname="pkg.t.T" name="test_flaky" time="0.1"><failure message="x"/></testcase>
+ <testcase classname="pkg.t.T" name="test_untouched" time="0.1"/>
+ """,
+ )
+ # Not re-executed on attempt 2: must not be re-reported under the new attempt.
+ _write_shard_xml(
+ tmp_path / "junit-results-backend-core-2",
+ filename="junit-core.xml",
+ timestamp="2026-05-04T10:00:00",
+ time="1.0",
+ body='<testcase classname="pkg.t.T" name="test_other" time="0.1"><failure message="x"/></testcase>',
+ )
+ _write_shard_xml(
+ tmp_path / "junit-results-backend-core-1-attempt2",
+ filename="junit-core.xml",
+ timestamp="2026-05-04T11:00:00",
+ time="1.0",
+ body="""\
+ <testcase classname="pkg.t.T" name="test_flaky" time="0.1"/>
+ <testcase classname="pkg.t.T" name="test_untouched" time="0.1"/>
+ """,
+ )
+ # A pass in a different leg runs a different config and must not read as recovery.
+ _write_shard_xml(
+ tmp_path / "junit-results-backend-core-3-attempt2",
+ filename="junit-core.xml",
+ timestamp="2026-05-04T11:00:00",
+ time="1.0",
+ body='<testcase classname="pkg.t.T" name="test_flaky" time="0.1"/>',
+ )
+
+ current, prior_failed = report_test_timings.partition_run_attempt(report_test_timings.collect_shards(tmp_path), 2)
+ filtered = report_test_timings.filter_shards(current, 0.5, prior_failed)
+
+ assert [(s.info.group, s.info.attempt) for s in filtered] == [(1, 2), (3, 2)]
+ assert prior_failed == {
+ "backend:core:1": frozenset({"pkg/t/T::test_flaky"}),
+ "backend:core:2": frozenset({"pkg/t/T::test_other"}),
+ }
+ # Only the same-leg recovery pass survives the threshold filter; the fast pass that never
+ # failed and the cross-leg pass are dropped.
+ assert [test.name for test in filtered[0].tests] == ["test_flaky"]
+ assert filtered[1].tests == []
+
+
class _FakeSpan:
def __init__(self, name: str, start_time: int) -> None:
self.name = name
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 609cec6d925f..978a9d72df78 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -2972,7 +2972,10 @@ jobs:
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
if: always()
with:
- name: junit-results-backend-${{ matrix.artifact_key }}
+ # Re-run attempts suffix the name: a same-name upload supersedes attempt 1's
+ # artifact, and the timing reporter needs both to pair a re-run recovery
+ # (attempt-N pass) with the attempt-1 failure it proves flaky.
+ name: junit-results-backend-${{ matrix.artifact_key }}${{ github.run_attempt != '1' && format('-attempt{0}', github.run_attempt) || '' }}
path: junit-*.xml
# Best-effort Trunk upload (continue-on-error); the "Fail on test failure" step below is
@@ -3235,6 +3238,20 @@ jobs:
with:
pattern: '{junit-results-backend,product-junit-results}-*'
path: /tmp/junit-gate/
+ # Re-run attempts upload under suffixed names, so superseded attempts must be dropped
+ # here or the rollup below lists attempt-1 failures the re-run already recovered.
+ - name: Keep only each shard's latest attempt
+ if: always() && (needs.django.result != 'success' || needs.turbo-tests.result != 'success')
+ continue-on-error: true
+ run: |
+ cd /tmp/junit-gate 2>/dev/null || exit 0
+ shopt -s nullglob
+ for d in *-attempt[0-9]*; do
+ base="${d%-attempt*}"
+ latest="$(printf '%s\n' "$base"-attempt[0-9]* | sort -V | tail -1)"
+ rm -rf "$base"
+ [[ "$d" == "$latest" ]] || rm -rf "$d"
+ done
- name: Check dependency results
run: |
# Per-test failure rollup, emitted from THIS step because GitHub only
@@ -3389,6 +3406,20 @@ jobs:
path: /tmp/junit-results/
continue-on-error: true
+ # Re-run attempts upload under suffixed names; without this the verdict double-counts
+ # re-executed shards and resurrects failures the re-run already recovered.
+ - name: Keep only each shard's latest attempt
+ continue-on-error: true
+ run: |
+ cd /tmp/junit-results 2>/dev/null || exit 0
+ shopt -s nullglob
+ for d in *-attempt[0-9]*; do
+ base="${d%-attempt*}"
+ latest="$(printf '%s\n' "$base"-attempt[0-9]* | sort -V | tail -1)"
+ rm -rf "$base"
+ [[ "$d" == "$latest" ]] || rm -rf "$d"
+ done
+
# Reuse the selection artifact from the select-tests job rather than
# re-running the snob script. Falls through if the artifact wasn't
# produced (select-tests forced full mode or failed) — the next step
@@ -3531,6 +3562,9 @@ jobs:
runs-on: ubuntu-latest
continue-on-error: true
timeout-minutes: 10
+ # Runs on every attempt: a re-run passing what an earlier attempt failed is the same-commit
+ # flake proof the test-health queue reads, and the shards a re-run re-executed upload under
+ # attempt-suffixed artifact names so only they are emitted for the new attempt.
# Master pushes and all in-repo PRs. Skip forks (no secrets access).
if: >-
!cancelled() &&
@@ -3543,34 +3577,39 @@ jobs:
steps:
# Labelled PRs run the trusted base parser, so the same PR can't swap the script that receives secrets.
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- if: github.run_attempt == '1'
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.sha }}
fetch-depth: 1
- name: Check for trusted timing reporter
id: timing-reporter
- if: github.run_attempt == '1'
shell: bash
run: |
# tools/owners is a path dep of the reporter, so a base ref predating it can't resolve its deps.
+ available=false
if [[ -f .github/scripts/report_test_timings.py && -d tools/owners ]]; then
- echo "available=true" >> "$GITHUB_OUTPUT"
- else
- echo "available=false" >> "$GITHUB_OUTPUT"
- echo "Trusted timing reporter is not available on the checked-out ref; skipping emit."
+ available=true
+ fi
+ # A re-run may emit only through an attempt-aware reporter: an older script would
+ # re-report every attempt-1 shard under the new attempt's resource attributes.
+ if [[ "$GITHUB_RUN_ATTEMPT" != "1" ]] && ! grep -q "def partition_run_attempt" .github/scripts/report_test_timings.py 2>/dev/null; then
+ available=false
+ fi
+ if [[ "$available" != "true" ]]; then
+ echo "Trusted timing reporter is not available on the checked-out ref for attempt $GITHUB_RUN_ATTEMPT; skipping emit."
fi
+ echo "available=$available" >> "$GITHUB_OUTPUT"
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- if: github.run_attempt == '1' && steps.timing-reporter.outputs.available == 'true'
+ if: steps.timing-reporter.outputs.available == 'true'
with:
version: '0.11.28' # pinned: unpinned setup-uv calls GH API on every job, exhausts rate limit
- name: Download junit artifacts
- if: github.run_attempt == '1' && steps.timing-reporter.outputs.available == 'true'
+ if: steps.timing-reporter.outputs.available == 'true'
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v6.0.0
with:
path: ./junit-artifacts
pattern: junit-results-*
- name: Emit per-test traces
- if: github.run_attempt == '1' && steps.timing-reporter.outputs.available == 'true'
+ if: steps.timing-reporter.outputs.available == 'true'
continue-on-error: true
env:
POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}
diff --git a/products/engineering_analytics/README.md b/products/engineering_analytics/README.md
index b45bee10b747..bdcb19451077 100644
--- a/products/engineering_analytics/README.md
+++ b/products/engineering_analytics/README.md
@@ -82,7 +82,7 @@ graph LR
- Job-level CI: per-job duration, queue time, runner tier, and dollar cost ride `workflow_jobs` (webhook stream plus bounded backfill).
- One write surface: test quarantine. The UI files a tracking issue plus a PR against the repo's checked-in `.test_quarantine.json` through the team's GitHub App. Everything else is read-only.
-- The test-health view is an active work queue, not a failure-rate leaderboard: evidence is counted per CI run, a test is called flaky only where the evidence proves it (an in-job retry recovered it), and every other failure ranks as an honest suspected regression by blast radius.
+- The test-health view is an active work queue, not a failure-rate leaderboard: evidence is counted per CI run, a test is called flaky only where the evidence proves it (one commit was seen both failing and passing it: a re-run attempt going green, or an in-job retry), and every other failure ranks as an honest suspected regression by blast radius.
- Access control: per-user warehouse RBAC at the source resolver, `engineering_analytics:read` scopes on tools, feature-flag gated.
## The goal: CI Signals for PostHog Code
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.md
index 7ba59bdf3d0f..ac33c75ae8df 100644
--- a/products/engineering_analytics/SPEC.md
+++ b/products/engineering_analytics/SPEC.md
@@ -89,7 +89,7 @@ The endpoint catalog is `presentation/views.py`; the agent-facing descriptions l
- Time windows are `date_from` / `date_to`, relative (`-30d`) or ISO8601.
- 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 (one run fans a test across matrix legs), 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 in-run recovery proof; unproven failures rank as `suspected_regression` by blast radius.
+- 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.
- Reads over optional data (e.g. `team_members`) degrade honestly (`has_membership_data: false`), never 500.
### Exposed warehouse views
diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.py
index e69f293de639..463839e7dd41 100644
--- a/products/engineering_analytics/backend/facade/contracts.py
+++ b/products/engineering_analytics/backend/facade/contracts.py
@@ -525,7 +525,7 @@ FLAKY_TEST_SIGNAL_CAVEAT = (
class FlakyTestClassification(StrEnum):
- # An in-job retry recovered the test in the same run.
+ # One commit both failed and passed the test: a re-run attempt going green, or an in-job retry.
CONFIRMED_FLAKE = "confirmed_flake"
# Only failures recorded, which is absence of proof, not proof of a regression.
SUSPECTED_REGRESSION = "suspected_regression"
@@ -534,12 +534,12 @@ class FlakyTestClassification(StrEnum):
@classmethod
def from_run_evidence(
- cls, *, quarantined_failed_run_count: int, rerun_passed_run_count: int
+ cls, *, quarantined_failed_run_count: int, same_commit_recovery_run_count: int
) -> "FlakyTestClassification":
# Quarantine wins over a recovery proof: an xfail is already masked, so surface that first.
if quarantined_failed_run_count > 0:
return cls.QUARANTINED
- if rerun_passed_run_count > 0:
+ if same_commit_recovery_run_count > 0:
return cls.CONFIRMED_FLAKE
return cls.SUSPECTED_REGRESSION
@@ -548,10 +548,11 @@ class FlakyTestClassification(StrEnum):
class FlakyTestItem:
"""One test in the active test-health queue, aggregated from the per-test CI spans in the Traces store.
- Ranked by blast radius: what a failing test costs, not how often it flakes. This queue only sees
- Backend CI. Evidence is counted per CI run, never per span: one run fans a test across matrix
- legs, so only the run grain counts one failure once. See ``FLAKY_TEST_SIGNAL_CAVEAT`` for why
- every figure is an absolute count.
+ Ranked by blast radius: what a failing test costs, not how often it flakes. This queue only
+ sees Backend CI. 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, so only the run grain
+ counts one failure once. See ``FLAKY_TEST_SIGNAL_CAVEAT`` for why every figure is an absolute
+ count.
"""
# Reconstructed pytest nodeid (the span name), e.g. 'posthog/api/test/test_x/TestX::test_y'.
@@ -560,10 +561,9 @@ class FlakyTestItem:
# reporter stamped it; reconstructed from the nodeid (file/class boundary guessed) for older spans.
selector: str
classification: FlakyTestClassification
- # Runs where an in-job pytest retry recovered the test after it failed. Only tests hand-marked
- # @pytest.mark.flaky(reruns=N) can reach this: Backend CI runs without --reruns so failures
- # stay visible instead of being retried away.
- rerun_passed_run_count: int
+ # Runs where one commit both failed and passed the test: a later run attempt going green, or an
+ # in-job retry. A pass in a different run is a different commit and proves nothing, hence the name.
+ same_commit_recovery_run_count: int
failed_run_count: int
# Master/branch failures carry no PR number and don't count here.
failed_pr_count: int
@@ -577,7 +577,7 @@ class FlakyTestItem:
class FlakyTestList:
"""The active test-health queue for a window: tests with a live failure signal, ranked by blast
radius (trunk first, then PRs, then runs), capped at ``limit`` with an explicit truncation flag
- (same shape as ``PullRequestList``). A test qualifies on any in-run recovery, any
+ (same shape as ``PullRequestList``). A test qualifies on any same-commit recovery, any
default-branch failure, failures on at least ``min_failed_prs`` distinct PRs, or an xfail.
"""
@@ -599,7 +599,7 @@ class TeamCIHealthItem:
# Owning team slug (CODEOWNERS handle minus '@PostHog/'), or 'unowned' for unstamped spans.
owner_team: str
- # Owned tests an in-job retry recovered in the window: the same proof, and the same word,
+ # Owned tests one commit was seen both failing and passing: the same proof, and the same word,
# the test-health queue's `confirmed_flake` uses.
flaky_test_count: int
flaky_test_count_prior: int
@@ -609,8 +609,8 @@ class TeamCIHealthItem:
# Runs (not spans) where an owned test's recorded outcome was failed or error.
failed_run_count: int
failed_run_count_prior: int
- rerun_passed_run_count: int
- rerun_passed_run_count_prior: int
+ same_commit_recovery_run_count: int
+ same_commit_recovery_run_count_prior: int
# Runs where an owned test failed while quarantined (xfail): already masked, still failing.
quarantined_failed_run_count: int
quarantined_failed_run_count_prior: int
@@ -633,8 +633,8 @@ class TeamCIHealthList:
@dataclass(frozen=True)
class TeamTestSignal:
"""One owned test's flaky signal across the current window and its equal-length prior
- window, the pair behind a before-vs-after slope reading. Signal = runs where the test
- failed, errored, or a retry recovered it (xfail excluded: already-quarantined noise).
+ window, the pair behind a before-vs-after slope reading. Signal = failed + error +
+ pass-on-retry spans (xfail excluded: already-quarantined noise).
"""
nodeid: str
diff --git a/products/engineering_analytics/backend/logic/queries/_test_spans.py b/products/engineering_analytics/backend/logic/queries/_test_spans.py
index 119b7e0e4f96..ee6d2e6a2f1d 100644
--- a/products/engineering_analytics/backend/logic/queries/_test_spans.py
+++ b/products/engineering_analytics/backend/logic/queries/_test_spans.py
@@ -8,17 +8,20 @@ outcomes, the repository scoping, the ownership fallback, and above all the **gr
drift apart. Sharing a predicate string was not enough: each caller still counted its own way,
and they disagreed.
-The grain is the CI run, not the span. One run fans a test out across matrix legs (person-on-events,
-compat, and friends), so span-grain counting multiplies a single failure by the number of legs that
-ran it. At run grain a failure in any leg counts once, and outweighs a pass in another.
-
-What this signal can and cannot prove:
-
-- ``rerun_passed`` is proof of nondeterminism: the test failed and passed within one run. It reaches
- only the handful of tests hand-marked ``@pytest.mark.flaky(reruns=N)``, because Backend CI runs
- pytest without ``--reruns`` deliberately, so failures stay visible instead of being retried away.
-- Everything else proves nothing about determinism. This surface answers how much a failing test
- costs us, so unproven failures are ranked by blast radius and never called flaky.
+The grain is the CI run, not the span and not the run attempt:
+
+- One run fans a test out across matrix legs (person-on-events, compat, and friends), so span-grain
+ counting multiplies a single failure by the number of legs that ran it. At run grain a failure in
+ any leg counts once, and outweighs a pass in another.
+- Every attempt of a run tests the same commit, so attempts are repeated trials: a run that both
+ failed and passed a test has proven it nondeterministic, whichever attempt failed first. That is
+ what ``recovered_in_run`` means. Backend CI runs pytest without ``--reruns`` deliberately (failures
+ stay visible instead of being retried away), so a "re-run failed jobs" recovery is where that proof
+ comes from; ``rerun_passed`` is the same proof from the handful of tests hand-marked
+ ``@pytest.mark.flaky(reruns=N)``.
+
+Failures with no recovery prove nothing about determinism. This surface answers how much a failing
+test costs us, so unproven failures are ranked by blast radius and never called flaky.
"""
from datetime import datetime
@@ -26,7 +29,9 @@ from datetime import datetime
from posthog.hogql import ast
# Only test spans carry test.outcome (job-root and setup spans don't), and only these
-# outcomes are flaky signal; plain 'passed'/'skipped' spans never reach any aggregation.
+# outcomes are flaky signal. Plain 'skipped' spans never reach any aggregation; 'passed'
+# spans are read only from re-run attempts (the scan's recovery arm), where they are the
+# same-commit recovery proof.
SIGNAL_OUTCOMES = ["failed", "error", "rerun_passed", "xfailed"]
# Scope to the CI test-timing emitter (report_test_timings.py sets this as service.name);
@@ -41,19 +46,42 @@ _RUN_EVIDENCE = """
SELECT
nodeid,
run_id,
- argMax(owner_team, span_timestamp) AS owner_team,
+ argMax(owner_team, trial_at) AS owner_team,
anyIf(selector, selector != '') AS selector,
anyIf(pr_number, pr_number != '') AS pr_number,
anyIf(branch, branch != '') AS branch,
max(is_current) AS is_current,
- max(outcome IN ('failed', 'error')) AS failed_in_run,
- max(outcome = 'xfailed') AS quarantined_in_run,
- max(outcome = 'rerun_passed') AS recovered_in_run,
- -- Every scanned span is a signal span (the fence admits no plain passes), so the run's last
- -- span is its last signal.
- max(span_timestamp) AS run_signal_at
- FROM (__SPAN_SCAN__)
+ max(trial_failed) AS failed_in_run,
+ max(trial_quarantined) AS quarantined_in_run,
+ -- Proof of nondeterminism either way it lands: an in-job retry recovered the test, or one
+ -- attempt of the run failed it and another attempt (same commit) passed it.
+ max(trial_rerun_passed) OR (max(trial_failed) AND max(trial_passed)) AS recovered_in_run,
+ -- Recovery passes are not signal, so recency comes from the signal trials alone.
+ maxIf(trial_at, trial_failed OR trial_rerun_passed OR trial_quarantined) AS run_signal_at
+ FROM (
+ -- One row per (test, run attempt). A test can appear in several matrix legs of one attempt
+ -- (and older data re-reported shards an attempt never re-executed); a failure in any leg
+ -- outweighs a pass in another, so a cross-leg pass never reads as recovery.
+ SELECT
+ nodeid,
+ run_id,
+ argMax(owner_team, span_timestamp) AS owner_team,
+ anyIf(selector, selector != '') AS selector,
+ anyIf(pr_number, pr_number != '') AS pr_number,
+ anyIf(branch, branch != '') AS branch,
+ max(is_current) AS is_current,
+ max(outcome IN ('failed', 'error')) AS trial_failed,
+ max(outcome = 'rerun_passed') AS trial_rerun_passed,
+ max(outcome = 'xfailed') AS trial_quarantined,
+ max(outcome = 'passed') AND NOT trial_failed AS trial_passed,
+ max(span_timestamp) AS trial_at
+ FROM (__SPAN_SCAN__)
+ GROUP BY nodeid, run_id, attempt
+ )
GROUP BY nodeid, run_id
+ -- The scan admits re-run passes so they can pair with a failure above; unpaired they are not
+ -- evidence, and a pass-only row would surface as an all-zero test everywhere downstream.
+ HAVING failed_in_run OR recovered_in_run OR quarantined_in_run
"""
@@ -83,13 +111,23 @@ _SCAN = """
-- The emitter always stamps ci.run_id; the trace_id fallback (one trace per job) keeps an
-- 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,
timestamp AS span_timestamp,
timestamp >= {date_from} AS is_current
FROM posthog.trace_spans
WHERE service_name = {service_name}
- AND attributes['test.outcome'] IN {signal_outcomes}
AND lower(resource_attributes['ci.repository']) = lower({repository})
AND timestamp >= {scan_from}__DATE_TO__
+ -- Only re-run attempts' passes are read. Reading first-attempt passes too would mean
+ -- scanning the whole passing corpus, which dwarfs the signal one, to gain only the runs
+ -- whose disagreement began with a pass (passed on attempt 1, failed on the re-run).
+ AND (
+ attributes['test.outcome'] IN {signal_outcomes}
+ OR (
+ attributes['test.outcome'] = 'passed'
+ AND resource_attributes['ci.run_attempt'] NOT IN ('', '1')
+ )
+ )
"""
diff --git a/products/engineering_analytics/backend/logic/queries/flaky_tests.py b/products/engineering_analytics/backend/logic/queries/flaky_tests.py
index 19df8d350890..41615c8d44f6 100644
--- a/products/engineering_analytics/backend/logic/queries/flaky_tests.py
+++ b/products/engineering_analytics/backend/logic/queries/flaky_tests.py
@@ -3,10 +3,11 @@
Groups ``_test_spans.run_evidence()`` (the one definition of the grain and of what a run proves)
by nodeid, and ranks by blast radius: how many PRs a test broke and how often it broke master.
-A test is a ``confirmed_flake`` only where the evidence already carries proof (an in-job retry
-recovered it), and every other failure is an honest ``suspected_regression`` rather than a guess
-dressed up as one. Failing on many distinct PRs proves only that a failure is not one PR's
-fault, never that the test is flaky: real regressions fail across PRs too.
+A test is a ``confirmed_flake`` only where the evidence already carries proof (one commit was
+seen both failing and passing it: a re-run attempt going green, or an in-job retry), and every
+other failure is an honest ``suspected_regression`` rather than a guess dressed up as one.
+Failing on many distinct PRs proves only that a failure is not one PR's fault, never that the
+test is flaky: real regressions fail across PRs too.
Every figure is an absolute count: the emitter drops sub-threshold passes, so there is no
denominator to divide by.
@@ -36,7 +37,7 @@ _SELECT = """
SELECT
nodeid,
anyIf(selector, selector != '') AS selector,
- countIf(recovered_in_run) AS rerun_passed_run_count,
+ countIf(recovered_in_run) AS same_commit_recovery_run_count,
countIf(failed_in_run) AS failed_run_count,
uniqIf(pr_number, failed_in_run AND pr_number != '') AS failed_pr_count,
countIf(failed_in_run AND branch IN ('master', 'main')) AS master_failed_run_count,
@@ -44,7 +45,7 @@ _SELECT = """
max(run_signal_at) AS last_signal_at
FROM (__RUN_EVIDENCE__)
GROUP BY nodeid
- HAVING rerun_passed_run_count > 0
+ HAVING same_commit_recovery_run_count > 0
OR quarantined_failed_run_count > 0
OR master_failed_run_count > 0
OR failed_pr_count >= {min_failed_prs}
@@ -94,9 +95,9 @@ def query_flaky_tests(
selector=selector or selector_from_nodeid(nodeid),
classification=FlakyTestClassification.from_run_evidence(
quarantined_failed_run_count=quarantined_failed_run_count,
- rerun_passed_run_count=rerun_passed_run_count,
+ same_commit_recovery_run_count=same_commit_recovery_run_count,
),
- rerun_passed_run_count=rerun_passed_run_count,
+ same_commit_recovery_run_count=same_commit_recovery_run_count,
failed_run_count=failed_run_count,
failed_pr_count=failed_pr_count,
master_failed_run_count=master_failed_run_count,
@@ -106,7 +107,7 @@ def query_flaky_tests(
for (
nodeid,
selector,
- rerun_passed_run_count,
+ same_commit_recovery_run_count,
failed_run_count,
failed_pr_count,
master_failed_run_count,
diff --git a/products/engineering_analytics/backend/logic/queries/team_ci_health.py b/products/engineering_analytics/backend/logic/queries/team_ci_health.py
index 58f5859c78cf..3b84946f711f 100644
--- a/products/engineering_analytics/backend/logic/queries/team_ci_health.py
+++ b/products/engineering_analytics/backend/logic/queries/team_ci_health.py
@@ -51,8 +51,8 @@ _ROSTER_SELECT = f"""
countIf(recovery_runs_prior = 0 AND blast_radius_prior) AS regression_test_count_prior,
sum(failed_runs_current) AS failed_run_count,
sum(failed_runs_prior) AS failed_run_count_prior,
- sum(recovery_runs_current) AS rerun_passed_run_count,
- sum(recovery_runs_prior) AS rerun_passed_run_count_prior,
+ sum(recovery_runs_current) AS same_commit_recovery_run_count,
+ sum(recovery_runs_prior) AS same_commit_recovery_run_count_prior,
sum(xfail_runs_current) AS quarantined_failed_run_count,
sum(xfail_runs_prior) AS quarantined_failed_run_count_prior,
max(last_signal) AS last_seen_at
@@ -147,8 +147,8 @@ def query_team_ci_health(
regression_test_count_prior=regression_test_count_prior,
failed_run_count=failed_run_count,
failed_run_count_prior=failed_run_count_prior,
- rerun_passed_run_count=rerun_passed_run_count,
- rerun_passed_run_count_prior=rerun_passed_run_count_prior,
+ same_commit_recovery_run_count=same_commit_recovery_run_count,
+ same_commit_recovery_run_count_prior=same_commit_recovery_run_count_prior,
quarantined_failed_run_count=quarantined_failed_run_count,
quarantined_failed_run_count_prior=quarantined_failed_run_count_prior,
last_seen_at=last_seen_at,
@@ -161,8 +161,8 @@ def query_team_ci_health(
regression_test_count_prior,
failed_run_count,
failed_run_count_prior,
- rerun_passed_run_count,
- rerun_passed_run_count_prior,
+ same_commit_recovery_run_count,
+ same_commit_recovery_run_count_prior,
quarantined_failed_run_count,
quarantined_failed_run_count_prior,
last_seen_at,
diff --git a/products/engineering_analytics/backend/presentation/serializers/suite_health.py b/products/engineering_analytics/backend/presentation/serializers/suite_health.py
index 339d747bf010..67d52f8f6b14 100644
--- a/products/engineering_analytics/backend/presentation/serializers/suite_health.py
+++ b/products/engineering_analytics/backend/presentation/serializers/suite_health.py
@@ -30,14 +30,16 @@ class FlakyTestItemSerializer(DataclassSerializer):
"otherwise reconstructed from the nodeid, where the file/class boundary is a best-effort guess.",
},
"classification": {
- "help_text": "confirmed_flake: an in-job retry recovered the test in the same run, so it is "
- "provably nondeterministic. quarantined: it fails while masked as xfail. suspected_regression: "
- "only failures were recorded, which is absence of proof, not proof that it is a real break.",
- },
- "rerun_passed_run_count": {
- "help_text": "Runs where an in-job pytest retry recovered the test after it failed. Above zero is "
- "the only proof of flakiness this data carries, and it reaches only tests hand-marked "
- "@pytest.mark.flaky(reruns=N), since Backend CI runs without --reruns so failures stay visible.",
+ "help_text": "confirmed_flake: one commit both failed and passed the test (a re-run attempt went "
+ "green, or an in-job retry recovered it), so it is provably nondeterministic. quarantined: it "
+ "fails while masked as xfail. suspected_regression: only failures were recorded, which is "
+ "absence of proof, not proof that it is a real break.",
+ },
+ "same_commit_recovery_run_count": {
+ "help_text": "Runs where one commit both failed and passed the test: 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. A pass in a different run is a different commit "
+ "and never counts.",
},
"failed_run_count": {
"help_text": "Distinct CI runs whose recorded outcome was failed or error. A run counts once "
diff --git a/products/engineering_analytics/backend/presentation/serializers/teams.py b/products/engineering_analytics/backend/presentation/serializers/teams.py
index 0ed0c3d4a478..a325f7f1445f 100644
--- a/products/engineering_analytics/backend/presentation/serializers/teams.py
+++ b/products/engineering_analytics/backend/presentation/serializers/teams.py
@@ -21,15 +21,15 @@ class TeamCIHealthItemSerializer(DataclassSerializer):
"or the literal 'unowned' for tests whose spans carry no ownership stamp.",
},
"flaky_test_count": {
- "help_text": "Owned tests an in-job retry recovered in the window: the same proof, and the same "
- "word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the "
- "delta.",
+ "help_text": "Owned tests one commit was seen both failing and passing in the window: the same "
+ "proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with "
+ "flaky_test_count_prior for the delta.",
},
"flaky_test_count_prior": {
"help_text": "Same count over the equal-length window immediately before date_from.",
},
"regression_test_count": {
- "help_text": "Owned tests that failed with no recorded in-run recovery and still hit the "
+ "help_text": "Owned tests that failed with no recorded same-commit recovery and still hit the "
"blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence "
"of proof, not proof.",
},
@@ -39,10 +39,11 @@ class TeamCIHealthItemSerializer(DataclassSerializer):
"An absolute count, not a rate: fast passing runs are not emitted.",
},
"failed_run_count_prior": {"help_text": "Same count over the prior window."},
- "rerun_passed_run_count": {
- "help_text": "Runs where an in-job pytest retry recovered an owned test after it failed.",
+ "same_commit_recovery_run_count": {
+ "help_text": "Runs where one commit both failed and passed an owned test: a re-run attempt went "
+ "green, or an in-job retry recovered it.",
},
- "rerun_passed_run_count_prior": {"help_text": "Same count over the prior window."},
+ "same_commit_recovery_run_count_prior": {"help_text": "Same count over the prior window."},
"quarantined_failed_run_count": {
"help_text": "Runs where an owned test failed while quarantined (xfail): masked in CI, still failing.",
},
diff --git a/products/engineering_analytics/backend/presentation/views/suite_health.py b/products/engineering_analytics/backend/presentation/views/suite_health.py
index cd60e0ca1e4c..2dea6c9ee826 100644
--- a/products/engineering_analytics/backend/presentation/views/suite_health.py
+++ b/products/engineering_analytics/backend/presentation/views/suite_health.py
@@ -70,11 +70,12 @@ class SuiteHealthActionsMixin(EngineeringAnalyticsViewSetBase):
},
description=(
"The active test-health queue: backend tests worth acting on now, from the per-test CI spans, over a "
- "window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span. "
- "A test is a 'confirmed_flake' when an in-job retry recovered it in the same run; 'quarantined' when "
- "it fails while masked as xfail; otherwise "
- "'suspected_regression'. It qualifies on any recovery, any master/main failure, an xfail, or failures "
- "on at least min_failed_prs distinct PRs. " + FLAKY_TEST_SIGNAL_CAVEAT
+ "window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span or run "
+ "attempt. A test is a 'confirmed_flake' when one commit both failed and passed it (a 'Re-run failed "
+ "jobs' attempt went green, or an in-job retry recovered it); 'quarantined' when it fails while "
+ "masked as xfail; otherwise 'suspected_regression'. It qualifies on any same-commit recovery, any "
+ "master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs. "
+ + FLAKY_TEST_SIGNAL_CAVEAT
),
)
@action(detail=False, methods=["get"], pagination_class=None)
diff --git a/products/engineering_analytics/backend/presentation/views/teams.py b/products/engineering_analytics/backend/presentation/views/teams.py
index f4d4a0a4bb48..3b6e0ebb8ae7 100644
--- a/products/engineering_analytics/backend/presentation/views/teams.py
+++ b/products/engineering_analytics/backend/presentation/views/teams.py
@@ -65,9 +65,9 @@ class TeamActionsMixin(EngineeringAnalyticsViewSetBase):
},
description=(
"Per-owning-team rollup of the CI test surfaces each team owns, over the same run evidence as "
- "flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests an in-job retry "
- "recovered in the window, regression_test_count is owned tests that failed with no such proof and "
- "still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an "
+ "flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests one commit was "
+ "seen both failing and passing in the window, regression_test_count is owned tests that failed "
+ "with no such proof and still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an "
"equal-length previous-window twin for honest deltas. Ownership is stamped on the spans at CI "
"emission time from the repo's ownership map (products/*/product.yaml + CODEOWNERS); unstamped "
"spans aggregate under the literal team 'unowned', and a re-stamped test lands under its latest "
diff --git a/products/engineering_analytics/backend/tests/test_flaky_tests.py b/products/engineering_analytics/backend/tests/test_flaky_tests.py
index 67954708af26..d1001a6350c6 100644
--- a/products/engineering_analytics/backend/tests/test_flaky_tests.py
+++ b/products/engineering_analytics/backend/tests/test_flaky_tests.py
@@ -13,6 +13,10 @@ from products.engineering_analytics.backend.logic.queries._test_spans import sel
from products.engineering_analytics.backend.tests._github_fixtures import connect_github_source_without_data
from products.warehouse_sources.backend.facade.models import ExternalDataSource
+T_RERUN_RECOVERY = "posthog/api/test/test_rerun/TestRerun::test_green_on_attempt_2"
+T_STALE_REREPORT = "posthog/api/test/test_stale/TestStale::test_reported_twice"
+T_CROSS_RUN_PASS = "posthog/api/test/test_cross/TestCross::test_passes_in_another_run"
+T_PASS_THEN_FAIL = "posthog/api/test/test_order/TestOrder::test_fails_after_passing"
T_MATRIX_LEGS = "posthog/api/test/test_legs/TestLegs::test_fails_in_two_legs"
T_IN_JOB_RETRY = "posthog/api/test/test_injob/TestInJob::test_pytest_retry"
T_IN_JOB_SELECTOR = "posthog/api/test/test_injob.py::TestInJob::test_pytest_retry"
@@ -52,15 +56,32 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
old = now - timedelta(days=10)
rows = [
+ # Failed on attempt 1, green on the re-run: one commit, both outcomes.
+ cls._span(1, T_RERUN_RECOVERY, "failed", ts=earlier, run="100", branch="master"),
+ cls._span(2, T_RERUN_RECOVERY, "passed", ts=recent, run="100", attempt="2", branch="master"),
+ # Older data re-reported the shards an attempt never re-executed, so the same failure
+ # arrives under two attempts. One run, one failure.
+ cls._span(3, T_STALE_REREPORT, "failed", ts=earlier, run="200", branch="master"),
+ cls._span(4, T_STALE_REREPORT, "failed", ts=earlier, run="200", attempt="2", branch="master"),
+ # A pass in a different run is a different commit and proves nothing.
+ cls._span(8, T_CROSS_RUN_PASS, "failed", ts=earlier, run="300", branch="master"),
+ cls._span(9, T_CROSS_RUN_PASS, "passed", ts=recent, run="301", attempt="2", branch="master"),
+ # One commit disagreeing with itself proves nondeterminism whichever way round it lands,
+ # so a pass on an earlier attempt than the failure still counts.
+ cls._span(24, T_PASS_THEN_FAIL, "passed", ts=earlier, run="1400", attempt="2", branch="master"),
+ cls._span(25, T_PASS_THEN_FAIL, "failed", ts=recent, run="1400", attempt="3", branch="master"),
# One run fans a test across matrix legs, and two of them fail. One run, one failure.
cls._span(5, T_MATRIX_LEGS, "failed", ts=earlier, run="250", branch="master"),
cls._span(6, T_MATRIX_LEGS, "failed", ts=recent, run="250", branch="master"),
- # A third leg passed. Plain passes sit outside the scan fence, so a passing leg can never
- # be mistaken for the test recovering.
- cls._span(7, T_MATRIX_LEGS, "passed", ts=recent, run="250", branch="master"),
- # In-job pytest retry: the only proof of nondeterminism this telemetry carries, and it
- # reaches only tests hand-marked @pytest.mark.flaky(reruns=N). The emitter stamped
- # test.selector here, so it wins over the nodeid reconstruction.
+ # A third leg passed. First-attempt passes sit outside the scan fence, so a passing leg
+ # can never be mistaken for the test recovering.
+ cls._span(7, T_MATRIX_LEGS, "passed", ts=recent, run="250", attempt="", branch="master"),
+ # An attempt re-reports a failing leg and a passing leg together. The failure wins.
+ cls._span(26, T_MATRIX_LEGS, "failed", ts=recent, run="250", attempt="2", branch="master"),
+ cls._span(27, T_MATRIX_LEGS, "passed", ts=recent, run="250", attempt="2", branch="master"),
+ # In-job pytest retry: the same same-commit proof from tests hand-marked
+ # @pytest.mark.flaky(reruns=N). The emitter stamped test.selector here, so it wins over
+ # the nodeid reconstruction.
cls._span(
10,
T_IN_JOB_RETRY,
@@ -86,8 +107,8 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
cls._span(18, T_OLD, "rerun_passed", ts=old, run="900", pr="901", branch="old1"),
# Two master failures whose spans carry no ci.run_id: the trace_id fallback keeps them
# two distinct runs instead of merging every unstamped execution into one phantom run.
- cls._span(24, T_NO_RUN_ID, "failed", ts=recent, run="", branch="master"),
- cls._span(25, T_NO_RUN_ID, "failed", ts=recent, run="", branch="master"),
+ cls._span(28, T_NO_RUN_ID, "failed", ts=recent, run="", branch="master"),
+ cls._span(29, T_NO_RUN_ID, "failed", ts=recent, run="", branch="master"),
# Identical evidence: nodeid is the deterministic final tiebreaker.
cls._span(19, T_TIE_B, "rerun_passed", ts=recent, run="1000", pr="1001", branch="tie"),
cls._span(20, T_TIE_A, "rerun_passed", ts=recent, run="1001", pr="1002", branch="tie"),
@@ -121,6 +142,7 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
*,
ts: datetime,
run: str = "",
+ attempt: str = "1",
pr: str = "",
branch: str = "",
selector: str = "",
@@ -128,7 +150,8 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
repo: str = "PostHog/posthog",
) -> str:
# Physical attributes carry a type suffix ('test.outcome__str'); the `attributes` ALIAS
- # column strips it. Resource attributes are stored as-is.
+ # column strips it. Resource attributes are stored as-is; attempt="" drops the
+ # ci.run_attempt key, the shape of spans emitted before attempts were stamped.
attr_pairs = ([f"'test.outcome__str', '{outcome}'"] if outcome else []) + (
[f"'test.selector__str', '{selector}'"] if selector else []
)
@@ -137,6 +160,7 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
f"'{key}', '{value}'"
for key, value in (
("ci.run_id", run),
+ ("ci.run_attempt", attempt),
("ci.pr_number", pr),
("ci.branch", branch),
("ci.repository", repo),
@@ -164,6 +188,10 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
# The 2-PR test is below the bar; the out-of-window, foreign-service, other-repo, and
# outcome-less job-root spans must never qualify.
assert {row["nodeid"] for row in data["items"]} == {
+ T_RERUN_RECOVERY,
+ T_STALE_REREPORT,
+ T_CROSS_RUN_PASS,
+ T_PASS_THEN_FAIL,
T_MATRIX_LEGS,
T_IN_JOB_RETRY,
T_THREE_PRS,
@@ -178,8 +206,13 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
@parameterized.expand(
[
+ ("recovered_on_rerun_attempt", T_RERUN_RECOVERY, "confirmed_flake"),
("recovered_via_in_job_retry", T_IN_JOB_RETRY, "confirmed_flake"),
- # A passing leg alongside a failing one is not proof of anything.
+ # The pass came before the failure; one commit, both outcomes, still a flake.
+ ("passed_then_failed_in_one_run", T_PASS_THEN_FAIL, "confirmed_flake"),
+ # The pass is in another run, so it is another commit and proves nothing.
+ ("pass_in_a_different_run", T_CROSS_RUN_PASS, "suspected_regression"),
+ # A passing leg alongside a failing one is not proof of anything, in any attempt.
("pass_in_another_matrix_leg", T_MATRIX_LEGS, "suspected_regression"),
("no_recovery_recorded", T_THREE_PRS, "suspected_regression"),
("failing_while_xfailed", T_QUARANTINED, "quarantined"),
@@ -195,11 +228,24 @@ class TestFlakyTestsAPI(ClickhouseTestMixin, APIBaseTest):
legs = rows[T_MATRIX_LEGS]
assert legs["failed_run_count"] == 1
assert legs["master_failed_run_count"] == 1
- # The passing leg must not read as a recovery.
- assert legs["rerun_passed_run_count"] == 0
+ # Neither the passing leg nor the attempt-2 leg mix reads as a recovery.
+ assert legs["same_commit_recovery_run_count"] == 0
+
+ # Two attempts of one run, both reporting the same failure: one run, one failure, and the
+ # re-report is not mistaken for a second occurrence.
+ stale = rows[T_STALE_REREPORT]
+ assert stale["failed_run_count"] == 1
+ assert stale["same_commit_recovery_run_count"] == 0
+ assert stale["master_failed_run_count"] == 1
+
+ recovered_on_rerun = rows[T_RERUN_RECOVERY]
+ assert recovered_on_rerun["same_commit_recovery_run_count"] == 1
+ assert recovered_on_rerun["failed_run_count"] == 1
+ # The attempt-2 pass is not a signal, so recency still points at the failure.
+ assert recovered_on_rerun["last_signal_at"] < rows[T_MASTER]["last_signal_at"]
recovered = rows[T_IN_JOB_RETRY]
- assert recovered["rerun_passed_run_count"] == 1
+ assert recovered["same_commit_recovery_run_count"] == 1
assert recovered["selector"] == T_IN_JOB_SELECTOR
three_prs = rows[T_THREE_PRS]
diff --git a/products/engineering_analytics/backend/tests/test_team_ci_health.py b/products/engineering_analytics/backend/tests/test_team_ci_health.py
index c108dc8c8f8d..866294d704a4 100644
--- a/products/engineering_analytics/backend/tests/test_team_ci_health.py
+++ b/products/engineering_analytics/backend/tests/test_team_ci_health.py
@@ -15,6 +15,7 @@ T_EXPORTS_RECOVERED = "products/batch_exports/backend/tests/test_snowflake/TestS
T_UNOWNED = "posthog/api/test/test_shared/TestShared::test_unowned"
T_FOREIGN = "posthog/api/test/test_foreign/TestForeign::test_other_service"
T_RESTAMPED = "products/moved/backend/tests/test_moved/TestMoved::test_restamped"
+T_PASS_ONLY = "products/quiet/backend/tests/test_quiet/TestQuiet::test_pass_only"
class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
@@ -56,13 +57,22 @@ class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
cls._span(6, T_REPLAY_RERUN, "rerun_passed", ts=cls.current_b, owner="team-replay", run="201", pr="201"),
cls._span(7, T_REPLAY_RERUN, "rerun_passed", ts=prior, owner="team-replay", run="202", pr="202"),
cls._span(8, T_REPLAY_RERUN, "rerun_passed", ts=prior, owner="team-replay", run="203", pr="203"),
- # batch-exports: unrecovered PR failures in the prior window, then an in-job retry recovers
- # it in the current one. The same test moves from regression to proven flake.
+ # batch-exports: unrecovered PR failures in the prior window, then a re-run attempt goes
+ # green on the same commit in the current one. The same test moves from regression to
+ # proven flake, through the same cross-attempt proof the queue reads.
cls._span(9, T_EXPORTS_RECOVERED, "failed", ts=prior, owner="batch-exports", run="301", pr="301"),
cls._span(10, T_EXPORTS_RECOVERED, "failed", ts=prior, owner="batch-exports", run="302", pr="302"),
cls._span(11, T_EXPORTS_RECOVERED, "failed", ts=prior, owner="batch-exports", run="303", pr="303"),
+ cls._span(14, T_EXPORTS_RECOVERED, "failed", ts=cls.current_a, owner="batch-exports", run="304", pr="304"),
cls._span(
- 14, T_EXPORTS_RECOVERED, "rerun_passed", ts=cls.current_a, owner="batch-exports", run="304", pr="304"
+ 15,
+ T_EXPORTS_RECOVERED,
+ "passed",
+ ts=cls.current_b,
+ owner="batch-exports",
+ run="304",
+ attempt="2",
+ pr="304",
),
# Ownership re-stamp: prior-window failure stamped team-old, current stamped team-new.
# The latest stamp owns the whole test, in the roster and the drill-in alike.
@@ -70,6 +80,11 @@ class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
cls._span(16, T_RESTAMPED, "failed", ts=cls.current_b, owner="team-new", run="602", pr="602"),
# No owner stamp: buckets under the literal 'unowned'.
cls._span(12, T_UNOWNED, "rerun_passed", ts=cls.current_b, owner="", run="401", pr="401"),
+ # A re-run pass with no same-run failure: a shard re-executed alongside the flaky one.
+ # It pairs with nothing, so its team must not appear in the roster at all.
+ cls._span(
+ 17, T_PASS_ONLY, "passed", ts=cls.current_b, owner="team-quiet", run="701", attempt="2", pr="701"
+ ),
# A non-CI service must never reach the roster (the scan is fenced by service_name).
cls._span(
13,
@@ -106,6 +121,7 @@ class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
ts: datetime,
owner: str,
run: str,
+ attempt: str = "1",
pr: str = "",
service: str = "ci-backend",
) -> str:
@@ -115,6 +131,7 @@ class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
resource_pairs = [
"'ci.repository', 'PostHog/posthog'",
f"'ci.run_id', '{run}'",
+ f"'ci.run_attempt', '{attempt}'",
]
if pr:
resource_pairs.append(f"'ci.pr_number', '{pr}'")
@@ -142,20 +159,23 @@ class TestTeamCIHealthAPI(ClickhouseTestMixin, APIBaseTest):
assert (replay["flaky_test_count"], replay["regression_test_count"]) == (1, 1)
assert (replay["flaky_test_count_prior"], replay["regression_test_count_prior"]) == (1, 0)
assert (replay["failed_run_count"], replay["failed_run_count_prior"]) == (3, 1)
- assert (replay["rerun_passed_run_count"], replay["rerun_passed_run_count_prior"]) == (1, 2)
+ assert (replay["same_commit_recovery_run_count"], replay["same_commit_recovery_run_count_prior"]) == (1, 2)
assert (replay["quarantined_failed_run_count"], replay["quarantined_failed_run_count_prior"]) == (1, 0)
- assert (rows["unowned"]["flaky_test_count"], rows["unowned"]["rerun_passed_run_count"]) == (1, 1)
+ assert (rows["unowned"]["flaky_test_count"], rows["unowned"]["same_commit_recovery_run_count"]) == (1, 1)
- # An in-job retry recovered it, so it is current-window flaky; the prior window's 3
- # unrecovered PR failures are a regression, not a flake.
+ # A re-run attempt went green on the same commit, so it is current-window flaky; the prior
+ # window's 3 unrecovered PR failures are a regression, not a flake.
exports = rows["batch-exports"]
assert (exports["flaky_test_count"], exports["regression_test_count"]) == (1, 0)
assert (exports["flaky_test_count_prior"], exports["regression_test_count_prior"]) == (0, 1)
- assert (exports["failed_run_count"], exports["failed_run_count_prior"]) == (0, 3)
+ assert (exports["failed_run_count"], exports["failed_run_count_prior"]) == (1, 3)
+ assert (exports["same_commit_recovery_run_count"], exports["same_commit_recovery_run_count_prior"]) == (1, 0)
# The foreign-service span's team must not appear at all.
assert "ghost-team" not in rows
+ # A re-run pass that pairs with no failure is not evidence: no phantom all-zero team row.
+ assert "team-quiet" not in rows
def test_restamped_test_lands_under_its_latest_owner_in_roster_and_drill_in(self):
rows = self._roster()
diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.ts
index 5661963014fd..32d59765c6df 100644
--- a/products/engineering_analytics/frontend/generated/api.schemas.ts
+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts
@@ -217,14 +217,14 @@ export interface FlakyTestItemApi {
nodeid: string
/** Runnable pytest selector, e.g. 'posthog/api/test/test_event.py::TestEvents::test_x'. Exact when the CI reporter emitted it; otherwise reconstructed from the nodeid, where the file/class boundary is a best-effort guess. */
selector: string
- /** confirmed_flake: an in-job retry recovered the test in the same run, so it is provably nondeterministic. quarantined: it fails while masked as xfail. suspected_regression: only failures were recorded, which is absence of proof, not proof that it is a real break.
+ /** confirmed_flake: one commit both failed and passed the test (a re-run attempt went green, or an in-job retry recovered it), so it is provably nondeterministic. quarantined: it fails while masked as xfail. suspected_regression: only failures were recorded, which is absence of proof, not proof that it is a real break.
*
* * `confirmed_flake` - CONFIRMED_FLAKE
* * `suspected_regression` - SUSPECTED_REGRESSION
* * `quarantined` - QUARANTINED */
classification: FlakyTestItemClassificationEnumApi
- /** Runs where an in-job pytest retry recovered the test after it failed. Above zero is the only proof of flakiness this data carries, and it reaches only tests hand-marked @pytest.mark.flaky(reruns=N), since Backend CI runs without --reruns so failures stay visible. */
- rerun_passed_run_count: number
+ /** Runs where one commit both failed and passed the test: 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. A pass in a different run is a different commit and never counts. */
+ same_commit_recovery_run_count: number
/** Distinct CI runs whose recorded outcome was failed or error. A run counts once however many matrix legs it failed in. */
failed_run_count: number
/** Distinct pull requests among the failed runs. Failures on master or unattributed branches carry no PR number and are excluded here (still in failed_run_count). */
@@ -980,11 +980,11 @@ export interface TeamCIActivityApi {
export interface TeamCIHealthItemApi {
/** Owning team slug (the CODEOWNERS handle minus '@PostHog/', e.g. 'team-replay'), or the literal 'unowned' for tests whose spans carry no ownership stamp. */
owner_team: string
- /** Owned tests an in-job retry recovered in the window: the same proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the delta. */
+ /** Owned tests one commit was seen both failing and passing in the window: the same proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the delta. */
flaky_test_count: number
/** Same count over the equal-length window immediately before date_from. */
flaky_test_count_prior: number
- /** Owned tests that failed with no recorded in-run recovery and still hit the blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence of proof, not proof. */
+ /** Owned tests that failed with no recorded same-commit recovery and still hit the blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence of proof, not proof. */
regression_test_count: number
/** Same count over the prior window. */
regression_test_count_prior: number
@@ -992,10 +992,10 @@ export interface TeamCIHealthItemApi {
failed_run_count: number
/** Same count over the prior window. */
failed_run_count_prior: number
- /** Runs where an in-job pytest retry recovered an owned test after it failed. */
- rerun_passed_run_count: number
+ /** Runs where one commit both failed and passed an owned test: a re-run attempt went green, or an in-job retry recovered it. */
+ same_commit_recovery_run_count: number
/** Same count over the prior window. */
- rerun_passed_run_count_prior: number
+ same_commit_recovery_run_count_prior: number
/** Runs where an owned test failed while quarantined (xfail): masked in CI, still failing. */
quarantined_failed_run_count: number
/** Same count over the prior window. */
diff --git a/products/engineering_analytics/frontend/generated/api.ts b/products/engineering_analytics/frontend/generated/api.ts
index 3784380b7917..2891afe0db85 100644
--- a/products/engineering_analytics/frontend/generated/api.ts
+++ b/products/engineering_analytics/frontend/generated/api.ts
@@ -284,7 +284,7 @@ export const getEngineeringAnalyticsFlakyTestsUrl = (
}
/**
- * The active test-health queue: backend tests worth acting on now, from the per-test CI spans, over a window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span. A test is a 'confirmed_flake' when an in-job retry recovered it in the same run; 'quarantined' when it fails while masked as xfail; otherwise 'suspected_regression'. It qualifies on any recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
+ * The active test-health queue: backend tests worth acting on now, from the per-test CI spans, over a window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span or run attempt. A test is a 'confirmed_flake' when one commit both failed and passed it (a 'Re-run failed jobs' attempt went green, or an in-job retry recovered it); 'quarantined' when it fails while masked as xfail; otherwise 'suspected_regression'. It qualifies on any same-commit recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
*/
export const engineeringAnalyticsFlakyTests = async (
projectId: string,
@@ -746,7 +746,7 @@ export const getEngineeringAnalyticsTeamCiHealthUrl = (
}
/**
- * Per-owning-team rollup of the CI test surfaces each team owns, over the same run evidence as flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests an in-job retry recovered in the window, regression_test_count is owned tests that failed with no such proof and still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an equal-length previous-window twin for honest deltas. Ownership is stamped on the spans at CI emission time from the repo's ownership map (products/*\/product.yaml + CODEOWNERS); unstamped spans aggregate under the literal team 'unowned', and a re-stamped test lands under its latest owner only. Teams are organizational owners of code surfaces, never authors. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
+ * Per-owning-team rollup of the CI test surfaces each team owns, over the same run evidence as flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window, regression_test_count is owned tests that failed with no such proof and still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an equal-length previous-window twin for honest deltas. Ownership is stamped on the spans at CI emission time from the repo's ownership map (products/*\/product.yaml + CODEOWNERS); unstamped spans aggregate under the literal team 'unowned', and a re-stamped test lands under its latest owner only. Teams are organizational owners of code surfaces, never authors. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
*/
export const engineeringAnalyticsTeamCiHealth = async (
projectId: string,
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
index 3c96628cee59..96f83f82c47d 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTeams.tsx
@@ -67,7 +67,7 @@ export function EngineeringAnalyticsTeams(): JSX.Element {
width: 140,
align: 'right',
tooltip:
- 'Owned tests an in-job retry recovered in this window, vs the previous one. Only tests with that recovery proof count as flaky.',
+ 'Owned tests one commit was seen both failing and passing in this window, vs the previous one. Only tests with that recovery proof count as flaky.',
sorter: (a, b) => a.flakyTestCount - b.flakyTestCount,
render: (_, row) => <CountWithDelta current={row.flakyTestCount} prior={row.flakyTestCountPrior} />,
},
@@ -95,13 +95,14 @@ export function EngineeringAnalyticsTeams(): JSX.Element {
},
{
title: 'Recoveries',
- key: 'rerunPassedRunCount',
+ key: 'sameCommitRecoveryRunCount',
width: 130,
align: 'right',
- tooltip: 'Runs where an in-job retry recovered an owned test after it failed. This is what proves a flake.',
- sorter: (a, b) => a.rerunPassedRunCount - b.rerunPassedRunCount,
+ tooltip:
+ 'Runs where one commit both failed and passed an owned test (a re-run went green, or an in-job retry recovered it). This is what proves a flake.',
+ sorter: (a, b) => a.sameCommitRecoveryRunCount - b.sameCommitRecoveryRunCount,
render: (_, row) => (
- <CountWithDelta current={row.rerunPassedRunCount} prior={row.rerunPassedRunCountPrior} />
+ <CountWithDelta current={row.sameCommitRecoveryRunCount} prior={row.sameCommitRecoveryRunCountPrior} />
),
},
]
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx
index fccd466d65f5..5ea52b1390bc 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx
@@ -22,7 +22,7 @@ const FLAKY_TESTS: FlakyTestListApi = {
nodeid: 'posthog/api/test/test_decide/TestDecide::test_flag_rollout_consistency',
selector: 'posthog/api/test/test_decide.py::TestDecide::test_flag_rollout_consistency',
classification: 'confirmed_flake',
- rerun_passed_run_count: 6,
+ same_commit_recovery_run_count: 6,
failed_run_count: 8,
failed_pr_count: 3,
master_failed_run_count: 2,
@@ -33,7 +33,7 @@ const FLAKY_TESTS: FlakyTestListApi = {
nodeid: 'posthog/tasks/test/test_usage_report/TestUsageReport::test_full_report',
selector: 'posthog/tasks/test/test_usage_report.py::TestUsageReport::test_full_report',
classification: 'suspected_regression',
- rerun_passed_run_count: 0,
+ same_commit_recovery_run_count: 0,
failed_run_count: 9,
failed_pr_count: 4,
master_failed_run_count: 5,
@@ -44,7 +44,7 @@ const FLAKY_TESTS: FlakyTestListApi = {
nodeid: 'posthog/hogql/test/test_resolver/TestResolver::test_asterisk_expander',
selector: 'posthog/hogql/test/test_resolver.py::TestResolver::test_asterisk_expander',
classification: 'quarantined',
- rerun_passed_run_count: 0,
+ same_commit_recovery_run_count: 0,
failed_run_count: 1,
failed_pr_count: 1,
master_failed_run_count: 0,
@@ -55,7 +55,7 @@ const FLAKY_TESTS: FlakyTestListApi = {
nodeid: 'posthog/temporal/tests/batch_exports/test_backfill::test_workflow_timeout',
selector: 'posthog/temporal/tests/batch_exports/test_backfill.py::test_workflow_timeout',
classification: 'confirmed_flake',
- rerun_passed_run_count: 1,
+ same_commit_recovery_run_count: 1,
failed_run_count: 1,
failed_pr_count: 1,
master_failed_run_count: 0,
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx
index c5c37622dc84..c3d0357f117c 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx
@@ -347,7 +347,7 @@ const FLAKY_CLASSIFICATION: Record<FlakyTestClassification, { label: string; typ
label: 'Confirmed flake',
type: 'warning',
tooltip:
- 'A retry recovered this test in the same run, so the failure is nondeterministic. Fix it, or quarantine it while you do.',
+ 'One commit both failed and passed this test, so the failure is nondeterministic. Fix it, or quarantine it while you do.',
},
suspected_regression: {
label: 'Suspected regression',
@@ -407,8 +407,8 @@ function ActiveTestHealthQueue(): JSX.Element {
{/* An xfail row has no recovery question to answer: it is masked, not racing. */}
{row.classification !== 'quarantined' && (
<span className="text-secondary">
- {row.rerunPassedRunCount > 0
- ? `A retry recovered it in ${pluralize(row.rerunPassedRunCount, 'run')}`
+ {row.sameCommitRecoveryRunCount > 0
+ ? `Recovered on the same commit in ${pluralize(row.sameCommitRecoveryRunCount, 'run')}`
: 'No recovery recorded'}
</span>
)}
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
index dde1624e0611..89ac88a52e56 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts
@@ -455,8 +455,8 @@ export interface FlakyTestRow {
/** Runnable pytest selector for the quarantine action; exact when the CI reporter emitted it. */
selector: string
classification: FlakyTestClassification
- /** Runs where an in-job retry recovered the test after failing: the only proof of flakiness here. */
- rerunPassedRunCount: number
+ /** Runs where one commit both failed and passed the test (re-run attempt or in-job retry): the flake proof. */
+ sameCommitRecoveryRunCount: number
failedRunCount: number
failedPrCount: number
masterFailedRunCount: number
@@ -559,8 +559,8 @@ export interface QuarantineModalState {
export function flakyEvidenceReason(row: FlakyTestRow, window: FlakyTestWindow): string {
const windowLabel = { '-7d': '7 days', '-14d': '14 days', '-30d': '30 days' }[window]
const parts: string[] = []
- if (row.rerunPassedRunCount > 0) {
- parts.push(`recovered on retry in ${pluralize(row.rerunPassedRunCount, 'run')}`)
+ if (row.sameCommitRecoveryRunCount > 0) {
+ parts.push(`recovered on the same commit in ${pluralize(row.sameCommitRecoveryRunCount, 'run')}`)
}
if (row.failedRunCount > 0) {
parts.push(`failed in ${pluralize(row.failedRunCount, 'run')}`)
@@ -1183,7 +1183,7 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTy
nodeid: it.nodeid,
selector: it.selector,
classification: it.classification,
- rerunPassedRunCount: it.rerun_passed_run_count,
+ sameCommitRecoveryRunCount: it.same_commit_recovery_run_count,
failedRunCount: it.failed_run_count,
failedPrCount: it.failed_pr_count,
masterFailedRunCount: it.master_failed_run_count,
diff --git a/products/engineering_analytics/frontend/scenes/teamsLogic.ts b/products/engineering_analytics/frontend/scenes/teamsLogic.ts
index edfabf13dc98..bcf120d27fda 100644
--- a/products/engineering_analytics/frontend/scenes/teamsLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/teamsLogic.ts
@@ -39,8 +39,8 @@ export interface TeamCIHealthRow {
regressionTestCountPrior: number
failedRunCount: number
failedRunCountPrior: number
- rerunPassedRunCount: number
- rerunPassedRunCountPrior: number
+ sameCommitRecoveryRunCount: number
+ sameCommitRecoveryRunCountPrior: number
}
export interface TeamsData {
@@ -115,8 +115,8 @@ export const teamsLogic = kea<teamsLogicType>([
regressionTestCountPrior: it.regression_test_count_prior,
failedRunCount: it.failed_run_count,
failedRunCountPrior: it.failed_run_count_prior,
- rerunPassedRunCount: it.rerun_passed_run_count,
- rerunPassedRunCountPrior: it.rerun_passed_run_count_prior,
+ sameCommitRecoveryRunCount: it.same_commit_recovery_run_count,
+ sameCommitRecoveryRunCountPrior: it.same_commit_recovery_run_count_prior,
})
),
truncated: data.truncated,
diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yaml
index 7a4c58ad0aa7..e492aac08cd5 100644
--- a/products/engineering_analytics/mcp/tools.yaml
+++ b/products/engineering_analytics/mcp/tools.yaml
@@ -84,15 +84,16 @@ tools:
Backend 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, and this data only sees Backend CI. Evidence is counted per CI run, never per span, because one run
- fans a test across matrix legs. classification is confirmed_flake only when an in-job pytest retry recovered
- the test in the same run (rerun_passed_run_count > 0), which is the only proof of flakiness here and reaches
- only tests hand-marked @pytest.mark.flaky(reruns=N). quarantined means the test fails while masked as xfail.
+ rates, and this data only sees Backend CI. 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 the test fails while masked as xfail.
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 recovery, any master/main
- failure, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are absolute,
- never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test; nodeid
- is only the stable grouping key.
+ break: treat it as real until a recovery proves otherwise. A test qualifies on any same-commit recovery, any
+ master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are
+ absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the
+ test; nodeid is only the stable grouping key.
feature_flag: engineering-analytics
engineering-analytics-job-aggregates:
operation: engineering_analytics_job_aggregates
@@ -200,17 +201,17 @@ tools:
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 an in-job retry recovered in the window (the only flake
- proof this data carries), 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 / rerun_passed_run_count /
- quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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.
+ 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 / quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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-analytics
engineering-analytics-team-merge-trend:
operation: engineering_analytics_team_merge_trend
diff --git a/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md b/products/engineering_analytics/skills/diagnosing-ci-and-merge-bottlenecks/SKILL.md
index 44ac8ad468b0..d7dd52df2a95 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
@@ -38,14 +38,16 @@ autonomous agents (e.g. PostHog Code) reasoning about their own PRs.
pair **per workflow run** (many on a multi-workflow repo, interleaved by time), then merged/closed. Answers
"where is PR N stuck". `metric_quality` is `partial`.
- **`engineering-analytics-flaky-tests`** — the active test-health queue from the per-test CI spans, over a
- window (`date_from` default `-7d`, max 30 days). Evidence is counted per CI run, never per span. `classification`
- is `confirmed_flake` only where the evidence proves nondeterminism (`rerun_passed_run_count > 0`, an
- in-job retry recovered it); `quarantined` means failing while masked as xfail; `suspected_regression` means only
- failures were recorded, which is absence of proof, not proof of a real break. A test qualifies on any recovery,
- an xfail, any master/main failure, or failures on ≥ `min_failed_prs` distinct PRs (`failed_pr_count`). Answers
- "what is this failing test costing us" and picks quarantine candidates. **It does not answer "which tests are
- flaky"**: this queue only sees Backend CI and only proves a flake for tests hand-marked
- `@pytest.mark.flaky(reruns=N)`. Counts are absolute signal, never rates: passing runs are mostly not
+ window (`date_from` default `-7d`, max 30 days). Evidence is counted per CI run, never per span or run attempt.
+ `classification` is `confirmed_flake` only where the evidence proves nondeterminism
+ (`same_commit_recovery_run_count > 0`: one commit both failed and passed the test, via a "Re-run failed jobs"
+ attempt going green or an in-job retry); `quarantined` means failing while masked as xfail;
+ `suspected_regression` means only failures were recorded, which is absence of proof, not proof of a real break.
+ A test qualifies on any same-commit recovery, an xfail, any master/main failure, or failures on ≥
+ `min_failed_prs` distinct PRs (`failed_pr_count`). Answers "what is this failing test costing us" and picks
+ quarantine candidates. **It does not answer "which tests are flaky"**: this queue only sees Backend CI, and
+ recovery proof only arrives when someone re-runs failed jobs (or a 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.
There is no aggregate time-to-merge tool and no "counts" tool — derive those from `pull-requests` (the stuck/failing
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 74bf66af7fb5..2a939cb4af3c 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -3146,7 +3146,7 @@
"feature_flag": "engineering-analytics"
},
"engineering-analytics-flaky-tests": {
- "description": "Backend 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, and this data only sees Backend CI. Evidence is counted per CI run, never per span, because one run fans a test across matrix legs. classification is confirmed_flake only when an in-job pytest retry recovered the test in the same run (rerun_passed_run_count > 0), which is the only proof of flakiness here and reaches only tests hand-marked @pytest.mark.flaky(reruns=N). quarantined means the test fails while masked as xfail. 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 recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test; nodeid is only the stable grouping key.",
+ "description": "Backend 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, and this data only sees Backend CI. 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 the test fails while masked as xfail. 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, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test; nodeid is only the stable grouping key.",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "Active test health queue",
@@ -3206,7 +3206,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 an in-job retry recovered in the window (the only flake proof this data carries), 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 / rerun_passed_run_count / quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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 / quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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.json
index c6daa3152387..1e2b2f3fe00a 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -3189,7 +3189,7 @@
"feature_flag": "engineering-analytics"
},
"engineering-analytics-flaky-tests": {
- "description": "Backend 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, and this data only sees Backend CI. Evidence is counted per CI run, never per span, because one run fans a test across matrix legs. classification is confirmed_flake only when an in-job pytest retry recovered the test in the same run (rerun_passed_run_count > 0), which is the only proof of flakiness here and reaches only tests hand-marked @pytest.mark.flaky(reruns=N). quarantined means the test fails while masked as xfail. 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 recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test; nodeid is only the stable grouping key.",
+ "description": "Backend 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, and this data only sees Backend CI. 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 the test fails while masked as xfail. 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, an xfail, or failures on at least min_failed_prs distinct PRs (default 3). Counts are absolute, never rates, because fast passing runs are not emitted. Use selector to run or quarantine the test; nodeid is only the stable grouping key.",
"category": "Engineering analytics",
"feature": "engineering_analytics",
"summary": "Active test health queue",
@@ -3249,7 +3249,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 an in-job retry recovered in the window (the only flake proof this data carries), 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 / rerun_passed_run_count / quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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 / quarantined_failed_run_count are run counts. 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 (products/*/product.yaml + CODEOWNERS); 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. 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.ts
index 97436e77772b..8c042f281e2a 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -31559,14 +31559,14 @@ export namespace Schemas {
nodeid: string;
/** Runnable pytest selector, e.g. 'posthog/api/test/test_event.py::TestEvents::test_x'. Exact when the CI reporter emitted it; otherwise reconstructed from the nodeid, where the file/class boundary is a best-effort guess. */
selector: string;
- /** confirmed_flake: an in-job retry recovered the test in the same run, so it is provably nondeterministic. quarantined: it fails while masked as xfail. suspected_regression: only failures were recorded, which is absence of proof, not proof that it is a real break.
+ /** confirmed_flake: one commit both failed and passed the test (a re-run attempt went green, or an in-job retry recovered it), so it is provably nondeterministic. quarantined: it fails while masked as xfail. suspected_regression: only failures were recorded, which is absence of proof, not proof that it is a real break.
*
* * `confirmed_flake` - CONFIRMED_FLAKE
* * `suspected_regression` - SUSPECTED_REGRESSION
* * `quarantined` - QUARANTINED */
classification: FlakyTestItemClassificationEnum;
- /** Runs where an in-job pytest retry recovered the test after it failed. Above zero is the only proof of flakiness this data carries, and it reaches only tests hand-marked @pytest.mark.flaky(reruns=N), since Backend CI runs without --reruns so failures stay visible. */
- rerun_passed_run_count: number;
+ /** Runs where one commit both failed and passed the test: 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. A pass in a different run is a different commit and never counts. */
+ same_commit_recovery_run_count: number;
/** Distinct CI runs whose recorded outcome was failed or error. A run counts once however many matrix legs it failed in. */
failed_run_count: number;
/** Distinct pull requests among the failed runs. Failures on master or unattributed branches carry no PR number and are excluded here (still in failed_run_count). */
@@ -68445,11 +68445,11 @@ export namespace Schemas {
export interface TeamCIHealthItem {
/** Owning team slug (the CODEOWNERS handle minus '@PostHog/', e.g. 'team-replay'), or the literal 'unowned' for tests whose spans carry no ownership stamp. */
owner_team: string;
- /** Owned tests an in-job retry recovered in the window: the same proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the delta. */
+ /** Owned tests one commit was seen both failing and passing in the window: the same proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the delta. */
flaky_test_count: number;
/** Same count over the equal-length window immediately before date_from. */
flaky_test_count_prior: number;
- /** Owned tests that failed with no recorded in-run recovery and still hit the blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence of proof, not proof. */
+ /** Owned tests that failed with no recorded same-commit recovery and still hit the blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence of proof, not proof. */
regression_test_count: number;
/** Same count over the prior window. */
regression_test_count_prior: number;
@@ -68457,10 +68457,10 @@ export namespace Schemas {
failed_run_count: number;
/** Same count over the prior window. */
failed_run_count_prior: number;
- /** Runs where an in-job pytest retry recovered an owned test after it failed. */
- rerun_passed_run_count: number;
+ /** Runs where one commit both failed and passed an owned test: a re-run attempt went green, or an in-job retry recovered it. */
+ same_commit_recovery_run_count: number;
/** Same count over the prior window. */
- rerun_passed_run_count_prior: number;
+ same_commit_recovery_run_count_prior: number;
/** Runs where an owned test failed while quarantined (xfail): masked in CI, still failing. */
quarantined_failed_run_count: number;
/** Same count over the prior window. */
diff --git a/services/mcp/src/generated/engineering_analytics/api.ts b/services/mcp/src/generated/engineering_analytics/api.ts
index d5d31e2cc7ee..9429749ec68c 100644
--- a/services/mcp/src/generated/engineering_analytics/api.ts
+++ b/services/mcp/src/generated/engineering_analytics/api.ts
@@ -57,7 +57,7 @@ export const EngineeringAnalyticsCiFailureLogsQueryParams = /* @__PURE__ */ zod.
})
/**
- * The active test-health queue: backend tests worth acting on now, from the per-test CI spans, over a window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span. A test is a 'confirmed_flake' when an in-job retry recovered it in the same run; 'quarantined' when it fails while masked as xfail; otherwise 'suspected_regression'. It qualifies on any recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
+ * The active test-health queue: backend tests worth acting on now, from the per-test CI spans, over a window (default -7d, maximum 30 days). Evidence is counted per CI run, never per span or run attempt. A test is a 'confirmed_flake' when one commit both failed and passed it (a 'Re-run failed jobs' attempt went green, or an in-job retry recovered it); 'quarantined' when it fails while masked as xfail; otherwise 'suspected_regression'. It qualifies on any same-commit recovery, any master/main failure, an xfail, or failures on at least min_failed_prs distinct PRs. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
*/
export const EngineeringAnalyticsFlakyTestsParams = /* @__PURE__ */ zod.object({
project_id: zod
@@ -207,7 +207,7 @@ export const EngineeringAnalyticsSourcesParams = /* @__PURE__ */ zod.object({
})
/**
- * Per-owning-team rollup of the CI test surfaces each team owns, over the same run evidence as flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests an in-job retry recovered in the window, regression_test_count is owned tests that failed with no such proof and still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an equal-length previous-window twin for honest deltas. Ownership is stamped on the spans at CI emission time from the repo's ownership map (products/*\/product.yaml + CODEOWNERS); unstamped spans aggregate under the literal team 'unowned', and a re-stamped test lands under its latest owner only. Teams are organizational owners of code surfaces, never authors. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
+ * Per-owning-team rollup of the CI test surfaces each team owns, over the same run evidence as flaky_tests and with the same meaning of flaky: flaky_test_count is owned tests one commit was seen both failing and passing in the window, regression_test_count is owned tests that failed with no such proof and still hit the blast-radius bar, plus failed/recovery/quarantined run counts. Each has an equal-length previous-window twin for honest deltas. Ownership is stamped on the spans at CI emission time from the repo's ownership map (products/*\/product.yaml + CODEOWNERS); unstamped spans aggregate under the literal team 'unowned', and a re-stamped test lands under its latest owner only. Teams are organizational owners of code surfaces, never authors. Counts are absolute, never rates: CI emits a span for every failure but only for passes slow enough to clear the emitter's duration threshold, so there is no execution denominator. 'suspected_regression' means no recovery was recorded in this data, not that the test never flakes.
*/
export const EngineeringAnalyticsTeamCiHealthParams = /* @__PURE__ */ zod.object({
project_id: zod