mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-16 03:22:05 +00:00
合入完整性修复 F3:Agent 查库的模板也记目录版本并提醒「可能涉及」,只探查了部分表时清单、目录页和助手上下文都说明,升级入口接上 SQL 检查,截断判定和工具节点遍历各收成一处
This commit is contained in:
@@ -354,7 +354,11 @@ function listOf(state, src) {
|
||||
const all = state.tables[src]
|
||||
const rows = all.filter((t) => !t.missing).sort((a, b) => b.usage - a.usage).map(rowOf)
|
||||
rows.push(...all.filter((t) => t.missing).map(rowOf))
|
||||
return { tables: rows, system_notes: isUpload(src), schema_note: all.length ? null : '尚未探查结构' }
|
||||
// 探查结构截断了的源(state.schemaTotal 里给了数据库里的总数):清单只有探查到的那部分
|
||||
const explored = all.filter((t) => !t.missing).length
|
||||
const total = state.schemaTotal?.[src] ?? explored
|
||||
return { tables: rows, system_notes: isUpload(src), schema_note: all.length ? null : '尚未探查结构',
|
||||
schema_truncated: total > explored, schema_total: total }
|
||||
}
|
||||
const detailOf = (src, t) => ({
|
||||
table_name: t.name, in_schema: !t.missing, notes: t.notes ?? {}, version: t.version, updated_at: t.updated_at, updated_by: t.updated_by,
|
||||
@@ -1225,6 +1229,38 @@ const profilePhase = (page) => profileBox(page).getAttribute('data-profile-dialo
|
||||
/** 报告里不该露的机读码:停止原因、跳过原因、状态、基数的英文值 */
|
||||
const PROFILE_CODE_RE = /\b(?:budget|deadline|failed|masked|too_large|high_cardinality|no_data|unsupported|verified|proposed|many_to_one|row_estimate)\b/
|
||||
|
||||
await section('数据目录 · 只探查了一部分表', async () => {
|
||||
// 探查结构每个数据源最多取 200 张表:多出来的不在清单里,助手也看不到。顶部要说出来,并给出下一步
|
||||
const state = freshState()
|
||||
const explored = state.tables[S1].filter((t) => !t.missing).length
|
||||
const total = explored + 57
|
||||
state.schemaTotal = { [S1]: total }
|
||||
const { page, sent, errors, natives, close } = await open(`/data/catalog/${S1}`, { handlers: catalogHandlers(state) })
|
||||
const bar = page.locator('[data-catalog-schema-partial]')
|
||||
check('顶部有一条说明', await bar.waitFor({ timeout: 3000 }).then(() => true, () => false))
|
||||
check('……数字:一共几张、探查了几张', (await bar.getAttribute('data-catalog-schema-partial')) === `${total},${explored}`,
|
||||
await bar.getAttribute('data-catalog-schema-partial'))
|
||||
const text = await bar.innerText().catch(() => '')
|
||||
check('……写成「共有 N 张表,只探查了前 M 张」', text.includes(`这个数据源共有 ${total} 张表,只探查了前 ${explored} 张`), text)
|
||||
check('……说明为什么只取了这些、其余的助手也看不到', text.includes('最多取 200 张表') && text.includes('其余 57 张不在数据目录中')
|
||||
&& text.includes('助手也看不到'), text.replace(/\s+/g, ' '))
|
||||
check('……给出下一步:换 schema 或缩小范围后重新探查', text.includes('换一个 schema') && text.includes('缩小范围')
|
||||
&& text.includes('探查结构'), text.replace(/\s+/g, ' '))
|
||||
await shot(page, 'catalog-schema-partial')
|
||||
await cleanCopy(page, '只探查了一部分表')
|
||||
await bar.locator('[data-catalog-schema-partial-go]').click()
|
||||
await page.waitForURL('**/data/databases', { timeout: 5000 }).catch(() => {})
|
||||
check('……按钮回到数据源卡片', new URL(page.url()).pathname === '/data/databases', page.url())
|
||||
// 没截断的库不出这一条
|
||||
await goto(page, `/data/catalog/${S4}`)
|
||||
await page.locator('[data-catalog-overview]').waitFor()
|
||||
check('没截断的库不出这一条', await page.locator('[data-catalog-schema-partial]').count() === 0)
|
||||
check('只读、不发写请求', writes(sent, /./).length === 0)
|
||||
check('没有原生对话框', natives.length === 0, natives.join(' | '))
|
||||
check('没有运行时报错', errors.length === 0, errors.join(' | '))
|
||||
await close()
|
||||
})
|
||||
|
||||
await section('数据目录 · 数据剖析设置', async () => {
|
||||
const state = freshState()
|
||||
const replies = { patch: [] }
|
||||
|
||||
@@ -685,6 +685,16 @@ await section('Copilot:这一轮参考了哪些表(context 操作)', async
|
||||
{ source: 'b', tables: [], selected_by: 'model', total: 70 }] })
|
||||
check('挑表成功但某个库一张没挑中:说清只给了表名', !!none?.detail.includes('「b」共 70 张表,未挑中与需求相关的表,已提供全部表名'),
|
||||
none?.detail)
|
||||
// 探查结构截断了(每个数据源最多取 200 张表):total 是数据库里的总数,explored 是探查到的
|
||||
const partial = mod.copilotContext({ op: 'context', sources: [
|
||||
{ source: 'wide', tables: ['t001', 't002'], selected_by: 'model', total: 205, explored: 200 },
|
||||
{ source: 'wide2', tables: [], selected_by: 'fallback', total: 260, explored: 200, reason: 'r' }] })
|
||||
check('截断了的库写「共 N 张,只探查了 200 张」', !!partial?.detail.includes('「wide」共 205 张,只探查了 200 张,按需求挑出 2 张:t001、t002')
|
||||
&& partial.detail.includes('「wide2」共 260 张,只探查了 200 张,未能按需求挑选'), partial?.detail)
|
||||
const whole = mod.copilotContext({ op: 'context', sources: [
|
||||
{ source: 'a', tables: ['x'], selected_by: 'model', total: 60, explored: 60 }] })
|
||||
check('探查到的和总数一样:照旧写「从 N 张表中挑出」', !!whole?.detail.includes('「a」按需求从 60 张表中挑出 1 张') && !whole.detail.includes('只探查了'),
|
||||
whole?.detail)
|
||||
check('形状不对不出行、不报错', mod.decodeCopilot([
|
||||
{ op: 'context' }, { op: 'context', sources: 'x' }, { op: 'context', sources: [null, 3, { tables: ['t'] }] },
|
||||
]).length === 0)
|
||||
@@ -737,6 +747,26 @@ await section('正式运行:发布之后数据目录有变化(catalog.drift
|
||||
&& row.detail.includes('「scenic」parks:发布时尚无目录,现为第 1 版'), row?.detail)
|
||||
const one = mod.catalogDrift({ tables: [{ source: 's', table: 't', label: null, published: 1, current: 2 }] })
|
||||
check('只有一张表:标题不写「等」', one?.title === '自发布以来,数据目录中「t」有变化', one?.title)
|
||||
check('老事件的表没有 impact:按直接引用', one?.direct.length === 1 && one?.possible.length === 0 && one?.tables[0].impact === 'direct')
|
||||
// Agent 可能查询的表(SQL 运行时才写):和直接引用分开说
|
||||
const mixed = mod.catalogDrift({ tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'visits', label: '入园记录', published: 3, current: 5, impact: 'direct' },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'orders', label: '订单', published: 2, current: 4, impact: 'possible' },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'gates', label: null, published: 0, current: 1, impact: 'possible' },
|
||||
] })
|
||||
check('两组都有:标题说直接引用的,再补一句 Agent 可能查询的表有变化',
|
||||
mixed?.title === '自发布以来,数据目录中「入园记录」有变化;另有 2 张 Agent 可能查询的表有变化', mixed?.title)
|
||||
check('……展开:直接引用在前,可能涉及的在小标题下面', mixed?.detail === [
|
||||
'「scenic」入园记录(visits):发布时第 3 版,现为第 5 版', 'Agent 可能查询的表:',
|
||||
'「scenic」订单(orders):发布时第 2 版,现为第 4 版', '「scenic」gates:发布时尚无目录,现为第 1 版'].join('\n'), mixed?.detail)
|
||||
const agentOnly = mod.catalogDrift({ tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'orders', label: '订单', published: 2, current: 4, impact: 'possible' },
|
||||
] })
|
||||
check('只有可能涉及的:标题直说「Agent 可能查询的表有变化」', agentOnly?.title === '自发布以来,Agent 可能查询的表有变化:「订单」', agentOnly?.title)
|
||||
const run = mod.decodeRun([{ seq: 1, type: 'catalog.drift', node_id: null, ts: 1, data: { version: 2, count: 1, tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'orders', label: '订单', published: 2, current: 4, impact: 'possible' }] } }])
|
||||
.find((s) => s.code === 'catalog_drift')
|
||||
check('……时间线里那一行同样是警告', run?.level === 'warn' && run?.title === agentOnly?.title, run?.title)
|
||||
check('形状不对不出行', mod.decodeRun([{ seq: 1, type: 'catalog.drift', node_id: null, ts: 1, data: { tables: 'x' } }])
|
||||
.every((s) => s.code !== 'catalog_drift'))
|
||||
})
|
||||
|
||||
+15
-4
@@ -706,9 +706,11 @@ await section('正式运行:发布之后数据目录有变化,提醒但不
|
||||
], edges: [{ source: 'a', target: 'q' }] }
|
||||
const events = [
|
||||
{ seq: 1, type: 'run.started', node_id: null, ts: t, data: { nodes: 2 } },
|
||||
{ seq: 2, type: 'catalog.drift', node_id: null, ts: t + 0.01, data: { version: 3, count: 2, tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'visits', label: '入园记录', published: 3, current: 5 },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'parks', label: null, published: 0, current: 1 },
|
||||
{ seq: 2, type: 'catalog.drift', node_id: null, ts: t + 0.01, data: { version: 3, count: 3, tables: [
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'visits', label: '入园记录', published: 3, current: 5, impact: 'direct' },
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'parks', label: null, published: 0, current: 1, impact: 'direct' },
|
||||
// Agent 绑定了这个源的查询工具:SQL 运行时才写,记的是源里有目录的表
|
||||
{ source: 'scenic', source_id: 'src-scenic', table: 'orders', label: '订单', published: 2, current: 4, impact: 'possible' },
|
||||
] } },
|
||||
{ seq: 3, type: 'node.started', node_id: 'a', ts: t + 0.1, data: {} },
|
||||
{ seq: 4, type: 'node.finished', node_id: 'a', ts: t + 0.2, data: { duration_ms: 100 } },
|
||||
@@ -723,11 +725,20 @@ await section('正式运行:发布之后数据目录有变化,提醒但不
|
||||
const banner = page.locator('[data-run-banner="catalog-drift"]')
|
||||
check('详情显示目录变化的横幅', await banner.waitFor({ timeout: 5000 }).then(() => true, () => false))
|
||||
const text = await banner.innerText().catch(() => '')
|
||||
check('横幅标题:「入园记录」等 2 张表有变化', text.includes('自发布以来,数据目录中「入园记录」等 2 张表有变化'), text.split('\n')[0])
|
||||
check('横幅标题:「入园记录」等 2 张表有变化,另有 1 张 Agent 可能查询的表有变化',
|
||||
text.includes('自发布以来,数据目录中「入园记录」等 2 张表有变化;另有 1 张 Agent 可能查询的表有变化'), text.split('\n')[0])
|
||||
check('写明运行未被拦截', text.includes('运行未被拦截'))
|
||||
check('逐表写发布时和现在的版本,没有目录写「尚无目录」', text.includes('「scenic」入园记录(visits):发布时第 3 版,现为第 5 版')
|
||||
&& text.includes('「scenic」parks:发布时尚无目录,现为第 1 版'), text.replace(/\s+/g, ' '))
|
||||
check('每张表给到数据目录的入口', (await banner.locator('[data-drift-open="visits"]').getAttribute('href')) === '/data/catalog/src-scenic/visits')
|
||||
const possible = banner.locator('[data-drift-possible]')
|
||||
const possibleText = await possible.innerText().catch(() => '')
|
||||
check('Agent 可能查询的表另起一组:小标题、说明、逐表一行', await possible.count() === 1
|
||||
&& possibleText.includes('Agent 可能查询的表') && possibleText.includes('SQL 在运行时生成')
|
||||
&& possibleText.includes('「scenic」订单(orders):发布时第 2 版,现为第 4 版'), possibleText.replace(/\s+/g, ' '))
|
||||
check('……直接引用的表不在这一组里', await possible.locator('[data-drift-table="visits"]').count() === 0
|
||||
&& (await banner.locator('[data-drift-table="orders"]').getAttribute('data-drift-impact')) === 'possible')
|
||||
check('……也给到数据目录的入口', (await banner.locator('[data-drift-open="orders"]').getAttribute('href')) === '/data/catalog/src-scenic/orders')
|
||||
check('运行照常完成:没有失败横幅', await page.locator('[data-run-banner=failed]').count() === 0)
|
||||
const row = page.locator('[data-step-code="catalog_drift"]')
|
||||
check('时间线里也有一行提醒', await row.count() === 1 && (await row.innerText()).includes('等 2 张表有变化'))
|
||||
|
||||
@@ -263,11 +263,17 @@ async function open({ width = 1440, height = 900, path = '/studio/st-main', pref
|
||||
if (sub === 'versions' && !v) return json(route, VERSIONS)
|
||||
if (sub === 'versions' && v) {
|
||||
const n = Number(v)
|
||||
// 已发布的 v2 记着发布时的目录版本:入园记录之后改过(第 3 版 → 第 5 版),景区表没变
|
||||
// 已发布的 v2 记着发布时的目录版本:入园记录之后改过(第 3 版 → 第 5 版),景区表没变;
|
||||
// Agent 绑定了 shop 的查询工具,可能查询的表里订单改过、闸机是发布之后才建的目录,另一个源发布时还没有目录
|
||||
return json(route, { ...VERSIONS.find((x) => x.version === n), workflow_id: id,
|
||||
graph: n === 1 ? V1 : GRAPH, graph_hash: 'x', input_fields: [{ name: 'goal' }], published: n === 2,
|
||||
catalog_versions: n === 2 ? { shop: { parks: 1, visits: 3 } } : null,
|
||||
catalog_changes: n === 2 ? [{ source: 'shop', source_id: 'src-shop', table: 'visits', label: '入园记录', published: 3, current: 5 }] : [] })
|
||||
catalog_versions: n === 2
|
||||
? { direct: { shop: { parks: 1, visits: 3 } }, possible: { shop: { orders: 2, channels: 1 }, crm: {} } } : null,
|
||||
catalog_changes: n === 2 ? [
|
||||
{ source: 'shop', source_id: 'src-shop', table: 'visits', label: '入园记录', published: 3, current: 5, impact: 'direct' },
|
||||
{ source: 'shop', source_id: 'src-shop', table: 'orders', label: '订单', published: 2, current: 4, impact: 'possible' },
|
||||
{ source: 'shop', source_id: 'src-shop', table: 'gates', label: null, published: 0, current: 1, impact: 'possible' },
|
||||
] : [] })
|
||||
}
|
||||
if (method === 'GET' && !sub) return state.deleted.has(id) ? json(route, { detail: '工作流不存在,可能已被删除' }, 404) : json(route, FAKES[id])
|
||||
if (method === 'DELETE' && !sub) {
|
||||
@@ -1011,8 +1017,20 @@ await section('版本历史:预览、恢复成一次可撤销的改动', async
|
||||
const catText = await cat.innerText().catch(() => '')
|
||||
check('已发布的版本写「发布时的目录版本」', catText.includes('发布时的目录版本') && catText.includes('parks') && catText.includes('第 1 版'), catText)
|
||||
check('之后改过的表标出来', (await page.locator('[data-version-catalog-table="visits"]').getAttribute('data-changed')) === 'true'
|
||||
&& catText.includes('之后有变化,现为第 5 版') && catText.includes('1 张表在发布之后有变化'), catText.replace(/\s+/g, ' '))
|
||||
&& catText.includes('之后有变化,现为第 5 版') && catText.includes('3 张表在发布之后有变化'), catText.replace(/\s+/g, ' '))
|
||||
check('没改过的表不标', (await page.locator('[data-version-catalog-table="parks"]').getAttribute('data-changed')) === null)
|
||||
// Agent 可能查询的表:另起一组,和 SQL 里写着的表分开
|
||||
const possible = cat.locator('[data-version-catalog-possible]')
|
||||
const possibleText = await possible.innerText().catch(() => '')
|
||||
check('Agent 可能查询的表另起一组', await possible.count() === 1 && possibleText.includes('Agent 可能查询的表')
|
||||
&& await possible.locator('[data-version-catalog-table="visits"]').count() === 0, possibleText.replace(/\s+/g, ' '))
|
||||
check('……改过的标出来,没改过的不标', (await possible.locator('[data-version-catalog-table="orders"]').getAttribute('data-changed')) === 'true'
|
||||
&& (await possible.locator('[data-version-catalog-table="channels"]').getAttribute('data-changed')) === null
|
||||
&& possibleText.includes('之后有变化,现为第 4 版'), possibleText.replace(/\s+/g, ' '))
|
||||
check('……发布之后才建目录的表也列出来,发布时写「尚无目录」',
|
||||
(await possible.locator('[data-version-catalog-table="gates"]').getAttribute('data-changed')) === 'true'
|
||||
&& (await possible.locator('[data-version-catalog-table="gates"]').innerText()).includes('尚无目录'))
|
||||
check('……发布时一张有目录的表都没有的源写一句', possibleText.includes('「crm」发布时还没有目录'), possibleText.replace(/\s+/g, ' '))
|
||||
await page.locator('ol[aria-label="版本"] > li').nth(2).locator('button').first().click()
|
||||
await page.waitForTimeout(300)
|
||||
check('没发布过的版本没有目录版本这一栏', await count(page, '[data-version-catalog]') === 0)
|
||||
|
||||
Reference in New Issue
Block a user