HEL-892: document two audio workflows with pinned definitions and protected upgrades

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
leefer
2026-10-30 08:42:30 +08:00
co-authored by multica-agent
parent 742e4b6a21
commit 238d84abf6
36 changed files with 7126 additions and 43 deletions
+89
View File
@@ -0,0 +1,89 @@
// Real local detail GET, all 13 audio saved fields, both viewport sizes and document isolation.
import fs from 'node:fs';
import assert from 'node:assert/strict';
const { chromium } = await import(process.env.PLAYWRIGHT_MODULE || 'playwright');
const out = '.local-evidence/audio-document/browser';
fs.mkdirSync(out, { recursive: true });
const checks = [], requests = [], errors = [];
function check(value, text) { assert.ok(value, text); checks.push(text); console.log('PASS ' + text); }
const browser = await chromium.launch({ headless: true, executablePath: process.env.BROWSER_EXECUTABLE });
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
page.on('request', r => { if (r.url().includes('/api/')) requests.push({method:r.method(),url:r.url()}); });
page.on('pageerror', e => errors.push(e.message));
const list = await (await fetch('http://127.0.0.1:8247/api/workflows')).json();
const details = [];
for (const name of ['音频转MP3格式', '音频人声分离', 'Minimax-H3提示词增强']) {
const record = list.find(x => x.name === name); assert.ok(record);
const url = `http://127.0.0.1:8247/api/workflows/${record.id}`;
requests.push({ method:'GET', url });
details.push(await (await fetch(url)).json());
}
check(details.map(d => d.doc_json.fixed_version.fields.length).join(',') === '5,8,18', '13新增保存定义与18旧H3定义独立');
await page.goto('http://127.0.0.1:5173/connections', { waitUntil: 'networkidle' });
const dialog = page.getByRole('dialog', { name: '工作流说明' });
async function begin(name) {
const row = page.locator('.wf-row').filter({ has: page.locator('.wf-name').filter({ hasText:name }) }).first();
const button = row.getByRole('button', { name:'说明', exact:true });
await button.focus(); await page.keyboard.press('Enter');
return button;
}
async function loaded() {
await dialog.getByText('用途与来源', {exact:true}).waitFor();
await dialog.evaluate(el => Promise.all(el.getAnimations().map(a => a.finished)));
}
for (const width of [1440,390]) {
await page.setViewportSize({width,height:width===390?844:1000});
for (const detail of details.slice(0,2)) {
const fixed = detail.doc_json.fixed_version;
const button = await begin(detail.name); await loaded();
check((await dialog.innerText()).includes(fixed.notice), `${width} ${detail.name}声明/假设提示`);
for (const text of ['说明未定稿','未验证实跑','未检查']) check((await dialog.innerText()).includes(text), `${width} ${detail.name} ${text}`);
check(!detail.is_enabled && detail.import_state==='needs_conversion' && !detail.doc_completed_at && !detail.exec_verified_at, `${width} ${detail.name}资格未改`);
const names = fixed.fields.map(f => `节点 ${f.node_id} · ${f.label}(${f.field})`);
for (const field of fixed.fields) {
const summary = dialog.getByText(`节点 ${field.node_id} · ${field.label}(${field.field})`, {exact:true});
await summary.focus(); await page.keyboard.press('Enter');
const box = summary.locator('..');
check(await box.evaluate(el => el.open), `${width} ${field.node_id}.${field.field}键盘展开`);
const text = await box.innerText();
check(text.includes(field.effect) && text.includes(field.limits) && text.includes(field.schema_default), `${width} ${field.node_id}.${field.field}语义/默认/限定`);
check(await box.locator(':scope > pre').textContent() === (typeof field.value==='string'?field.value:JSON.stringify(field.value,null,2)), `${width} ${field.node_id}.${field.field}原值/类型/null/空值`);
await box.getByText('来源依据',{exact:true}).click();
const evidence = await box.innerText();
check(evidence.includes(field.pointer) && field.evidence.every(i => { const e=fixed.sources[i]; return evidence.includes(e.commit) && evidence.includes(e.sha256) && evidence.includes(e.lines.join('~')); }), `${width} ${field.node_id}.${field.field}可回读依据`);
check(!evidence.includes('undefined'), `${width} ${field.node_id}.${field.field}无伪具名指针`);
check(await dialog.locator('.drawer-body').evaluate(el=>el.scrollWidth<=el.clientWidth), `${width} ${field.node_id}.${field.field}无溢出`);
if (['audioUI','chunk_overlap','quality'].includes(field.field)) await page.screenshot({path:`${out}/${width}-${detail.id}-${field.field}.png`});
await summary.click();
}
check(await dialog.locator('summary').filter({hasText:/节点 \d+ · .*(/}).count() === names.length, `${width} ${detail.name}无跨图参数`);
if (detail.name==='音频人声分离') {
const text=await dialog.innerText();
check(text.includes('11槽3 Vocals → 15.audio') && text.includes('10槽0 → 18.audio') && text.includes('18槽0 → 11.audio'), `${width} 3连线/非零槽3`);
check(text.includes('PreviewAudio15') && text.includes('临时目录FLAC') && text.includes('type=temp'), `${width} 无保存控件预览的临时文件副作用`);
} else check((await dialog.innerText()).includes('1槽0 → 4.audio'), `${width} MP3连线`);
await dialog.getByText('固定版本参数说明',{exact:true}).scrollIntoViewIfNeeded();
await page.screenshot({path:`${out}/${width}-${detail.id}-overview.png`});
await page.keyboard.press('Escape'); await dialog.waitFor({state:'hidden'});
check(await button.evaluate(el=>el===document.activeElement), `${width} ${detail.name}关闭归还焦点`);
}
// Return to H3 and back, ensuring definition lookup does not leak across records.
for (const detail of [details[2],details[0],details[1]]) {
await begin(detail.name); await loaded();
check(await dialog.locator('summary').filter({hasText:/节点 \d+ · .*(/}).count()===detail.doc_json.fixed_version.fields.length, `${width}切换${detail.name}定义不串条`);
await page.keyboard.press('Escape');
}
}
// Hold audio response, switch to another actual audio graph, then deliver the old response.
let release, entered, delivered;
const hold = new Promise(r=>release=r), intercept = new Promise(r=>entered=r), done = new Promise(r=>delivered=r);
await page.route(`**/api/workflows/${details[0].id}`, async route=>{entered();await hold;await route.fulfill({json:details[0]});delivered();});
await begin(details[0].name); await intercept; await page.keyboard.press('Escape');
await begin(details[1].name); await loaded(); release(); await done;
check(await dialog.locator('summary').filter({hasText:/节点 \d+ · .*(/}).count()===8, '迟到MP3响应不覆盖人声分离8项');
await page.unroute(`**/api/workflows/${details[0].id}`); await page.keyboard.press('Escape');
check(errors.length===0,'浏览无脚本错误');
check(requests.every(r=>r.method==='GET' && new URL(r.url).hostname==='127.0.0.1'),'音频浏览全本地GET,无生成/目标机请求');
fs.writeFileSync(`${out}/browser-results.json`, JSON.stringify({checks,requests,errors,viewports:[1440,390]},null,2));
} finally { await browser.close(); }
+77
View File
@@ -0,0 +1,77 @@
"""Foreground local browser check; stop every owned service before returning."""
from __future__ import annotations
import os
import signal
import subprocess
import sys
import time
import urllib.error
import urllib.request
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / ".local-evidence/audio-document/browser"
def main():
OUT.mkdir(parents=True, exist_ok=True)
# Refuse to reuse another operator's service or port.
import socket
for port in (8247, 5173):
with socket.socket() as sock:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("127.0.0.1", port))
processes = []
logs = []
try:
commands = [
([sys.executable, str(ROOT / "e2e/workflow-document-server.py")], ROOT),
(
["node", "node_modules/vite/bin/vite.js", "--host", "127.0.0.1"],
ROOT / "calliope-web",
),
]
for i, (command, cwd) in enumerate(commands):
log = (OUT / f"service-{i}.log").open("w")
logs.append(log)
processes.append(
subprocess.Popen(command, cwd=cwd, stdout=log, stderr=log, start_new_session=True)
)
for url in (
"http://127.0.0.1:8247/api/workflows",
"http://127.0.0.1:5173/connections",
):
deadline = time.monotonic() + 30
while True:
if any(p.poll() is not None for p in processes):
raise RuntimeError("Local service exited; inspect service logs")
try:
with urllib.request.urlopen(url, timeout=1) as response:
if response.status == 200:
break
except (urllib.error.URLError, TimeoutError):
pass
if time.monotonic() > deadline:
raise TimeoutError(url)
time.sleep(0.2)
subprocess.run(["node", "e2e/audio-document.mjs"], cwd=ROOT, check=True)
subprocess.run(["node", "e2e/h3-document.mjs"], cwd=ROOT, check=True)
finally:
for p in processes:
if p.poll() is None:
os.killpg(p.pid, signal.SIGTERM)
try:
p.wait(timeout=10)
except subprocess.TimeoutExpired:
os.killpg(p.pid, signal.SIGKILL)
p.wait(timeout=5)
for log in logs:
log.close()
print("All owned browser services stopped.")
if __name__ == "__main__":
main()