Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ milestone: bugfix
depends:
- bugfix-107
priority: P2
status: ready
status: done
scope:
- apps/api/**
- apps/web/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 双语配对一致性记录(docs/i18n/README.md):两侧在最后一次确认一致状态下的
# git blob hash。两种语言同等权威;编辑任一侧后带上另一侧,然后重录:
# pnpm run record:i18n -- .agents/flow/issues/bugfix-cluster-source-attribution-production.md
bugfix-cluster-source-attribution-production.md: b467929b7741be84e909ef8ad53d3d75fce09412
bugfix-cluster-source-attribution-production.en.md: ce3608167b1311f5a7990d60a8a5e47b4fdade8a
bugfix-cluster-source-attribution-production.md: e5286185bce5beecda83413f547e4132a2f63406
bugfix-cluster-source-attribution-production.en.md: 3dec514ff06ab0302efab154e081dd9c761eeed7
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ milestone: bugfix
depends:
- bugfix-107
priority: P2
status: ready
status: done
scope:
- apps/api/**
- apps/web/**
Expand Down
195 changes: 195 additions & 0 deletions .agents/flow/issues/bugfix-edit-patch-member-scope.en.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 双语配对一致性记录(docs/i18n/README.md):两侧在最后一次确认一致状态下的
# git blob hash。两种语言同等权威;编辑任一侧后带上另一侧,然后重录:
# pnpm run record:i18n -- .agents/flow/issues/bugfix-edit-patch-member-scope.md
bugfix-edit-patch-member-scope.md: 85b253475f76b5b5197c400bfc424cf6ac6a7ed9
bugfix-edit-patch-member-scope.en.md: 90fe69098f540927f68161702db6a59bf5f4030e
195 changes: 195 additions & 0 deletions .agents/flow/issues/bugfix-edit-patch-member-scope.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ depends:
- bugfix-86
- bugfix-93
priority: P2
status: in-progress
status: done
scope:
- apps/api/app/main.py
- apps/api/tests/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 双语配对一致性记录(docs/i18n/README.md):两侧在最后一次确认一致状态下的
# git blob hash。两种语言同等权威;编辑任一侧后带上另一侧,然后重录:
# pnpm run record:i18n -- .agents/flow/issues/bugfix-startup-locator-backfill.md
bugfix-startup-locator-backfill.md: 25627101e820a0a4a0fc298168dba5cb1c80cb27
bugfix-startup-locator-backfill.en.md: c7d1f36ffe32e13ee78e67ff91fff85550c4c1d0
bugfix-startup-locator-backfill.md: 1b4ae956e291da1a735e4fb06b8727674aa15cfc
bugfix-startup-locator-backfill.en.md: 3c3373b26f6e553606e71c94bab6c16266353a30
2 changes: 1 addition & 1 deletion .agents/flow/issues/bugfix-startup-locator-backfill.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ depends:
- bugfix-86
- bugfix-93
priority: P2
status: in-progress
status: done
scope:
- apps/api/app/main.py
- apps/api/tests/**
Expand Down
18 changes: 14 additions & 4 deletions plans/ui-prototype-v2/design-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,25 @@ Content-Type: application/json
→ 判断对象版本是否在这些 Session 中出现(出现才关联)
→ 对关联 Session 找对象触发点与所有 bad case 触发点
→ 按潜在策略筛选潜在 bad case
→ 对每个潜在 bad case 生成「对象版本级」归因
→ 对归因后的 bad case 按问题类型聚类,按严重程度降序排序
→ 按聚类结果逐轮打 patch / 评测 / 接纳
→ 对每个潜在 bad case 按每个成员生成成员级归因报告(一个 case 可有多份)
→ 按(成员 × 根因)聚类,不同成员的问题不合并;同一 case 可进入多个成员簇
→ 每个成员簇逐轮生成只改该成员的 patch / 评测 / 接纳
→ 测试集终评
```

原型把 Session 关联与潜在 bad case 拆成向导第 2、3 步:第 2 步只看关联 Session(分页),第 3 步只看潜在 bad case(分页),第 4 步才做归因预览与启动。

运行详情的聚类步骤按严重程度降序展示簇卡片;每簇有标题与聚类问题描述,可折叠,展开后在簇下方列出全部来源归因报告(报告 ID、归因问题描述、进化对象/成员、分类、来源 bad case 链接、报告时间),默认展开第一簇。
运行详情的聚类步骤先按成员分组,再按严重程度降序展示簇卡片;每簇有且只有一个成员标签、标题与聚类问题描述,可折叠,展开后在簇下方列出该成员的来源归因报告(报告 ID、归因问题描述、进化对象/成员、分类、来源 bad case 链接、报告时间),默认展开第一簇。同一 bad case 若同时归因到多个成员,会在多个成员簇里各出现一次,但不与另一成员的结论合并。

### 7.1.1 成员级归因、聚类与 patch

多成员进化对象的三段投影必须使用同一个成员身份:

- **归因**:每个潜在 bad case 对每个相关成员各生成一份报告;报告带成员、分类、结论与独立置信度。第 4 步按 case 分组,一个 case 可显示多行成员报告,行首用 rowspan 合并同一 case;对象级报告仅在无法归属任何成员时兜底。
- **聚类**:聚类键是 `(归因成员, 根因)`,同一 case 的多份成员报告分别进入各自成员的簇;簇卡片只显示一个成员标签,页面按成员分组,不出现同时含两个成员来源的簇。
- **Patch**:每个轮次继承簇的成员,`allowed_paths` 只含该成员子目录,生成的 patch 文件必须落在该成员目录内;commit 主题与「## 问题」写该成员,不写全部成员。

前后原型对照使用同一 demo run `EV-20261109-01`(成员 `deep-research`、`code-review`)、同一 1440×900 视口与同一模拟完成态;截图与 `capture.mjs` 在 [`evidence/member-scope`](evidence/member-scope/)。设计依据见 18 §5.2/§5.4 与 07 §5.5.2/§5.5.4。

### 7.1.1 聚类等待态与零结果

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
185 changes: 185 additions & 0 deletions plans/ui-prototype-v2/evidence/member-scope/capture.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// Capture before/after V2 prototype screenshots for member-scoped attribution,
// clustering and edit patches.
// Usage: node capture.mjs <before|after>
// PROTOTYPE_HTML=<path> optional prototype file; defaults to ../../harness-evolution.html.
// For the "before" pass, export the base revision first:
// git show HEAD:plans/ui-prototype-v2/harness-evolution.html > <tmp>
// Requires Chrome (CHROME_BIN or the default macOS/Linux locations).
import { mkdir, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath, pathToFileURL } from "node:url";

import { createBrowserPage } from "../../../../tests/support/runtime.mjs";

const phase = process.argv[2];
if (!["before", "after"].includes(phase)) {
console.error("usage: node capture.mjs <before|after>");
process.exit(2);
}

const evidenceDir = path.dirname(fileURLToPath(import.meta.url));
const prototypePath =
process.env.PROTOTYPE_HTML || path.join(evidenceDir, "..", "..", "harness-evolution.html");
const pageUrl = pathToFileURL(path.resolve(prototypePath)).href;
console.log(`prototype: ${pageUrl}`);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

/**
* Evaluate one expression and return its JSON value.
* @param {object} session CDP session.
* @param {string} expression JavaScript expression.
* @returns {Promise<unknown>} Serialized result.
*/
async function evaluate(session, expression) {
const result = await session.send("Runtime.evaluate", {
expression,
returnByValue: true,
awaitPromise: true,
});
if (result.exceptionDetails) {
throw new Error(`evaluation failed: ${result.exceptionDetails.text} ${expression}`);
}
return result.result.value;
}

/**
* Evaluate one expression until it returns true.
* @param {object} session CDP session.
* @param {string} expression JavaScript expression.
* @param {string} label Wait reason for the error message.
* @returns {Promise<void>} Resolves once the expression is truthy.
*/
async function waitUntil(session, expression, label) {
const deadline = Date.now() + 90_000;
let lastLog = 0;
while (Date.now() < deadline) {
const value = await evaluate(session, expression);
if (value) return;
if (Date.now() - lastLog > 10_000) {
lastLog = Date.now();
console.log(` waiting for ${label}: ${expression} => ${JSON.stringify(value)}`);
}
await sleep(150);
}
throw new Error(`timed out waiting for ${label}`);
}

/**
* Click one element through the page's own click delegation.
* @param {object} session CDP session.
* @param {string} selector CSS selector.
* @returns {Promise<void>} Resolves after the click dispatched.
*/
async function click(session, selector) {
const ok = await evaluate(
session,
`(() => { const el = document.querySelector(${JSON.stringify(selector)}); if (!el) return false; el.click(); return true; })()`,
);
if (!ok) throw new Error(`element not found: ${selector}`);
await sleep(350);
}

/**
* Capture the visible step card as a crisp PNG.
* @param {object} session CDP session.
* @param {string} name Output file stem.
* @returns {Promise<void>} Resolves after the PNG is written.
*/
async function shootStep(session, name) {
const rect = await evaluate(
session,
`(() => {
const cards = [...document.querySelectorAll('.card.panel')];
const el = cards[cards.length - 1];
if (!el) return null;
const r = el.getBoundingClientRect();
const y = r.top + window.scrollY;
window.scrollTo(0, Math.max(0, y - 170));
return { x: r.left + window.scrollX, y, width: r.width, height: r.height };
})()`,
);
if (!rect) throw new Error("step card not found");
await sleep(250);
const { data } = await session.send("Page.captureScreenshot", {
format: "png",
fromSurface: true,
captureBeyondViewport: true,
clip: {
x: Math.max(0, rect.x - 16),
y: Math.max(0, rect.y - 16),
width: rect.width + 32,
height: rect.height + 32,
scale: 2,
},
});
const target = path.join(evidenceDir, `${phase}-${name}.png`);
await writeFile(target, Buffer.from(data, "base64"));
console.log(`wrote ${path.relative(process.cwd(), target)}`);
}

const buildClusters = phase === "after" ? "run.model.attributedReports" : "run.model.attributed";

await mkdir(evidenceDir, { recursive: true });
const page = await createBrowserPage();
try {
await page.session.send("Emulation.setDeviceMetricsOverride", {
width: 1440,
height: 900,
deviceScaleFactor: 1,
mobile: false,
});
await page.session.send("Page.navigate", { url: `${pageUrl}?u=admin&page=evo&demo=run` });
await waitUntil(
page.session,
"window.V2_READY === true && !!document.querySelector('[data-action=\"ev-sel-step\"][data-step=\"3\"]')",
"run detail",
);
await sleep(1000);

// Freeze the same demo inputs for both revisions: the attribution review is
// treated as completed, all potential cases have a fresh report, and the
// non-member self case stays object-level (not a member cluster).
await evaluate(
page.session,
`(() => {
const run = EV_RUNS.find(r => r.id === 'EV-20261109-01');
run.reviewRequired = false;
for (const row of run.model.potentialRows) {
row.skipped = false; row.hasReport = true; row.cached = false;
if (row.c.type === 'self' && !evIsMember(run, row.c.objectName)) row.conclusion = 'not-object';
}
run.model.reused = 0; run.model.fresh = run.model.potentialRows.length; run.model.missing = 0;
evAttachReports(run);
evBuildClusters(run, ${buildClusters});
run.progress = evTotal(run);
evRenderDetail(run.id);
return run.clusters.length;
})()`,
);
await sleep(500);

const steps = [
{ index: 3, slug: "step4-attribution", title: "第 4 步 · 对象归因" },
{ index: 4, slug: "step5-clusters", title: "第 5 步 · 归因聚类与严重度排序" },
{ index: 5, slug: "step6-iteration", title: "第 6 步 · 迭代优化" },
];
for (const step of steps) {
await evaluate(
page.session,
`(() => { window.__evState.selStep = ${step.index}; evRenderDetail('EV-20261109-01'); return true; })()`,
);
await waitUntil(
page.session,
`!![...document.querySelectorAll('.card.panel')].at(-1)?.innerText.includes(${JSON.stringify(step.title)})`,
step.slug,
);
await sleep(500);
if (step.index === 5) {
const first = await evaluate(page.session, "!!document.querySelector('.cluster-head')");
if (first) await click(page.session, ".cluster-head");
}
await shootStep(page.session, step.slug);
}
} finally {
await page.close();
}
Loading
Loading