:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(eng-analytics): stop silent query truncation (#95096)
Raúl Negrón-Otero92fb76ef47c2
diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex fe995db0718c..d56743075396 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -706,6 +706,9 @@ class TrunkQuarantineDebt:trunk_url: str | Noneteams: list[TrunkQuarantineTeamDebt]tests: list[TrunkQuarantinedTest]+ # ``teams`` rolls up only the returned ``tests``, so when ``truncated`` its counts are lower bounds.+ truncated: bool+ limit: int@dataclass(frozen=True)diff --git a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py b/products/engineering_analytics/backend/logic/queries/_workflow_filters.pyindex 5f90699c57c1..5e498d7885de 100644--- a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py+++ b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py@@ -7,11 +7,16 @@ source as ``FROM __RUNS_SOURCE__ AS r`` (or joins it as ``r``).from datetime import datetime, timedeltafrom posthog.hogql import ast+from posthog.hogql.constants import MAX_SELECT_RETURNED_ROWSfrom posthog.dataclasses import frozenfrom products.engineering_analytics.backend.facade.contracts import WorkflowHealthRunScope+# HogQL caps a query that names no LIMIT at 100 rows and clamps any larger LIMIT to this ceiling. Reads+# bounded by the repo's shape (workflows, job names, a PR's runs) rather than by a page size take it whole.+UNPAGED_SCAN_LIMIT = MAX_SELECT_RETURNED_ROWS+# Trunk's merge-queue batch branches. Trunk-specific and hardcoded like KNOWN_BOT_HANDLES;# defined once here so every surface breaks queue spend out with the same key.MERGE_QUEUE_BRANCH_PREFIX = "trunk-merge/"diff --git a/products/engineering_analytics/backend/logic/queries/broken_tests.py b/products/engineering_analytics/backend/logic/queries/broken_tests.pyindex 6e832f3c7f77..48fe180c9767 100644--- a/products/engineering_analytics/backend/logic/queries/broken_tests.py+++ b/products/engineering_analytics/backend/logic/queries/broken_tests.py@@ -44,7 +44,10 @@ from products.engineering_analytics.backend.facade.contracts import ()from products.engineering_analytics.backend.logic.merge_queue import looks_like_merge_queue_branch_exprfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource-from products.engineering_analytics.backend.logic.queries._workflow_filters import job_created_floor_constant+from products.engineering_analytics.backend.logic.queries._workflow_filters import (+ UNPAGED_SCAN_LIMIT,+ job_created_floor_constant,+)from products.engineering_analytics.backend.logic.views import ci_failures# Branch names treated as trunk — the failure "hit master" and job-status filters key on these.@@ -111,14 +114,15 @@ _FINGERPRINTS_SELECT = """# hour was (0 = current hour). Bounded to the fingerprints we actually kept ({fingerprints}) so a repo# with thousands of distinct 24h failures doesn't scan+group them all just to fill ~200 sparklines;# folded into a fixed array per fingerprint below.-_HOURLY_SELECT = """+_HOURLY_SELECT = f"""SELECTfingerprint,dateDiff('hour', toStartOfHour(timestamp), toStartOfHour(now())) AS hours_ago,count() AS cFROM __FAILURES_SOURCE__- WHERE timestamp >= {hourly_from} AND lower(repo) = lower({repository}) AND fingerprint IN {fingerprints}+ WHERE timestamp >= {{hourly_from}} AND lower(repo) = lower({{repository}}) AND fingerprint IN {{fingerprints}}GROUP BY fingerprint, hours_ago+ LIMIT {UNPAGED_SCAN_LIMIT}"""# Latest default-branch status per (workflow, job), from the curated workflow-jobs source. Keyed by@@ -130,16 +134,17 @@ _HOURLY_SELECT = """# real recovery. ``latest_conclusion`` is that newest-finishing completed run's conclusion (red =# broken now); ``latest_completed_age`` is how long ago it finished, so the classifier can tell a# genuine recovery from a stale-green row the logs have already overtaken.-_MASTER_JOBS_SELECT = """+_MASTER_JOBS_SELECT = f"""SELECTworkflow_name,name AS job_name,argMaxIf(conclusion, completed_at, status = 'completed') AS latest_conclusion,dateDiff('second', maxIf(completed_at, status = 'completed'), now()) AS latest_completed_ageFROM __JOBS_SOURCE__- WHERE head_branch IN {default_branches}- AND created_at >= {date_from}+ WHERE head_branch IN {{default_branches}}+ AND created_at >= {{date_from}}GROUP BY workflow_name, name+ LIMIT {UNPAGED_SCAN_LIMIT}"""diff --git a/products/engineering_analytics/backend/logic/queries/census_counts.py b/products/engineering_analytics/backend/logic/queries/census_counts.pyindex d3fbf6b48760..034c3281d01c 100644--- a/products/engineering_analytics/backend/logic/queries/census_counts.py+++ b/products/engineering_analytics/backend/logic/queries/census_counts.py@@ -8,22 +8,24 @@ from posthog.hogql import astfrom products.engineering_analytics.backend.logic._shared import WindowedCountfrom products.engineering_analytics.backend.logic.census import CENSUS_EVENTfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource+from products.engineering_analytics.backend.logic.queries._workflow_filters import UNPAGED_SCAN_LIMIT-_SELECT = """+_SELECT = f"""SELECTtoString(properties.owner_team) AS owner_team,argMax(accurateCastOrNull(properties.test_file_count, 'Int64'), timestamp) AS test_file_count,argMaxIf(accurateCastOrNull(properties.test_file_count, 'Int64'),timestamp,- timestamp < {date_from}+ timestamp < {{date_from}}) AS test_file_count_priorFROM events- WHERE event = {census_event}- AND properties.repository = {repository}- AND timestamp >= {scan_from}- AND timestamp <= {date_to}+ WHERE event = {{census_event}}+ AND properties.repository = {{repository}}+ AND timestamp >= {{scan_from}}+ AND timestamp <= {{date_to}}GROUP BY owner_team+ LIMIT {UNPAGED_SCAN_LIMIT}"""diff --git a/products/engineering_analytics/backend/logic/queries/current_branch_health.py b/products/engineering_analytics/backend/logic/queries/current_branch_health.pyindex 3838f5c77e02..be8170aca8e2 100644--- a/products/engineering_analytics/backend/logic/queries/current_branch_health.py+++ b/products/engineering_analytics/backend/logic/queries/current_branch_health.py@@ -6,7 +6,10 @@ from posthog.hogql import astfrom products.engineering_analytics.backend.facade.contracts import CurrentBranchHealthfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource-from products.engineering_analytics.backend.logic.queries._workflow_filters import LATEST_COMPLETED_RUN_FAILED+from products.engineering_analytics.backend.logic.queries._workflow_filters import (+ LATEST_COMPLETED_RUN_FAILED,+ UNPAGED_SCAN_LIMIT,+)_FAILING_NAME_LIMIT = 20@@ -18,6 +21,7 @@ _SELECT = f"""FROM __RUNS_SOURCE__ AS rWHERE run_started_at >= {{date_from}} AND head_branch = {{branch}}GROUP BY workflow_name+ LIMIT {UNPAGED_SCAN_LIMIT}"""diff --git a/products/engineering_analytics/backend/logic/queries/job_aggregates.py b/products/engineering_analytics/backend/logic/queries/job_aggregates.pyindex 5211fc02cbcc..b40f597e199b 100644--- a/products/engineering_analytics/backend/logic/queries/job_aggregates.py+++ b/products/engineering_analytics/backend/logic/queries/job_aggregates.py@@ -21,6 +21,7 @@ from products.engineering_analytics.backend.facade.contracts import WorkflowHealfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource, opt_floatfrom products.engineering_analytics.backend.logic.queries._workflow_filters import (DURATION_PERCENTILE_CONDITION,+ UNPAGED_SCAN_LIMIT,branch_filter_clause,cost_run_scope_filter_clause,date_to_filter_clause,@@ -81,6 +82,7 @@ _COST_SELECT = f"""WHERE workflow_name = {{workflow_name}} AND created_at >= {{date_from}} __DATE_TO__ __BRANCH____COST_RUN_SCOPE__GROUP BY job_name+ LIMIT {UNPAGED_SCAN_LIMIT}"""_RUNS_WINDOW = (diff --git a/products/engineering_analytics/backend/logic/queries/master_failures.py b/products/engineering_analytics/backend/logic/queries/master_failures.pyindex 4cec51754784..23d1e14f14b1 100644--- a/products/engineering_analytics/backend/logic/queries/master_failures.py+++ b/products/engineering_analytics/backend/logic/queries/master_failures.py@@ -20,10 +20,11 @@ from products.engineering_analytics.backend.facade.contracts import MasterFailurfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSourcefrom products.engineering_analytics.backend.logic.queries._workflow_filters import (DECISIVE_FAILURE_CONCLUSIONS_SQL,+ UNPAGED_SCAN_LIMIT,run_windowed_job_created_floor_constant,)-# Failed default-branch runs in the window is a triage view, not an archive — cap it.+# Failed default-branch runs in the window is a triage view, not an archive, so cap it._RUN_CAP = 500_FAILED_RUNS_SELECT = f"""@@ -40,6 +41,7 @@ _FAILED_JOBS_SELECT = f"""SELECT run_id, nameFROM __JOBS_SOURCE__ AS jWHERE run_id IN {{run_ids}} AND conclusion IN ({DECISIVE_FAILURE_CONCLUSIONS_SQL})+ LIMIT {UNPAGED_SCAN_LIMIT}"""# Trailing "(G/N)" shard suffix, incl. nested parens ("Product tests (experiments (1/2))") —diff --git a/products/engineering_analytics/backend/logic/queries/pr_lifecycle.py b/products/engineering_analytics/backend/logic/queries/pr_lifecycle.pyindex f10dcf9654d4..fd43c945dfa6 100644--- a/products/engineering_analytics/backend/logic/queries/pr_lifecycle.py+++ b/products/engineering_analytics/backend/logic/queries/pr_lifecycle.py@@ -23,6 +23,7 @@ from products.engineering_analytics.backend.facade.contracts import ()from products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSourcefrom products.engineering_analytics.backend.logic.queries._pr_header import pr_header_placeholders, pr_header_query+from products.engineering_analytics.backend.logic.queries._workflow_filters import UNPAGED_SCAN_LIMITfrom products.engineering_analytics.backend.logic.views import issue_events# The curated subqueries and the repo filter are filled with str.replace (trusted@@ -36,20 +37,23 @@ _HEADER = pr_header_query(""")-_RUNS = """+# Newest first, so a PR past the cap loses its oldest rows; the caller restores chronological order.+_RUNS = f"""SELECT id, workflow_name, status, conclusion, run_started_at, updated_atFROM __RUNS_SOURCE__ AS r- WHERE head_sha = {head_sha}- ORDER BY run_started_at ASC+ WHERE head_sha = {{head_sha}}+ ORDER BY run_started_at DESC+ LIMIT {UNPAGED_SCAN_LIMIT}"""# pr_number alone is the key: a resolved table set is a single repo's, the same repo the# PR header was resolved from.-_STATE_EVENTS = """+_STATE_EVENTS = f"""SELECT event, created_at, actor_loginFROM __STATE_EVENTS_SOURCE__ AS se- WHERE pr_number = {pr_number}- ORDER BY created_at ASC, id ASC+ WHERE pr_number = {{pr_number}}+ ORDER BY created_at DESC, id DESC+ LIMIT {UNPAGED_SCAN_LIMIT}"""_STATE_EVENT_KINDS = {@@ -132,7 +136,7 @@ def query_pr_lifecycle(query_type="engineering_analytics.pr_lifecycle.state_events",placeholders={"pr_number": ast.Constant(value=pr_number)},)- for event, at, actor_login in transitions.results:+ for event, at, actor_login in reversed(transitions.results):kind = _STATE_EVENT_KINDS.get(event)if kind is not None:add(kind, at, detail=actor_login or None)@@ -147,7 +151,7 @@ def query_pr_lifecycle(else None)if runs is not None:- for run_id, workflow_name, status, conclusion, run_started_at, updated_at in runs.results:+ for run_id, workflow_name, status, conclusion, run_started_at, updated_at in reversed(runs.results):run_id = int(run_id) if run_id is not None else Noneadd(PRLifecycleEventKind.CI_STARTED, run_started_at, detail=workflow_name, run_id=run_id)if status == "completed":diff --git a/products/engineering_analytics/backend/logic/queries/team_merged_prs.py b/products/engineering_analytics/backend/logic/queries/team_merged_prs.pyindex 07d3fac7915a..9d11bbbbeddb 100644--- a/products/engineering_analytics/backend/logic/queries/team_merged_prs.py+++ b/products/engineering_analytics/backend/logic/queries/team_merged_prs.py@@ -8,19 +8,21 @@ from posthog.hogql import astfrom products.engineering_analytics.backend.logic._shared import WindowedCountfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource+from products.engineering_analytics.backend.logic.queries._workflow_filters import UNPAGED_SCAN_LIMIT-_SELECT = """+_SELECT = f"""SELECTmembers.team_slug AS owner_team,- countIf(pr.merged_at >= {date_from}) AS merged_pr_count,- countIf(pr.merged_at < {date_from}) AS merged_pr_count_prior+ countIf(pr.merged_at >= {{date_from}}) AS merged_pr_count,+ countIf(pr.merged_at < {{date_from}}) AS merged_pr_count_priorFROM __PR_SOURCE__ AS prJOIN __MEMBERS_SOURCE__ AS members ON pr.author_handle = members.member_handleWHERE pr.merged_at IS NOT NULL- AND pr.merged_at >= {scan_from}- AND pr.merged_at <= {date_to}+ AND pr.merged_at >= {{scan_from}}+ AND pr.merged_at <= {{date_to}}AND NOT pr.is_botGROUP BY owner_team+ LIMIT {UNPAGED_SCAN_LIMIT}"""diff --git a/products/engineering_analytics/backend/logic/queries/trunk_quarantine.py b/products/engineering_analytics/backend/logic/queries/trunk_quarantine.pyindex e8ec2677a300..243bd930c5c0 100644--- a/products/engineering_analytics/backend/logic/queries/trunk_quarantine.py+++ b/products/engineering_analytics/backend/logic/queries/trunk_quarantine.py@@ -16,9 +16,14 @@ from products.engineering_analytics.backend.facade.contracts import (from products.engineering_analytics.backend.logic.ownership import QuarantinedTestFile, resolve_test_ownershipfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource-_QUARANTINED_SELECT = """+# Oldest first, so a repo past the cap keeps the debt that has aged past its TTL.+_LIMIT = 5000++_QUARANTINED_SELECT = f"""SELECT runner, nodeid, source_path, crate, status, quarantine_setting, test_case_id, quarantined_atFROM __TRUNK_SOURCE__+ ORDER BY quarantined_at ASC, nodeid ASC+ LIMIT {_LIMIT + 1}"""@@ -54,6 +59,8 @@ def query_trunk_quarantine_debt(trunk_url=None,teams=[],tests=[],+ truncated=False,+ limit=_LIMIT,)org_url_slug = curated.trunk_org_url_slug()trunk_url = _trunk_url(org_url_slug, curated.repository)@@ -64,6 +71,8 @@ def query_trunk_quarantine_debt(placeholders={},)rows = quarantined.results or []+ truncated = len(rows) > _LIMIT+ rows = rows[:_LIMIT]if not rows:return TrunkQuarantineDebt(available=True,@@ -73,6 +82,8 @@ def query_trunk_quarantine_debt(trunk_url=trunk_url,teams=[],tests=[],+ truncated=False,+ limit=_LIMIT,)parsed = [@@ -125,4 +136,6 @@ def query_trunk_quarantine_debt(trunk_url=trunk_url,teams=teams,tests=tests,+ truncated=truncated,+ limit=_LIMIT,)diff --git a/products/engineering_analytics/backend/logic/queries/workflow_health.py b/products/engineering_analytics/backend/logic/queries/workflow_health.pyindex 30ce3da39e7c..e06f215680c7 100644--- a/products/engineering_analytics/backend/logic/queries/workflow_health.py+++ b/products/engineering_analytics/backend/logic/queries/workflow_health.py@@ -44,6 +44,7 @@ from products.engineering_analytics.backend.logic.queries._workflow_filters impoLATEST_COMPLETED_RUN_FAILED,RUN_DURATION_PERCENTILE_CONDITION,SUCCESSFUL_RUN_CONDITION,+ UNPAGED_SCAN_LIMIT,branch_filter_clause,date_to_filter_clause,default_branch_predicate,@@ -86,9 +87,10 @@ _SELECT = f"""LIMIT {_LIMIT}"""-# Success rate over the equal-length window before date_from — the delta baseline the UI renders as+# Success rate over the equal-length window before date_from, the delta baseline the UI renders as# an honest Δpp instead of a server-baked percentage. Kept as its own slim scan so the main query's-# window (and its LIMIT semantics) stay untouched.+# window (and its LIMIT semantics) stay untouched. It is an unranked lookup, so capping it at _LIMIT+# would drop workflows _SELECT ranked and make them read as "no previous window"._PREV_SELECT = f"""SELECTrepo_owner,@@ -98,6 +100,7 @@ _PREV_SELECT = f"""FROM __RUNS_SOURCE__ AS rWHERE run_started_at >= {{prev_from}} AND run_started_at < {{date_from}} __BRANCH__ __RUN_SCOPE__GROUP BY repo_owner, repo_name, workflow_name+ LIMIT {UNPAGED_SCAN_LIMIT}"""# Merge-queue run counts over the same window with no branch/run_scope filter, so the list can rankdiff --git a/products/engineering_analytics/backend/presentation/serializers/suite_health.py b/products/engineering_analytics/backend/presentation/serializers/suite_health.pyindex 7d47a611b907..c81952eed2ff 100644--- a/products/engineering_analytics/backend/presentation/serializers/suite_health.py+++ b/products/engineering_analytics/backend/presentation/serializers/suite_health.py@@ -134,6 +134,11 @@ class TrunkQuarantineDebtSerializer(DataclassSerializer):"help_text": "The Trunk app's flaky-tests page for this repository; null when the connected ""source has no organization slug.",},+ "truncated": {+ "help_text": "True when more tests are quarantined than limit. The per-team counts then "+ "cover only the returned tests, so treat them as lower bounds.",+ },+ "limit": {"help_text": "Maximum tests returned, oldest quarantine first."},}diff --git a/products/engineering_analytics/backend/tests/test_logic_workflows.py b/products/engineering_analytics/backend/tests/test_logic_workflows.pyindex 315ab920d877..8bde45324185 100644--- a/products/engineering_analytics/backend/tests/test_logic_workflows.py+++ b/products/engineering_analytics/backend/tests/test_logic_workflows.py@@ -13,6 +13,7 @@ from products.engineering_analytics.backend.facade import apifrom products.engineering_analytics.backend.facade.contracts import DeliveryStagefrom products.engineering_analytics.backend.logic import build_workflow_healthfrom products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource+from products.engineering_analytics.backend.logic.queries._workflow_filters import UNPAGED_SCAN_LIMITfrom products.engineering_analytics.backend.logic.queries.pr_cost import query_cost_per_merge_seriesfrom products.engineering_analytics.backend.logic.sources import GitHubTablesfrom products.engineering_analytics.backend.logic.views.source_schema import (@@ -61,7 +62,8 @@ class TestWorkflowEndpointMapping(BaseTest):if query_type == "engineering_analytics.default_branch":return _resp([(0, 12)])assert query_type == "engineering_analytics.current_branch_health"- assert "LIMIT" not in sql.upper()+ # HogQL caps a query with no LIMIT at 100 rows, so the query must name the ceiling.+ assert f"LIMIT {UNPAGED_SCAN_LIMIT}" in sqlreturn _resp(workflow_rows)with mock.patch(_RUN_QUERY, side_effect=run):diff --git a/products/engineering_analytics/backend/tests/test_quarantine.py b/products/engineering_analytics/backend/tests/test_quarantine.pyindex 0b9bfcfbfca3..6823f896f42d 100644--- a/products/engineering_analytics/backend/tests/test_quarantine.py+++ b/products/engineering_analytics/backend/tests/test_quarantine.py@@ -17,6 +17,7 @@ from parameterized import parameterizedfrom rest_framework import statusfrom products.engineering_analytics.backend.facade import contracts+from products.engineering_analytics.backend.logic.ownership import PlacedTest, RepoOwnershipResultfrom products.engineering_analytics.backend.logic.quarantine import (QUARANTINE_FILENAME,_canonical_entry,@@ -30,8 +31,14 @@ from products.engineering_analytics.backend.logic.quarantine import (render_quarantine_file,request_quarantine,)+from products.engineering_analytics.backend.logic.queries.trunk_quarantine import (+ _LIMIT as QUARANTINE_LIMIT,+ query_trunk_quarantine_debt,+)from products.engineering_analytics.backend.presentation.serializers.suite_health import QuarantineRequestSerializer+_TRUNK_QUARANTINE = "products.engineering_analytics.backend.logic.queries.trunk_quarantine"+_TODAY = date(2026, 6, 12)_REQUESTS_GET = "products.engineering_analytics.backend.logic.quarantine.requests.get"_MAX_BYTES = "products.engineering_analytics.backend.logic.quarantine._MAX_QUARANTINE_BYTES"@@ -768,3 +775,61 @@ class TestQuarantineRequestValidation(SimpleTestCase):assert not serializer.is_valid()assert serializer.errors[field][0].code == code+++class _StubCurated:+ def __init__(self, rows: list[tuple[Any, ...]]) -> None:+ self.repository = "PostHog/posthog"+ self._rows = rows+ self.sql = ""++ def trunk_quarantined_tests_source(self) -> str:+ return "(SELECT 1)"++ def trunk_org_url_slug(self) -> str | None:+ return None++ def run(self, sql: str, **_kwargs: Any) -> SimpleNamespace:+ self.sql = sql+ return SimpleNamespace(results=self._rows)+++class TestTrunkQuarantineDebtTruncation(TestCase):+ @staticmethod+ def _rows(count: int) -> list[tuple[Any, ...]]:+ return [+ (+ "pytest",+ f"test_{index}",+ f"products/a/test_{index}.py",+ "",+ "quarantined",+ "always",+ f"case-{index}",+ datetime(2026, 1, 1, tzinfo=UTC),+ )+ for index in range(count)+ ]++ @parameterized.expand(+ [("under the cap", QUARANTINE_LIMIT - 1, False), ("over the cap", QUARANTINE_LIMIT + 1, True)]+ )+ def test_rollup_never_counts_more_tests_than_it_returns(self, _name: str, row_count: int, truncated: bool) -> None:+ curated = _StubCurated(self._rows(row_count))++ def place(_repository: str, tests: list[Any]) -> RepoOwnershipResult:+ return RepoOwnershipResult(tests=[PlacedTest(path="p", owner_team="team-a")] * len(tests), resolved=True)++ with mock.patch(f"{_TRUNK_QUARANTINE}.resolve_test_ownership", side_effect=place):+ debt = query_trunk_quarantine_debt(+ curated=curated, # type: ignore[arg-type]+ ttl_days=30,+ now=datetime(2026, 6, 1, tzinfo=UTC),+ )+ kept = min(row_count, QUARANTINE_LIMIT)++ assert f"LIMIT {QUARANTINE_LIMIT + 1}" in curated.sql+ assert debt.truncated is truncated+ assert debt.limit == QUARANTINE_LIMIT+ assert {test.nodeid for test in debt.tests} == {f"test_{index}" for index in range(kept)}+ assert sum(team.test_count for team in debt.teams) == keptdiff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex a12f29dc7baa..71c73d1dad09 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -1802,6 +1802,10 @@ export interface TrunkQuarantineDebtApi {* @nullable*/trunk_url: string | null+ /** True when more tests are quarantined than limit. The per-team counts then cover only the returned tests, so treat them as lower bounds. */+ truncated: boolean+ /** Maximum tests returned, oldest quarantine first. */+ limit: number}export interface WorkflowHealthBucketApi {diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsxindex ed484b37b10a..c4909ab81927 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.stories.tsx@@ -24,6 +24,8 @@ const TRUNK_QUARANTINE: TrunkQuarantineDebtApi = {available: true,owners_resolved: true,ttl_days: 15,+ truncated: false,+ limit: 5000,repository: 'PostHog/posthog',trunk_url: 'https://app.trunk.io/posthog-inc/flaky-tests?repo=PostHog/posthog',teams: [diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsxindex 30f6c5f006c8..52da2cb68d11 100644--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsTestHealth.tsx@@ -29,6 +29,8 @@ function TrunkQuarantineDebtBoard(): JSX.Element {const ttlDays = trunkQuarantine?.ttlDays ?? 15const overdueCount = trunkQuarantine ? trunkQuarantine.teams.reduce((n, t) => n + t.overdueCount, 0) : nullconst oldestAgeDays = trunkQuarantine?.tests.length ? trunkQuarantine.tests[0].ageDays : null+ const formatCappedCount = (count: number): string =>+ `${humanFriendlyNumber(count)}${trunkQuarantine?.truncated ? '+' : ''}`const teamColumns: LemonTableColumns<TrunkQuarantineTeamRow> = [{@@ -41,7 +43,7 @@ function TrunkQuarantineDebtBoard(): JSX.Element {key: 'testCount',align: 'right',sorter: (a, b) => a.testCount - b.testCount,- render: (_, row) => humanFriendlyNumber(row.testCount),+ render: (_, row) => formatCappedCount(row.testCount),},{title: 'Overdue',@@ -51,9 +53,9 @@ function TrunkQuarantineDebtBoard(): JSX.Element {sorter: (a, b) => a.overdueCount - b.overdueCount,render: (_, row) =>row.overdueCount > 0 ? (- <span className="font-semibold text-danger">{humanFriendlyNumber(row.overdueCount)}</span>+ <span className="font-semibold text-danger">{formatCappedCount(row.overdueCount)}</span>) : (- '0'+ formatCappedCount(0)),},{@@ -97,19 +99,19 @@ function TrunkQuarantineDebtBoard(): JSX.Element {<div className="grid grid-cols-1 gap-3 @2xl/main-content:grid-cols-2 @5xl/main-content:grid-cols-4"><StatCardlabel="Quarantined tests"- value={trunkQuarantine ? humanFriendlyNumber(trunkQuarantine.tests.length) : '—'}+ value={trunkQuarantine ? formatCappedCount(trunkQuarantine.tests.length) : '—'}caption="currently masked in CI"loading={trunkQuarantineLoading}/><StatCardlabel="Overdue"- value={overdueCount !== null ? humanFriendlyNumber(overdueCount) : '—'}+ value={overdueCount !== null ? formatCappedCount(overdueCount) : '—'}caption={`quarantined over ${ttlDays} days`}loading={trunkQuarantineLoading}/><StatCardlabel="Teams affected"- value={trunkQuarantine ? humanFriendlyNumber(trunkQuarantine.teams.length) : '—'}+ value={trunkQuarantine ? formatCappedCount(trunkQuarantine.teams.length) : '—'}caption="own at least one quarantined test"loading={trunkQuarantineLoading}/>@@ -120,6 +122,12 @@ function TrunkQuarantineDebtBoard(): JSX.Element {loading={trunkQuarantineLoading}/></div>+ {trunkQuarantine?.truncated && (+ <div className="text-xs text-tertiary">+ Showing the oldest {humanFriendlyNumber(trunkQuarantine.limit)} quarantined tests. The counts above+ are lower bounds.+ </div>+ )}{trunkQuarantine && !trunkQuarantine.ownersResolved && (<LemonBanner type="warning">We could not read {trunkQuarantine.repository}'s ownership files, so every test below is listed asdiff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.tsindex e8eb5239efed..65b38e61f789 100644--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts@@ -201,6 +201,8 @@ describe('engineeringAnalyticsLogic', () => {available: true,owners_resolved: true,ttl_days: 15,+ truncated: false,+ limit: 5000,repository: 'PostHog/posthog',trunk_url: null,teams: [],@@ -693,6 +695,8 @@ describe('engineeringAnalyticsLogic', () => {available: true,owners_resolved: true,ttl_days: 15,+ truncated: true,+ limit: 5000,repository: 'PostHog/posthog',trunk_url: 'https://app.trunk.io/posthog-inc/flaky-tests?repo=PostHog/posthog',teams: [{ owner_team: 'team-replay', test_count: 1, overdue_count: 1, oldest_age_days: 44 }],@@ -728,6 +732,8 @@ describe('engineeringAnalyticsLogic', () => {await expectLogic(logic).toDispatchActions(['loadTrunkQuarantineSuccess'])expect(logic.values.trunkQuarantine?.ttlDays).toBe(15)+ expect(logic.values.trunkQuarantine?.truncated).toBe(true)+ expect(logic.values.trunkQuarantine?.limit).toBe(5000)expect(logic.values.trunkQuarantine?.repository).toBe('PostHog/posthog')expect(logic.values.trunkQuarantine?.trunkUrl).toBe('https://app.trunk.io/posthog-inc/flaky-tests?repo=PostHog/posthog'diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.tsindex da023890ac6b..a2aca23c1e71 100644--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.ts@@ -377,6 +377,9 @@ export interface TrunkQuarantineData {trunkUrl: string | nullteams: TrunkQuarantineTeamRow[]tests: TrunkQuarantinedTestRow[]+ /** True when more tests are quarantined than `limit`; `tests` and the team counts are then lower bounds. */+ truncated: boolean+ limit: number}/**@@ -823,6 +826,8 @@ export const engineeringAnalyticsLogic: LogicWrapper<engineeringAnalyticsLogicTyttlDays: data.ttl_days,repository: data.repository,trunkUrl: data.trunk_url ?? null,+ truncated: data.truncated,+ limit: data.limit,teams: data.teams.map((it): TrunkQuarantineTeamRow => ({ownerTeam: it.owner_team,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 3091166c3d0c..0219e4fcb6b3 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -91023,6 +91023,10 @@ export namespace Schemas {* @nullable*/trunk_url: string | null;+ /** True when more tests are quarantined than limit. The per-team counts then cover only the returned tests, so treat them as lower bounds. */+ truncated: boolean;+ /** Maximum tests returned, oldest quarantine first. */+ limit: number;}export interface UnquarantineQuery {