: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(engineering-analytics): serve overview attention prs from server (#109165)
Raúl Negrón-Otero5d8858622e37
diff --git a/products/engineering_analytics/backend/facade/api.py b/products/engineering_analytics/backend/facade/api.pyindex 5ffbea87b09b..0157b3115a24 100644--- a/products/engineering_analytics/backend/facade/api.py+++ b/products/engineering_analytics/backend/facade/api.py@@ -24,6 +24,7 @@ from posthog.models.team import Teamfrom products.engineering_analytics.backend import logicfrom products.engineering_analytics.backend.facade.contracts import (+ AttentionPullRequestList,AuthorFrictionDetail,AuthorFrictionList,BranchPRMatch,@@ -441,6 +442,18 @@ def list_pull_requests()+def list_attention_pull_requests(+ *,+ team: Team,+ source_id: str | None = None,+ repo: str | None = None,+ user_access_control: "UserAccessControl | None" = None,+) -> AttentionPullRequestList:+ return logic.build_attention_pull_requests(+ curated=_authorized_source(team, source_id, user_access_control, repo=repo)+ )++def list_recently_merged_pull_requests(*,team: Team,diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex a4adeaf8a806..585b6932afde 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -947,6 +947,18 @@ class PullRequestList:limit: int+@dataclass(frozen=True)+class AttentionPullRequestList:+ """Open pull requests that need attention: failing CI, or stuck by the ``CICardSummary`` rule.+ Failing first, then newest. ``items`` holds at most ``limit``; ``total`` counts every match, so+ a consumer can say how many it did not show.+ """++ items: list[PullRequestListItem]+ total: int+ limit: int++@dataclass(frozen=True)class BranchPRMatch:"""A pull request a git branch resolves to — the cross-product link seam so a callerdiff --git a/products/engineering_analytics/backend/logic/__init__.py b/products/engineering_analytics/backend/logic/__init__.pyindex 839754d3a6f0..5de342e7ed0b 100644--- a/products/engineering_analytics/backend/logic/__init__.py+++ b/products/engineering_analytics/backend/logic/__init__.py@@ -37,6 +37,7 @@ from products.engineering_analytics.backend.logic.github_teams import (build_github_team_roster as build_github_team_roster,)from products.engineering_analytics.backend.logic.pull_requests import (+ build_attention_pull_requests as build_attention_pull_requests,build_author_workflow_costs as build_author_workflow_costs,build_ci_cards as build_ci_cards,build_ci_failure_logs as build_ci_failure_logs,diff --git a/products/engineering_analytics/backend/logic/pull_requests.py b/products/engineering_analytics/backend/logic/pull_requests.pyindex ce7b768f1994..eea0cf2c7e9e 100644--- a/products/engineering_analytics/backend/logic/pull_requests.py+++ b/products/engineering_analytics/backend/logic/pull_requests.py@@ -6,6 +6,7 @@ from datetime import datetimeimport structlogfrom products.engineering_analytics.backend.facade.contracts import (+ AttentionPullRequestList,BranchPRMatch,CICardSummary,CIFailureLogs,@@ -31,7 +32,10 @@ from products.engineering_analytics.backend.logic.queries.merged_pull_requests ifrom products.engineering_analytics.backend.logic.queries.pr_cost import query_author_workflow_costs, query_pr_costfrom products.engineering_analytics.backend.logic.queries.pr_lifecycle import query_pr_lifecyclefrom products.engineering_analytics.backend.logic.queries.pr_runs import query_pr_runs-from products.engineering_analytics.backend.logic.queries.pull_request_list import query_pull_request_list+from products.engineering_analytics.backend.logic.queries.pull_request_list import (+ query_attention_pull_requests,+ query_pull_request_list,+)from products.engineering_analytics.backend.logic.queries.resolve_branch import query_resolve_branchlogger = structlog.get_logger(__name__)@@ -107,6 +111,10 @@ def build_pull_request_list(return query_pull_request_list(curated=curated, date_from=parsed_from, author=author)+def build_attention_pull_requests(*, curated: CuratedGitHubSource) -> AttentionPullRequestList:+ return query_attention_pull_requests(curated=curated)++def build_merged_pull_requests(*, curated: CuratedGitHubSource, repo: str, since: datetime | None = None, numbers: list[int] | None = None) -> list[MergedPullRequest]:diff --git a/products/engineering_analytics/backend/logic/queries/_curated.py b/products/engineering_analytics/backend/logic/queries/_curated.pyindex de08cbf1cefb..775d5f193a77 100644--- a/products/engineering_analytics/backend/logic/queries/_curated.py+++ b/products/engineering_analytics/backend/logic/queries/_curated.py@@ -124,7 +124,7 @@ class ReadyToMergeSql:return f"quantileIf(0.5)({self.expr}, {scope})" if self.observable else self.expr-_READY_TO_MERGE_UNOBSERVABLE = ReadyToMergeSql(cte="", join="", expr="NULL")+READY_TO_MERGE_UNOBSERVABLE = ReadyToMergeSql(cte="", join="", expr="NULL")def _ready_to_merge_expr(window: _IssueEventsWindow) -> str:@@ -339,7 +339,7 @@ class CuratedGitHubSource:window = self._issue_events_window()cte = self.ready_by_pr_cte()if window is None or cte is None:- return _READY_TO_MERGE_UNOBSERVABLE+ return READY_TO_MERGE_UNOBSERVABLEreturn ReadyToMergeSql(cte=cte, join=_READY_BY_PR_JOIN, expr=_ready_to_merge_expr(window))def _issue_events_window(self) -> "_IssueEventsWindow | None":@@ -525,19 +525,18 @@ class CuratedGitHubSource:)"""- def pr_list_rollup_query(self, select: str, *, pr_scope_where: str) -> str:- """``pr_rollup_query`` plus the per-PR runs rollup and, when it is observable, the- ``ready_by_pr`` rollup ``ready_to_merge_sql`` reads. ``pr_scope_where`` scopes both- runs rollups via the shared ``pr_scope`` CTE (see ``pr_rollup_query``)."""+ def pr_list_rollup_query(self, select: str, *, pr_scope_where: str, ready: ReadyToMergeSql) -> str:+ """``pr_rollup_query`` plus the per-PR runs rollup and the CTE of the ``ready`` measure that+ ``select`` reads. ``pr_scope_where`` scopes both runs rollups via the shared ``pr_scope`` CTE+ (see ``pr_rollup_query``)."""ctes = [self.runs_cte(),self._pr_scope_cte(pr_scope_where),self.ci_rollup_cte(),self.runs_by_pr_cte(),]- ready_cte = self.ready_to_merge_sql().cte- if ready_cte:- ctes.append(ready_cte)+ if ready.cte:+ ctes.append(ready.cte)return self._compose_pr_query(ctes, select)def _compose_pr_query(self, ctes: list[str], select: str) -> str:diff --git a/products/engineering_analytics/backend/logic/queries/ci_cards.py b/products/engineering_analytics/backend/logic/queries/ci_cards.pyindex ebcbf52d6290..5231b4337fcb 100644--- a/products/engineering_analytics/backend/logic/queries/ci_cards.py+++ b/products/engineering_analytics/backend/logic/queries/ci_cards.py@@ -10,18 +10,25 @@ from products.engineering_analytics.backend.logic.queries._curated import Curate_EMPTY = CICardSummary(open_prs=0, repos=0, stuck=0, failing_ci=0)-# Every _SELECT metric below is gated on this, and it also scopes the rollup CTEs to the-# same PRs (see query_ci_cards) — one definition so the two can never drift apart.-_OPEN = "state = 'open'"+# Every _SELECT metric below is gated on OPEN_PR_SQL, and it also scopes the rollup CTEs to the same PRs+# (see query_ci_cards).+OPEN_PR_SQL = "state = 'open'"+FAILING_CI_SQL = "coalesce(ci.failing, 0) > 0"+++def stuck_pr_sql(prefix: str) -> str:+ return (+ f"{prefix}{OPEN_PR_SQL} AND NOT {prefix}is_draft AND NOT {prefix}is_bot "+ f"AND {prefix}created_at < now() - INTERVAL 7 DAY"+ )+_SELECT = f"""SELECT- countIf(pr.{_OPEN}) AS open_prs,- count(DISTINCT if(pr.{_OPEN}, concat(pr.repo_owner, '/', pr.repo_name), NULL)) AS repos,- countIf(- pr.{_OPEN} AND NOT pr.is_draft AND NOT pr.is_bot AND pr.created_at < now() - INTERVAL 7 DAY- ) AS stuck,- countIf(pr.{_OPEN} AND coalesce(ci.failing, 0) > 0) AS failing_ci+ countIf(pr.{OPEN_PR_SQL}) AS open_prs,+ count(DISTINCT if(pr.{OPEN_PR_SQL}, concat(pr.repo_owner, '/', pr.repo_name), NULL)) AS repos,+ countIf({stuck_pr_sql("pr.")}) AS stuck,+ countIf(pr.{OPEN_PR_SQL} AND {FAILING_CI_SQL}) AS failing_ciFROM __PR_SOURCE__ AS prLEFT JOIN ci_rollup AS ci ON ci.head_sha = pr.head_sha"""@@ -30,7 +37,7 @@ _SELECT = f"""def query_ci_cards(*, curated: CuratedGitHubSource) -> CICardSummary:# Every count only reads CI for open PRs, so the rollup scan is scoped to their head SHAs.response = curated.run(- curated.pr_rollup_query(_SELECT, pr_scope_where=_OPEN),+ curated.pr_rollup_query(_SELECT, pr_scope_where=OPEN_PR_SQL),query_type="engineering_analytics.ci_cards",)if not response.results:diff --git a/products/engineering_analytics/backend/logic/queries/pull_request_list.py b/products/engineering_analytics/backend/logic/queries/pull_request_list.pyindex 013378b3ceaa..211fafc4a017 100644--- a/products/engineering_analytics/backend/logic/queries/pull_request_list.py+++ b/products/engineering_analytics/backend/logic/queries/pull_request_list.py@@ -12,6 +12,7 @@ from datetime import datetimefrom posthog.hogql import astfrom products.engineering_analytics.backend.facade.contracts import (+ AttentionPullRequestList,Author,CIStatusRollup,PRState,@@ -21,11 +22,17 @@ from products.engineering_analytics.backend.facade.contracts import (RepoRef,)from products.engineering_analytics.backend.logic.cost import PRCostAggregate-from products.engineering_analytics.backend.logic.queries._curated import CuratedGitHubSource+from products.engineering_analytics.backend.logic.queries._curated import (+ READY_TO_MERGE_UNOBSERVABLE,+ CuratedGitHubSource,+ ReadyToMergeSql,+)from products.engineering_analytics.backend.logic.queries._workflow_filters import DECISIVE_FAILURE_CONCLUSIONS_SQL+from products.engineering_analytics.backend.logic.queries.ci_cards import FAILING_CI_SQL, OPEN_PR_SQL, stuck_pr_sqlfrom products.engineering_analytics.backend.logic.queries.pr_cost import query_pr_costs_LIMIT = 1000+_ATTENTION_LIMIT = 15# Sparkline cap: enough to read a PR's CI history at a glance without bloating a 1000-row page._PUSH_HISTORY_LIMIT = 20@@ -58,14 +65,15 @@ _SELECT = f"""ci.failing_workflows AS failing_workflows,coalesce(rp.pushes, 0) AS pushes,coalesce(rp.rerun_cycles, 0) AS rerun_cycles+ __EXTRA_COLUMNS__FROM __PR_SOURCE__ AS prLEFT JOIN ci_rollup AS ci ON ci.head_sha = pr.head_shaLEFT JOIN runs_by_pr AS rpON rp.repo_owner = pr.repo_owner AND rp.repo_name = pr.repo_name AND rp.pr_number = pr.number__READY_JOIN__- WHERE __VISIBLE_PRS__- ORDER BY pr.created_at DESC- LIMIT {_LIMIT + 1}+ WHERE __ROWS__+ ORDER BY __ORDER_BY__+ LIMIT __LIMIT__"""@@ -142,34 +150,84 @@ def query_pr_push_history(return {key: samples[::-1] for key, samples in by_pr.items()}-def query_pull_request_list(- *, curated: CuratedGitHubSource, date_from: datetime, author: str | None = None-) -> PullRequestList:- placeholders: dict[str, ast.Expr] = {"date_from": ast.Constant(value=date_from)}- if author:- placeholders["author"] = ast.Constant(value=author)-- ready = curated.ready_to_merge_sql()+def _query_rows(+ *,+ curated: CuratedGitHubSource,+ scope_where: str,+ rows_where: str,+ order_by: str,+ limit: int,+ query_type: str,+ placeholders: dict[str, ast.Expr],+ ready: ReadyToMergeSql,+ extra_columns: str = "",+) -> list[tuple]:+ """``scope_where`` is over unqualified curated PR columns and must keep every row ``rows_where``+ keeps, because it prunes the runs rollups (see ``pr_list_rollup_query``)."""select = (_SELECT.replace("__READY_TO_MERGE__", f"{ready.expr} AS ready_to_merge_seconds").replace("__READY_JOIN__", ready.join)- .replace("__VISIBLE_PRS__", _visible_prs_where("pr.", author))+ .replace("__EXTRA_COLUMNS__", extra_columns)+ .replace("__ROWS__", rows_where)+ .replace("__ORDER_BY__", order_by)+ .replace("__LIMIT__", str(limit)))response = curated.run(- curated.pr_list_rollup_query(select, pr_scope_where=_visible_prs_where("", author)),- query_type="engineering_analytics.pull_request_list",+ curated.pr_list_rollup_query(select, pr_scope_where=scope_where, ready=ready),+ query_type=query_type,placeholders=placeholders,)- rows = response.results or []- truncated = len(rows) > _LIMIT- visible = rows[:_LIMIT]+ return list(response.results or [])+++def _enrich(*, curated: CuratedGitHubSource, rows: list[tuple]) -> list[PullRequestListItem]:# Scope the cost and push-history rollups to exactly the PRs we're about to show (row[0] is# pr.number), so the scans track the page instead of the team's whole CI history.- pr_numbers = sorted({int(row[0]) for row in visible})+ pr_numbers = sorted({int(row[0]) for row in rows})cost_by_pr = query_pr_costs(curated=curated, pr_numbers=pr_numbers)pushes_by_pr = query_pr_push_history(curated=curated, pr_numbers=pr_numbers)- items = [_map_row(row, cost_by_pr, pushes_by_pr) for row in visible]- return PullRequestList(items=items, truncated=truncated, limit=_LIMIT)+ return [_map_row(row, cost_by_pr, pushes_by_pr) for row in rows]+++def query_pull_request_list(+ *, curated: CuratedGitHubSource, date_from: datetime, author: str | None = None+) -> PullRequestList:+ placeholders: dict[str, ast.Expr] = {"date_from": ast.Constant(value=date_from)}+ if author:+ placeholders["author"] = ast.Constant(value=author)+ rows = _query_rows(+ curated=curated,+ scope_where=_visible_prs_where("", author),+ rows_where=_visible_prs_where("pr.", author),+ order_by="pr.created_at DESC",+ limit=_LIMIT + 1,+ query_type="engineering_analytics.pull_request_list",+ placeholders=placeholders,+ ready=curated.ready_to_merge_sql(),+ )+ return PullRequestList(+ items=_enrich(curated=curated, rows=rows[:_LIMIT]), truncated=len(rows) > _LIMIT, limit=_LIMIT+ )+++def query_attention_pull_requests(*, curated: CuratedGitHubSource) -> AttentionPullRequestList:+ rows = _query_rows(+ curated=curated,+ scope_where=OPEN_PR_SQL,+ rows_where=f"pr.{OPEN_PR_SQL} AND ({FAILING_CI_SQL} OR {stuck_pr_sql('pr.')})",+ order_by=f"{FAILING_CI_SQL} DESC, pr.created_at DESC, pr.repo_owner, pr.repo_name, pr.number DESC",+ limit=_ATTENTION_LIMIT,+ query_type="engineering_analytics.attention_pull_requests",+ placeholders={},+ # An open pull request has no ready-to-merge time, so the issue-events scans would add nothing.+ ready=READY_TO_MERGE_UNOBSERVABLE,+ extra_columns=", count() OVER () AS matching",+ )+ return AttentionPullRequestList(+ items=_enrich(curated=curated, rows=[row[:-1] for row in rows]),+ total=int(rows[0][-1]) if rows else 0,+ limit=_ATTENTION_LIMIT,+ )def _map_row(diff --git a/products/engineering_analytics/backend/presentation/serializers/pull_requests.py b/products/engineering_analytics/backend/presentation/serializers/pull_requests.pyindex 17e9035d290f..9dfa5abcd454 100644--- a/products/engineering_analytics/backend/presentation/serializers/pull_requests.py+++ b/products/engineering_analytics/backend/presentation/serializers/pull_requests.py@@ -3,6 +3,7 @@from rest_framework_dataclasses.serializers import DataclassSerializerfrom products.engineering_analytics.backend.facade.contracts import (+ AttentionPullRequestList,Author,BranchPRMatch,CICardSummary,@@ -298,6 +299,21 @@ class PullRequestListSerializer(DataclassSerializer):}+class AttentionPullRequestListSerializer(DataclassSerializer):+ items = PullRequestListItemSerializer(+ many=True, help_text="Open pull requests needing attention, failing CI first, then newest, capped at `limit`."+ )++ class Meta:+ dataclass = AttentionPullRequestList+ extra_kwargs = {+ "total": {+ "help_text": "Number of open pull requests needing attention, including the ones past the cap.",+ },+ "limit": {"help_text": "Maximum number of pull requests returned in `items`."},+ }++class BranchPRMatchSerializer(DataclassSerializer):class Meta:dataclass = BranchPRMatchdiff --git a/products/engineering_analytics/backend/presentation/views/pull_requests.py b/products/engineering_analytics/backend/presentation/views/pull_requests.pyindex d9efddeb9118..d48a53511cb4 100644--- a/products/engineering_analytics/backend/presentation/views/pull_requests.py+++ b/products/engineering_analytics/backend/presentation/views/pull_requests.py@@ -9,6 +9,7 @@ from rest_framework.response import Responsefrom products.engineering_analytics.backend.facade import apifrom products.engineering_analytics.backend.presentation.serializers.pull_requests import (+ AttentionPullRequestListSerializer,BranchPRMatchSerializer,CICardSummarySerializer,CIFailureLogsSerializer,@@ -34,6 +35,7 @@ class PullRequestActionsMixin(EngineeringAnalyticsViewSetBase):READ_ACTIONS = ["ci_cards","pull_requests",+ "attention_pull_requests","pr_lifecycle","resolve_branch","pr_runs",@@ -108,6 +110,32 @@ class PullRequestActionsMixin(EngineeringAnalyticsViewSetBase):return _bad_request(exc, fallback="Invalid date_from or source_id")return Response(PullRequestListSerializer(instance=result).data)+ @extend_schema(+ operation_id="engineering_analytics_attention_pull_requests",+ parameters=[_SOURCE_ID, _REPO],+ responses={+ 200: AttentionPullRequestListSerializer,+ 400: OpenApiResponse(description="Invalid source_id."),+ },+ description=(+ "Open pull requests that need attention: failing CI, or stuck (open, non-draft, non-bot, older than "+ "7 days), by the same rules as the ci_cards counts. Failing first, then newest, capped; `total` counts "+ "every match in the whole open backlog, however old."+ ),+ )+ @action(detail=False, methods=["get"], pagination_class=None)+ def attention_pull_requests(self, request: Request, **kwargs) -> Response:+ try:+ result = api.list_attention_pull_requests(+ team=self.team,+ source_id=request.query_params.get("source_id") or None,+ repo=request.query_params.get("repo") or None,+ user_access_control=self.user_access_control,+ )+ except ValueError as exc:+ return _bad_request(exc, fallback="Invalid source_id")+ return Response(AttentionPullRequestListSerializer(instance=result).data)+@extend_schema(operation_id="engineering_analytics_pr_lifecycle",parameters=[diff --git a/products/engineering_analytics/backend/tests/test_logic_pull_requests.py b/products/engineering_analytics/backend/tests/test_logic_pull_requests.pyindex 1d7a1b3e40f6..8d52b712ad93 100644--- a/products/engineering_analytics/backend/tests/test_logic_pull_requests.py+++ b/products/engineering_analytics/backend/tests/test_logic_pull_requests.py@@ -16,6 +16,7 @@ from products.engineering_analytics.backend.facade.contracts import (PRLifecycleEventKind,PRState,)+from products.engineering_analytics.backend.logic.queries import pull_request_listfrom products.engineering_analytics.backend.logic.views.source_schema import (ISSUE_EVENTS_COLUMNS,PULL_REQUESTS_COLUMNS,@@ -288,7 +289,7 @@ class TestResolveBranchMapping(BaseTest):class TestPullRequestEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):"""PR-scoped end-to-end aggregates over the shared seeded warehouse tables."""- def test_ci_cards_counts(self) -> None:+ def test_ci_cards_and_attention_list_agree(self) -> None:self._seed()cards = api.get_ci_cards(team=self.team)assert cards.open_prs == 5 # 10, 11, 12, 13, 16@@ -296,6 +297,16 @@ class TestPullRequestEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):assert cards.stuck == 1 # only 11 (10 recent, 12 draft, 13 and 16 bots)assert cards.failing_ci == 1 # only 10 has a failing latest run+ attention = api.list_attention_pull_requests(team=self.team)+ assert [item.number for item in attention.items] == [10, 11] # failing first, then stuck+ assert attention.total == 2+ assert attention.items[0].push_history # enriched like the full list++ with mock.patch.object(pull_request_list, "_ATTENTION_LIMIT", 1):+ capped = api.list_attention_pull_requests(team=self.team)+ assert [item.number for item in capped.items] == [10]+ assert capped.total == 2 # counts past the cap+def test_pull_request_list_window_and_rollup(self) -> None:self._seed()result = api.list_pull_requests(team=self.team)diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex 0f21903c2098..c91e53841473 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -7,6 +7,136 @@* PostHog API - generated* OpenAPI spec version: 1.0.0*/+export interface AuthorApi {+ /** Login handle of the pull request author. */+ handle: string+ /** Human-readable name; equals the handle in v1. */+ display_name: string+ /** URL of the author's avatar image. */+ avatar_url: string+ /** True if the author is a bot (handle ends in [bot] or is a known bot). */+ is_bot: boolean+}++export interface RepoRefApi {+ /** Code host provider, e.g. 'github'. */+ provider: string+ /** Repository owner or organization. */+ owner: string+ /** Repository name. */+ name: string+}++export interface CIStatusRollupApi {+ /** Distinct workflows run on the PR's head SHA. */+ runs: number+ /** Latest runs that completed with conclusion 'success'. */+ passing: number+ /** Latest runs that ended in failure, timeout, startup failure, or staleness. */+ failing: number+ /** Latest runs not yet completed (queued or in progress). */+ pending: number+ /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */+ inconclusive: number+ /** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */+ failing_workflows?: string[]+}++export interface PushCISampleApi {+ /** Head commit SHA of this push (CI round). */+ head_sha: string+ /** Earliest workflow-run start on this push. */+ started_at: string+ /**+ * Wall-clock CI seconds for this push: earliest run start to latest completed run end. Null while nothing has completed.+ * @nullable+ */+ wall_seconds: number | null+ /** True when any latest-per-workflow run on this push ended in a decisive failure. */+ failed: boolean+ /** True when any latest-per-workflow run on this push hasn't completed yet. */+ pending: boolean+}++/**+ * * `open` - OPEN+ * * `closed` - CLOSED+ * * `merged` - MERGED+ */+export type EngineeringAnalyticsPRStateEnumApi =+ (typeof EngineeringAnalyticsPRStateEnumApi)[keyof typeof EngineeringAnalyticsPRStateEnumApi]++export const EngineeringAnalyticsPRStateEnumApi = {+ Open: 'open',+ Closed: 'closed',+ Merged: 'merged',+} as const++export interface PullRequestListItemApi {+ /** The pull request author. */+ author: AuthorApi+ /** Repository the pull request belongs to. */+ repo: RepoRefApi+ /** CI status from the latest workflow runs on the head SHA. */+ ci: CIStatusRollupApi+ /** This PR's CI rounds oldest-first, capped to the most recent pushes - one sample per push for the push-history sparkline. `pushes` stays the uncapped count. */+ push_history: PushCISampleApi[]+ /** Pull request number within the repository. */+ number: number+ /** Pull request title. */+ title: string+ /** Derived state: 'open', 'closed', or 'merged'.+ *+ * * `open` - OPEN+ * * `closed` - CLOSED+ * * `merged` - MERGED */+ state: EngineeringAnalyticsPRStateEnumApi+ /** True if the pull request is a draft. */+ is_draft: boolean+ /** When the pull request was opened. */+ created_at: string+ /**+ * When the pull request was merged, or null.+ * @nullable+ */+ merged_at: string | null+ /**+ * Coarse open-to-merge time in seconds (merged_at - created_at; fuses draft and ready-for-review time). Null until merged.+ * @nullable+ */+ open_to_merge_seconds: number | null+ /**+ * True ready-to-merge cycle time in seconds: merged_at minus the last observed ready_for_review transition (only the last draft/ready switch counts), or minus created_at for a merged PR verifiably never drafted. Null when unmerged or not observed (the PR's life isn't fully inside the synced issue-event window) - null never means zero.+ * @nullable+ */+ ready_to_merge_seconds: number | null+ /** GitHub label names on the pull request. */+ labels: string[]+ /** CI triggers attributed to this PR: distinct head SHAs across its workflow runs. Fork-PR runs are unattributed. */+ pushes: number+ /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */+ rerun_cycles: number+ /**+ * Estimated CI cost in USD summed over this PR's jobs (billable runners only). Null when nothing was costable or the job-level source isn't synced.+ * @nullable+ */+ estimated_cost_usd?: number | null+ /**+ * Billable (self-hosted) minutes summed over this PR's jobs. Null when the job source isn't synced.+ * @nullable+ */+ billable_minutes?: number | null+}++export interface AttentionPullRequestListApi {+ /** Open pull requests needing attention, failing CI first, then newest, capped at `limit`. */+ items: PullRequestListItemApi[]+ /** Number of open pull requests needing attention, including the ones past the cap. */+ total: number+ /** Maximum number of pull requests returned in `items`. */+ limit: number+}+/*** * `ci` - CI* * `review` - REVIEW@@ -248,15 +378,6 @@ export interface CICardSummaryApi {failing_ci: number}-export interface RepoRefApi {- /** Code host provider, e.g. 'github'. */- provider: string- /** Repository owner or organization. */- owner: string- /** Repository name. */- name: string-}-export interface CIFailureLogLineApi {/*** 1-based line number in the full pre-thinning job log, or null for a '... N lines omitted ...' marker. The gap between consecutive values is how many lines were elided.@@ -907,31 +1028,6 @@ export interface PRCostSummaryApi {excluded_jobs: number}-export interface AuthorApi {- /** Login handle of the pull request author. */- handle: string- /** Human-readable name; equals the handle in v1. */- display_name: string- /** URL of the author's avatar image. */- avatar_url: string- /** True if the author is a bot (handle ends in [bot] or is a known bot). */- is_bot: boolean-}--/**- * * `open` - OPEN- * * `closed` - CLOSED- * * `merged` - MERGED- */-export type EngineeringAnalyticsPRStateEnumApi =- (typeof EngineeringAnalyticsPRStateEnumApi)[keyof typeof EngineeringAnalyticsPRStateEnumApi]--export const EngineeringAnalyticsPRStateEnumApi = {- Open: 'open',- Closed: 'closed',- Merged: 'merged',-} as const-export interface PullRequestApi {/** The pull request author. */author: AuthorApi@@ -1287,93 +1383,6 @@ export interface PullRequestTimelinesApi {limit: number}-export interface CIStatusRollupApi {- /** Distinct workflows run on the PR's head SHA. */- runs: number- /** Latest runs that completed with conclusion 'success'. */- passing: number- /** Latest runs that ended in failure, timeout, startup failure, or staleness. */- failing: number- /** Latest runs not yet completed (queued or in progress). */- pending: number- /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */- inconclusive: number- /** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */- failing_workflows?: string[]-}--export interface PushCISampleApi {- /** Head commit SHA of this push (CI round). */- head_sha: string- /** Earliest workflow-run start on this push. */- started_at: string- /**- * Wall-clock CI seconds for this push: earliest run start to latest completed run end. Null while nothing has completed.- * @nullable- */- wall_seconds: number | null- /** True when any latest-per-workflow run on this push ended in a decisive failure. */- failed: boolean- /** True when any latest-per-workflow run on this push hasn't completed yet. */- pending: boolean-}--export interface PullRequestListItemApi {- /** The pull request author. */- author: AuthorApi- /** Repository the pull request belongs to. */- repo: RepoRefApi- /** CI status from the latest workflow runs on the head SHA. */- ci: CIStatusRollupApi- /** This PR's CI rounds oldest-first, capped to the most recent pushes - one sample per push for the push-history sparkline. `pushes` stays the uncapped count. */- push_history: PushCISampleApi[]- /** Pull request number within the repository. */- number: number- /** Pull request title. */- title: string- /** Derived state: 'open', 'closed', or 'merged'.- *- * * `open` - OPEN- * * `closed` - CLOSED- * * `merged` - MERGED */- state: EngineeringAnalyticsPRStateEnumApi- /** True if the pull request is a draft. */- is_draft: boolean- /** When the pull request was opened. */- created_at: string- /**- * When the pull request was merged, or null.- * @nullable- */- merged_at: string | null- /**- * Coarse open-to-merge time in seconds (merged_at - created_at; fuses draft and ready-for-review time). Null until merged.- * @nullable- */- open_to_merge_seconds: number | null- /**- * True ready-to-merge cycle time in seconds: merged_at minus the last observed ready_for_review transition (only the last draft/ready switch counts), or minus created_at for a merged PR verifiably never drafted. Null when unmerged or not observed (the PR's life isn't fully inside the synced issue-event window) - null never means zero.- * @nullable- */- ready_to_merge_seconds: number | null- /** GitHub label names on the pull request. */- labels: string[]- /** CI triggers attributed to this PR: distinct head SHAs across its workflow runs. Fork-PR runs are unattributed. */- pushes: number- /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */- rerun_cycles: number- /**- * Estimated CI cost in USD summed over this PR's jobs (billable runners only). Null when nothing was costable or the job-level source isn't synced.- * @nullable- */- estimated_cost_usd?: number | null- /**- * Billable (self-hosted) minutes summed over this PR's jobs. Null when the job source isn't synced.- * @nullable- */- billable_minutes?: number | null-}-export interface PullRequestListApi {/** Pull requests, newest first, capped at `limit`. */items: PullRequestListItemApi[]@@ -2252,6 +2261,17 @@ export interface WorkflowRunnerCostApi {estimated_cost_usd: number | null}+export type EngineeringAnalyticsAttentionPullRequestsParams = {+ /**+ * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.+ */+ repo?: string+ /**+ * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.+ */+ source_id?: string+}+export type EngineeringAnalyticsAuthorFrictionParams = {/*** GitHub team slug: list only the team's members, through the team membership table. Ranks stay repository-wide.diff --git a/products/engineering_analytics/frontend/generated/api.ts b/products/engineering_analytics/frontend/generated/api.tsindex cc1ff35e5bec..b6d8172ff2a3 100644--- a/products/engineering_analytics/frontend/generated/api.ts+++ b/products/engineering_analytics/frontend/generated/api.ts@@ -9,6 +9,7 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'* OpenAPI spec version: 1.0.0*/import type {+ AttentionPullRequestListApi,AuthorFrictionDetailApi,AuthorFrictionListApi,BranchPRMatchApi,@@ -21,6 +22,7 @@ import type {DeliveryComparisonApi,DeliverySummaryApi,DoraOverviewApi,+ EngineeringAnalyticsAttentionPullRequestsParams,EngineeringAnalyticsAuthorFrictionDetailParams,EngineeringAnalyticsAuthorFrictionParams,EngineeringAnalyticsAuthorWorkflowCostsParams,@@ -81,6 +83,39 @@ import type {WorkflowRunnerCostApi,} from './api.schemas'+export const getEngineeringAnalyticsAttentionPullRequestsUrl = (+ projectId: string,+ params?: EngineeringAnalyticsAttentionPullRequestsParams+) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/engineering_analytics/attention_pull_requests/?${stringifiedParams}`+ : `/api/projects/${projectId}/engineering_analytics/attention_pull_requests/`+}++/**+ * Open pull requests that need attention: failing CI, or stuck (open, non-draft, non-bot, older than 7 days), by the same rules as the ci_cards counts. Failing first, then newest, capped; `total` counts every match in the whole open backlog, however old.+ */+export const engineeringAnalyticsAttentionPullRequests = async (+ projectId: string,+ params?: EngineeringAnalyticsAttentionPullRequestsParams,+ options?: RequestInit+): Promise<AttentionPullRequestListApi> => {+ return apiMutator<AttentionPullRequestListApi>(getEngineeringAnalyticsAttentionPullRequestsUrl(projectId, params), {+ ...options,+ method: 'GET',+ })+}+export const getEngineeringAnalyticsAuthorFrictionUrl = (projectId: string,params?: EngineeringAnalyticsAuthorFrictionParamsdiff --git a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsxindex 63e835b42dd1..c11766913033 100644--- a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx+++ b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.stories.tsx@@ -7,6 +7,7 @@ import { urls } from 'scenes/urls'import { mswDecorator } from '~/mocks/browser'import type {+ AttentionPullRequestListApi,GitHubSourceApi,PullRequestListApi,RepoOverviewApi,@@ -232,6 +233,12 @@ const PULL_REQUESTS: PullRequestListApi = {limit: 1000,}+const ATTENTION_PULL_REQUESTS: AttentionPullRequestListApi = {+ items: PULL_REQUESTS.items.filter((item) => item.state === 'open'),+ total: 1,+ limit: 15,+}+const meta: Meta = {component: App,title: 'Scenes-App/Engineering Analytics/Repo Overview',@@ -258,6 +265,7 @@ const meta: Meta = {failing_ci: 4,},'api/projects/:team_id/engineering_analytics/pull_requests/': PULL_REQUESTS,+ 'api/projects/:team_id/engineering_analytics/attention_pull_requests/': ATTENTION_PULL_REQUESTS,'api/projects/:team_id/engineering_analytics/workflow_health/': WORKFLOW_HEALTH,},}),diff --git a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsxindex 3ba046b6754b..f0b7045cfc62 100644--- a/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx+++ b/products/engineering_analytics/frontend/scenes/RepoOverviewScene.tsx@@ -34,7 +34,9 @@ export function RepoOverviewScene(): JSX.Element {activityTruncated,repoActivityLoading,repoActivityFailed,- attentionPrs,+ attention,+ attentionFailed,+ attentionLoading,jobsAvailable,overviewDefaultBranch,notConnected,@@ -43,17 +45,11 @@ export function RepoOverviewScene(): JSX.Element {prPreviewCount,workflowPreviewCount,} = useValues(repoOverviewLogic)- const {- pullRequestsLoading,- pullRequestsStatus,- workflowHealth,- workflowHealthLoadError,- workflowHealthLoading,- sourceId,- activeSource,- } = useValues(engineeringAnalyticsLogic)- const { loadPullRequests, loadWorkflowHealth } = useActions(engineeringAnalyticsLogic)- const { loadOverview, loadRepoActivity, showMorePrs, showMoreWorkflows } = useActions(repoOverviewLogic)+ const { workflowHealth, workflowHealthLoadError, workflowHealthLoading, sourceId, activeSource } =+ useValues(engineeringAnalyticsLogic)+ const { loadWorkflowHealth } = useActions(engineeringAnalyticsLogic)+ const { loadAttention, loadOverview, loadRepoActivity, showMorePrs, showMoreWorkflows } =+ useActions(repoOverviewLogic)const { searchParams } = useValues(router)// Window/source changes reload the overview, activity, and workflow health (the date-scoped@@ -63,9 +59,9 @@ export function RepoOverviewScene(): JSX.Element {// The hub previews each table: a short, sorted slice with "Show more" to grow in place, and "View all"// to the dedicated full table. Workflows are ranked by cost (or run count) to pick the top few; the- // table then displays them merge-queue-first. attentionPrs is already ordered failing-first.- const shownPrs = attentionPrs.slice(0, prPreviewCount)- const canShowMorePrs = shownPrs.length < attentionPrs.length && prPreviewCount < HUB_PREVIEW_MAX+ // table then displays them merge-queue-first. The server already orders them failing-first.+ const shownPrs = attention.rows.slice(0, prPreviewCount)+ const canShowMorePrs = shownPrs.length < attention.rows.length && prPreviewCount < HUB_PREVIEW_MAX// Rank the leaderboard by spend when cost is known (where the money goes), else by run volume.const rankedWorkflows = jobsAvailable? [...workflowHealth].sort((a, b) => (b.estimatedCostUsd ?? -1) - (a.estimatedCostUsd ?? -1))@@ -250,13 +246,13 @@ export function RepoOverviewScene(): JSX.Element {title="Pull requests needing attention"note="Current open backlog. Not affected by the date range.">- {pullRequestsStatus === 'error' ? (- <CIAnalyticsLoadError onRetry={loadPullRequests} loading={pullRequestsLoading} />+ {attentionFailed ? (+ <CIAnalyticsLoadError onRetry={loadAttention} loading={attentionLoading} />) : (<LemonCard hoverEffect={false} className="overflow-hidden p-0"><PullRequestTablerows={shownPrs}- loading={pullRequestsLoading}+ loading={attentionLoading}sourceId={sourceId}embeddedpageSize={HUB_PREVIEW_MAX}@@ -265,8 +261,8 @@ export function RepoOverviewScene(): JSX.Element {/><div className="flex flex-wrap items-center justify-between gap-2 border-t border-primary px-4 py-2 text-[11px] text-tertiary"><span>- Showing {shownPrs.length} of {humanFriendlyNumber(attentionPrs.length)} needing- attention+ Showing <span translate="no">{shownPrs.length}</span> of{' '}+ <span translate="no">{humanFriendlyNumber(attention.total)}</span> needing attention</span><div className="flex items-center gap-3">{canShowMorePrs && (diff --git a/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts b/products/engineering_analytics/frontend/scenes/repoOverviewLogic.tsindex d7e021b27258..ffd25ac395a8 100644--- a/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts+++ b/products/engineering_analytics/frontend/scenes/repoOverviewLogic.ts@@ -2,21 +2,33 @@ import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reduimport { loaders } from 'kea-loaders'import { ApiConfig } from 'lib/api'-import { dayjs } from 'lib/dayjs'import type { ActivityRun } from '../components/RunActivityChart'-import { engineeringAnalyticsRepoOverview, engineeringAnalyticsRepoRunActivity } from '../generated/api'+import {+ engineeringAnalyticsAttentionPullRequests,+ engineeringAnalyticsRepoOverview,+ engineeringAnalyticsRepoRunActivity,+} from '../generated/api'import type { RepoOverviewApi, WorkflowRunActivityApi } from '../generated/api.schemas'-import { ciStatusOf } from '../lib/ci'import { HUB_PREVIEW_MAX, HUB_PREVIEW_ROWS, HUB_PREVIEW_STEP } from '../lib/preview'import { engineeringAnalyticsFiltersLogic } from './engineeringAnalyticsFiltersLogic'-import { PullRequestRow, STUCK_AFTER_DAYS, engineeringAnalyticsLogic, isStuck } from './engineeringAnalyticsLogic'+import {+ PullRequestRow,+ engineeringAnalyticsLogic,+ loaderStatusFromError,+ toPullRequestRow,+} from './engineeringAnalyticsLogic'import type { WorkflowHealthRow } from './engineeringAnalyticsLogic'const projectId = (): string => String(ApiConfig.getCurrentProjectId())const TOP_COST_WORKFLOWS = 5+export interface AttentionPullRequests {+ rows: PullRequestRow[]+ total: number+}+export interface CostShareRow {workflowName: string | nullcostUsd: number@@ -28,17 +40,16 @@ export interface repoOverviewLogicValues {dateFrom: string | null // engineeringAnalyticsFiltersLogicdateTo: string | null // engineeringAnalyticsFiltersLogicnotConnected: boolean // engineeringAnalyticsLogic- pullRequests: PullRequestRow[] // engineeringAnalyticsLogic- pullRequestsLoading: boolean // engineeringAnalyticsLogicscopeRepo: string | null // engineeringAnalyticsLogicsourceId: string | null // engineeringAnalyticsLogicworkflowHealth: WorkflowHealthRow[] // engineeringAnalyticsLogicworkflowHealthLoading: boolean // engineeringAnalyticsLogicactivityRuns: ActivityRun[]activityTruncated: boolean- attentionPrs: PullRequestRow[]+ attention: AttentionPullRequests+ attentionFailed: boolean+ attentionLoading: booleancostByWorkflow: CostShareRow[]- draftCount: numberjobsAvailable: booleanotherCostWorkflowCount: numberoverview: RepoOverviewApi | null@@ -54,6 +65,21 @@ export interface repoOverviewLogicValues {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface repoOverviewLogicActions {+ loadAttention: (_: void) => void+ loadAttentionFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadAttentionSuccess: (+ attention: AttentionPullRequests,+ payload?: void+ ) => {+ attention: AttentionPullRequests+ payload?: void+ }loadOverview: () => anyloadOverviewFailure: (error: string,@@ -99,8 +125,6 @@ export interface repoOverviewLogicMeta {overviewDefaultBranch: (overview: RepoOverviewApi | null) => stringactivityRuns: (repoActivity: WorkflowRunActivityApi) => ActivityRun[]activityTruncated: (repoActivity: WorkflowRunActivityApi) => boolean- attentionPrs: (pullRequests: PullRequestRow[]) => PullRequestRow[]- draftCount: (pullRequests: PullRequestRow[]) => numbercostByWorkflow: (workflowHealth: WorkflowHealthRow[]) => CostShareRow[]otherCostWorkflowCount: (workflowHealth: WorkflowHealthRow[]) => number}@@ -121,15 +145,7 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([engineeringAnalyticsFiltersLogic,['dateFrom', 'dateTo'],engineeringAnalyticsLogic,- [- 'sourceId',- 'scopeRepo',- 'pullRequests',- 'pullRequestsLoading',- 'workflowHealth',- 'workflowHealthLoading',- 'notConnected',- ],+ ['sourceId', 'scopeRepo', 'workflowHealth', 'workflowHealthLoading', 'notConnected'],],})),@@ -139,6 +155,19 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([}),loaders(({ values }) => ({+ attention: [+ { rows: [], total: 0 } as AttentionPullRequests,+ {+ loadAttention: async (_: void, breakpoint): Promise<AttentionPullRequests> => {+ const response = await engineeringAnalyticsAttentionPullRequests(projectId(), {+ source_id: values.sourceId ?? undefined,+ repo: values.scopeRepo ?? undefined,+ })+ breakpoint()+ return { rows: response.items.map(toPullRequestRow), total: response.total }+ },+ },+ ],overview: [null as RepoOverviewApi | null,{@@ -172,6 +201,14 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([reducers({// Non-400 failure only; the shared 400 "not connected" state comes from engineeringAnalyticsLogic.+ attentionFailed: [+ false,+ {+ loadAttention: () => false,+ loadAttentionSuccess: () => false,+ loadAttentionFailure: (_, { errorObject }) => loaderStatusFromError(errorObject) === 'error',+ },+ ],overviewFailed: [false,{@@ -232,23 +269,6 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([(s) => [s.repoActivity],(repoActivity: WorkflowRunActivityApi): boolean => repoActivity.truncated,],- // Open PRs with failing CI or stuck (open >7d, non-draft, non-bot) — not the full open list.- attentionPrs: [- (s) => [s.pullRequests],- (pullRequests: PullRequestRow[]): PullRequestRow[] => {- const stuckCutoffMs = dayjs().subtract(STUCK_AFTER_DAYS, 'day').valueOf()- return pullRequests- .filter(- (row) => row.state === 'open' && (ciStatusOf(row) === 'failing' || isStuck(row, stuckCutoffMs))- )- .sort((a, b) => Number(ciStatusOf(b) === 'failing') - Number(ciStatusOf(a) === 'failing'))- },- ],- draftCount: [- (s) => [s.pullRequests],- (pullRequests: PullRequestRow[]): number =>- pullRequests.filter((row) => row.state === 'open' && row.isDraft).length,- ],costByWorkflow: [(s) => [s.workflowHealth],(workflowHealth: import('./engineeringAnalyticsLogic').WorkflowHealthRow[]): CostShareRow[] => {@@ -287,17 +307,15 @@ export const repoOverviewLogic = kea<repoOverviewLogicType>([actions.loadOverview()actions.loadRepoActivity()},- [engineeringAnalyticsLogic.actionTypes.setSourceId]: () => {- actions.loadOverview()- actions.loadRepoActivity()- },[engineeringAnalyticsLogic.actionTypes.refresh]: () => {+ actions.loadAttention()actions.loadOverview()actions.loadRepoActivity()},})),afterMount(({ actions }) => {+ actions.loadAttention()actions.loadOverview()actions.loadRepoActivity()}),diff --git a/products/engineering_analytics/mcp/tools.yaml b/products/engineering_analytics/mcp/tools.yamlindex 164ac1229193..7091f6136979 100644--- a/products/engineering_analytics/mcp/tools.yaml+++ b/products/engineering_analytics/mcp/tools.yaml@@ -9,6 +9,9 @@ feature: engineering_analyticsurl_prefix: /engineering-analyticsui_apps: {}tools:+ engineering-analytics-attention-pull-requests:+ operation: engineering_analytics_attention_pull_requests+ enabled: falseengineering-analytics-author-friction:operation: engineering_analytics_author_frictionenabled: falsediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 9b169546c7f6..0d4c7ffc7822 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -12614,6 +12614,136 @@ export namespace Schemas {delete_verified_at: string | null;}+ export interface Author {+ /** Login handle of the pull request author. */+ handle: string;+ /** Human-readable name; equals the handle in v1. */+ display_name: string;+ /** URL of the author's avatar image. */+ avatar_url: string;+ /** True if the author is a bot (handle ends in [bot] or is a known bot). */+ is_bot: boolean;+ }++ export interface RepoRef {+ /** Code host provider, e.g. 'github'. */+ provider: string;+ /** Repository owner or organization. */+ owner: string;+ /** Repository name. */+ name: string;+ }++ export interface CIStatusRollup {+ /** Distinct workflows run on the PR's head SHA. */+ runs: number;+ /** Latest runs that completed with conclusion 'success'. */+ passing: number;+ /** Latest runs that ended in failure, timeout, startup failure, or staleness. */+ failing: number;+ /** Latest runs not yet completed (queued or in progress). */+ pending: number;+ /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */+ inconclusive: number;+ /** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */+ failing_workflows?: string[];+ }++ export interface PushCISample {+ /** Head commit SHA of this push (CI round). */+ head_sha: string;+ /** Earliest workflow-run start on this push. */+ started_at: string;+ /**+ * Wall-clock CI seconds for this push: earliest run start to latest completed run end. Null while nothing has completed.+ * @nullable+ */+ wall_seconds: number | null;+ /** True when any latest-per-workflow run on this push ended in a decisive failure. */+ failed: boolean;+ /** True when any latest-per-workflow run on this push hasn't completed yet. */+ pending: boolean;+ }++ /**+ * * `open` - OPEN+ * * `closed` - CLOSED+ * * `merged` - MERGED+ */+ export type EngineeringAnalyticsPRStateEnum = typeof EngineeringAnalyticsPRStateEnum[keyof typeof EngineeringAnalyticsPRStateEnum];+++ export const EngineeringAnalyticsPRStateEnum = {+ Open: 'open',+ Closed: 'closed',+ Merged: 'merged',+ } as const;++ export interface PullRequestListItem {+ /** The pull request author. */+ author: Author;+ /** Repository the pull request belongs to. */+ repo: RepoRef;+ /** CI status from the latest workflow runs on the head SHA. */+ ci: CIStatusRollup;+ /** This PR's CI rounds oldest-first, capped to the most recent pushes - one sample per push for the push-history sparkline. `pushes` stays the uncapped count. */+ push_history: PushCISample[];+ /** Pull request number within the repository. */+ number: number;+ /** Pull request title. */+ title: string;+ /** Derived state: 'open', 'closed', or 'merged'.+ *+ * * `open` - OPEN+ * * `closed` - CLOSED+ * * `merged` - MERGED */+ state: EngineeringAnalyticsPRStateEnum;+ /** True if the pull request is a draft. */+ is_draft: boolean;+ /** When the pull request was opened. */+ created_at: string;+ /**+ * When the pull request was merged, or null.+ * @nullable+ */+ merged_at: string | null;+ /**+ * Coarse open-to-merge time in seconds (merged_at - created_at; fuses draft and ready-for-review time). Null until merged.+ * @nullable+ */+ open_to_merge_seconds: number | null;+ /**+ * True ready-to-merge cycle time in seconds: merged_at minus the last observed ready_for_review transition (only the last draft/ready switch counts), or minus created_at for a merged PR verifiably never drafted. Null when unmerged or not observed (the PR's life isn't fully inside the synced issue-event window) - null never means zero.+ * @nullable+ */+ ready_to_merge_seconds: number | null;+ /** GitHub label names on the pull request. */+ labels: string[];+ /** CI triggers attributed to this PR: distinct head SHAs across its workflow runs. Fork-PR runs are unattributed. */+ pushes: number;+ /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */+ rerun_cycles: number;+ /**+ * Estimated CI cost in USD summed over this PR's jobs (billable runners only). Null when nothing was costable or the job-level source isn't synced.+ * @nullable+ */+ estimated_cost_usd?: number | null;+ /**+ * Billable (self-hosted) minutes summed over this PR's jobs. Null when the job source isn't synced.+ * @nullable+ */+ billable_minutes?: number | null;+ }++ export interface AttentionPullRequestList {+ /** Open pull requests needing attention, failing CI first, then newest, capped at `limit`. */+ items: PullRequestListItem[];+ /** Number of open pull requests needing attention, including the ones past the cap. */+ total: number;+ /** Maximum number of pull requests returned in `items`. */+ limit: number;+ }+export interface AttributeBreakdownRow {count: number;error_count: number;@@ -12736,17 +12866,6 @@ export namespace Schemas {Credentials: 'credentials',} as const;- export interface Author {- /** Login handle of the pull request author. */- handle: string;- /** Human-readable name; equals the handle in v1. */- display_name: string;- /** URL of the author's avatar image. */- avatar_url: string;- /** True if the author is a bot (handle ends in [bot] or is a known bot). */- is_bot: boolean;- }-/*** * `ci` - CI* * `review` - REVIEW@@ -18532,15 +18651,6 @@ export namespace Schemas {text: string;}- export interface RepoRef {- /** Code host provider, e.g. 'github'. */- provider: string;- /** Repository owner or organization. */- owner: string;- /** Repository name. */- name: string;- }-export interface CIJobFailureLog {/** The thinned failure-log lines in original order, with omission markers. */lines: CIFailureLogLine[];@@ -18672,21 +18782,6 @@ export namespace Schemas {enabled: boolean;}- export interface CIStatusRollup {- /** Distinct workflows run on the PR's head SHA. */- runs: number;- /** Latest runs that completed with conclusion 'success'. */- passing: number;- /** Latest runs that ended in failure, timeout, startup failure, or staleness. */- failing: number;- /** Latest runs not yet completed (queued or in progress). */- pending: number;- /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */- inconclusive: number;- /** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */- failing_workflows?: string[];- }-/*** * `pytest` - PYTEST* * `jest` - JEST@@ -37937,20 +38032,6 @@ export namespace Schemas {window_days: number;}- /**- * * `open` - OPEN- * * `closed` - CLOSED- * * `merged` - MERGED- */- export type EngineeringAnalyticsPRStateEnum = typeof EngineeringAnalyticsPRStateEnum[keyof typeof EngineeringAnalyticsPRStateEnum];--- export const EngineeringAnalyticsPRStateEnum = {- Open: 'open',- Closed: 'closed',- Merged: 'merged',- } as const;-/*** * `allow` - Allow* * `reject` - Reject@@ -85569,78 +85650,6 @@ export namespace Schemas {window_days: number;}- export interface PushCISample {- /** Head commit SHA of this push (CI round). */- head_sha: string;- /** Earliest workflow-run start on this push. */- started_at: string;- /**- * Wall-clock CI seconds for this push: earliest run start to latest completed run end. Null while nothing has completed.- * @nullable- */- wall_seconds: number | null;- /** True when any latest-per-workflow run on this push ended in a decisive failure. */- failed: boolean;- /** True when any latest-per-workflow run on this push hasn't completed yet. */- pending: boolean;- }-- export interface PullRequestListItem {- /** The pull request author. */- author: Author;- /** Repository the pull request belongs to. */- repo: RepoRef;- /** CI status from the latest workflow runs on the head SHA. */- ci: CIStatusRollup;- /** This PR's CI rounds oldest-first, capped to the most recent pushes - one sample per push for the push-history sparkline. `pushes` stays the uncapped count. */- push_history: PushCISample[];- /** Pull request number within the repository. */- number: number;- /** Pull request title. */- title: string;- /** Derived state: 'open', 'closed', or 'merged'.- *- * * `open` - OPEN- * * `closed` - CLOSED- * * `merged` - MERGED */- state: EngineeringAnalyticsPRStateEnum;- /** True if the pull request is a draft. */- is_draft: boolean;- /** When the pull request was opened. */- created_at: string;- /**- * When the pull request was merged, or null.- * @nullable- */- merged_at: string | null;- /**- * Coarse open-to-merge time in seconds (merged_at - created_at; fuses draft and ready-for-review time). Null until merged.- * @nullable- */- open_to_merge_seconds: number | null;- /**- * True ready-to-merge cycle time in seconds: merged_at minus the last observed ready_for_review transition (only the last draft/ready switch counts), or minus created_at for a merged PR verifiably never drafted. Null when unmerged or not observed (the PR's life isn't fully inside the synced issue-event window) - null never means zero.- * @nullable- */- ready_to_merge_seconds: number | null;- /** GitHub label names on the pull request. */- labels: string[];- /** CI triggers attributed to this PR: distinct head SHAs across its workflow runs. Fork-PR runs are unattributed. */- pushes: number;- /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */- rerun_cycles: number;- /**- * Estimated CI cost in USD summed over this PR's jobs (billable runners only). Null when nothing was costable or the job-level source isn't synced.- * @nullable- */- estimated_cost_usd?: number | null;- /**- * Billable (self-hosted) minutes summed over this PR's jobs. Null when the job source isn't synced.- * @nullable- */- billable_minutes?: number | null;- }-export interface PullRequestList {/** Pull requests, newest first, capped at `limit`. */items: PullRequestListItem[];@@ -114214,6 +114223,17 @@ export namespace Schemas {offset?: number;};+ export type EngineeringAnalyticsAttentionPullRequestsParams = {+ /**+ * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.+ */+ repo?: string;+ /**+ * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source when the team has more than one.+ */+ source_id?: string;+ };+export type EngineeringAnalyticsAuthorFrictionParams = {/*** GitHub team slug: list only the team's members, through the team membership table. Ranks stay repository-wide.