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.

chore(eng-analytics): trim workflow comments (#102391)

Raúl Negrón-Oterob5dc1360bf71
diff --git a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
index f2829664c07b..0ff773343e29 100644
--- a/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
+++ b/products/engineering_analytics/backend/logic/queries/_workflow_filters.py
@@ -197,9 +197,8 @@ def window_pair_predicates(column: str, *, date_to: datetime | None) -> WindowPr
def default_branch_predicate(branch_column: str = "r.head_branch") -> str:
- """True when the branch expression names the repo's default branch. The source does not record
- which branch that is, so the common default names stand in. ``repo_overview.query_default_branch``
- resolves it per repo, but that costs an extra query."""
+ """Treats ``master`` and ``main`` as the default branch, because the runs source does not record it.
+ ``default_branches.query_default_branches`` reads GitHub's value from the PR snapshot."""
return f"{branch_column} IN ('master', 'main')"
@@ -210,14 +209,9 @@ def run_scope_filter_clause(
attributed_predicate: str = "r.pr_number > 0",
merge_queue_predicate: str = "r.is_merge_queue",
) -> str:
- """The WHERE fragment that narrows a run population to one ``WorkflowHealthRunScope`` (see that
- enum for what each group covers), or '' for ``all``.
-
- ``pull_request`` needs all three predicates. A default-branch run can still carry a PR
- association (its SHA matches an open PR), so attribution alone (pr_number > 0 — see the
- workflow_runs builder docstring) does not keep trunk runs out, and gate runs belong to
- ``merge_queue`` instead.
- """
+ """The WHERE fragment for one ``WorkflowHealthRunScope``, or '' for ``all``. ``pull_request`` needs
+ all three predicates: a default-branch run can still carry a PR association, and gate runs belong to
+ ``merge_queue``."""
if run_scope == WorkflowHealthRunScope.DEFAULT_BRANCH:
return f"AND {default_branch_predicate(branch_column)}"
if run_scope == WorkflowHealthRunScope.PULL_REQUEST:
diff --git a/products/engineering_analytics/backend/logic/queries/workflow_health.py b/products/engineering_analytics/backend/logic/queries/workflow_health.py
index 0195e4bfadd8..4f547d95fe38 100644
--- a/products/engineering_analytics/backend/logic/queries/workflow_health.py
+++ b/products/engineering_analytics/backend/logic/queries/workflow_health.py
@@ -104,11 +104,8 @@ _PREV_SELECT = f"""
LIMIT {UNPAGED_SCAN_LIMIT}
"""
-# Merge-queue run counts over the same window with no branch/run_scope filter, so the list can rank
-# queue-gating workflows whatever scope is active. Only needed when a filter is on: without one, the
-# main query's own countIf already answers this. The scan covers only the workflows the main query
-# returned, HAVING keeps the gating ones, and the explicit bound keeps HogQL's default 100-row cap
-# from silently dropping some of them.
+# Merge-queue run counts with no branch or run_scope filter, over the workflows the main query returned.
+# The explicit LIMIT stops HogQL's default 100-row cap from dropping gating rows.
_GATING_SELECT = f"""
SELECT
repo_owner,
diff --git a/products/engineering_analytics/backend/tests/test_logic_workflows.py b/products/engineering_analytics/backend/tests/test_logic_workflows.py
index 819c2127bf7e..8f5795ac1014 100644
--- a/products/engineering_analytics/backend/tests/test_logic_workflows.py
+++ b/products/engineering_analytics/backend/tests/test_logic_workflows.py
@@ -1125,9 +1125,8 @@ class TestWorkflowEndpointsWarehouse(_EndpointsWarehouseMixin, BaseTest):
)
assert (all_jobs, main_jobs) == (3, 2)
- # A run scope narrows the same two job-level surfaces. The jobs source carries no branch
- # attribution of its own, so job_aggregates scopes through a run-id subquery; this is the one
- # place that subquery and the runner-cost scope clause run against a warehouse.
+ # A run scope narrows the same two job-level surfaces. job_aggregates scopes through a run-id
+ # subquery, because jobs carry no PR attribution or merge-queue state.
default_branch_jobs = sum(
c.job_count
for c in api.get_workflow_runner_costs(
diff --git a/products/engineering_analytics/backend/tests/test_presentation.py b/products/engineering_analytics/backend/tests/test_presentation.py
index 0d33a8debd0e..95d4d271f079 100644
--- a/products/engineering_analytics/backend/tests/test_presentation.py
+++ b/products/engineering_analytics/backend/tests/test_presentation.py
@@ -599,8 +599,6 @@ class TestEngineeringAnalyticsAPI(APIBaseTest):
]
)
def test_400_on_invalid_run_scope(self, action: str, params: dict[str, str]) -> None:
- # A typo'd scope must 400 on every endpoint that accepts it, not silently return the
- # all-runs population as a 200.
response = self.client.get(self._url(action), {**params, "run_scope": "bogus"})
assert response.status_code == status.HTTP_400_BAD_REQUEST
diff --git a/products/engineering_analytics/frontend/components/ScopeBar.tsx b/products/engineering_analytics/frontend/components/ScopeBar.tsx
index e5afcf41c07b..b4b7529d4ebb 100644
--- a/products/engineering_analytics/frontend/components/ScopeBar.tsx
+++ b/products/engineering_analytics/frontend/components/ScopeBar.tsx
@@ -216,8 +216,6 @@ const RUN_SCOPE_SEGMENTS = RUN_SCOPE_OPTIONS.map((option) => ({
'data-attr': `engineering-analytics-run-scope-${option.value}`,
}))
-/** The shared run-scope control: four fixed groups that partition the repo's runs. Every workflow
- * surface sends the picked group, so a drill-down reports the same population as the list it came from. */
export function RunScopeControl(): JSX.Element {
const { runScope } = useValues(engineeringAnalyticsFiltersLogic)
const { setRunScope } = useActions(engineeringAnalyticsFiltersLogic)
@@ -260,7 +258,6 @@ export function ScopeDateFilter({
)
}
-/** The scope-panel rim both workflow pages share: run group on the left, window on the right. */
export function WorkflowScopeControls(): JSX.Element {
return (
<>
diff --git a/products/engineering_analytics/frontend/components/WorkflowHealthTable.tsx b/products/engineering_analytics/frontend/components/WorkflowHealthTable.tsx
index ff8c319f7844..ba365ba5d903 100644
--- a/products/engineering_analytics/frontend/components/WorkflowHealthTable.tsx
+++ b/products/engineering_analytics/frontend/components/WorkflowHealthTable.tsx
@@ -109,19 +109,13 @@ export function WorkflowHealthTable({
compact = false,
}: WorkflowHealthTableProps): JSX.Element {
const { searchParams } = useValues(router)
- // Each row opens the workflow's runs page, carrying the active window, run scope, and source so the
- // drill-down reports the same group of runs.
const rowUrl = (row: WorkflowHealthRow): string =>
withScope(
urls.engineeringAnalyticsWorkflowRuns(row.repoOwner, row.repoName, row.workflowName),
searchParams,
sourceId
)
- // Workflows the merge queue runs come first, because they gate every merge. Failing workflows stay
- // findable through the Status tag and its sorter, so they need no pass of their own.
const orderedRows = orderWorkflowHealthRows(rows)
- // Computed once for the whole table: without a gating row there is nothing to rank against, so a repo
- // with no merge queue mutes nothing.
const hasGatingRow = orderedRows.some(isGatingWorkflow)
const columns: LemonTableColumns<WorkflowHealthRow> = [
{
diff --git a/products/engineering_analytics/frontend/lib/runHealth.test.ts b/products/engineering_analytics/frontend/lib/runHealth.test.ts
index 00c0ebc7db5f..11264cce85df 100644
--- a/products/engineering_analytics/frontend/lib/runHealth.test.ts
+++ b/products/engineering_analytics/frontend/lib/runHealth.test.ts
@@ -214,7 +214,6 @@ describe('runHealth', () => {
})
it.each<[string, OrderableWorkflowRow[], string[]]>([
- // A gating workflow outranks a busier non-gating one: the queue runs it before every merge.
[
'merge-queue workflows first, then run count',
[
@@ -224,7 +223,6 @@ describe('runHealth', () => {
],
['Frontend CI', 'Backend CI', 'Docs'],
],
- // A repo with no merge queue falls straight through to run count.
[
'no gating rows leaves pure run-count order',
[
@@ -233,7 +231,6 @@ describe('runHealth', () => {
],
['Backend CI', 'Docs'],
],
- // Equal run counts settle by name, so the table keeps a fixed order between renders.
[
'equal run counts settle by name',
[
diff --git a/products/engineering_analytics/frontend/lib/runHealth.ts b/products/engineering_analytics/frontend/lib/runHealth.ts
index 687b4603ae2e..a237dad76ef5 100644
--- a/products/engineering_analytics/frontend/lib/runHealth.ts
+++ b/products/engineering_analytics/frontend/lib/runHealth.ts
@@ -245,8 +245,6 @@ export function computeFleetSummary(rows: FleetRow[]): FleetSummary {
}
}
-/** The fields the workflow-list order reads. Structural, so a table row and a test fixture both satisfy
- * it without importing the full health row. */
export interface OrderableWorkflowRow {
workflowName: string
runCount: number
@@ -259,8 +257,7 @@ export function isGatingWorkflow(row: OrderableWorkflowRow): boolean {
return row.mergeQueueRunCount > 0
}
-/** The workflow list's default order: gating workflows first, then the busiest, then by name. The name
- * tiebreak keeps equal run counts in a fixed order, so the table does not reshuffle between renders. */
+/** The name tiebreak keeps equal run counts in a fixed order, so the table does not reshuffle between renders. */
export function orderWorkflowHealthRows<T extends OrderableWorkflowRow>(rows: T[]): T[] {
return [...rows].sort(
(a, b) =>
diff --git a/products/engineering_analytics/frontend/lib/scope.ts b/products/engineering_analytics/frontend/lib/scope.ts
index 5a6db7c33ceb..c8804ab8d829 100644
--- a/products/engineering_analytics/frontend/lib/scope.ts
+++ b/products/engineering_analytics/frontend/lib/scope.ts
@@ -1,10 +1,7 @@
import { combineUrl, router } from 'kea-router'
-/** Carry the shared window + run scope (and active source/repo) onto an internal nav URL, so drilling in,
- * switching workflows, or stepping back never silently resets it. The scope lives in the URL, and every
- * cross-page link threads it the same way the tab links do (`?date_from` / `?date_to` / `?run_scope` /
- * `?source` / `?repo`). Every workflow surface reads `run_scope`, so a drill-down keeps the same group
- * of runs instead of widening back to all of them. */
+/** Carry the shared window, run scope, source, and repo onto an internal nav URL, so drilling in or stepping
+ * back never silently resets them. */
export function withScope(
url: string,
searchParams: Record<string, string | undefined>,
@@ -15,8 +12,6 @@ export function withScope(
...(searchParams.date_to ? { date_to: searchParams.date_to } : {}),
...(searchParams.run_scope ? { run_scope: searchParams.run_scope } : {}),
...(sourceId ? { source: sourceId } : {}),
- // Carry the repo scope of a multi-repo source (set by the picker) from the current URL the same
- // way as `?run_scope`, so every withScope-based link preserves it with no caller change.
...(searchParams.repo ? { repo: searchParams.repo } : {}),
}).url
}
diff --git a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
index d9971ab3bb90..746c4ae8c107 100644
--- a/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
+++ b/products/engineering_analytics/frontend/scenes/EngineeringAnalyticsWorkflows.tsx
@@ -43,7 +43,6 @@ export function EngineeringAnalyticsWorkflows(): JSX.Element {
<div className="flex flex-col gap-4">
<RepoEntityHeader repoFullName={activeSource?.repo || ''} right={<SourceScopeChip pickerOnly />} />
- {/* Scope + window govern every surface inside the panel, the same scope the overview carries. */}
<ScopePanel busy={workflowHealthLoading && workflowHealth.length > 0} controls={<WorkflowScopeControls />}>
<WorkflowsHealthHeader
summary={fleetSummary}
diff --git a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
index 2c166cd2bdd4..e3244dfdac4c 100644
--- a/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
+++ b/products/engineering_analytics/frontend/scenes/WorkflowRunsScene.tsx
@@ -293,7 +293,6 @@ export function WorkflowRunsScene(): JSX.Element {
</LemonButton>
}
/>
- {/* Navigation only: the window and run scope dock on the panel below. */}
<ScopeBar
repoSlot={
<RepoScopeChip
@@ -322,7 +321,6 @@ export function WorkflowRunsScene(): JSX.Element {
slug={`${repoOwner}/${repoName}`}
right={verdictPill}
/>
- {/* Same window + run scope as the repo hub, so numbers match after drilling in. */}
{workflowHealthFailed && (
<LemonBanner type="warning">
These figures could not load, so they cover only the runs in the table below rather than the whole
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsFiltersLogic.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsFiltersLogic.ts
index 4480491e9f0f..a9fd814c67b6 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsFiltersLogic.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsFiltersLogic.ts
@@ -10,8 +10,8 @@ import { EngineeringAnalyticsWorkflowHealthRunScope } from '../generated/api.sch
// to the others. 7 days: long enough to read a week of spend, short enough that health reads as recent.
export const SHARED_DEFAULT_DATE_FROM = '-7d'
-/** The four groups the backend partitions a repo's runs into. Derived from the generated enum, so a
- * backend rename breaks the typecheck here instead of silently sending a value the API rejects. */
+/** Derived from the generated enum, so a backend rename breaks the typecheck here instead of sending a
+ * value the API rejects. */
export type RunScope = EngineeringAnalyticsWorkflowHealthRunScope
/** The request params the active scope resolves to. `all` sends nothing, because the backend already
@@ -47,10 +47,8 @@ export const RUN_SCOPE_OPTIONS: { value: RunScope; label: string; tooltip: strin
const RUN_SCOPE_VALUES: RunScope[] = RUN_SCOPE_OPTIONS.map((option) => option.value)
-/** Resolve the scope a URL asks for. An unknown `run_scope` falls back to all runs rather than failing
- * the request. `?q=` was the exact-branch param this scope replaced: master and main are the only two
- * values a fixed group can still honor, so they map to the default branch and every other branch is
- * dropped. */
+/** Resolve the scope a URL asks for. An unknown `run_scope` falls back to all runs. A legacy `?q=` of
+ * master or main maps to the default branch; any other branch is dropped. */
function runScopeFromUrl(runScope: string | undefined, legacyBranch: string | undefined): RunScope {
if (runScope) {
return RUN_SCOPE_VALUES.includes(runScope as RunScope)
@@ -142,9 +140,6 @@ export type engineeringAnalyticsFiltersLogicType = MakeLogicType<
engineeringAnalyticsFiltersLogicMeta
>
-// The run scope is shared like the window: one of four fixed groups that partition a repo's runs, not a
-// branch a user types. Every workflow surface sends the same group, so the list and the detail page
-// report the same population.
export const engineeringAnalyticsFiltersLogic = kea<engineeringAnalyticsFiltersLogicType>([
path(['products', 'engineering_analytics', 'frontend', 'scenes', 'engineeringAnalyticsFiltersLogic']),
@@ -187,8 +182,7 @@ export const engineeringAnalyticsFiltersLogic = kea<engineeringAnalyticsFiltersL
}
return [pathname, next, hashParams, { replace: true }]
},
- // Mirror the scope into `?run_scope=` so a scoped view is shareable, and drop the `?q=` branch
- // param it replaced so an old link stops re-hydrating a branch nothing reads any more.
+ // Mirror the scope into `?run_scope=` so a scoped view is shareable, and drop the legacy `?q=` param.
setRunScope: () => {
const { pathname, searchParams, hashParams } = router.values.currentLocation
const next = { ...searchParams }
diff --git a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
index 10a37b1b0e0f..86e7a62c5359 100644
--- a/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
+++ b/products/engineering_analytics/frontend/scenes/engineeringAnalyticsLogic.test.ts
@@ -345,8 +345,6 @@ describe('engineeringAnalyticsLogic', () => {
})
it('scopes workflow health to the shared run group', async () => {
- // The scope lives in the shared filters logic so it carries into the workflow detail page; the
- // Workflows tab reads it and reloads workflow health whenever the group changes.
logic = engineeringAnalyticsLogic()
logic.mount()
const filters = engineeringAnalyticsFiltersLogic()
@@ -359,7 +357,6 @@ describe('engineeringAnalyticsLogic', () => {
await expectLogic(logic).toDispatchActions(['loadWorkflowHealth', 'loadWorkflowHealthSuccess'])
expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-7d', run_scope: 'pull_request' })
- // The group persists across a window change.
filters.actions.setDateRange('-90d', null)
await expectLogic(logic).toDispatchActions(['loadWorkflowHealthSuccess'])
expect(mockWorkflowHealth).toHaveBeenLastCalledWith('1', { date_from: '-90d', run_scope: 'pull_request' })
diff --git a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
index b6eb460ee86e..23b9f0eb2bdc 100644
--- a/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
+++ b/products/engineering_analytics/frontend/scenes/workflowRunsLogic.test.ts
@@ -67,13 +67,14 @@ describe('workflowRunsLogic', () => {
logic.mount()
const filters = engineeringAnalyticsFiltersLogic()
unmountFilters = filters.mount()
- await expectLogic(logic).toDispatchActions([
+ const windowedReadSuccesses = [
'loadRunsSuccess',
'loadWorkflowHealthSuccess',
'loadRunActivitySuccess',
'loadRunnerCostsSuccess',
'loadJobAggregatesSuccess',
- ])
+ ]
+ await expectLogic(logic).toDispatchActionsInAnyOrder(windowedReadSuccesses)
const windowedReads = [mockRuns, mockWorkflowHealth, mockRunActivity, mockRunnerCosts, mockJobAggregates]
for (const read of windowedReads) {
@@ -88,18 +89,7 @@ describe('workflowRunsLogic', () => {
// Picking a group on the shared filters logic reloads all five reads scoped to it, so the detail
// page's numbers and its chart match the list it was opened from.
filters.actions.setRunScope('merge_queue')
- await expectLogic(logic).toDispatchActions([
- 'loadRuns',
- 'loadWorkflowHealth',
- 'loadRunActivity',
- 'loadRunnerCosts',
- 'loadJobAggregates',
- 'loadRunsSuccess',
- 'loadWorkflowHealthSuccess',
- 'loadRunActivitySuccess',
- 'loadRunnerCostsSuccess',
- 'loadJobAggregatesSuccess',
- ])
+ await expectLogic(logic).toDispatchActionsInAnyOrder(windowedReadSuccesses)
for (const read of windowedReads) {
expect(read).toHaveBeenLastCalledWith('1', expect.objectContaining({ run_scope: 'merge_queue' }))
}