From 973d32b52cc4e7047fea495f1aebc87bf4d63eee Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:38:22 +0000 Subject: [PATCH 1/2] fix(ui): show never-run nodes, cross-job skip causes and root causes on group runs Nodes a stopped worker never reached read as not run instead of skipped, with the run's reason. A skip caused by another job's node names and links that job. The group run's title line names the jobs that failed on their own account and how many jobs each held back, and each attempt in the job panel shows its own outcome. Members read `blocked` from the run status instead of deriving it. The real-server UI tests run on a PostgreSQL control database, and a new one kills a worker mid-build. --- .github/workflows/verify.yml | 16 ++-- ui/e2e/real/crash.spec.ts | 76 ++++++++++++++++ .../job_groups/crash_job_group.toml | 3 + .../orchestration/jobs/after_crash_job.toml | 3 + .../project/orchestration/jobs/crash_job.toml | 3 + .../project/python/nodes/crash_after/asset.py | 9 ++ .../project/python/nodes/crash_first/asset.py | 7 ++ .../python/nodes/crash_report/asset.py | 9 ++ .../project/python/nodes/crash_side/asset.py | 7 ++ .../project/python/nodes/crash_wait/asset.py | 19 ++++ ui/e2e/real/project/sqlbuild_project.toml | 2 +- ui/e2e/real/server.ts | 32 ++++++- ui/src/lib/api/http-runs.test.ts | 27 +++++- ui/src/lib/api/http-runs.ts | 22 ++++- ui/src/lib/api/mock/operate-store.ts | 2 +- ui/src/lib/api/mock/operate.ts | 2 +- ui/src/lib/api/mock/run-detail.ts | 16 ++-- ui/src/lib/api/types/operate.ts | 7 +- ui/src/lib/build-area/attention.test.ts | 2 +- ui/src/lib/operate/labels.ts | 3 +- ui/src/lib/status.ts | 4 + ui/src/routes/layout.css | 7 +- ui/src/routes/runs/[id]/job-drawer.svelte | 20 ++++- ui/src/routes/runs/[id]/node-drawer.svelte | 18 +++- ui/src/routes/runs/[id]/root-causes.svelte | 90 +++++++++++++++++++ ui/src/routes/runs/[id]/run-summary.svelte | 8 +- ui/src/routes/runs/[id]/run-tree.svelte | 4 + ui/src/routes/runs/[id]/run-view.svelte | 17 ++-- .../runs/[id]/utils/job-outcomes.test.ts | 59 ++++++++++++ ui/src/routes/runs/[id]/utils/job-outcomes.ts | 54 +++++++---- .../routes/runs/[id]/utils/run-tree.test.ts | 13 ++- ui/src/routes/runs/[id]/utils/run-tree.ts | 13 +-- ui/src/routes/runs/[id]/utils/skips.ts | 29 ++++-- ui/src/routes/runs/utils/status-line.ts | 2 + 34 files changed, 524 insertions(+), 81 deletions(-) create mode 100644 ui/e2e/real/crash.spec.ts create mode 100644 ui/e2e/real/project/orchestration/job_groups/crash_job_group.toml create mode 100644 ui/e2e/real/project/orchestration/jobs/after_crash_job.toml create mode 100644 ui/e2e/real/project/orchestration/jobs/crash_job.toml create mode 100644 ui/e2e/real/project/python/nodes/crash_after/asset.py create mode 100644 ui/e2e/real/project/python/nodes/crash_first/asset.py create mode 100644 ui/e2e/real/project/python/nodes/crash_report/asset.py create mode 100644 ui/e2e/real/project/python/nodes/crash_side/asset.py create mode 100644 ui/e2e/real/project/python/nodes/crash_wait/asset.py create mode 100644 ui/src/routes/runs/[id]/root-causes.svelte create mode 100644 ui/src/routes/runs/[id]/utils/job-outcomes.test.ts diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 7e81af6966..2d4527a7f8 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -213,10 +213,10 @@ jobs: esac case "${path}" in # The UI's flows on a real server (ui/e2e/real/): the UI, and the server code a group - # run's Rerun goes through: group runs and retries, the run, retry, snapshot and change - # handlers, publication, and the control store. Every crate path here also selects the - # wheels the job installs. - ui/*|.github/workflows/verify.yml|crates/sqlbuild-orchestration/src/runs/*|crates/sqlbuild-orchestration/src/snapshots/*|crates/sqlbuild-orchestration/src/store/*|crates/sqlbuild-orchestration/src/store_migrations/*|crates/sqlbuild-orchestration/src/api/_helpers/resources/runs.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/run_reads.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/person_operations.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/snapshots.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/changes.rs) + # run's Rerun and a stopped worker go through: group runs and retries, the run, retry, + # snapshot and change handlers, publication, the control store and the worker + # supervisor. Every crate path here also selects the wheels the job installs. + ui/*|.github/workflows/verify.yml|crates/sqlbuild-cli/src/workers/*|crates/sqlbuild-orchestration/src/runs/*|crates/sqlbuild-orchestration/src/snapshots/*|crates/sqlbuild-orchestration/src/store/*|crates/sqlbuild-orchestration/src/store_migrations/*|crates/sqlbuild-orchestration/src/api/_helpers/resources/runs.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/run_reads.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/person_operations.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/snapshots.rs|crates/sqlbuild-orchestration/src/api/_helpers/resources/changes.rs) ui_real=true ;; esac @@ -1437,8 +1437,14 @@ jobs: npm ci npm run build npx playwright install --with-deps chromium - - name: Group run, failure, new version and Rerun failed on a real server + - name: Start a PostgreSQL server for the control databases + run: | + sudo systemctl start postgresql.service + sudo -u postgres psql -v ON_ERROR_STOP=1 -c "ALTER USER postgres PASSWORD 'postgres'" + - name: Group runs with a failure, a new version, Rerun failed and a stopped worker on a real server working-directory: ui + env: + SQB_TEST_CONTROL_POSTGRES_URL: postgresql://postgres:postgres@127.0.0.1:5432/postgres run: SQB="${GITHUB_WORKSPACE}/.venv/bin/sqb" npx playwright test --project=real --reporter=line podman: diff --git a/ui/e2e/real/crash.spec.ts b/ui/e2e/real/crash.spec.ts new file mode 100644 index 0000000000..ac93ce73aa --- /dev/null +++ b/ui/e2e/real/crash.spec.ts @@ -0,0 +1,76 @@ +import { expect, test } from '@playwright/test'; +import { RealServer, type RunRecord } from './server'; + +// A group run whose job loses its worker mid-build, as an out-of-memory kill would: the node building then +// fails, the nodes it never reached read as not run, not skipped; the job that reads them names the job that +// stopped; and the line under the title names that job and why it stopped. Every wait watches +// the server's state. +test.describe.configure({ mode: 'serial' }); +test.use({ viewport: { width: 1440, height: 900 } }); + +let server: RealServer; + +test.beforeAll(async () => { + test.setTimeout(300_000); + server = new RealServer(); + await server.up(); +}); + +test.afterAll(async () => { + await server?.down(); +}); + +const member = (members: RunRecord[], job: string) => members.filter((m) => m.job_key === job).at(-1); + +test("a stopped worker's unreached nodes read as not run, and the jobs that read them name it", async ({ page }) => { + test.setTimeout(300_000); + const groupRunId = server.startGroupRun('crash_job_group'); + let crashRunId = ''; + await server.until('crash_wait to start building', async () => { + const crash = member(await server.members(groupRunId), 'crash_job'); + if (!crash) return false; + crashRunId = crash.run_id; + return (await server.nodes(crash.run_id)).some((n) => n.node_key.endsWith('crash_wait') && n.status === 'running'); + }); + server.stopWorker(crashRunId); + await server.until('the group run to end', async () => !['queued', 'running'].includes((await server.status(groupRunId)) ?? 'queued')); + + // The server's facts, which the page shows: the node building when the worker stopped failed, the one + // after it never ran; after_crash_job built what reads nothing and skipped what reads it. + const members = await server.members(groupRunId); + const after = member(members, 'after_crash_job')!; + const byName = async (runId: string) => new Map((await server.nodes(runId)).map((n) => [n.node_key.split(':').at(-1), n])); + const crashNodes = await byName(crashRunId); + expect([crashNodes.get('crash_first')?.status, crashNodes.get('crash_wait')?.status, crashNodes.get('crash_after')?.status], server.tail()).toEqual(['success', 'failed', 'not_run']); + const afterNodes = await byName(after.run_id); + expect([afterNodes.get('crash_side')?.status, afterNodes.get('crash_report')?.status]).toEqual(['success', 'skipped']); + + await page.goto(`${server.uiUrl}/runs/${groupRunId}`); + const crashRow = page.locator(`.line.job[data-row="j:${crashRunId}"]`); + await expect(crashRow).toBeVisible({ timeout: 30_000 }); + await expect(crashRow).toContainText('1 not run'); + await expect(crashRow).not.toContainText('skipped'); + await crashRow.click(); + const afterRow = page.locator(`.line.node[data-row="n:${crashRunId}:${[...crashNodes.values()].find((n) => n.node_key.endsWith('crash_after'))!.node_key}"]`); + await expect(afterRow.locator('.sb-mark')).toHaveAttribute('data-state', 'not_run'); + + // The line under the title names the job that stopped and why, and that it held one job back, first. + const cause = page.getByTestId('root-cause').first(); + await expect(cause).toContainText('crash_job'); + await expect(cause).toContainText('crash_wait failed: worker stopped'); + await expect(cause).toContainText('held back 1 job'); + await expect(page.getByTestId('run-summary')).toContainText('1 not run'); + + // A skipped node names the unreached node in the other job, and opens it. + await page.locator(`.line.job[data-row="j:${after.run_id}"]`).click(); + await page.getByRole('button', { name: 'crash_report', exact: true }).click(); + await expect(page.getByTestId('node-cause')).toContainText('crash_after did not run in crash_job'); + await page.getByTestId('node-cause').getByRole('button', { name: 'open crash_after' }).click(); + await expect(page.getByTestId('node-drawer')).toContainText('Not run'); + await expect(page.getByTestId('node-cause')).toContainText('worker stopped'); + + // The job's panel gives its attempt's own outcome. + await page.getByRole('button', { name: 'crash_job', exact: true }).first().click(); + await expect(page.getByTestId('job-stopped')).toContainText('Stopped: worker stopped'); + await expect(page.getByRole('alert')).toHaveCount(0); +}); diff --git a/ui/e2e/real/project/orchestration/job_groups/crash_job_group.toml b/ui/e2e/real/project/orchestration/job_groups/crash_job_group.toml new file mode 100644 index 0000000000..8a56d2e53e --- /dev/null +++ b/ui/e2e/real/project/orchestration/job_groups/crash_job_group.toml @@ -0,0 +1,3 @@ +name = "crash_job_group" +description = "A job whose worker stops mid-build, then a job that reads from it" +jobs = ["crash_job", "after_crash_job"] diff --git a/ui/e2e/real/project/orchestration/jobs/after_crash_job.toml b/ui/e2e/real/project/orchestration/jobs/after_crash_job.toml new file mode 100644 index 0000000000..3ed76f5ad6 --- /dev/null +++ b/ui/e2e/real/project/orchestration/jobs/after_crash_job.toml @@ -0,0 +1,3 @@ +name = "after_crash_job" +description = "Reads what crash_job builds, and one node that reads nothing" +select = "crash_report crash_side" diff --git a/ui/e2e/real/project/orchestration/jobs/crash_job.toml b/ui/e2e/real/project/orchestration/jobs/crash_job.toml new file mode 100644 index 0000000000..f6ec1d3ee6 --- /dev/null +++ b/ui/e2e/real/project/orchestration/jobs/crash_job.toml @@ -0,0 +1,3 @@ +name = "crash_job" +description = "Builds until the test stops its worker" +select = "crash_first crash_wait crash_after" diff --git a/ui/e2e/real/project/python/nodes/crash_after/asset.py b/ui/e2e/real/project/python/nodes/crash_after/asset.py new file mode 100644 index 0000000000..e74f31baaf --- /dev/null +++ b/ui/e2e/real/project/python/nodes/crash_after/asset.py @@ -0,0 +1,9 @@ +from python.nodes.crash_wait.asset import crash_wait + +from sqlbuild.assets import asset + + +@asset(depends_on=crash_wait) +def crash_after(ctx): + """Never reached: its worker is stopped while crash_wait runs.""" + return ctx.result(metadata={"built": True}) diff --git a/ui/e2e/real/project/python/nodes/crash_first/asset.py b/ui/e2e/real/project/python/nodes/crash_first/asset.py new file mode 100644 index 0000000000..a7c67fa1ce --- /dev/null +++ b/ui/e2e/real/project/python/nodes/crash_first/asset.py @@ -0,0 +1,7 @@ +from sqlbuild.assets import asset + + +@asset +def crash_first(ctx): + """Builds before the worker is stopped.""" + return ctx.result(metadata={"built": True}) diff --git a/ui/e2e/real/project/python/nodes/crash_report/asset.py b/ui/e2e/real/project/python/nodes/crash_report/asset.py new file mode 100644 index 0000000000..e3b0b02c1e --- /dev/null +++ b/ui/e2e/real/project/python/nodes/crash_report/asset.py @@ -0,0 +1,9 @@ +from python.nodes.crash_after.asset import crash_after + +from sqlbuild.assets import asset + + +@asset(depends_on=crash_after) +def crash_report(ctx): + """Reads crash_after, which another job never built.""" + return ctx.result(metadata={"built": True}) diff --git a/ui/e2e/real/project/python/nodes/crash_side/asset.py b/ui/e2e/real/project/python/nodes/crash_side/asset.py new file mode 100644 index 0000000000..0e9509445b --- /dev/null +++ b/ui/e2e/real/project/python/nodes/crash_side/asset.py @@ -0,0 +1,7 @@ +from sqlbuild.assets import asset + + +@asset +def crash_side(ctx): + """Reads nothing upstream, so it builds whatever happens to crash_job.""" + return ctx.result(metadata={"built": True}) diff --git a/ui/e2e/real/project/python/nodes/crash_wait/asset.py b/ui/e2e/real/project/python/nodes/crash_wait/asset.py new file mode 100644 index 0000000000..d5ad0072cd --- /dev/null +++ b/ui/e2e/real/project/python/nodes/crash_wait/asset.py @@ -0,0 +1,19 @@ +import os +import time +from pathlib import Path + +from python.nodes.crash_first.asset import crash_first + +from sqlbuild.assets import asset + + +@asset(depends_on=crash_first) +def crash_wait(ctx): + """Runs until the test has stopped its worker and writes the file RERUN_FIXTURE_GATE names.""" + gate = Path(os.environ["RERUN_FIXTURE_GATE"]) + deadline = time.monotonic() + 300 + while not gate.exists(): + if time.monotonic() > deadline: + raise TimeoutError(f"{gate} was never written") + time.sleep(0.2) + return ctx.result(metadata={"released": True}) diff --git a/ui/e2e/real/project/sqlbuild_project.toml b/ui/e2e/real/project/sqlbuild_project.toml index cf5534f6f1..10a5babe94 100644 --- a/ui/e2e/real/project/sqlbuild_project.toml +++ b/ui/e2e/real/project/sqlbuild_project.toml @@ -1,4 +1,4 @@ -# The project the real-server UI test serves. Small on purpose: three jobs in one group. +# The project the real-server UI tests serve. Small on purpose: two groups of a few jobs each. name = "rerun_fixture" adapter = "duckdb" default_target = "dev" diff --git a/ui/e2e/real/server.ts b/ui/e2e/real/server.ts index 458578263d..111eb064b0 100644 --- a/ui/e2e/real/server.ts +++ b/ui/e2e/real/server.ts @@ -1,6 +1,6 @@ import { spawn, spawnSync, type ChildProcess } from 'node:child_process'; import { randomUUID } from 'node:crypto'; -import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; import { createServer } from 'node:net'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; @@ -8,7 +8,9 @@ import { fileURLToPath } from 'node:url'; // A real `sqb server` with a local location on a copy of ./project, and this checkout's built UI in front // of it, signed in as one admin through the preview's proxy. `SQB` names the sqb executable (default: the -// one on PATH). Every wait here watches the server's state; none sleeps for a fixed time. +// one on PATH). The control database is a new PostgreSQL database on the server `SQB_TEST_CONTROL_POSTGRES_URL` +// names, dropped afterwards; `psql` creates it. Every wait here watches the server's state; none sleeps for a +// fixed time. const PROJECT = fileURLToPath(new URL('./project', import.meta.url)); const UI_DIR = fileURLToPath(new URL('../..', import.meta.url)); @@ -16,6 +18,7 @@ const SQB = process.env.SQB || 'sqb'; const LOCATION = 'shop'; const TARGET = 'dev'; const USER = 'tester'; +const POSTGRES = process.env.SQB_TEST_CONTROL_POSTGRES_URL; export type RunRecord = { run_id: string; @@ -51,16 +54,28 @@ export class RealServer { private locationId = ''; private children: ChildProcess[] = []; private logs: string[] = []; + /** The control database's name on the PostgreSQL server, and its URL. */ + private readonly database = `sqb_ui_${randomUUID().replaceAll('-', '')}`; + private readonly control: string; constructor() { + if (!POSTGRES) throw new Error('SQB_TEST_CONTROL_POSTGRES_URL names no PostgreSQL server for the control database'); this.root = mkdtempSync(join(tmpdir(), 'sqb-real-ui-')); this.dir = join(this.root, 'project'); this.gate = join(this.root, 'release-hold'); cpSync(PROJECT, this.dir, { recursive: true }); + const url = new URL(POSTGRES); + url.pathname = `/${this.database}`; + this.control = url.toString(); + } + + private psql(sql: string): void { + const result = spawnSync('psql', [POSTGRES!, '-v', 'ON_ERROR_STOP=1', '-c', sql], { encoding: 'utf8' }); + if (result.status !== 0) throw new Error(`psql failed: ${result.stderr || result.error}`); } private admin(...args: string[]): Record { - const result = spawnSync(SQB, ['admin', args[0], '--json', ...args.slice(1)], { cwd: this.dir, encoding: 'utf8' }); + const result = spawnSync(SQB, ['admin', args[0], '--json', ...args.slice(1)], { cwd: this.dir, encoding: 'utf8', env: { ...process.env, SQLBUILD_CONTROL_DATABASE_URL: this.control } }); if (result.status !== 0) throw new Error(`sqb admin ${args[0]} failed: ${result.stderr || result.error}`); return JSON.parse(result.stdout); } @@ -86,10 +101,12 @@ export class RealServer { this.uiUrl = `http://127.0.0.1:${uiPort}`; const serverUrl = `http://127.0.0.1:${serverPort}`; this.apiBase = serverUrl; + this.psql(`CREATE DATABASE ${this.database}`); const person = this.admin('create-user', USER); this.locationId = this.admin('create-location', LOCATION).location_id; const expiry = new Date(Date.now() + 86_400_000).toISOString().replace(/\.\d+Z$/, '+00:00'); const token = this.admin('issue-location-token', this.locationId, '--expires-at', expiry).bearer; + mkdirSync(join(this.dir, '.sqlbuild'), { recursive: true }); const config = join(this.dir, '.sqlbuild', 'server.toml'); writeFileSync( config, @@ -97,7 +114,7 @@ export class RealServer { `[[launchers.local]]\nlocation = "${LOCATION}"\ntarget = "${TARGET}"\nserver_url = "${serverUrl}"\nmax_workers = 1\nproject_dir = "${this.dir}"\nexecutable = "${SQB}"\n` ); const env = { RERUN_FIXTURE_GATE: this.gate }; - this.start('server', SQB, ['server', '--config', config], this.dir, env); + this.start('server', SQB, ['server', '--config', config], this.dir, { ...env, SQLBUILD_CONTROL_DATABASE_URL: this.control }); this.start('location', SQB, ['location', 'serve', '--server', serverUrl, '--location-id', this.locationId, '--target', TARGET], this.dir, { ...env, SQLBUILD_LOCATION_TOKEN: token }); this.start('ui', 'npx', ['vite', 'preview', '--host', '127.0.0.1', '--port', String(uiPort), '--strictPort'], UI_DIR, { SQB_SERVER_URL: serverUrl, @@ -124,6 +141,7 @@ export class RealServer { ) ); rmSync(this.root, { recursive: true, force: true }); + this.psql(`DROP DATABASE IF EXISTS ${this.database} WITH (FORCE)`); } /** Polls `check` until it holds. A child that stops fails the wait at once, with its output. */ @@ -181,4 +199,10 @@ export class RealServer { release(): void { writeFileSync(this.gate, ''); } + + /** Kills a job run's worker outright, as a crash or an out-of-memory kill would: no chance to report. */ + stopWorker(runId: string): void { + const result = spawnSync('pkill', ['-KILL', '-f', `run-id ${runId}`]); + if (result.status !== 0) throw new Error(`no worker process for run ${runId} to stop (pkill exit ${result.status})`); + } } diff --git a/ui/src/lib/api/http-runs.test.ts b/ui/src/lib/api/http-runs.test.ts index e83fcad3be..5447e5c79c 100644 --- a/ui/src/lib/api/http-runs.test.ts +++ b/ui/src/lib/api/http-runs.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import type { components } from '$control/schema.d.ts'; +import type { Run } from '$lib/api'; import { groupRunNodes, mergePlanPage, nodeKindOf, parseRunCursor, queueEntriesOf, planResultOf, runDetailOf, runRowPage, runRowPageOver, runTabCountsOf, toRunNode, toRuns, toRunEvent, toRunStatements, toRunOutput } from './http-runs'; type RunRecord = components['schemas']['RunRecord']; @@ -51,7 +52,7 @@ describe('run mapping', () => { expect([part.narrowing, whole.narrowing]).toEqual([{ select: [], exclude: ['customers'] }, null]); }); - it('counts cancelled nodes as failed, not-run nodes among the skipped as well as on their own, and each run’s direct children', () => { + it('counts cancelled nodes as failed, not-run nodes apart from the skipped, and each run’s direct children', () => { const runs = toRuns( [ wire('group', { kind: 'group', node_counts_json: { success: 3, cancelled: 2, failed: 1, pending: 4, skipped: 1, not_run: 2 } }), @@ -61,7 +62,7 @@ describe('run mapping', () => { ], LOCATION ); - expect(runs[0].nodeCounts).toEqual({ success: 3, warn: 0, failed: 3, skipped: 3, notRun: 2, running: 0, pending: 4 }); + expect(runs[0].nodeCounts).toEqual({ success: 3, warn: 0, failed: 3, skipped: 1, notRun: 2, running: 0, pending: 4 }); expect(runs.map((r) => r.childRunCount)).toEqual([2, 1, 0, 0]); }); }); @@ -400,6 +401,28 @@ describe('group run nodes', () => { ['model:raw', 's', 'failed'] ]); }); + + it("names the job run whose node a skip waited on, and keeps a skip's cause in its own run", () => { + const member = (id: string, job: string) => toRuns([wire(id, { parent_run_id: 'g', job_key: job })], LOCATION)[0]; + const [load1, load2, stage] = [member('l1', 'load'), member('l2', 'load'), member('s', 'stage')]; + const node = (key: string, status: string, owner: Run, cause: string | null = null, ended: string | null = null) => + toRunNode({ node_key: key, status, skipped_because_of: cause, ended_at: ended } as W['RunNodeRecord'], owner); + const nodes = groupRunNodes( + [], + // Newest attempt first, as the server lists them. Both attempts of load left raw unbuilt; stage skipped + // its own mart after stg_orders failed, and stg_payments for raw in load. + [ + node('loader:raw', 'not_run', load2, null, '2026-11-30T02:00:00Z'), + node('loader:raw', 'failed', load1, null, '2026-11-30T01:00:00Z'), + node('model:stg_orders', 'failed', stage), + node('model:stg_payments', 'skipped', stage, 'loader:raw'), + node('model:mart', 'skipped', stage, 'model:stg_orders') + ] + ); + const causes = new Map(nodes.filter((n) => n.skippedBecauseOf).map((n) => [n.nodeKey, [n.skippedBecauseOf!.runId, n.skippedBecauseOf!.jobKey]])); + expect(causes.get('model:stg_payments')).toEqual(['l2', 'load']); + expect(causes.get('model:mart')).toEqual(['s', 'stage']); + }); }); describe('planResultOf', () => { diff --git a/ui/src/lib/api/http-runs.ts b/ui/src/lib/api/http-runs.ts index 7fd09285e9..265b3ae6f3 100644 --- a/ui/src/lib/api/http-runs.ts +++ b/ui/src/lib/api/http-runs.ts @@ -140,7 +140,7 @@ function countsOf(wire: Wire['RunRecord']): NodeCounts { success: n('success'), warn: n('warn'), failed: n('failed') + n('cancelled'), - skipped: n('skipped') + n('not_run'), + skipped: n('skipped'), notRun: n('not_run'), running: n('running'), pending: n('pending') @@ -238,7 +238,7 @@ export function runsMatching(runs: Run[], query: RunListQuery): Run[] { function rowOf(run: Run, wire: Wire['RunRecord']): RunRow { const c = run.nodeCounts; - const total = c.success + c.warn + c.failed + c.skipped + c.running + c.pending; + const total = c.success + c.warn + c.failed + c.skipped + c.notRun + c.running + c.pending; return { run, progress: { done: total - c.running - c.pending, total }, @@ -402,11 +402,25 @@ export function runDetailOf(run: Run, wire: Wire['RunRecord'], listed: Run[], no /** * A run's nodes with its job runs' nodes. A group run's own rows repeat its job runs' nodes, so they - * stay only for nodes no job run has, such as those of members that never started. + * stay only for nodes no job run has, such as those of members that never started. The server names a + * skip's cause by node key alone; one its own run doesn't hold is another job's: the job run that has + * that node failed, cancelled or not run, the last to end where a retried job's attempts both do. */ export function groupRunNodes(own: RunNode[], children: RunNode[]): RunNode[] { const covered = new Set(children.map((n) => n.nodeKey)); - return [...own.filter((n) => !covered.has(n.nodeKey)), ...children]; + const inRun = new Set(children.map((n) => `${n.runId}\u0000${n.nodeKey}`)); + const holder = new Map(); + for (const n of children) { + if (!isUnfinishedNode(n.status) || n.status === 'skipped') continue; + const seen = holder.get(n.nodeKey); + if (!seen || (n.endedAt ?? '') > (seen.endedAt ?? '')) holder.set(n.nodeKey, n); + } + const resolved = (n: RunNode): RunNode => { + const why = n.skippedBecauseOf; + const at = why && !inRun.has(`${n.runId}\u0000${why.nodeKey}`) ? holder.get(why.nodeKey) : undefined; + return at ? { ...n, skippedBecauseOf: { nodeKey: why!.nodeKey, runId: at.runId, jobKey: at.jobKey } } : n; + }; + return [...own.filter((n) => !covered.has(n.nodeKey)), ...children].map(resolved); } const KNOWN_EVENTS: ReadonlySet = new Set(RECALL_EVENT_TYPES); diff --git a/ui/src/lib/api/mock/operate-store.ts b/ui/src/lib/api/mock/operate-store.ts index 1a23f84ae0..0e9357b96d 100644 --- a/ui/src/lib/api/mock/operate-store.ts +++ b/ui/src/lib/api/mock/operate-store.ts @@ -1262,7 +1262,7 @@ export class MockOperate { launchedAt: null, startedAt: null, endedAt: null, - nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, running: 0, pending: 0 }, + nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, notRun: 0, running: 0, pending: 0 }, cost: null, ignoredAuditFailures: 0, versionPolicy: null, diff --git a/ui/src/lib/api/mock/operate.ts b/ui/src/lib/api/mock/operate.ts index 7671a31820..95d265c7c5 100644 --- a/ui/src/lib/api/mock/operate.ts +++ b/ui/src/lib/api/mock/operate.ts @@ -972,7 +972,7 @@ export function createOperateFixtures(now: number): OperateFixtures { launchedAt: launched != null ? new Date(launched).toISOString() : null, startedAt: started != null ? new Date(started).toISOString() : null, endedAt: ended ? new Date(ended).toISOString() : null, - nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, running: 0, pending: 0 }, + nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, notRun: 0, running: 0, pending: 0 }, cost: null, ignoredAuditFailures: seed.ignored ?? 0, versionPolicy: null, diff --git a/ui/src/lib/api/mock/run-detail.ts b/ui/src/lib/api/mock/run-detail.ts index be57bc5a8f..10cd43eaad 100644 --- a/ui/src/lib/api/mock/run-detail.ts +++ b/ui/src/lib/api/mock/run-detail.ts @@ -324,10 +324,8 @@ export function countNodes(nodes: RunNode[]): NodeCounts { if (n.status === 'success') c.success++; else if (n.status === 'warn') c.warn++; else if (n.status === 'failed') c.failed++; - else if (n.status === 'skipped' || n.status === 'cancelled' || n.status === 'not_run') { - c.skipped++; - if (n.status !== 'skipped') c.notRun!++; - } + else if (n.status === 'skipped') c.skipped++; + else if (n.status === 'cancelled' || n.status === 'not_run') c.notRun++; else if (n.status === 'running') c.running++; else c.pending++; } @@ -340,14 +338,16 @@ export function deriveTerminalStatus(end: RunEnd, nodes: RunNode[]): RunStatus { if (end === 'cancelled') return 'cancelled'; if (end === 'presumed_failed') return 'presumed_failed'; const c = countNodes(nodes); - const blocked = c.failed + nodes.filter((n) => n.skippedBecauseOf).length; - if (blocked) return 'failed'; + // As on the server: a failure of its own fails the run; skips only for another member's node block it. + const upstream = (n: RunNode) => n.status === 'skipped' && !!n.skippedBecauseOf && n.skippedBecauseOf.runId !== n.runId; + if (c.failed || c.notRun || nodes.some((n) => n.status === 'skipped' && !upstream(n))) return 'failed'; + if (nodes.some(upstream)) return 'blocked'; return c.warn ? 'warn' : 'success'; } export function statusReason(status: RunStatus, nodes: RunNode[]): string | null { const c = countNodes(nodes); - if (status === 'failed' && c.success + c.warn > 0 && (c.failed || nodes.some((n) => n.skippedBecauseOf))) + if ((status === 'failed' || status === 'blocked') && c.success + c.warn > 0 && (c.failed || nodes.some((n) => n.skippedBecauseOf))) return c.failed ? `${c.failed} node${c.failed === 1 ? '' : 's'} failed and ${c.skipped} that depend on ${c.failed === 1 ? 'it' : 'them'} were skipped; the other ${c.success + c.warn} finished` : `${c.skipped} node${c.skipped === 1 ? '' : 's'} skipped because something they depend on failed; the other ${c.success + c.warn} finished`; @@ -355,7 +355,7 @@ export function statusReason(status: RunStatus, nodes: RunNode[]): string | null const first = nodes.find((n) => n.status === 'failed'); return first ? `${first.nodeKey} failed: ${first.errorMessage}` : null; } - if (status === 'failed' && c.skipped) { + if ((status === 'failed' || status === 'blocked') && c.skipped) { const why = nodes.find((n) => n.skippedBecauseOf)?.skippedBecauseOf; return why ? `Every node was skipped: ${why.nodeKey} failed in run ${why.runId.replace(/^run-/, '')}` : null; } diff --git a/ui/src/lib/api/types/operate.ts b/ui/src/lib/api/types/operate.ts index 4425af816d..603b20514b 100644 --- a/ui/src/lib/api/types/operate.ts +++ b/ui/src/lib/api/types/operate.ts @@ -18,6 +18,8 @@ export const RUN_STATUSES = [ 'failed', 'cancelled', 'skipped', + /** A group member that ran, failed nothing of its own, and skipped nodes because another member's node didn't succeed. */ + 'blocked', 'presumed_failed' ] as const; export type RunStatus = (typeof RUN_STATUSES)[number]; @@ -34,11 +36,12 @@ export type NodeCounts = { success: number; warn: number; failed: number; + /** Nodes left out because a node they depend on did not succeed. */ skipped: number; + /** Nodes that never ran because the run stopped first, such as its worker stopping. */ + notRun: number; running: number; pending: number; - /** Of `skipped`, the nodes that never ran because the run stopped first: "not run", not "skipped". */ - notRun?: number; }; /** Compute estimate for a finished run; null where the adapter reports no cost. */ diff --git a/ui/src/lib/build-area/attention.test.ts b/ui/src/lib/build-area/attention.test.ts index 877739ba18..7c587cca5f 100644 --- a/ui/src/lib/build-area/attention.test.ts +++ b/ui/src/lib/build-area/attention.test.ts @@ -9,7 +9,7 @@ const event = (id: string, kind: PlatformEvent['kind'], locationId: string | nul kind: 'platform_event', event: { id, kind, severity: 'warning', stopsRuns: false, occurredAt: ago(5), active: true, locationId, subject: null, message: `${kind} message`, ...over } }); -const run = (id: string, jobKey: string | null): AttentionRun => ({ id, jobKey, kind: 'job', status: 'unresponsive', statusReason: null, nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, running: 1, pending: 0 }, startedAt: ago(30), endedAt: null }); +const run = (id: string, jobKey: string | null): AttentionRun => ({ id, jobKey, kind: 'job', status: 'unresponsive', statusReason: null, nodeCounts: { success: 0, warn: 0, failed: 0, skipped: 0, notRun: 0, running: 1, pending: 0 }, startedAt: ago(30), endedAt: null }); const unresponsive = (id: string, jobKey: string | null, heardMinutesAgo: number): AttentionItem => ({ kind: 'run_unresponsive', run: run(id, jobKey), lastHeartbeatAt: ago(heardMinutesAgo), acknowledged: null }); const waiting = (id: string, jobKey: string | null, waitingFor: Extract['waitingFor']): AttentionItem => ({ kind: 'run_waiting', run: { ...run(id, jobKey), status: 'running' }, waitingFor }); const queued = (runId: string, jobKey: string | null, waits: Extract['waits']): AttentionItem => ({ kind: 'queue_blocked', runId, jobKey, queuedAt: ago(20), waits }); diff --git a/ui/src/lib/operate/labels.ts b/ui/src/lib/operate/labels.ts index c9ae230f2f..79b5de1e25 100644 --- a/ui/src/lib/operate/labels.ts +++ b/ui/src/lib/operate/labels.ts @@ -98,9 +98,8 @@ export type WaitPart = { text: string; href?: string; code?: boolean }; /** What went wrong in a finished run, such as "3 failed, 12 skipped"; empty when nothing did. */ export function outcomeCounts(c: NodeCounts): string { - const notRun = c.notRun ?? 0; const counted = (count: number, word: string) => (count ? `${count} ${word}` : null); - return [counted(c.failed, 'failed'), counted(c.skipped - notRun, 'skipped'), counted(notRun, 'not run')].filter(Boolean).join(', '); + return [counted(c.failed, 'failed'), counted(c.notRun, 'not run'), counted(c.skipped, 'skipped')].filter(Boolean).join(', '); } /** `run-4f2a` → `4f2a`, a UUID → its first 8 digits: the short form shown in lists; the full ID stays in links and copies. */ diff --git a/ui/src/lib/status.ts b/ui/src/lib/status.ts index 6c3079ac06..15725f202c 100644 --- a/ui/src/lib/status.ts +++ b/ui/src/lib/status.ts @@ -17,6 +17,7 @@ export const runStatusTone: Record = { failed: 'var(--sb-error)', cancelled: 'var(--sb-text-faint)', skipped: 'var(--sb-text-faint)', + blocked: 'var(--sb-text-faint)', presumed_failed: 'var(--sb-error)' }; @@ -38,6 +39,7 @@ export const runStatusLabel: Record = { failed: 'Failed', cancelled: 'Cancelled', skipped: 'Skipped', + blocked: 'Blocked', presumed_failed: 'Lost contact' }; @@ -52,6 +54,7 @@ export const runStatusHelp: Record = { failed: 'Failed (failed)', cancelled: 'Cancelled (cancelled)', skipped: 'Its group did not run it because a job it depends on failed (skipped)', + blocked: 'Nothing of its own failed; it skipped nodes because a node in another job of its group did not succeed (blocked)', presumed_failed: 'The run went silent and was marked failed; rerunning is safe (presumed_failed)' }; @@ -141,6 +144,7 @@ export function formatNodeCounts(counts: NodeCounts): string { if (counts.success) parts.push(`${counts.success} ok`); if (counts.warn) parts.push(`${counts.warn} warn`); if (counts.failed) parts.push(`${counts.failed} failed`); + if (counts.notRun) parts.push(`${counts.notRun} not run`); if (counts.skipped) parts.push(`${counts.skipped} skipped`); if (counts.pending) parts.push(`${counts.pending} pending`); return parts.join(' · ') || '—'; diff --git a/ui/src/routes/layout.css b/ui/src/routes/layout.css index 7828efe0f3..5239b4c964 100644 --- a/ui/src/routes/layout.css +++ b/ui/src/routes/layout.css @@ -582,7 +582,8 @@ } /* A run state's mark, alike in the run tree and on graph cards. Colour is never the only cue: running - pulses (the one thing that moves), waiting is a hollow ring, skipped a struck-through ring. */ + pulses (the one thing that moves), waiting is a hollow ring, skipped a struck-through ring, and not + run (its run stopped first) a dashed ring. */ .sb-mark { width: 8px; height: 8px; @@ -598,6 +599,10 @@ background: transparent; box-shadow: inset 0 0 0 1.5px var(--sb-text-faint); } +.sb-mark[data-state='not_run'] { + background: transparent; + border: 1.5px dashed var(--sb-error); +} .sb-mark[data-state='skipped'] { background: linear-gradient(135deg, transparent 42%, var(--muted-foreground) 42% 58%, transparent 58%); box-shadow: inset 0 0 0 1.5px var(--muted-foreground); diff --git a/ui/src/routes/runs/[id]/job-drawer.svelte b/ui/src/routes/runs/[id]/job-drawer.svelte index 8548143bbc..f196d024e6 100644 --- a/ui/src/routes/runs/[id]/job-drawer.svelte +++ b/ui/src/routes/runs/[id]/job-drawer.svelte @@ -2,11 +2,11 @@ import InspectorSection from '$lib/components/lineage/inspector-section.svelte'; import type { RunNode } from '$lib/api'; import { formatAgo, formatDuration, formatStamp } from '$lib/format/time'; - import { nodeLabel, shortRunId } from '$lib/operate/labels'; + import { nodeLabel, outcomeCounts, shortRunId } from '$lib/operate/labels'; import { to } from '$lib/paths'; import { app } from '$lib/state/app.svelte'; import { createResource } from '$lib/state/resource.svelte'; - import { runStatusLabel, runStatusTone } from '$lib/status'; + import { isActiveRun, runStatusLabel, runStatusTone } from '$lib/status'; import OutcomeStrip from '$lib/components/build-area/outcome-strip.svelte'; import { errorHeadline, formatSpan, pythonPlace } from './utils'; import RunDrawer from './run-drawer.svelte'; @@ -46,8 +46,9 @@ const jobKey = $derived(run?.jobKey ?? job.label); let width = $state(420); - const BAR: ['failed' | 'running' | 'skipped' | 'built', string][] = [ + const BAR: ['failed' | 'running' | 'not_run' | 'skipped' | 'built', string][] = [ ['failed', 'var(--sb-error)'], + ['not_run', 'color-mix(in srgb, var(--sb-error) 35%, transparent)'], ['running', 'var(--sb-running)'], ['skipped', 'var(--sb-text-faint)'], ['built', 'var(--sb-success)'] @@ -102,6 +103,8 @@ {#if failures.length > 1} · and {failures.length - 1} more of its nodes{/if} {#if said}

{said}

{:else if view.nodeErrorFailure(first)}

Couldn't read its error: {view.nodeErrorFailure(first)}

{/if} + + {#if run?.statusReason && nodes.some((n) => n.status === 'not_run')}

Stopped: {run.statusReason}

{/if} {:else if outcome === 'blocked'} @@ -138,6 +141,8 @@ {runStatusLabel[a.status].toLowerCase()} {#if a.snapshotGeneration !== null}v{a.snapshotGeneration}{/if} {#if a.startedAt}{formatAgo(a.startedAt, app.now)}{/if} + + {#if !isActiveRun(a.status)}{@const said = outcomeCounts(a.nodeCounts) || (a.status === 'failed' ? a.statusReason : null)}{#if said}{said}{/if}{/if} {/each} @@ -226,9 +231,16 @@ } .attempts li { display: flex; - gap: 10px; + flex-wrap: wrap; + gap: 2px 10px; align-items: baseline; } + .attempt-said { + flex-basis: 100%; + color: var(--muted-foreground); + font-size: 12px; + overflow-wrap: anywhere; + } .attempts li.current a { font-weight: 600; } diff --git a/ui/src/routes/runs/[id]/node-drawer.svelte b/ui/src/routes/runs/[id]/node-drawer.svelte index d93bad0eea..f17dca1bfb 100644 --- a/ui/src/routes/runs/[id]/node-drawer.svelte +++ b/ui/src/routes/runs/[id]/node-drawer.svelte @@ -30,7 +30,7 @@ const key = $derived(view.drawer); const n = $derived(key ? (view.nodes.find((x) => x.nodeKey === key) ?? null) : null); const name = $derived(key ? nodeLabel(key) : ''); - const cause = $derived(n ? skipCauses(view.nodes, view.detail?.edges ?? [])(n) : null); + const cause = $derived(n ? skipCauses(view.nodes, view.detail?.edges ?? [], [...(view.run ? [view.run] : []), ...(view.detail?.children ?? [])])(n) : null); const checks = $derived(key ? view.events.filter((e) => e.type === 'audit_completed' && e.nodeKey === key) : []); const statements = $derived(key ? view.statements.filter((s) => s.nodeKey === key && s.runId === n?.runId) : []); const running = $derived(statements.find((s) => s.status === 'running') ?? null); @@ -109,7 +109,15 @@
Checks{checks.length ? `${checks.filter((c) => c.level === 'info').length}/${checks.length} passed` : '—'}
Cost{cost ? formatQueryCost(cost) : '—'}
- {#if cause}

{cause}

{/if} + {#if cause} +

+ {cause}{#if n.skippedBecauseOf}{@const by = n.skippedBecauseOf} + {' · '} + + + {/if} +

+ {/if}
{#if n.startedAt}
Started
{fullStamp(n.startedAt)}
{/if} {#if running?.queryId} @@ -260,6 +268,12 @@ margin: 6px 0 0; color: var(--muted-foreground); } + .cause-link { + color: var(--primary); + } + .cause-link:hover { + text-decoration: underline; + } .error { margin-top: 6px; padding: 8px 10px; diff --git a/ui/src/routes/runs/[id]/root-causes.svelte b/ui/src/routes/runs/[id]/root-causes.svelte new file mode 100644 index 0000000000..61dffb12e2 --- /dev/null +++ b/ui/src/routes/runs/[id]/root-causes.svelte @@ -0,0 +1,90 @@ + + +{#if causes.length} +
+
+{/if} + + diff --git a/ui/src/routes/runs/[id]/run-summary.svelte b/ui/src/routes/runs/[id]/run-summary.svelte index c969d69d75..4f099565a0 100644 --- a/ui/src/routes/runs/[id]/run-summary.svelte +++ b/ui/src/routes/runs/[id]/run-summary.svelte @@ -26,7 +26,7 @@ type Fig = { key: string; n: number; word: string; tone?: 'err' | 'warn' | 'run' | 'muted'; colour: string; note?: string; on: boolean; toggle: () => void; title: string }; const COLOUR = { err: 'var(--sb-error)', run: 'var(--sb-running)', ok: 'var(--sb-success)', muted: 'var(--sb-text-faint)', warn: 'var(--sb-warning)', none: 'transparent' }; - const outcomes = $derived(memberOutcomes(members, view.nodes)); + const outcomes = $derived(memberOutcomes(members)); const allJobFigs = $derived.by((): Fig[] => { const counts = new Map(); for (const o of outcomes.values()) counts.set(o, (counts.get(o) ?? 0) + 1); @@ -40,14 +40,14 @@ colour: o.text === 'failed' ? COLOUR.err : o.text === 'running' ? COLOUR.run : o.text === 'succeeded' ? COLOUR.ok : o.text === 'queued' ? COLOUR.none : COLOUR.muted, on, toggle: () => (view.jobFilter = on ? null : o.text), - title: on ? 'Show every job in the tree' : o.text === 'blocked' ? 'Show only the jobs that failed for an upstream failure in another job, with none of their own' : `Show only the ${o.text} jobs in the tree` + title: on ? 'Show every job in the tree' : o.text === 'blocked' ? 'Show only the jobs held back by a node in another job, with no failure of their own' : `Show only the ${o.text} jobs in the tree` }; }); }); const jobFigs = $derived(pick(allJobFigs, ['failed', 'blocked', 'running', 'skipped', 'cancelled'], 'succeeded')); /** On a group run, the tree state each node figure narrows to as well. */ - const TREE: Record = { failed: 'failed', running: 'running', skipped: 'skipped', not_run: 'skipped', waiting: 'waiting', built: 'built' }; + const TREE: Record = { failed: 'failed', running: 'running', skipped: 'skipped', not_run: 'not_run', waiting: 'waiting', built: 'built' }; const group = $derived(view.run?.kind === 'group'); const nodeFig = (key: string, count: number, word: string, filter: QuickFilter, tone: Fig['tone'], colour: string, note?: string): Fig => { const on = view.logHolds(filter.text); @@ -77,7 +77,7 @@ nodeFig('waiting', s.waiting, 'waiting', QUICK.waiting, 'muted', COLOUR.none), nodeFig('built', s.built, 'built', QUICK.built, undefined, COLOUR.ok, s.incremental ? `${s.incremental} incremental, +${n(s.incrementalRows)} rows` : undefined) ]); - const nodeFigs = $derived(pick(allNodeFigs, ['failed', 'checks_failed', 'warned', 'running'], 'built')); + const nodeFigs = $derived(pick(allNodeFigs, ['failed', 'checks_failed', 'warned', 'not_run', 'running'], 'built')); function pick(figs: Fig[], loud: string[], done: string): Fig[] { // A pressed figure always stays, even at 0, so the filter it set can be taken off again. diff --git a/ui/src/routes/runs/[id]/run-tree.svelte b/ui/src/routes/runs/[id]/run-tree.svelte index 0ca8f2f0fb..2dc997387b 100644 --- a/ui/src/routes/runs/[id]/run-tree.svelte +++ b/ui/src/routes/runs/[id]/run-tree.svelte @@ -614,6 +614,10 @@ .s-running { --tone: var(--sb-running); } + .s-not_run { + --tone: var(--sb-error); + color: var(--muted-foreground); + } .s-skipped { --tone: var(--muted-foreground); color: var(--muted-foreground); diff --git a/ui/src/routes/runs/[id]/run-view.svelte b/ui/src/routes/runs/[id]/run-view.svelte index abd2ce4236..e71c79dd66 100644 --- a/ui/src/routes/runs/[id]/run-view.svelte +++ b/ui/src/routes/runs/[id]/run-view.svelte @@ -13,6 +13,7 @@ import AppTopbar from '$lib/components/app-topbar.svelte'; import { app } from '$lib/state/app.svelte'; import FailureSummary from './failure-summary.svelte'; + import RootCauses from './root-causes.svelte'; import CantRunProblem from '$lib/run/cant-run-problem.svelte'; import { runDetailCantRun } from '$lib/run/cant-run'; import IgnoredAuditsPanel from './ignored-audits-panel.svelte'; @@ -28,7 +29,7 @@ import RunGantt from './run-gantt.svelte'; import RunTree, { treeUi, type TreeUi } from './run-tree.svelte'; import PanelLeftIcon from '@lucide/svelte/icons/panel-left'; - import { memberOutcomes } from './utils/job-outcomes'; + import { memberOutcomes, rootCauses } from './utils/job-outcomes'; import { attentionKeys, keysUnder, runTree, stateOfNode } from './utils/run-tree'; import { useCatalogNodes } from '$lib/state/catalog.svelte'; import RunHeader from './run-header.svelte'; @@ -59,7 +60,7 @@ /** The graph is always offered: the run's nodes on their lineage, by folder. */ const hasGraph = $derived(nodes.length > 0); const names = $derived([...new Map(nodes.map((n) => [nodeLabel(n.nodeKey), { value: nodeLabel(n.nodeKey), hint: n.jobKey ?? '' }])).values()]); - const skipCause = $derived(skipCauses(nodes, detail?.edges ?? [])); + const skipCause = $derived(skipCauses(nodes, detail?.edges ?? [], [...(view.run ? [view.run] : []), ...(detail?.children ?? [])])); const nodeByKey = $derived(new Map(nodes.map((n) => [n.nodeKey, n]))); const causeOf = (key: string) => { const n = nodeByKey.get(key); @@ -139,9 +140,7 @@ /** What blocked the open job: the first of its skipped nodes' causes, the failed node upstream and its job. */ const jobBlocker = $derived.by(() => { const n = jobNodes.find((x) => x.status === 'skipped'); - const why = n?.skippedBecauseOf; - if (why) return `${nodeLabel(why.nodeKey)} failed${why.jobKey && why.jobKey !== jobOf.get(n!.runId) ? ` in ${why.jobKey}` : ''}`; - return n ? (causeOf(n.nodeKey)?.replace(/^skipped: /, '') ?? null) : null; + return n ? (skipCause(n)?.replace(/^skipped: /, '') ?? null) : null; }); const jobFailures = $derived(jobNodes.filter((n) => n.status === 'failed')); /** The tree as a full-height column beside the view and the log, in place of the 40/60 split; remembered per browser. */ @@ -153,7 +152,9 @@ } const columnMode = $derived(isGroup && treeColumn); /** A header job count shows only the jobs with that outcome. */ - const outcomes = $derived(memberOutcomes(view.detail?.children ?? [], nodes)); + const outcomes = $derived(memberOutcomes(view.detail?.children ?? [])); + /** The jobs that failed on their own account, for the line under the title, as soon as one does. */ + const causes = $derived(isGroup ? rootCauses(view.detail?.children ?? [], view.currentNodes) : []); const shownTree = $derived(view.jobFilter ? tree.filter((r) => outcomes.get(r.runId) === view.jobFilter) : tree); /** * Opening a job zooms the timeline to it. The window is taken once, when the job opens, so a @@ -229,8 +230,8 @@ {#if detail} - - {#if !isGroup}{/if} + + {#if !isGroup}{:else} openJob(id, true)} onmore={() => (view.jobFilter = 'failed')} />{/if} {#if cantRun.length}
diff --git a/ui/src/routes/runs/[id]/utils/job-outcomes.test.ts b/ui/src/routes/runs/[id]/utils/job-outcomes.test.ts new file mode 100644 index 0000000000..b718f2417d --- /dev/null +++ b/ui/src/routes/runs/[id]/utils/job-outcomes.test.ts @@ -0,0 +1,59 @@ +import { describe, expect, it } from 'vitest'; +import type { Run, RunNode } from '$lib/api'; +import { memberOutcomes, rootCauses } from './job-outcomes'; + +const member = (id: string, jobKey: string, status: Run['status'], endedAt: string | null = null, statusReason: string | null = null) => + ({ id, jobKey, status, endedAt, statusReason, memberAttempt: null, rerunOfRunId: null, parentRunId: 'g' }) as unknown as Run; +const node = (runId: string, nodeKey: string, status: RunNode['status'], cause: { runId: string; nodeKey: string } | null = null) => + ({ runId, nodeKey, status, skippedBecauseOf: cause && { ...cause, jobKey: null } }) as unknown as RunNode; + +// load fails a loader; stage skips a model for it; report skips a model for its own failed model; crash's +// worker stopped before two of its nodes ran, and it also skipped one for load; publish skips a node for +// crash's unreached one. +const members = [ + member('load', 'load_job', 'failed', '2026-11-30T01:10:00Z'), + member('stage', 'stage_job', 'blocked'), + member('report', 'report_job', 'failed', '2026-11-30T01:20:00Z'), + member('crash', 'crash_job', 'failed', '2026-11-30T01:05:00Z', 'worker stopped; physical exit or absence confirmed'), + member('publish', 'publish_job', 'blocked'), + member('ok', 'ok_job', 'success') +]; +const nodes = [ + node('load', 'loader:raw', 'failed'), + node('stage', 'model:stg', 'success'), + node('stage', 'model:stg_raw', 'skipped', { runId: 'load', nodeKey: 'loader:raw' }), + node('report', 'model:rep', 'failed'), + node('report', 'model:rep_after', 'skipped', { runId: 'report', nodeKey: 'model:rep' }), + node('crash', 'model:c1', 'success'), + node('crash', 'model:c2', 'not_run'), + node('crash', 'model:c3', 'not_run'), + node('crash', 'model:c4', 'skipped', { runId: 'load', nodeKey: 'loader:raw' }), + node('publish', 'model:pub', 'skipped', { runId: 'crash', nodeKey: 'model:c2' }), + node('ok', 'model:fine', 'success') +]; + +describe('member outcomes of a group run', () => { + it("reads each job's outcome from its latest attempt, blocked apart from failed", () => { + const retried = [...members, { ...member('load2', 'load_job', 'success'), memberAttempt: 2, rerunOfRunId: 'load' } as Run]; + const outcomes = memberOutcomes(retried); + expect(Object.fromEntries([...outcomes].map(([id, o]) => [retried.find((m) => m.id === id)!.jobKey, o]))).toEqual({ + load_job: 'succeeded', + stage_job: 'blocked', + report_job: 'failed', + crash_job: 'failed', + publish_job: 'blocked', + ok_job: 'succeeded' + }); + }); +}); + +describe('root causes of a group run', () => { + it('names the jobs that failed on their own account, most held back first, with what failed or why they stopped', () => { + const causes = rootCauses(members, nodes); + expect(causes.map((c) => [c.run.jobKey, c.failedNodes.map((n) => n.nodeKey), c.heldBack, c.stopped])).toEqual([ + ['load_job', ['loader:raw'], 2, false], + ['crash_job', [], 1, true], + ['report_job', ['model:rep'], 0, false] + ]); + }); +}); diff --git a/ui/src/routes/runs/[id]/utils/job-outcomes.ts b/ui/src/routes/runs/[id]/utils/job-outcomes.ts index a30e530dad..5678653f9b 100644 --- a/ui/src/routes/runs/[id]/utils/job-outcomes.ts +++ b/ui/src/routes/runs/[id]/utils/job-outcomes.ts @@ -2,12 +2,12 @@ import type { Run, RunNode, RunStatus } from '$lib/api'; import { latestAttempts } from './members'; /** - * A job group's members by outcome, problems first, adding up to every job. A member that failed with no - * failure of its own, only nodes skipped for an upstream failure in another job, is blocked, not failed. + * A job group's members by outcome, problems first, adding up to every job. A member the server marks blocked + * failed nothing of its own: it skipped nodes because a node in another job didn't succeed. */ export const JOB_OUTCOMES: { text: string; of: readonly RunStatus[]; tone?: 'err' | 'run' | 'muted'; live?: boolean }[] = [ { text: 'failed', of: ['failed', 'presumed_failed'], tone: 'err' }, - { text: 'blocked', of: [], tone: 'muted' }, + { text: 'blocked', of: ['blocked'], tone: 'muted' }, { text: 'running', of: ['launched', 'running', 'unresponsive'], tone: 'run', live: true }, { text: 'queued', of: ['queued'], tone: 'muted', live: true }, { text: 'cancelled', of: ['cancelled'], tone: 'muted' }, @@ -15,22 +15,44 @@ export const JOB_OUTCOMES: { text: string; of: readonly RunStatus[]; tone?: 'err { text: 'succeeded', of: ['success', 'warn'] } ]; -/** Each member run's outcome by run ID, `blocked` told apart from `failed` by the member's own nodes. */ -export function memberOutcomes(members: readonly Run[], nodes: readonly RunNode[]): Map { - const own = new Map(); - for (const n of nodes) { - if (n.status !== 'failed' && n.status !== 'skipped') continue; - const c = own.get(n.runId) ?? { failed: 0, skipped: 0 }; - c[n.status]++; - own.set(n.runId, c); - } +/** Each job's outcome by the run ID of its latest attempt; a retried job counts once. */ +export function memberOutcomes(members: readonly Run[]): Map { const out = new Map(); - // A retried job counts once, by its latest attempt. for (const m of latestAttempts(members)) { const text = JOB_OUTCOMES.find((o) => o.of.includes(m.status))?.text; - if (!text) continue; - const c = own.get(m.id); - out.set(m.id, text === 'failed' && c && !c.failed && c.skipped ? 'blocked' : text); + if (text) out.set(m.id, text); } return out; } + +/** A member that failed on its own account, and the other jobs that skipped nodes because of it. */ +export type RootCause = { run: Run; failedNodes: RunNode[]; heldBack: number; stopped: boolean }; + +/** + * A group run's root causes: each job whose latest attempt failed. A failed job failed on its own account (a + * node failed, or its run stopped before its nodes ran): the server marks one held back upstream as blocked. + * Each counts the other jobs holding a node skipped because of one of its nodes, and says whether its run + * stopped short: a node it never reached, as when its worker stopped mid-build. + */ +export function rootCauses(members: readonly Run[], nodes: readonly RunNode[]): RootCause[] { + const outcomes = memberOutcomes(members); + const jobOf = new Map(members.map((m) => [m.id, m.jobKey ?? m.id])); + const failedOf = new Map(); + const heldBy = new Map>(); + const stopped = new Set(); + for (const n of nodes) { + const job = jobOf.get(n.runId); + if (job === undefined) continue; + if (n.status === 'not_run' || n.status === 'cancelled') stopped.add(job); + if (n.status === 'failed') (failedOf.get(job) ?? failedOf.set(job, []).get(job)!).push(n); + const cause = n.skippedBecauseOf && jobOf.get(n.skippedBecauseOf.runId); + if (n.status === 'skipped' && cause && cause !== job) (heldBy.get(cause) ?? heldBy.set(cause, new Set()).get(cause)!).add(job); + } + return latestAttempts(members) + .filter((m) => outcomes.get(m.id) === 'failed') + .map((run) => { + const job = run.jobKey ?? run.id; + return { run, failedNodes: failedOf.get(job) ?? [], heldBack: heldBy.get(job)?.size ?? 0, stopped: stopped.has(job) }; + }) + .sort((a, b) => b.heldBack - a.heldBack || (a.run.endedAt ?? '').localeCompare(b.run.endedAt ?? '')); +} diff --git a/ui/src/routes/runs/[id]/utils/run-tree.test.ts b/ui/src/routes/runs/[id]/utils/run-tree.test.ts index a9ec4b444c..7146a7ed57 100644 --- a/ui/src/routes/runs/[id]/utils/run-tree.test.ts +++ b/ui/src/routes/runs/[id]/utils/run-tree.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import type { CatalogNode, Run, RunEdge, RunNode } from '$lib/api'; -import { attentionKeys, QUEUED_FOLD, runTree, visibleRows, type TreeView, type VisibleRow } from './run-tree'; +import { attentionKeys, countsText, QUEUED_FOLD, runTree, visibleRows, type TreeView, type VisibleRow } from './run-tree'; const run = (id: string, jobKey: string, status: Run['status']) => ({ id, jobKey, status }) as unknown as Run; const at = (minute: number) => new Date(Date.UTC(2026, 10, 28, 1, minute)).toISOString(); @@ -54,6 +54,17 @@ describe('runTree', () => { expect([failedJob.worst, failedJob.start, failedJob.counts.failed]).toEqual(['running', Date.parse(at(0)), 1]); }); + it("counts nodes its stopped worker never reached as not run, apart from skipped, and shows them before the skipped", () => { + const nodes = [node('crash', 'built', 'success', 1, 2), node('crash', 'lost', 'not_run'), node('crash', 'cut', 'cancelled'), node('crash', 'after', 'skipped')]; + const [crashed] = runTree([{ ...run('crash', 'crash_job', 'failed'), startedAt: at(0), endedAt: at(3) } as Run], nodes, new Map()); + expect(crashed.counts).toMatchObject({ built: 1, not_run: 2, skipped: 1, failed: 0, total: 4 }); + expect(crashed.worst).toBe('not_run'); + expect(crashed.children.find((r) => r.label === 'lost')!.worst).toBe('not_run'); + // Its span ends with its last node, not at the time the page is read. + expect(crashed.end).toBe(Date.parse(at(2))); + expect(countsText(crashed.counts, false)).toBe('2 not run · 1 skipped · 1 built'); + }); + it('ticks node names where a path would select other nodes or is refused, and keeps folder IDs apart', () => { // 50 nodes in sql/models/shop: 30 in a declared group `orders`, 20 plain; and 10 seeds. const grouped = Array.from({ length: 30 }, (_, i) => node('mix', `ord_${i}`, 'success', 1, 2)); diff --git a/ui/src/routes/runs/[id]/utils/run-tree.ts b/ui/src/routes/runs/[id]/utils/run-tree.ts index f6b7a5ce69..0ba5ffc0f9 100644 --- a/ui/src/routes/runs/[id]/utils/run-tree.ts +++ b/ui/src/routes/runs/[id]/utils/run-tree.ts @@ -14,7 +14,7 @@ import { latestAttempts } from './members'; * comes before failed, because what is running is what a reader looks for; a row's failures still show * in its counts, and the row turns failed once nothing inside it runs. */ -export const ROW_STATES = ['running', 'failed', 'skipped', 'waiting', 'built'] as const; +export const ROW_STATES = ['running', 'failed', 'not_run', 'skipped', 'waiting', 'built'] as const; export type RowState = (typeof ROW_STATES)[number]; export function stateOfNode(n: RunNode): RowState { @@ -28,8 +28,11 @@ export function stateOfNode(n: RunNode): RowState { case 'success': case 'warn': return 'built'; - default: + case 'skipped': return 'skipped'; + case 'not_run': + case 'cancelled': + return 'not_run'; } } @@ -60,9 +63,9 @@ export type TreeRow = { }; /** Jobs smaller than this list their nodes with no folder level. */ -/** A row's counts in a line, problems first: "1 failed · 2 skipped · 93 built"; waiting only while the run is live. */ +/** A row's counts in a line, problems first: "1 failed · 4 not run · 2 skipped · 93 built"; waiting only while the run is live. */ export function countsText(c: RowCounts, live: boolean): string { - return [c.failed && `${c.failed} failed`, c.running && `${c.running} running`, c.skipped && `${c.skipped} skipped`, live && c.waiting && `${c.waiting.toLocaleString('en')} waiting`, c.built && `${c.built.toLocaleString('en')} built`] + return [c.failed && `${c.failed} failed`, c.running && `${c.running} running`, c.not_run && `${c.not_run} not run`, c.skipped && `${c.skipped} skipped`, live && c.waiting && `${c.waiting.toLocaleString('en')} waiting`, c.built && `${c.built.toLocaleString('en')} built`] .filter(Boolean) .join(' · '); } @@ -78,7 +81,7 @@ function nodesUnder(row: TreeRow): RunNode[] { export const FOLDERLESS_BELOW = 50; -const emptyCounts = (): RowCounts => ({ failed: 0, running: 0, skipped: 0, waiting: 0, built: 0, total: 0 }); +const emptyCounts = (): RowCounts => ({ failed: 0, running: 0, not_run: 0, skipped: 0, waiting: 0, built: 0, total: 0 }); /** A node row, rolled up from its one node. */ function leaf(runId: string, n: RunNode): TreeRow { diff --git a/ui/src/routes/runs/[id]/utils/skips.ts b/ui/src/routes/runs/[id]/utils/skips.ts index 36a28c34e8..c767e0c725 100644 --- a/ui/src/routes/runs/[id]/utils/skips.ts +++ b/ui/src/routes/runs/[id]/utils/skips.ts @@ -1,26 +1,37 @@ -// Why a skipped node was skipped, naming the chain of skips back to the failure. Pure. +// Why a node didn't build: a skipped node names the chain of skips back to the failure; one that never +// ran names why its run stopped. Pure. -import type { RunEdge, RunNode } from '$lib/api'; +import type { Run, RunEdge, RunNode } from '$lib/api'; import { nodeLabel } from '$lib/operate/labels'; /** - * Why a skipped node was skipped, on one line, naming the chain: a node under a failure says that node - * failed; one under another skipped node says that node was skipped, and after which failure. The run's - * nodes and edges are indexed once, so asking for every skipped node of a large run stays linear. + * Why a node didn't build, on one line. A node under a failure says that node failed; one under another + * skipped node says that node was skipped, and after which failure; one that never ran says why its run + * stopped, in the run's own words. The run's nodes and edges are indexed once, so asking for every + * skipped node of a large run stays linear. */ -export function skipCauses(nodes: readonly RunNode[], edges: readonly RunEdge[]): (n: RunNode) => string | null { +export function skipCauses(nodes: readonly RunNode[], edges: readonly RunEdge[], runs: readonly Run[] = []): (n: RunNode) => string | null { const byKey = new Map(nodes.map((x) => [x.nodeKey, x])); const parentsOf = new Map(); for (const e of edges) (parentsOf.get(e.to) ?? parentsOf.set(e.to, []).get(e.to)!).push(byKey.get(e.from)); + const reasonOf = new Map(runs.map((r) => [r.id, r.statusReason])); return (n) => { + if (n.status === 'not_run' || n.status === 'cancelled') { + const reason = reasonOf.get(n.runId); + const state = n.status === 'cancelled' ? 'cancelled' : 'not run'; + return reason ? `${state}: ${reason}` : null; + } if (n.status !== 'skipped') return null; const why = n.skippedBecauseOf; if (!why) return 'skipped: an upstream node did not run'; const across = why.runId !== n.runId ? ` in ${why.jobKey ?? why.runId}` : ''; + // A cause its run stopped before reaching did not fail; it never ran. + const cause = byKey.get(why.nodeKey); + const ended = cause && cause.runId === why.runId && (cause.status === 'not_run' || cause.status === 'cancelled') ? 'did not run' : 'failed'; const parents = parentsOf.get(n.nodeKey) ?? []; - if (parents.some((p) => p?.nodeKey === why.nodeKey)) return `skipped: ${nodeLabel(why.nodeKey)} failed${across}`; + if (parents.some((p) => p?.nodeKey === why.nodeKey)) return `skipped: ${nodeLabel(why.nodeKey)} ${ended}${across}`; const via = parents.find((p) => p?.status === 'skipped' && p.skippedBecauseOf?.nodeKey === why.nodeKey); - if (via) return `skipped: ${nodeLabel(via.nodeKey)} was skipped (after ${nodeLabel(why.nodeKey)} failed${across})`; - return `skipped: ${nodeLabel(why.nodeKey)} failed${across}`; + if (via) return `skipped: ${nodeLabel(via.nodeKey)} was skipped (after ${nodeLabel(why.nodeKey)} ${ended}${across})`; + return `skipped: ${nodeLabel(why.nodeKey)} ${ended}${across}`; }; } diff --git a/ui/src/routes/runs/utils/status-line.ts b/ui/src/routes/runs/utils/status-line.ts index 8b32cccc4b..4788abf96b 100644 --- a/ui/src/routes/runs/utils/status-line.ts +++ b/ui/src/routes/runs/utils/status-line.ts @@ -48,6 +48,8 @@ export function statusLine(row: RunRow, now: number): StatusLine { }; case 'cancelled': return { text: run.statusReason?.startsWith('Cancelled') ? run.statusReason : 'Cancelled', tone: 'muted' }; + case 'blocked': + return { text: outcomeCounts(run.nodeCounts) || 'Blocked', tone: 'muted', title: run.statusReason ?? 'A node in another job of its group did not succeed' }; case 'skipped': return { text: run.statusReason ? run.statusReason.charAt(0).toUpperCase() + run.statusReason.slice(1) : 'Skipped', tone: 'muted', title: 'Its group did not run it because a job it depends on failed' }; } From 4497b97710d2c7f3dad9449a4fd61f6425dbddb2 Mon Sep 17 00:00:00 2001 From: Kevin Longe <273747162+kvlonge@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:44:21 +0000 Subject: [PATCH 2/2] fix(ui): read a skip's cause from the attempt it names --- ui/src/routes/runs/[id]/utils/skips.ts | 6 ++++-- ui/src/routes/runs/[id]/utils/summary.test.ts | 13 ++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ui/src/routes/runs/[id]/utils/skips.ts b/ui/src/routes/runs/[id]/utils/skips.ts index c767e0c725..b1fda02106 100644 --- a/ui/src/routes/runs/[id]/utils/skips.ts +++ b/ui/src/routes/runs/[id]/utils/skips.ts @@ -15,6 +15,7 @@ export function skipCauses(nodes: readonly RunNode[], edges: readonly RunEdge[], const parentsOf = new Map(); for (const e of edges) (parentsOf.get(e.to) ?? parentsOf.set(e.to, []).get(e.to)!).push(byKey.get(e.from)); const reasonOf = new Map(runs.map((r) => [r.id, r.statusReason])); + const inRun = new Map(nodes.map((x) => [`${x.runId}\u0000${x.nodeKey}`, x])); return (n) => { if (n.status === 'not_run' || n.status === 'cancelled') { const reason = reasonOf.get(n.runId); @@ -26,8 +27,9 @@ export function skipCauses(nodes: readonly RunNode[], edges: readonly RunEdge[], if (!why) return 'skipped: an upstream node did not run'; const across = why.runId !== n.runId ? ` in ${why.jobKey ?? why.runId}` : ''; // A cause its run stopped before reaching did not fail; it never ran. - const cause = byKey.get(why.nodeKey); - const ended = cause && cause.runId === why.runId && (cause.status === 'not_run' || cause.status === 'cancelled') ? 'did not run' : 'failed'; + // The cause as its own run left it: a retried job's attempts each hold the node. + const cause = inRun.get(`${why.runId}\u0000${why.nodeKey}`); + const ended = cause && (cause.status === 'not_run' || cause.status === 'cancelled') ? 'did not run' : 'failed'; const parents = parentsOf.get(n.nodeKey) ?? []; if (parents.some((p) => p?.nodeKey === why.nodeKey)) return `skipped: ${nodeLabel(why.nodeKey)} ${ended}${across}`; const via = parents.find((p) => p?.status === 'skipped' && p.skippedBecauseOf?.nodeKey === why.nodeKey); diff --git a/ui/src/routes/runs/[id]/utils/summary.test.ts b/ui/src/routes/runs/[id]/utils/summary.test.ts index 1aa016739b..e42c010da4 100644 --- a/ui/src/routes/runs/[id]/utils/summary.test.ts +++ b/ui/src/routes/runs/[id]/utils/summary.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import type { RunEdge, RunEvent, RunNode } from '$lib/api'; +import type { Run, RunEdge, RunEvent, RunNode } from '$lib/api'; import { rowsText } from './events'; import { quickPickText, withNameToggled } from './picks'; import { skipCauses } from './skips'; @@ -60,6 +60,17 @@ describe('why a node was skipped', () => { null ]); }); + + it("says a cause in another job did not run by that job's attempt the skip names, whichever attempt comes first", () => { + // load's first attempt failed raw; its retry stopped before raw ran; stage's skip names the retry. + const first = node('loader:raw', 'failed', { runId: 'load1' }); + const retry = node('loader:raw', 'not_run', { runId: 'load2' }); + const skip = node('model:stg', 'skipped', { runId: 'stage', skippedBecauseOf: { nodeKey: 'loader:raw', runId: 'load2', jobKey: 'load_job' } }); + const runs = [{ id: 'load2', statusReason: 'worker stopped' }] as Run[]; + const said = (all: RunNode[]) => skipCauses(all, [{ from: 'loader:raw', to: 'model:stg' }], runs)(skip); + expect([said([retry, first, skip]), said([first, retry, skip])]).toEqual(['skipped: raw did not run in load_job', 'skipped: raw did not run in load_job']); + expect(skipCauses([retry], [], runs)(retry)).toBe('not run: worker stopped'); + }); }); describe('quick picks', () => {