W3-a 前端跟上:运行里的结构变化提醒、剖析清单里取值观察的说法

后端这一波新写的 schema.drift 事件、剖析任务里的取值观察检查,前端不跟上就是半截的:

- run/decode.ts 认 schema.drift:时间线里一行警告(运行未被拦截),展开逐表写发布时和现在的结构版本、表删了写「表已删除」,
  下面列出还没处理的结构变化;schemaDrift / schemaDriftLine 解析,和 catalog.drift 分开记、不混读版本号。
- 运行横幅(pages/runs/Banners.tsx):和 catalog.drift 共用同一块横幅(data-run-banner 不变)。只有结构变了时标题按结构说;
  目录、结构都变了时结构另起一组带小标题;每张表给到数据目录的入口。RunDetailView 取最后一条 schema.drift 一并传进去。
- 剖析清单:取值观察的四类检查(行数、码值观察、最新业务日期、按日行数)在检查项、发过的查询、跳过的项里有中文叫法;
  逐表进度多一类「取值观察 N/M」(后端 checks_by_kind 加 observe 一组)。剖析的范围、任务的触发(定时维护建的)进类型。
- 文案进 lib/terms.ts(SCHEMA_DRIFT_TEXT:叫「结构变化」,和已有的「目录有变化」分开,X10)。
- 检查脚本:check-decode 加 schema.drift 一节(标题、警告级、逐表版本、表已删除、另有几条、形状不对不出行),check-runs
  加一节(只有结构变化、目录和结构都变了两种情形下的同一块横幅、入口链接、时间线一行、运行照常完成)。

验证:tsc、check-copy;decode 680、runs 327、catalog-profile 191、stream 461、publish 285 项全过。
This commit is contained in:
ThearchyHelios
2026-10-16 17:28:07 +08:00
parent ed72ee68d6
commit 8181efe836
8 changed files with 269 additions and 24 deletions
+27
View File
@@ -857,6 +857,33 @@ await section('正式运行:发布之后数据目录有变化(catalog.drift
.every((s) => s.code !== 'catalog_drift'))
})
await section('正式运行:发布之后表结构有变化(schema.drift 事件)', async () => {
const steps = mod.decodeRun([
{ seq: 1, type: 'run.started', node_id: null, ts: 1, data: { nodes: 1 } },
{ seq: 2, type: 'schema.drift', node_id: null, ts: 1.01, data: { version: 2, count: 2, tables: [
{ source: 'shop', source_id: 'src-shop', table: 'orders', label: '订单', published: 1, current: 2, removed: false,
changes: [{ id: 'c1', kind: 'column_removed', column: 'status', severity: 'action', summary: 'orders.status:删除了列' },
{ id: 'c2', kind: 'column_type_changed', column: 'amount', severity: 'warning', summary: 'orders.amount:列的类型变了' }],
more: 3 },
{ source: 'shop', source_id: 'src-shop', table: 'refunds', label: null, published: 4, current: null, removed: true,
changes: [], more: 0 },
] } },
])
const row = steps.find((s) => s.code === 'schema_drift')
check('一行提醒:「订单」等 2 张表的结构有变化', row?.title === '自发布以来,「订单」等 2 张表的结构有变化', row?.title)
check('是警告、不是失败', row?.level === 'warn' && row?.status === 'done' && row?.kind === 'note')
check('副标题写明运行未被拦截', !!row?.sub?.includes('运行未被拦截'), row?.sub)
check('展开逐表写结构版本,表删了写「表已删除」', !!row?.detail?.includes('「shop」订单(orders):结构第 1 版 → 第 2 版')
&& row.detail.includes('「shop」refunds:表已删除'), row?.detail)
check('……下面列出还没处理的变化和另有几条', !!row?.detail?.includes('· orders.status:删除了列')
&& row.detail.includes('另有 3 条结构变化'), row?.detail)
const one = mod.schemaDrift({ tables: [{ source: 's', table: 't', published: 1, current: 2 }] })
check('只有一张表:标题不写「等」', one?.title === '自发布以来,「t」的结构有变化', one?.title)
check('和目录漂移分开记:catalog.drift 的解析不认它', mod.catalogDrift({ tables: [] }) === null)
check('形状不对不出行', mod.decodeRun([{ seq: 1, type: 'schema.drift', node_id: null, ts: 1, data: { tables: 'x' } }])
.every((s) => s.code !== 'schema_drift'))
})
await section('Copilot:心跳穿插、回话、少了一步、报错', async () => {
const steps = mod.decodeCopilot(synthetic.COPILOT_STUCK, { context: 'canvas' })
check('心跳穿插的思考仍然并成一条', steps.filter((s) => s.kind === 'think').length === 1,
+59
View File
@@ -796,6 +796,65 @@ await section('正式运行:发布之后数据目录有变化,提醒但不
for (const k of [`GET /api/runs/${id}`, `GET /api/runs/${id}/events`, `GET /api/runs/${id}/graph`]) fakes.delete(k)
})
// ------------------------------------------------------------------ 发布之后表结构有变化(schema.drift)
await section('正式运行:发布之后表结构有变化,和目录变化同一块横幅,提醒但不拦', async () => {
const id = 'fake0schemadrift000000000000000'
const t = Date.now() / 1000 - 30
const run = {
...base, id, status: 'succeeded', run_class: 'formal', version: 2, workflow_id: null,
created_at: new Date(t * 1000).toISOString(), started_at: new Date(t * 1000).toISOString(),
finished_at: new Date((t + 2) * 1000).toISOString(), output: { 结果: '共 12 单' },
}
const graph = { nodes: [
{ id: 'a', type: 'input', position: { x: 0, y: 0 }, data: { label: '输入', config: {} } },
{ id: 'q', type: 'tool', position: { x: 200, y: 0 }, data: { label: '查订单', config: {} } },
], edges: [{ source: 'a', target: 'q' }] }
const schemaTables = [
{ source: 'shop', source_id: 'src-shop', table: 'orders', label: '订单', published: 1, current: 2, removed: false,
changes: [{ id: 'c1', kind: 'column_removed', column: 'status', severity: 'action', summary: 'orders.status:删除了列' }],
more: 0 },
]
const events = (withCatalog) => [
{ seq: 1, type: 'run.started', node_id: null, ts: t, data: { nodes: 2 } },
...(withCatalog ? [{ seq: 2, type: 'catalog.drift', node_id: null, ts: t + 0.01, data: { version: 2, count: 1, tables: [
{ source: 'shop', source_id: 'src-shop', table: 'orders', label: '订单', published: 3, current: 4, impact: 'direct' },
] } }] : []),
{ seq: 3, type: 'schema.drift', node_id: null, ts: t + 0.02, data: { version: 2, count: 1, tables: schemaTables } },
{ seq: 4, type: 'node.started', node_id: 'a', ts: t + 0.1, data: {} },
{ seq: 5, type: 'node.finished', node_id: 'a', ts: t + 0.2, data: { duration_ms: 100 } },
{ seq: 6, type: 'node.started', node_id: 'q', ts: t + 0.3, data: {} },
{ seq: 7, type: 'node.finished', node_id: 'q', ts: t + 0.4, data: { duration_ms: 100 } },
{ seq: 8, type: 'run.finished', node_id: null, ts: t + 2, data: { output: run.output } },
]
let withCatalog = false
fakes.set(`GET /api/runs/${id}`, () => ({ status: 200, json: run }))
fakes.set(`GET /api/runs/${id}/events`, () => ({ status: 200, json: events(withCatalog) }))
fakes.set(`GET /api/runs/${id}/graph`, () => ({ status: 200, json: { graph, workflow_id: null, version: 2 } }))
await page.goto(`${WEB}/runs/${id}`, { waitUntil: 'networkidle' })
const banner = page.locator('[data-run-banner="catalog-drift"]')
check('只有结构变了:照样是那一块横幅', await banner.waitFor({ timeout: 5000 }).then(() => true, () => false))
let text = await banner.innerText().catch(() => '')
check('标题按结构说', text.includes('自发布以来,「订单」的结构有变化'), text.split('\n')[0])
check('写明运行未被拦截', text.includes('运行未被拦截'))
check('逐表写结构版本、列出还没处理的变化', text.includes('「shop」订单(orders):结构第 1 版 → 第 2 版')
&& text.includes('要处理 · orders.status:删除了列'), text.replace(/\s+/g, ' '))
check('给到数据目录的入口', (await banner.locator('[data-drift-schema-table="orders"] [data-drift-open="orders"]')
.getAttribute('href')) === '/data/catalog/src-shop/orders')
check('时间线里也有一行提醒', await page.locator('[data-step-code="schema_drift"]').count() === 1)
withCatalog = true
await page.goto(`${WEB}/runs/${id}`, { waitUntil: 'networkidle' })
await banner.waitFor({ timeout: 5000 }).catch(() => {})
text = await banner.innerText().catch(() => '')
check('目录、结构都变了:仍是一块横幅', await page.locator('[data-run-banner="catalog-drift"]').count() === 1)
check('……标题按目录说,结构另起一组带小标题', text.includes('自发布以来,数据目录中「订单」有变化')
&& text.includes('结构变化:自发布以来,「订单」的结构有变化'), text.replace(/\s+/g, ' '))
check('……结构那一组逐表一行', await banner.locator('[data-drift-schema] [data-drift-schema-table="orders"]').count() === 1)
check('运行照常完成:没有失败横幅', await page.locator('[data-run-banner=failed]').count() === 0)
for (const k of [`GET /api/runs/${id}`, `GET /api/runs/${id}/events`, `GET /api/runs/${id}/graph`]) fakes.delete(k)
})
// ------------------------------------------------------------------ 运行中:接流、停止、不能删
const FAKE = 'fake0running0000000000000000000'