mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-18 08:11:58 +00:00
合入遗留收口分支 nr8/l(问数据心跳不落库与事件日志清理、续跑重新核对身份、事件触发批量查询与去抖边界、子图编号与驳回出口等),W2-b 在此之上做多进程协调
This commit is contained in:
@@ -178,6 +178,9 @@ function freshChanges() {
|
||||
templates: [{ workflow_id: 'wf-check-weekly', name: '门店周报', version: 3, level: 'published', impact: 'direct',
|
||||
nodes: [{ node_id: 'q_orders', label: '取订单', type: 'tool', impact: 'direct', breaks: true, unknown_columns: ['status'] }] }],
|
||||
rules_touched: true,
|
||||
// 表结构变了之后没能试算的口径(服务端 ledger/recall._probe_skipped):缺哪几个参数
|
||||
probes: [{ workflow_id: 'wf-check-weekly', version: 3, name: '门店周报', outcome: 'skipped', missing: ['start', 'end'],
|
||||
reason: '「start」必填;「end」必填', inputs_from: 'defaults' }],
|
||||
},
|
||||
actions: [act('clean_catalog'), act('redraft'), act('reprofile', NOT_PROFILED), ...COMMON] }),
|
||||
change({ seq: 14, id: 'chg-codes', table: 'orders', column: 'channel', kind: 'codes_new', category: 'value', severity: 'action',
|
||||
@@ -458,6 +461,8 @@ await section('变化:依据、前后、影响面、动作照服务端给的
|
||||
check('……写死这张表的已发布模板:「这条 SQL 现在会报列不存在(status)」', (await textOf(d.locator('[data-change-node="q_orders"]'))).includes('这条 SQL 现在会报列不存在(status)')
|
||||
&& (await d.locator('[data-change-node="q_orders"]').getAttribute('data-change-breaks')) === '1')
|
||||
check('……模板链到编排页那个节点', (await d.locator('[data-change-template] a').first().getAttribute('href')) === '/studio/wf-check-weekly?focus=q_orders')
|
||||
check('……没能试算的口径照实写缺哪几个参数', (await textOf(d.locator('[data-change-probe="wf-check-weekly"]')))
|
||||
.includes('「门店周报」v3:缺少参数 start、end,没有试算'))
|
||||
check('……有效记录条件用到了这一列', (await textOf(d.locator('[data-change-rules]'))).includes('有效记录条件用到了这一列'))
|
||||
check('动作照服务端给的:清理目录项、重新起草、重新剖析、知道了、误报', JSON.stringify(await attrs(d.locator('[data-change-action]'), 'data-change-action'))
|
||||
=== '["clean_catalog","redraft","reprofile","acknowledge","dismiss"]')
|
||||
|
||||
+19
-4
@@ -1271,10 +1271,17 @@ async function driveTurn(T, epoch) {
|
||||
{ cause: { kind: 'refused', message, code: got.json.code ?? null }, runId: null, usage: T.usage })
|
||||
}
|
||||
const ops = []
|
||||
T.beatPhase = undefined // 每一次生成从头算:第一拍心跳照落
|
||||
for (const op of got.ops) {
|
||||
if (op.gate) { await until(() => ctl[op.gate] || gone(T, epoch), 15000); continue }
|
||||
if (gone(T, epoch)) return
|
||||
emit(T, 'op', op)
|
||||
// 心跳只落换了阶段的那一拍(服务端 chat/job.ChatDriver.on_op);同一阶段接着的不落库、不带 seq(chat/log.beat):只记
|
||||
// 最近的一拍,流上发一条不带 seq 的;之后落了新事件就作废
|
||||
if (op.op === 'heartbeat' && op.phase === T.beatPhase) T.beat = { op, at: T.events.length }
|
||||
else {
|
||||
if (op.op === 'heartbeat') T.beatPhase = op.phase
|
||||
emit(T, 'op', op)
|
||||
}
|
||||
if (op.op !== 'thinking' && op.op !== 'heartbeat') ops.push(op)
|
||||
if (op.op === 'look') T.looks.push(op)
|
||||
if (op.op === 'usage') T.usage.copilot = addTotal(T.usage.copilot, op)
|
||||
@@ -1500,6 +1507,9 @@ async function streamTurn(route, T, after) {
|
||||
await until(() => T.events.length > after || !turnActive(T) || T.gen !== srv.gen, 6000)
|
||||
const fresh = T.events.filter((e) => e.seq > after)
|
||||
let body = fresh.map((e) => `data: ${JSON.stringify(e)}\n\n`).join('')
|
||||
if (turnActive(T) && T.beat && T.beat.at === T.events.length) {
|
||||
body += `data: ${JSON.stringify({ type: 'op', data: T.beat.op, ts: Date.now() / 1000 })}\n\n`
|
||||
}
|
||||
if (!turnActive(T) && after + fresh.length >= T.events.length) {
|
||||
body += `data: ${JSON.stringify({ type: 'stream.end', status: T.job.status, data: { status: T.job.status } })}\n\n`
|
||||
}
|
||||
@@ -2631,9 +2641,14 @@ for (const theme of THEMES) {
|
||||
check('从不往回要:重连的 seq 只增不减', afters.every((a, i) => i === 0 || a >= afters[i - 1]), afters.join(','))
|
||||
check('补齐:服务端这一轮记下的事件,页面一条不少地收到了', !!T && t.turnSeq === T.events.length,
|
||||
`${t.turnSeq} / ${T?.events.length}`)
|
||||
const ops = T?.events.filter((e) => e.type === 'op').length ?? -1
|
||||
check('不重复:助手的操作一条只收一份', t.ops.length === ops && t.ops.filter((o) => o.op === 'add_node').length === 3,
|
||||
`${t.ops.length} / ${ops}`)
|
||||
// 心跳只落换了阶段的那一拍,同一阶段接着的不带 seq(服务端 chat/log.beat):重连时服务端会补最近的一拍,页面接着的那一拍
|
||||
// 顶替上一拍,不另起一条。按 seq 补齐的「一条只收一份」比的是心跳之外的操作
|
||||
const ops = T?.events.filter((e) => e.type === 'op' && e.data?.op !== 'heartbeat').length ?? -1
|
||||
const mine = t.ops.filter((o) => o.op !== 'heartbeat').length
|
||||
check('不重复:助手的操作一条只收一份', mine === ops && t.ops.filter((o) => o.op === 'add_node').length === 3,
|
||||
`${mine} / ${ops}`)
|
||||
check('……补过的心跳不叠成好几条', t.ops.every((o, i) => o.op !== 'heartbeat' || t.ops[i + 1]?.op !== 'heartbeat'),
|
||||
t.ops.map((o) => o.op).join(','))
|
||||
check('画布边收边长到收尾:图有 3 个节点,运行接上了', t.graph?.nodes?.length === 3 && !!t.run?.id)
|
||||
check('页面不写这一轮的结局(不 PATCH)', log.patches.slice(patchesBefore).length === 0)
|
||||
await page.getByRole('button', { name: '停止这一轮' }).click().catch(() => {})
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
// 待办箱一行写所属实例,同标题的分得开;
|
||||
// - 补充输入带表单的:本地校验,服务端 422 的错误挂回字段;表单里的选人控件按这条待办的候选池取候选(使用者读不到
|
||||
// 整份名录),不在池里的服务端 422(code=principal)挂回那个字段(05-已知遗留 (b));
|
||||
// - 驳回之后去哪(中断内容的 reject_route):接了驳回出口的提示、驳回后的提示、处理过的结果写「转到「x」」,子工作流里的
|
||||
// 写「子工作流 › x」、不露内部 id;补充输入接了出口的按钮写「驳回」,没接出口的工具审批写「驳回并终止」;
|
||||
// - 关登录时签批人一行写本机署名;会签只记下一票(resolved 为假)时提示「等待其他人处理」;
|
||||
// - 审核个人应用(kind=review,payload 同服务端 blueprints/personal.review_payload):写提交人(显示名)、目的、说明;没有
|
||||
// 「同意」——「取副本,去发布」调 POST /api/blueprints/{id}/copy 后进副本蓝图;取过的给「打开我的副本」(只认自己取的那
|
||||
@@ -204,6 +206,24 @@ const TASKS = {
|
||||
reviewer: { type: 'string', title: '复核人', 'x-widget': 'principal' } } },
|
||||
payload: { kind: 'human_node', message: '请指定复核人' },
|
||||
},
|
||||
// 驳回之后去哪(中断内容的 reject_route,服务端 engine/replay.reject_route):接了驳回出口的写转到哪一步,没接的写运行终止
|
||||
routed: {
|
||||
...base, id: 'routed', approval_id: 'ap9', kind: 'approve', title: '主管审批(接了驳回出口)',
|
||||
payload: { kind: 'human_node', message: '王五报销 800 元', reject_route: { to: [{ node_id: 'tell', label: '通知申请人' }] } },
|
||||
},
|
||||
routedInput: {
|
||||
...base, id: 'routedInput', approval_id: 'ap10', kind: 'input', title: '补填用途(接了驳回出口)',
|
||||
payload: { kind: 'human_node', message: '请补填用途', reject_route: { to: [{ node_id: 'sub/back', label: '复核子流程 › 退回' }] } },
|
||||
},
|
||||
stopTool: {
|
||||
...base, id: 'stopTool', approval_id: 'ap11', kind: 'tool', title: '调用工具:erp_query',
|
||||
payload: { kind: 'tool_approval', tool: 'erp_query', args: { q: 1 }, reject_route: { ends: 'run' } },
|
||||
},
|
||||
rejectedDone: {
|
||||
...base, id: 'rejectedDone', approval_id: 'ap12', kind: 'approve', title: '主管审批(已驳回)', status: 'resolved',
|
||||
can_respond: false, outcome: { decision: 'reject' }, resolved_by: 'zhangsan', resolved_at: ago(300_000),
|
||||
payload: { kind: 'human_node', message: '赵六报销 50 元', reject_route: { to: [{ node_id: 'tell', label: '通知申请人' }] } },
|
||||
},
|
||||
input: {
|
||||
...base, id: 'input', approval_id: 'ap5', kind: 'input', title: '补填发票信息',
|
||||
form: { format: 'agentlab.form/1', type: 'object', required: ['invoice'], properties: {
|
||||
@@ -612,6 +632,38 @@ await section('口径召回:后台的系统通知点开去待办页(不去
|
||||
}
|
||||
})
|
||||
|
||||
await section('驳回之后去哪:提示、按钮、驳回后的提示、处理过的结果', async () => {
|
||||
const state = { writes: [] }
|
||||
const page = await open(state)
|
||||
await page.goto(`${WEB}/apps/inbox/routed`)
|
||||
await card(page).waitFor({ timeout: 15000 })
|
||||
let text = await card(page).innerText()
|
||||
check('接了驳回出口的审批:提示写驳回后转到哪一步', text.includes('驳回:转到「通知申请人」'), text.slice(-80))
|
||||
check('……不再写「转入「驳回」分支」', !text.includes('转入「驳回」分支'))
|
||||
await page.locator('[data-task-reject]').click()
|
||||
check('驳回之后提示转到哪一步', await page.getByText('已驳回,转到「通知申请人」').waitFor({ timeout: 3000 }).then(() => true, () => false))
|
||||
check('驳回照约定交给待办接口', state.writes.some((w) => w.path === '/api/tasks/routed/respond' && w.body?.decision === 'reject'))
|
||||
|
||||
await page.goto(`${WEB}/apps/inbox/routedInput`)
|
||||
await card(page).waitFor({ timeout: 15000 })
|
||||
text = await card(page).innerText()
|
||||
check('补充输入接了驳回出口:按钮写「驳回」,不写「驳回并终止」', (await page.locator('[data-task-reject]').innerText()).trim() === '驳回')
|
||||
check('……提示写子工作流里的那一步', text.includes('驳回:转到「复核子流程 › 退回」'), text.slice(-80))
|
||||
check('……不露内部 id', !text.includes('sub/back'))
|
||||
|
||||
await page.goto(`${WEB}/apps/inbox/stopTool`)
|
||||
await card(page).waitFor({ timeout: 15000 })
|
||||
text = await card(page).innerText()
|
||||
check('没接驳回出口的工具审批:按钮写「驳回并终止」', (await page.locator('[data-task-reject]').innerText()).trim() === '驳回并终止')
|
||||
check('……提示写本次运行终止', text.includes('驳回:本次运行终止'), text.slice(-80))
|
||||
|
||||
await page.goto(`${WEB}/apps/inbox/rejectedDone`)
|
||||
await card(page).waitFor({ timeout: 15000 })
|
||||
const resolved = await page.locator('[data-task-resolved]').first().innerText()
|
||||
check('处理过的:结果写驳回之后去了哪', resolved.includes('结果:驳回,转到「通知申请人」'), resolved)
|
||||
check('没有未捕获的运行时错误', page.errors.length === 0, page.errors[0] ?? '')
|
||||
})
|
||||
|
||||
await section('待办箱:列表和徽标', async () => {
|
||||
const page = await open({ writes: [] })
|
||||
await page.goto(`${WEB}/apps?tab=inbox`)
|
||||
|
||||
@@ -306,6 +306,39 @@ await section('口径对账:核对参数 → 发起 → 选对照的指标 →
|
||||
|
||||
// ---------------------------------------------------------------- 「按口径」那个数的出处跨卡追到取数查询
|
||||
|
||||
await section('口径对账:逐格证明了的列预选上对照,人可以改', async () => {
|
||||
// 服务端按逐格比对(ledger/match._cells)证明了的那一列给出预选(options.suggested),界面照它预选、标「预选」
|
||||
const posts = []
|
||||
const extra = (method, p, body) => {
|
||||
if (method === 'POST' && p === `/ledger/answers/${RUN}/reconcile`) {
|
||||
posts.push(body)
|
||||
if (!body?.pairs) {
|
||||
return { status: 409, json: { detail: '认不出这次的哪一列对应口径的哪个指标,请选择要对照的指标', code: 'ledger_reconcile_needs_pairs',
|
||||
options: { columns: ['orders', 'refunds'], metrics: [{ id: 'orders', name: '订单数', unit: '单' }],
|
||||
suggested: [{ ours: 'orders', metric: 'orders' }] } } }
|
||||
}
|
||||
return { status: 201, json: { run_id: 'run-rec-9', reconciled: reconciledOf('running') } }
|
||||
}
|
||||
return null
|
||||
}
|
||||
const { page, errors } = await open('/ui-harness.html?evidence=1', { reply: evidenceReply(() => ledgerOf(RUN, {}), extra) })
|
||||
await page.waitForSelector('#evidence-wide [data-seg="s8"]', { timeout: 10000 })
|
||||
await openSeg(page, 's8')
|
||||
await page.locator('[data-evidence-panel] [data-ledger-reconcile-open]').click()
|
||||
await page.locator('[data-ledger-reconcile-dialog]').waitFor({ timeout: 4000 })
|
||||
await page.locator('[data-ledger-reconcile-launch]').click()
|
||||
await page.locator('[data-ledger-pairs]').waitFor({ timeout: 4000 })
|
||||
check('证明了的那一列预选上对照的指标', await page.locator('[data-ledger-pair="orders"]').inputValue() === 'orders')
|
||||
check('……标「预选」,说明可以改选', await page.locator('[data-ledger-pair-suggested="orders"]').count() === 1
|
||||
&& (await page.locator('[data-ledger-pairs]').innerText()).includes('可以改选'))
|
||||
check('没证明的那一列不替人猜', await page.locator('[data-ledger-pair="refunds"]').inputValue() === '')
|
||||
await page.locator('[data-ledger-reconcile-launch]').click()
|
||||
await until(() => posts.length === 2)
|
||||
check('直接发起:带上预选的对照', JSON.stringify(posts[1]?.pairs) === JSON.stringify([{ ours: 'orders', metric: 'orders' }]),
|
||||
JSON.stringify(posts[1]))
|
||||
check('没有运行时报错', errors.length === 0, errors.join(' | '))
|
||||
})
|
||||
|
||||
await section('对账结果里「按口径」那个数:出处跨卡追到口径的取数查询', async () => {
|
||||
const extra = (method, p) => {
|
||||
const m = p.match(/^\/runs\/run-rec-1\/evidence\/metrics\/reconcile\/([^/]+)$/)
|
||||
|
||||
@@ -2349,6 +2349,41 @@ await section('事件触发:新建的请求体', async () => {
|
||||
check('没有页面报错、原生对话框', !errors.length, errors.join(' | '))
|
||||
})
|
||||
|
||||
await section('事件触发:对象太多时按名称查找', async () => {
|
||||
// 服务端一页没给完(more):选择框上面多一个查找框,输入后按事件种类、关键字再查,结果只换这一种事件的对象
|
||||
const many = { ...TRIGGER_OPTIONS, events: TRIGGER_OPTIONS.events.map((e) => (e.event === 'workflow.finished'
|
||||
? { ...e, more: true } : e)) }
|
||||
const queries = []
|
||||
const override = (method, path, _body, url) => {
|
||||
if (method !== 'GET' || path !== '/schedules/trigger-options') return null
|
||||
const q = url.searchParams.get('q')
|
||||
if (!q) return { json: many }
|
||||
queries.push({ event: url.searchParams.get('event'), q })
|
||||
return { json: { ...many, events: [{ event: 'workflow.finished', label: '上游工作流运行成功结束', subject_label: '工作流',
|
||||
more: false, objects: [{ id: 'wf-far', name: `${q}周报(第 301 个)`, ok: true, reason: null }] }] } }
|
||||
}
|
||||
const { page, errors } = await open('/schedules/new', { state: { ...freshState(), override } })
|
||||
await page.locator('[data-schedule-form]').waitFor()
|
||||
await page.locator('[data-trigger-mode="event"]').click()
|
||||
await page.locator('[data-trigger-event="workflow.finished"]').click()
|
||||
const search = page.locator('[data-trigger-subject-search]')
|
||||
await search.waitFor()
|
||||
check('一页没列完:选择框上面有按名称查找', await search.isVisible())
|
||||
check('上传表格一页列完了:没有查找框', await (async () => {
|
||||
await page.locator('[data-trigger-event="table.version"]').click()
|
||||
const none = await page.locator('[data-trigger-subject-search]').count() === 0
|
||||
await page.locator('[data-trigger-event="workflow.finished"]').click()
|
||||
return none
|
||||
})())
|
||||
await page.locator('[data-trigger-subject-search]').fill('华东')
|
||||
const far = page.locator('[data-trigger-subject="workflow.finished"] option[value="wf-far"]')
|
||||
await far.waitFor({ state: 'attached', timeout: 5000 }).catch(() => {})
|
||||
check('按关键字查到的对象换进选择框', await far.count() === 1, String(await far.count()))
|
||||
check('查的是这一种事件、带着关键字', queries.some((x) => x.event === 'workflow.finished' && x.q === '华东'),
|
||||
JSON.stringify(queries))
|
||||
check('没有未捕获的运行时错误', errors.length === 0, errors[0] ?? '')
|
||||
})
|
||||
|
||||
await section('事件触发:上游工作流的请求体(途经驳回、应用补算)', async () => {
|
||||
const { page, sent, errors } = await open('/schedules/new')
|
||||
await page.locator('[data-schedule-form]').waitFor()
|
||||
|
||||
Reference in New Issue
Block a user