diff --git a/.agents/flow/issues/bugfix-cluster-source-attribution-production.en.md b/.agents/flow/issues/bugfix-cluster-source-attribution-production.en.md index ce360816..3dec514f 100644 --- a/.agents/flow/issues/bugfix-cluster-source-attribution-production.en.md +++ b/.agents/flow/issues/bugfix-cluster-source-attribution-production.en.md @@ -9,7 +9,7 @@ milestone: bugfix depends: - bugfix-107 priority: P2 -status: ready +status: done scope: - apps/api/** - apps/web/** diff --git a/.agents/flow/issues/bugfix-cluster-source-attribution-production.i18n.yaml b/.agents/flow/issues/bugfix-cluster-source-attribution-production.i18n.yaml index 34a58aee..1790ea40 100644 --- a/.agents/flow/issues/bugfix-cluster-source-attribution-production.i18n.yaml +++ b/.agents/flow/issues/bugfix-cluster-source-attribution-production.i18n.yaml @@ -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 diff --git a/.agents/flow/issues/bugfix-cluster-source-attribution-production.md b/.agents/flow/issues/bugfix-cluster-source-attribution-production.md index b467929b..e5286185 100644 --- a/.agents/flow/issues/bugfix-cluster-source-attribution-production.md +++ b/.agents/flow/issues/bugfix-cluster-source-attribution-production.md @@ -9,7 +9,7 @@ milestone: bugfix depends: - bugfix-107 priority: P2 -status: ready +status: done scope: - apps/api/** - apps/web/** diff --git a/.agents/flow/issues/bugfix-edit-patch-member-scope.en.md b/.agents/flow/issues/bugfix-edit-patch-member-scope.en.md new file mode 100644 index 00000000..90fe6909 --- /dev/null +++ b/.agents/flow/issues/bugfix-edit-patch-member-scope.en.md @@ -0,0 +1,195 @@ +# Attribution, clustering and edit patches are not member-isolated: one bad case needs per-member reports, member clusters and member patches + +English | [中文](bugfix-edit-patch-member-scope.md) + +```yaml flow +kind: issue +id: bugfix-115 +milestone: bugfix +depends: + - bugfix-102 + - bugfix-106 +priority: P2 +status: ready +scope: + - apps/api/app/** + - apps/api/tests/** + - apps/web/src/** + - packages/contracts/** + - tests/e2e/** + - plans/** + - .agents/** +adr: [] +github: + number: 814 + url: https://github.com/Shadow-Azure/harness-evolution/issues/814 +``` + +## Background + +At 15:43 (+08) on 2026-12-04, production workspace `01M7KJ05ENF9784GPBDV544VB0` started full run [`01M9004SE7E4ZNS1SA1RV5K6M2`](http://8.149.232.63/workspaces/01M7KJ05ENF9784GPBDV544VB0/evolution/runs/01M9004SE7E4ZNS1SA1RV5K6M2). The evolution object `01M8WRB9Y7RMGKPYJE1345VADE` (`code-generator`) has two members: `agent:code-generator` (`agents/code-generator`, member `01M8WRB9YN3X4YKDDEHAY4DWMJ`) and `skill:codespec-subagent-driven-development` (`skills/codespec-subagent-driven-development`, member `01M8WRB9YNFXV7DB4PAX7MV86E`). + +The reporter further clarified the expected model: attribution should resolve to members; one bad case in one attribution can belong to multiple members of the evolution object, and each member gets its own attribution analysis report; clustering must not merge problems from different members; the final edit patch must modify only that cluster's member. The production run violates all three stages: + +| Stage | Current production behaviour | Expected | +|---|---|---| +| Attribution | Four potential cases produce four reports: three for codespec and one for code-generator; no case has reports for multiple members | One case can produce one report per related member | +| Clustering | Three clusters; cluster `01M901ECX6X2NE767M4YQ4XFGF` contains both code-generator case `swe-ba7af8b8c52626e231f9` and codespec case `swe-d348ed547fc3c292d962` | The cluster key carries the member; different members do not merge | +| edit patch | The first turn's patch contains both `agents/code-generator/AGENT.md` and `skills/codespec-subagent-driven-development/SKILL.md`; the commit is named after the first member `code-generator` | The patch only touches the cluster member's directory and the commit names that member | + +### Production evidence + +| Layer | Production value | Meaning | +|---|---|---| +| Step-4 attribution row | `badCaseId=swe-31d26398caa9f2cc7fde`, `memberName=codespec-subagent-driven-development`, `objectLevel=false`, `attributionId=01M90194RSVZ1BCJ6RAJRNV22W` | Attribution correctly points at the skill member, but it is the only report | +| Other step-4 rows | `swe-ba7af8…` maps to code-generator, `swe-d348ed…` to codespec, `swe-b76c10…` to codespec | One report per case; no case has multiple members | +| Step-5 mixed cluster | `01M901ECX6X2NE767M4YQ4XFGF`: `swe-ba7af8…` (code-generator) and `swe-d348ed…` (codespec) | Cases from different members are merged into one cluster | +| Step-6 first turn | `roundId=01M901ENC2HYP3TS6PFA5S3SEC`, `files=[agents/code-generator/AGENT.md, skills/codespec-subagent-driven-development/SKILL.md]`, `Harness-Patch-Hash: sha256:513bff…` | One turn changes two members | +| Patch note | “complete the per-task review convergence criteria, iteration cap and time-budget guardrails for the codespec-subagent-driven-development skill, and add one-shot batch handling and closure-evidence reporting discipline to code-generator” | The model writes a cross-member mitigation into one candidate | +| Candidate commit body | The “## 问题” section says “the cluster of `code-generator@openspec-cn-main-copy-ar-a7ec200-claude-core` … contains source issue swe-31d26398caa9f2cc7fde” | The commit message names the first member as the cluster's object | +| Page rendering | Step 4 is one row per case; step 5 cluster headers can show two member chips; step 6 patch and commit carry no member scope | The three identities are not aligned | + +The run is currently blocked after an evaluation-stage timeout (`stage=eval`, `asset_source_validation_timeout`); it is unrelated to this issue, and turns 2 and 3 have no patch yet. + +### Why this is neither a bad attribution binding nor an out-of-scope patch + +- The step-4 row's `memberId`, `objectName` and `objectVersion` all belong to `codespec-subagent-driven-development` and `digest:422aa583…`, matching the run's member snapshot; the case was not bound to another member. +- Both patch files fall inside the member union returned by `_run_allowed_paths()`, and the applier rejected no edit; `SKILL.md` really does receive the root-cause fix (“审查循环的收敛与停止策略” and related sections). The patch neither only changes code-generator nor writes outside the object. +- The real problem is that attribution, clustering and the patch do not share one member identity. Attribution is member-level, clustering may merge across members, and patch generation is object-level; the model freely chooses files from the prompt's object union and writes the “add convergence discipline to code-generator” mitigation as a cross-member change. + +### Current root cause + +1. **Attribution resolves one member and does not fan out per member.** `_member_target()` returns a single member or `None` (object-level); `_build_input()` builds one `AttributionInput` per case and the executor returns one conclusion; `probe_reports` has `member_id`, but the runner never produces one report per member, and `AttributionRunSummary` counts cases. In fact `cache_key`/`execution_manifest` already include `member_id`, so the data layer can hold multiple reports for one case across members; the gap is in the attribution runner and the API projection. +2. **The cluster key has no member.** `ProbeForCluster` only carries `probe_id/attribute_type/text`; `cluster_probes()` groups by category and lexical similarity, and `build_attribution_drafts()` sends one draft per report to an LLM review that merges by root cause; `probe_clusters` has no `member_id`. Reports from different members can therefore be pulled into one cluster, as the production step-5 second cluster shows. Once a cluster is cross-member, the later patch has no single member owner. +3. **The patch is generated over the object union.** `AgentEditPatchSource.build_bundle()` takes the union of every member directory via `_run_allowed_paths(run)`, and `_edit_prompt()` writes only “对象:” without the cluster member; the “## 问题” section in `_message_sections()` always uses `run.target_name` (the first member); `PatchBundle` and the turn payload have no member field. Design document 18 §5.4 currently defines only the object-level allowed range and never defined member-level patch semantics. +4. **The frontend is organised by case, not member.** Step 4 renders one row per case with that case's single report; step 5 derives member chips from the source case set and allows several chips per cluster; step 6 has no member label or change scope for the patch/commit. The three pages each derive members independently, so their accounts cannot be cross-checked. + +### Impact + +- When a bad case involves several members, only one conclusion survives today and the other members' evidence is lost; clustering mixes root causes across members, so the cluster title cannot say whose problem it is. +- A patch candidate couples two members: evaluation gives one score for the whole run, so it cannot tell which member's change produced the gain; acceptance/rejection cannot be attributed per member, and rolling back one member takes the other with it. +- The commit body is an immutable audit record, yet it assigns the cluster to the first member; per-member report, cost, acceptance and rollback statistics become wrong. +- The UI does not show which members a turn changes, so a reviewer cannot distinguish an intentional cross-member mitigation from a scope leak. + +## Frontend prototype before/after + +The prototype uses the existing demo run `EV-20261109-01` in `plans/ui-prototype-v2/harness-evolution.html` (members `deep-research` and `code-review`) as the same input, at a 1440×900 viewport, default theme, and the same simulated “attribution review complete, every potential case has a fresh report” state. Baseline is the `HEAD` prototype at commit `da6396ea`; after is the prototype at commit `245c4f30`; the capture script is [`plans/ui-prototype-v2/evidence/member-scope/capture.mjs`](../../../plans/ui-prototype-v2/evidence/member-scope/capture.mjs). + +**Step 4 · object attribution: one case can have several member reports** + +**Before (`da6396ea`)** + +![attribution before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step4-attribution.png) + +**After (`245c4f30`)** + +![attribution after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step4-attribution.png) + +Before: 10 potential cases and 10 reports, one report per row (`deep-research` 4, `code-review` 3, object-level 3). After: 10 potential cases and 11 reports; `BC-HC-016` produces both a `deep-research` and a `code-review` report, merged with rowspan and labelled “2 份成员报告”; the summary counts per member. + +**Step 5 · clustering: different members do not merge** + +**Before (`da6396ea`)** + +![clusters before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step5-clusters.png) + +**After (`245c4f30`)** + +![clusters after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step5-clusters.png) + +Before: `C1` contains four source reports from both `deep-research` and `code-review`, and the cluster header shows two member chips side by side. After: clusters are grouped by member, with 3 clusters for `deep-research` and 3 for `code-review`; every cluster header has one member chip, the summary shows “0 跨成员簇”, and case `BC-HC-016` appears once in each member's clusters. + +**Step 6 · edit patch: only the cluster member changes** + +**Before (`da6396ea`)** + +![iteration before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step6-iteration.png) + +**After (`245c4f30`)** + +![iteration after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step6-iteration.png) + +Before: mixed cluster `C1` has source reports from two members, yet the patch only lands in `skills/deep-research/SKILL.md` while the commit subject says `evolve(deep-research、code-review@v2.4.0)` and no change scope is shown. After: the cluster belongs to `deep-research`, the patch only lands in `skills/deep-research/SKILL.md`, the page shows “改动范围:skills/deep-research/**(仅 deep-research)”, and the commit is `evolve(deep-research@v2.4.0)`. + +Note: the prototype uses demo data to demonstrate interaction and information hierarchy; it is not production data. Production behaviour and code evidence are above. The capture script reuses `tests/support/runtime.mjs` and adds no dependency. + +## Goals + +- Attribution: for a multi-member evolution object, evaluate each potential bad case against the members that may be involved and produce one member-level report per member; each report carries its member, category, conclusion and confidence, and an object-level report is only the fallback when no member can own the case. +- Clustering: the cluster key includes the attributed member, so reports from different members never share a cluster; multiple member reports of one case enter their respective member clusters; the cluster records its member for the patch and the UI. +- Patch: each turn inherits the cluster member, `allowed_paths` contains only that member's subdirectory, and patch files must stay inside it; the commit subject and “## 问题” name that member, not all members. +- Frontend: step 4 groups multiple member reports under one case; step 5 groups clusters by member and shows one member chip per cluster; step 6 shows the member, change scope and member-level commit. +- Compatibility: old reports/clusters/turns with a null `member_id` read as object-level or historical data and are not rewritten; single-member runs keep their current path and cache keys. +- Update design documents 18 §5.2/§5.4, 07 §5.5.2/§5.5.4, `plans/ui-prototype-v2/design-v2.md` §7.1.1 and an Agent Note. + +## Design authority + +- [`plans/fullstack-design/18-multi-member-evolution-target.md` §5.2](../../../plans/fullstack-design/18-multi-member-evolution-target.md): attribution conclusions are expressed as `(evolution_object_id, member_id)`; a member-level report's `probe_object` is the member name, and an object-level report has `member_id=null`. +- [`plans/fullstack-design/18-multi-member-evolution-target.md` §5.4](../../../plans/fullstack-design/18-multi-member-evolution-target.md): it currently only says `_allowed_paths(sub_dirs)` returns multiple globs and `_edit_prompt` lists members; this issue changes it to “member cluster → member directory” patch scope. +- [`plans/fullstack-design/07-backend-implementation.md` §5.5.2](../../../plans/fullstack-design/07-backend-implementation.md): clustering algorithms and attribution drafts; the member key must enter this layer. +- [`plans/fullstack-design/07-backend-implementation.md` §5.5.4](../../../plans/fullstack-design/07-backend-implementation.md): the EditPlan `allowed_paths`, per-edit status and `PatchBundle` contracts. +- [`plans/ui-prototype-v2/design-v2.md` §7.1.1](../../../plans/ui-prototype-v2/design-v2.md): the member-level attribution, clustering and patch interactions and screenshots of this prototype. + +## Implementation + +- **Attribution fan-out**: for a multi-member run, derive the candidate member set from the session's hit members ∪ the case's own member (a discovery case never borrows the first member); the executor writes one `probe_reports` row per candidate member with `evolution_object_id`, `member_id`, `probe_object`, and its own category/conclusion/confidence; `cache_key`/manifest already include `member_id`, so reuse is per member; write an object-level report only when no member can own the case. `AttributionRunSummary` adds member-report and multi-member-case counts. +- **Cluster member key**: add `member_id` to `ProbeForCluster`/`ClusterDraft`; `cluster_probes()` groups by `(member_id, attribute_type)`; the LLM review in `build_attribution_drafts()` may merge drafts only within one member; `probe_clusters` gains `member_id` (nullable for object-level/history); cluster and source-report APIs return the member; one case may be referenced by several member clusters. +- **Patch member scope**: `ClusterDraft`/the turn inherit the member; `AgentEditPatchSource` uses the member subdirectory as `allowed_paths`, and `_edit_prompt()` states “本簇归因成员:,只修改该成员定义”; `PatchBundle` and the turn patch payload gain `member`; `_message_sections()` uses the member for “## 问题” and “## 改动”; cross-member changes are not silently merged and must be split into another member's cluster/turn. +- **Frontend**: step 4 expands a case into multiple report rows (grouped by rowspan) and counts the summary per member; step 5 groups clusters by member, uses one member chip per cluster and shows “0 cross-member clusters”; step 6 shows the member, change scope and member-level patch/commit; contracts add `reports[]`/`member`/`scope` fields. +- **Compatibility and migration**: `probe_clusters.member_id` and `evolution_rounds.member_id` are nullable; old rows with null read as object-level/historical, and the page falls back to the old presentation; single-member runs keep their cache keys and report identities; historical reports, clusters and commits are not rewritten. +- **Cost trade-off**: a case produces as many member reports as candidate members; use session hit members to bound candidates, cache per member, and optionally batch several member conclusions into one executor call to avoid N×M independent calls. +- **Documentation**: update 18 §5.2/§5.4, 07 §5.5.2/§5.5.4 and design-v2 §7.1.1; add an Agent Note recording the “member-level attribution → member cluster → member patch” decision and the object-level fallback. + +## Implementation steps + +1. Write failing tests first: one case with two candidate members produces two reports, member-level cache reuse, and the object-level fallback; reports from different members never share a cluster; a member patch only allows that member's directory. +2. Change the attribution runner and store: candidate member set, per-member reports, `AttributionRunSummary`, API projection and contracts. +3. Change clustering: `ProbeForCluster`/`ClusterDraft`/`probe_clusters` member fields, grouping and LLM review constraints, migration and read compatibility. +4. Change the patch: turn member, `_edit_prompt`, `allowed_paths`, `PatchBundle`/payload, commit message and validation. +5. Change the frontend: step 4 multiple report rows, step 5 member grouping, step 6 member scope; add Web component tests. +6. Add API/integration/E2E coverage on a two-member fixture: one case with two reports, two member clusters, two member patches. +7. Update the design documents and Agent Note; run the gates, the production-shape replay and the prototype capture. + +## Dependencies and boundary + +- Depends on: bugfix-102 (member-level attribution and `probe_reports.member_id`), bugfix-106 (object-level reports and `objectLevel` projection). +- Do not rewrite historical reports, clusters, turns or produced commits; old `member_id=null` reads as object-level/historical. +- Candidate association stays at the evolution-object level (steps 2/3 are unchanged); do not force a potential case onto the first member. +- Do not change the evaluation platform, the run's member selection or the member definition format in this issue; a cross-member patch is not the default and must be split into another member cluster/turn. +- Delivery boundary: complete the member-level attribution, member cluster and member patch main path first; the object-level fallback and historical compatibility must remain. + +## Verification + +```sh +pnpm test:api -- tests/evolution +pnpm test:web -- src/pages/evolution +pnpm contract:check +pnpm test:e2e -- --pattern "multi-member|member-scope" +pnpm verify:flow +node plans/ui-prototype-v2/evidence/member-scope/capture.mjs after +``` + +- Production-shape replay (run `01M9004SE7E4ZNS1SA1RV5K6M2`): `swe-31d26398caa9f2cc7fde` produces only a codespec report; mixed cluster `01M901ECX6X2NE767M4YQ4XFGF` splits into a code-generator cluster and a codespec cluster; member patches land in `agents/code-generator/**` and `skills/codespec-subagent-driven-development/**` respectively, and no patch changes two members at once. +- Two-member demo: one case produces two member reports; two member clusters; each cluster's patch stays in its member subdirectory; `0` cross-member clusters. +- API unit tests assert two `probe_reports` rows for one case with different `member_id` and independent `cache_key`; cluster tests assert different-member reports do not merge; patch tests assert an edit outside the member directory is rejected. +- Web/component tests assert steps 4/5/6 use the same member account; historical `member_id=null` reads do not fail. + +## Acceptance + +- One potential bad case can produce multiple member reports (one per related member), each with its own member, category, conclusion and confidence; an object-level report appears only when no member can own it. +- Every source report in a cluster belongs to the same member; the cluster records its member; different members' problems do not merge; one case may enter several member clusters. +- Every turn's patch files stay inside that cluster member's subdirectory, and the prompt and commit name the member; a cross-member change is never silently merged into the same turn. +- Step 4 groups multiple member reports under one case; step 5 groups by member with one member chip per cluster; step 6 shows the member, change scope and member-level commit; the prototype before/after screenshots agree with the production evidence. +- Single-member runs and historical reports/clusters/turns read compatibly; `pnpm verify:flow`, `pnpm contract:check`, API/Web/E2E tests pass. + +## Gates and CI + +- `pnpm verify:flow`, `pnpm contract:check`, `pnpm test:api`, `pnpm test:web`, `pnpm test:e2e`, `pnpm lint:docs`/`pnpm verify:docs`. +- Coverage at or above 80%; a new or updated Agent Note, design documents 18 §5.2/§5.4 and 07 §5.5.2/§5.5.4, and design-v2 §7.1.1. + +## Non-goals + +- Do not rewrite historical reports, clusters, turns or produced commit bodies. +- Do not change the evaluation platform protocol or score each member separately; evaluation remains one score per run. +- Do not change the object-level semantics of candidate association, and do not force an object-level case onto the first member. +- Do not make a cross-member patch a default capability; when it is truly needed, split it into an independent member cluster/turn and decide in a follow-up issue. diff --git a/.agents/flow/issues/bugfix-edit-patch-member-scope.i18n.yaml b/.agents/flow/issues/bugfix-edit-patch-member-scope.i18n.yaml new file mode 100644 index 00000000..c4f5676f --- /dev/null +++ b/.agents/flow/issues/bugfix-edit-patch-member-scope.i18n.yaml @@ -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 diff --git a/.agents/flow/issues/bugfix-edit-patch-member-scope.md b/.agents/flow/issues/bugfix-edit-patch-member-scope.md new file mode 100644 index 00000000..85b25347 --- /dev/null +++ b/.agents/flow/issues/bugfix-edit-patch-member-scope.md @@ -0,0 +1,195 @@ +# 归因、聚类与 edit patch 未按成员隔离:一个 bad case 需要每成员报告、成员簇与成员 patch + +[English](bugfix-edit-patch-member-scope.en.md) | 中文 + +```yaml flow +kind: issue +id: bugfix-115 +milestone: bugfix +depends: + - bugfix-102 + - bugfix-106 +priority: P2 +status: ready +scope: + - apps/api/app/** + - apps/api/tests/** + - apps/web/src/** + - packages/contracts/** + - tests/e2e/** + - plans/** + - .agents/** +adr: [] +github: + number: 814 + url: https://github.com/Shadow-Azure/harness-evolution/issues/814 +``` + +## 背景 + +2026-12-04 15:43(+08),生产 workspace `01M7KJ05ENF9784GPBDV544VB0` 启动 full run [`01M9004SE7E4ZNS1SA1RV5K6M2`](http://8.149.232.63/workspaces/01M7KJ05ENF9784GPBDV544VB0/evolution/runs/01M9004SE7E4ZNS1SA1RV5K6M2)。进化对象 `01M8WRB9Y7RMGKPYJE1345VADE`(`code-generator`)含两个成员:`agent:code-generator`(`agents/code-generator`,member `01M8WRB9YN3X4YKDDEHAY4DWMJ`)与 `skill:codespec-subagent-driven-development`(`skills/codespec-subagent-driven-development`,member `01M8WRB9YNFXV7DB4PAX7MV86E`)。 + +提出人进一步明确期望的模型:归因应落到成员,一个 bad case 一次归因可以属于进化对象的多个成员,且每个成员各有一份归因分析报告;聚类时不同成员的问题不能聚成一类;最后 edit patch 只针对该簇的成员修改。对照生产 run,当前三段行为都不符合这个模型: + +| 阶段 | 生产现状 | 期望 | +|---|---|---| +| 归因 | 4 条潜在 case 各 1 份报告;3 份归到 codespec、1 份归到 code-generator,没有 case 产出多成员报告 | 一个 case 可对每个相关成员各出一份报告 | +| 聚类 | 3 簇;第 2 簇 `01M901ECX6X2NE767M4YQ4XFGF` 同时含 code-generator 的 case `swe-ba7af8b8c52626e231f9` 与 codespec 的 case `swe-d348ed547fc3c292d962` | 聚类键带成员,不同成员不合并 | +| edit patch | 第 1 轮 patch 同时含 `agents/code-generator/AGENT.md` 与 `skills/codespec-subagent-driven-development/SKILL.md`,commit 以首成员 `code-generator` 命名 | patch 只改簇成员目录,commit 写该成员 | + +### 现场证据 + +| 层级 | 生产值 | 说明 | +|---|---|---| +| 第 4 步归因行 | `badCaseId=swe-31d26398caa9f2cc7fde`、`memberName=codespec-subagent-driven-development`、`objectLevel=false`、`attributionId=01M90194RSVZ1BCJ6RAJRNV22W` | 归因正确指向技能成员,但只有这一份 | +| 第 4 步其他行 | `swe-ba7af8…` 归到 code-generator、`swe-d348ed…` 归到 codespec、`swe-b76c10…` 归到 codespec | 每个 case 一份报告,没有 case 多成员 | +| 第 5 步混合簇 | `01M901ECX6X2NE767M4YQ4XFGF`:`swe-ba7af8…`(code-generator)与 `swe-d348ed…`(codespec) | 不同成员的 case 被聚成一簇 | +| 第 6 步第 1 轮 | `roundId=01M901ENC2HYP3TS6PFA5S3SEC`、`files=[agents/code-generator/AGENT.md, skills/codespec-subagent-driven-development/SKILL.md]`、`Harness-Patch-Hash: sha256:513bff…` | 一个轮次同时改两个成员 | +| patch note | “为 codespec-subagent-driven-development 技能补齐 per-task 审查流程的收敛判据、迭代上限与时间预算护栏,并给 code-generator 增加一次性批量处理与闭合证据回报纪律” | 模型把跨成员缓解写进同一候选 | +| candidate 提交正文 | “## 问题”写“`code-generator@openspec-cn-main-copy-ar-a7ec200-claude-core` 的聚类「…」包含需要处理的来源问题:swe-31d26398caa9f2cc7fde” | 提交信息把簇写成首成员 | +| 页面呈现 | 第 4 步按 case 一行;第 5 步簇头可同时出现两个成员 chip;第 6 步 patch 与 commit 没有成员作用域 | 三处身份没有对齐 | + +run 当前在评测阶段超时被 blocked(`stage=eval`,`asset_source_validation_timeout`),与本问题无因果关系;第 2、3 轮还未生成 patch。 + +### 为什么不是归因绑错或 patch 越界 + +- 第 4 步该行的 `memberId`、`objectName` 与 `objectVersion` 都是 `codespec-subagent-driven-development` 的成员与 `digest:422aa583…`,与 run 成员快照一致;不是把 case 绑到了别的成员。 +- patch 的两份文件都落在 `_run_allowed_paths()` 的成员并集内,应用器没有拒绝任何编辑;`SKILL.md` 里确实写入了“审查循环的收敛与停止策略”等根因修复。patch 不是“只改 code-generator”,也不是越界写文件。 +- 真正的问题是:归因、聚类与 patch 没有共享同一个成员身份。归因是成员级,聚类可以跨成员合并,patch 生成又是对象级;模型按 prompt 的对象并集自由选择文件,把“给 code-generator 增加收敛纪律”作为跨成员缓解一并写入。 + +### 当前实现根因 + +1. **归因只解析一个成员,不按成员 fan-out。** `_member_target()` 返回单个成员或 `None`(对象级);`_build_input()` 为每个 case 构造一个 `AttributionInput`,执行器只返回一个结论;`probe_reports` 虽然有 `member_id`,但 runner 不按成员逐一产出报告,`AttributionRunSummary` 也按 case 计数。实际上 `cache_key`/`execution_manifest` 已包含 `member_id`,数据层有能力承载“同一 case × 多个成员”的多份报告,缺口在归因 runner 与 API 投影。 +2. **聚类键没有成员。** `ProbeForCluster` 只有 `probe_id/attribute_type/text`;`cluster_probes()` 按类别与词面相似度分组,`build_attribution_drafts()` 一报告一草稿后由 LLM 复核按根因合并;`probe_clusters` 没有 `member_id`。因此不同成员的报告可以被同一个根因吸进一簇,生产第 5 步第 2 簇就是实例。簇一旦跨成员,后续 patch 就失去了单一成员归属。 +3. **patch 按对象并集生成。** `AgentEditPatchSource.build_bundle()` 用 `_run_allowed_paths(run)` 取全部成员子目录的并集,`_edit_prompt()` 只写“对象:<全部成员>”,不写本簇成员;`_message_sections()` 的“## 问题”固定用 `run.target_name`(首成员);`PatchBundle`/round payload 没有成员字段。设计文档 18 §5.4 目前只约定对象级允许范围,成员级 patch 语义从未定义。 +4. **前端按 case 而非成员组织。** 第 4 步一行一个 case,只展示该 case 的单一报告;第 5 步簇头的成员 chip 来自来源 case 的集合,允许一簇多个 chip;第 6 步 patch/commit 没有成员标签与改动范围。三个页面各自推导成员,口径无法互相校验。 + +### 影响 + +- 一个 bad case 若同时涉及多个成员,当前只能保留一份结论,另一成员的证据被丢掉;聚类把不同成员的根因混在一起,簇标题无法说明是谁的问题。 +- patch 候选耦合两个成员:评测只给整个 run 一个分数,无法判断是哪个成员的改动带来收益;接纳/拒绝也无法按成员归因,回滚一个成员会连带另一个。 +- commit 正文是不可变审计记录,却把簇归到首成员;按成员统计报告、成本、接纳率与回滚范围都会失真。 +- UI 让“同一轮改了哪些成员”不可见,评审者无法区分有意的跨成员缓解与范围泄漏。 + +## 前端原型对照(before / after) + +原型以 `plans/ui-prototype-v2/harness-evolution.html` 的既有 demo run `EV-20261109-01`(成员 `deep-research`、`code-review`)为同一输入,视口 1440×900、默认主题、同一“归因复核已完成、所有潜在 case 均有新报告”的模拟状态。baseline 为提交 `da6396ea` 的 `HEAD` 原型,after 为提交 `245c4f30` 的原型;截图脚本在 [`plans/ui-prototype-v2/evidence/member-scope/capture.mjs`](../../../plans/ui-prototype-v2/evidence/member-scope/capture.mjs)。 + +**第 4 步 · 对象归因:一个 case 可以有多份成员报告** + +**Before(`da6396ea`)** + +![第 4 步归因 before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step4-attribution.png) + +**After(`245c4f30`)** + +![第 4 步归因 after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step4-attribution.png) + +Before:10 条潜在 case、10 条报告,每行只有一份报告(`deep-research` 4、`code-review` 3、对象级 3)。After:10 条潜在 case、11 条报告;`BC-HC-016` 同时产出 `deep-research` 与 `code-review` 两份报告,行首用 rowspan 合并,并标“2 份成员报告”;汇总按成员分别计数。 + +**第 5 步 · 聚类:不同成员不合并** + +**Before(`da6396ea`)** + +![第 5 步聚类 before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step5-clusters.png) + +**After(`245c4f30`)** + +![第 5 步聚类 after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step5-clusters.png) + +Before:`C1` 同时含 `deep-research` 与 `code-review` 的 4 份来源报告,簇头并列两个成员 chip。After:按成员分组,`deep-research` 3 个簇、`code-review` 3 个簇;每个簇头只有一个成员 chip,统计显示“0 跨成员簇”;同一个 case `BC-HC-016` 分别在两个成员的簇中各出现一次。 + +**第 6 步 · edit patch:只改簇成员** + +**Before(`da6396ea`)** + +![第 6 步迭代 before](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/before-step6-iteration.png) + +**After(`245c4f30`)** + +![第 6 步迭代 after](https://raw.githubusercontent.com/Shadow-Azure/harness-evolution/245c4f309ab51368e7ce7dd04b08f8e33b2bfa0c/plans/ui-prototype-v2/evidence/member-scope/after-step6-iteration.png) + +Before:混合簇 `C1` 的来源报告跨两个成员,但 patch 只落 `skills/deep-research/SKILL.md`,commit 主题却写 `evolve(deep-research、code-review@v2.4.0)`,没有改动范围。After:簇属于 `deep-research`,patch 只落 `skills/deep-research/SKILL.md`,显示“改动范围:skills/deep-research/**(仅 deep-research)”,commit 为 `evolve(deep-research@v2.4.0)`。 + +说明:原型使用 demo 数据演示交互与信息层级,不等同生产数据;生产行为与代码证据见上文。截图脚本复用 `tests/support/runtime.mjs`,无额外依赖。 + +## 目标 + +- 归因阶段:对多成员进化对象,一个潜在 bad case 按“可能相关的成员”逐一评估并各产出一份成员级报告;报告带成员、分类、结论与置信度,对象级报告只在无法归属任何成员时兜底。 +- 聚类阶段:聚类键包含归因成员,不同成员的报告不进入同一簇;同一 case 的多份成员报告分别进入各自成员的簇;簇记录自己的成员,供 patch 与 UI 使用。 +- patch 阶段:每个轮次继承簇的成员,`allowed_paths` 只含该成员子目录,patch 文件必须落在该成员目录内;commit 主题与“## 问题”写该成员,不写全部成员。 +- 前端:第 4 步按 case 分组展示多份成员报告;第 5 步按成员分组展示单成员簇;第 6 步显示成员、改动范围与成员级 commit。 +- 历史兼容:旧报告/簇/轮次的 `member_id` 为 null 时按对象级或历史数据读取,不重写;单成员 run 保持现有路径与缓存键。 +- 更新设计文档 18 §5.2/§5.4、07 §5.5.2/§5.5.4、`plans/ui-prototype-v2/design-v2.md` §7.1.1 与 Agent Note。 + +## 设计依据 + +- [`plans/fullstack-design/18-multi-member-evolution-target.md` §5.2](../../../plans/fullstack-design/18-multi-member-evolution-target.md):归因结论以 `(evolution_object_id, member_id)` 表达;成员级报告 `probe_object` 是成员名,对象级报告 `member_id=null`。 +- [`plans/fullstack-design/18-multi-member-evolution-target.md` §5.4](../../../plans/fullstack-design/18-multi-member-evolution-target.md):当前只约定 `_allowed_paths(sub_dirs)` 返回多个 glob、`_edit_prompt` 列出成员;本 issue 将其改为“成员簇 → 成员目录”的 patch 作用域。 +- [`plans/fullstack-design/07-backend-implementation.md` §5.5.2](../../../plans/fullstack-design/07-backend-implementation.md):聚类算法与归因草稿;成员键需要进入该层。 +- [`plans/fullstack-design/07-backend-implementation.md` §5.5.4](../../../plans/fullstack-design/07-backend-implementation.md):EditPlan 的 `allowed_paths`、逐条 status 与 `PatchBundle` 契约。 +- [`plans/ui-prototype-v2/design-v2.md` §7.1.1](../../../plans/ui-prototype-v2/design-v2.md):本次原型的成员级归因、聚类与 patch 交互与截图。 + +## 实现内容 + +- **归因 fan-out**:多成员 run 的潜在 case 先取候选成员集合(Session 命中成员 ∪ case 自身成员;发现型 case 不借用首成员);执行器对每个候选成员产出一份 `probe_reports` 行,写 `evolution_object_id`、`member_id`、`probe_object`、独立分类/结论/置信度;`cache_key`/manifest 已含 `member_id`,按成员复用;无任何成员可归属时才写对象级报告。`AttributionRunSummary` 增加成员报告数与多成员 case 数。 +- **聚类成员键**:`ProbeForCluster`/`ClusterDraft` 增加 `member_id`;`cluster_probes()` 按 `(member_id, attribute_type)` 分组,`build_attribution_drafts()` 的 LLM 复核只允许同一成员的草稿合并;`probe_clusters` 增加 `member_id`(可空,对象级/历史为 null);API 的簇与来源报告返回成员;同一 case 可被多个成员簇引用。 +- **patch 成员作用域**:`ClusterDraft`/round 继承成员;`AgentEditPatchSource` 用成员子目录作为 `allowed_paths`,`_edit_prompt()` 写“本簇归因成员:,只修改该成员定义”;`PatchBundle`/round patch payload 增加 `member`;`_message_sections()` 用成员写“## 问题”和“## 改动”;跨成员修改不静默合并,必须拆成另一成员的簇/轮次。 +- **前端**:第 4 步把 case 的报告展开为多行(rowspan 分组),汇总按成员计数;第 5 步按成员分组、簇头单成员 chip、统计“跨成员簇 0”;第 6 步显示成员、改动范围、成员级 patch/commit;契约增加 `reports[]`/`member`/`scope` 字段。 +- **兼容与迁移**:`probe_clusters.member_id`、`evolution_rounds.member_id` 可空;旧行按 null 读取,页面回落为对象级/旧口径;单成员 run 的缓存键与报告身份不变;不重写历史报告、簇或提交。 +- **成本取舍**:一个 case 的成员报告数等于候选成员数;使用 Session 命中成员收敛候选,按成员缓存,必要时在同一个 executor 调用内批量返回多成员结论,避免 N×M 次独立调用。 +- **文档**:更新 18 §5.2/§5.4、07 §5.5.2/§5.5.4、design-v2 §7.1.1;新增 Agent Note 记录“成员级归因 → 成员簇 → 成员 patch”的决策与对象级兜底。 + +## 实施步骤 + +1. 先写失败测试:同一 case 两个候选成员产出两份报告、成员级缓存复用、对象级兜底;不同成员报告不进入同一簇;成员 patch 只允许成员目录。 +2. 改归因 runner 与 store:候选成员集合、逐成员报告、`AttributionRunSummary`、API 投影与契约。 +3. 改聚类:`ProbeForCluster`/`ClusterDraft`/`probe_clusters` 成员字段,分组与 LLM 复核约束,迁移与读取兼容。 +4. 改 patch:round 成员、`_edit_prompt`、`allowed_paths`、`PatchBundle`/payload、commit 消息与校验。 +5. 改前端:Step 4 多报告行、Step 5 成员分组、Step 6 成员作用域;补 Web 组件测试。 +6. 用双成员 fixture 补 API/集成/E2E:一个 case 双报告、两个成员簇、两个成员 patch。 +7. 更新设计文档与 Agent Note;跑门禁、生产形状 replay 和原型截图。 + +## 依赖与交付边界 + +- 依赖:bugfix-102(成员级归因与 `probe_reports.member_id`)、bugfix-106(对象级报告与 `objectLevel` 投影)。 +- 不重写历史报告、簇、轮次或已产生提交;旧 `member_id=null` 按对象级/历史读取。 +- 候选关联保持进化对象级(步骤 2/3 不改);不把潜在 case 强行分配给首成员。 +- 不在本 issue 改评测平台、run 的成员选择或成员定义格式;跨成员 patch 默认禁止,需拆成另一个成员簇/轮次。 +- 交付边界:先完成成员级归因、成员簇与成员 patch 的主链路;对象级兜底与历史兼容必须保留。 + +## 独立验证 + +```sh +pnpm test:api -- tests/evolution +pnpm test:web -- src/pages/evolution +pnpm contract:check +pnpm test:e2e -- --pattern "multi-member|member-scope" +pnpm verify:flow +node plans/ui-prototype-v2/evidence/member-scope/capture.mjs after +``` + +- 生产形状 replay(run `01M9004SE7E4ZNS1SA1RV5K6M2`):`swe-31d26398caa9f2cc7fde` 只产出 codespec 报告;混合簇 `01M901ECX6X2NE767M4YQ4XFGF` 拆成 code-generator 簇与 codespec 簇;成员 patch 分别落在 `agents/code-generator/**` 与 `skills/codespec-subagent-driven-development/**`,不再出现一份 patch 同时改两个成员。 +- 双成员 demo:一个 case 产出两份成员报告;两个成员簇;每个簇的 patch 只在该成员子目录;`0` 跨成员簇。 +- API 单测断言 `probe_reports` 两行同 case 不同 `member_id`、独立 `cache_key`;聚类单测断言成员不同的报告不合并;patch 单测断言越出成员目录的编辑被拒绝。 +- Web/组件测试断言第 4/5/6 步的成员口径一致;历史 `member_id=null` 读取不报错。 + +## 验收标准 + +- 一个潜在 bad case 可产出多份成员报告(每个相关成员一份),每份报告有独立成员、分类、结论与置信度;对象级只在无成员可归属时出现。 +- 同一簇内所有来源报告属于同一成员;簇记录成员;不同成员的问题不合并;同一 case 可以进入多个成员簇。 +- 每个轮次的 patch 文件全部落在该簇成员子目录内,prompt 与 commit 写该成员;跨成员修改不会被静默合并到同一轮。 +- 第 4 步按 case 分组展示多份成员报告;第 5 步按成员分组且簇头单成员;第 6 步显示成员、改动范围与成员级 commit;原型 before/after 截图与生产证据一致。 +- 单成员 run、历史报告/簇/轮次读取兼容;`pnpm verify:flow`、`pnpm contract:check`、API/Web/E2E 测试通过。 + +## 门禁与 CI + +- `pnpm verify:flow`、`pnpm contract:check`、`pnpm test:api`、`pnpm test:web`、`pnpm test:e2e`、`pnpm lint:docs`/`pnpm verify:docs`。 +- 覆盖率不低于 80%;新增/更新 Agent Note、设计文档 18 §5.2/§5.4、07 §5.5.2/§5.5.4 与 design-v2 §7.1.1。 + +## 非目标 + +- 不改写历史报告、簇、轮次或已产生的提交正文。 +- 不改评测平台协议,不为每个成员单独出分;评测仍是整个 run 一个分数。 +- 不改候选关联的对象级语义,不把对象级 case 强行归到首成员。 +- 不把跨成员 patch 作为默认能力;确需跨成员时拆成独立成员簇/轮次并在后续 issue 决策。 diff --git a/.agents/flow/issues/bugfix-startup-locator-backfill.en.md b/.agents/flow/issues/bugfix-startup-locator-backfill.en.md index c7d1f36f..3c3373b2 100644 --- a/.agents/flow/issues/bugfix-startup-locator-backfill.en.md +++ b/.agents/flow/issues/bugfix-startup-locator-backfill.en.md @@ -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/** diff --git a/.agents/flow/issues/bugfix-startup-locator-backfill.i18n.yaml b/.agents/flow/issues/bugfix-startup-locator-backfill.i18n.yaml index dd0830d1..be161109 100644 --- a/.agents/flow/issues/bugfix-startup-locator-backfill.i18n.yaml +++ b/.agents/flow/issues/bugfix-startup-locator-backfill.i18n.yaml @@ -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 diff --git a/.agents/flow/issues/bugfix-startup-locator-backfill.md b/.agents/flow/issues/bugfix-startup-locator-backfill.md index 25627101..1b4ae956 100644 --- a/.agents/flow/issues/bugfix-startup-locator-backfill.md +++ b/.agents/flow/issues/bugfix-startup-locator-backfill.md @@ -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/** diff --git a/plans/ui-prototype-v2/design-v2.md b/plans/ui-prototype-v2/design-v2.md index 15f28908..d255fc49 100644 --- a/plans/ui-prototype-v2/design-v2.md +++ b/plans/ui-prototype-v2/design-v2.md @@ -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 聚类等待态与零结果 diff --git a/plans/ui-prototype-v2/evidence/member-scope/after-step4-attribution.png b/plans/ui-prototype-v2/evidence/member-scope/after-step4-attribution.png new file mode 100644 index 00000000..3f4d683e Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/after-step4-attribution.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/after-step5-clusters.png b/plans/ui-prototype-v2/evidence/member-scope/after-step5-clusters.png new file mode 100644 index 00000000..04fa4bc7 Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/after-step5-clusters.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/after-step6-iteration.png b/plans/ui-prototype-v2/evidence/member-scope/after-step6-iteration.png new file mode 100644 index 00000000..1291f0e0 Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/after-step6-iteration.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/before-step4-attribution.png b/plans/ui-prototype-v2/evidence/member-scope/before-step4-attribution.png new file mode 100644 index 00000000..0ae7ce3d Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/before-step4-attribution.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/before-step5-clusters.png b/plans/ui-prototype-v2/evidence/member-scope/before-step5-clusters.png new file mode 100644 index 00000000..f0bf425b Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/before-step5-clusters.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/before-step6-iteration.png b/plans/ui-prototype-v2/evidence/member-scope/before-step6-iteration.png new file mode 100644 index 00000000..d701c890 Binary files /dev/null and b/plans/ui-prototype-v2/evidence/member-scope/before-step6-iteration.png differ diff --git a/plans/ui-prototype-v2/evidence/member-scope/capture.mjs b/plans/ui-prototype-v2/evidence/member-scope/capture.mjs new file mode 100644 index 00000000..5313a7b1 --- /dev/null +++ b/plans/ui-prototype-v2/evidence/member-scope/capture.mjs @@ -0,0 +1,185 @@ +// Capture before/after V2 prototype screenshots for member-scoped attribution, +// clustering and edit patches. +// Usage: node capture.mjs +// PROTOTYPE_HTML= 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 > +// 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 "); + 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} 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} 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} 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} 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(); +} diff --git a/plans/ui-prototype-v2/harness-evolution.html b/plans/ui-prototype-v2/harness-evolution.html index 4bd1d605..39023966 100644 --- a/plans/ui-prototype-v2/harness-evolution.html +++ b/plans/ui-prototype-v2/harness-evolution.html @@ -821,6 +821,13 @@ .evo-app .cluster-desc { padding: 0 14px 12px 14px; } .evo-app .cluster-desc .cb-label { margin-bottom: 3px; } .evo-app .cluster-desc p { margin: 0; color: var(--text-dim); font-size: 12px; line-height: 1.65; max-width: 980px; } +.evo-app .member-group { margin-bottom: 14px; } +.evo-app .member-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 2px 8px; border-bottom: 1px dashed var(--border); margin-bottom: 8px; } +.evo-app .member-group-head > span:not(.chip) { font-size: 11.5px; color: var(--text-dim); } +.evo-app .member-group-head .hint { color: var(--text-faint); } +.evo-app .scope-note { margin: 2px 0 7px; padding: 5px 8px; border-left: 2px solid color-mix(in srgb, var(--blue) 45%, transparent); background: color-mix(in srgb, var(--blue) 4%, transparent); color: var(--text-dim); font-size: 11.5px; } +.evo-app .v2-badge.member-report { margin-left: 6px; background: color-mix(in srgb, var(--purple) 10%, transparent); color: var(--purple); } +.evo-app .multi-report-row > td { border-top-style: dashed; } .evo-app .cluster-body { border-top: 1px solid var(--border); padding: 14px 16px; display: none; } .evo-app .cluster.open .cluster-body { display: block; } .evo-app .cb-sec { margin-bottom: 14px; } @@ -5481,6 +5488,8 @@

错误详情

reload: { file: 'skills/deep-research/SKILL.md', lines: ['@@ -70,4 +70,7 @@ ## 文档缓存', ' 按路径缓存已读文档。', '+命中缓存时跳过重复加载与重复总结;', '+缓存键加入文档 mtime,避免陈旧内容。'] }, bounds: { file: 'agents/Explore/AGENT.md', lines: ['@@ -24,6 +24,10 @@ ## 分析约束', ' 对指定代码区域做只读分析。', '+### 范围约束(新增)', '+- 仅访问任务声明的目录与文件清单;', '+越界访问前必须先向调用方确认;', '+- 会话快照读取做边界检查,越界即返回空。'] }, readonly: { file: 'agents/Explore/AGENT.md', lines: ['@@ -40,4 +40,7 @@ ## 工具使用', ' 可使用文件检索与读取工具。', '+Explore 全程只读:禁止写入、移动、删除任何文件;', '+需要修改时输出建议而非执行。'] }, + crExport: { file: 'skills/code-review/SKILL.md', lines: ['@@ -64,5 +64,10 @@ ## 审查输出', ' 按严重程度输出审查结论。', '+### 导出结构自检(新增)', '+- 导出前校验标题层级、代码围栏与清单编号;', '+- 校验失败时降级为纯文本并标注「结构降级」,不得静默丢失。'] }, + crSchema: { file: 'skills/code-review/SKILL.md', lines: ['@@ -30,6 +30,11 @@ ## 审查结果', ' 输出审查结论与依据。', '+### 结果 schema(新增)', '+- 每条结论必须包含 file、line、severity、reason 四个字段;', '+- 缺少字段时先补全再输出,不得以自然语言替代结构。'] }, }; const EV_CLUSTER_TEMPLATES = [ @@ -5516,40 +5525,63 @@

错误详情

function evReportMember(run, row) { return evRunMembers(run).find(m => m.name === row.c.objectName) || null; } +function evBuildMemberReport(run, row, member, index) { + const c = row.c; + const objectLevel = !member; + const memberKey = member ? member.name : '__object__'; + const memberName = member ? member.name : evRunGroupName(run); + const version = run.target.version; + const key = evReportCacheKey(c, memberKey, version); + let report = row.cached && evLatestReport.get(key); + if (!report) { + const atIso = row.cached ? c.createdAt : run.createdAt; + const skill = row.cached ? row.reportSkill : evRunSkill(run); + const definitions = window.V2?.user && run.workspace === V2.wsId ? v2SkillState().items : [V2_SKILL_FIXTURES.default, V2_SKILL_FIXTURES.seed]; + const promptTemplate = definitions.find(item => item.name === skill)?.prompt || null; + const attributed = row.conclusion === 'attributed'; + const reason = objectLevel + ? (attributed ? `「${c.title}」没有归属到单个成员;按进化对象整体评估为问题。` : `当前轨迹未显示「${c.title}」由单个成员引起;按进化对象整体判为非该对象问题。`) + : (attributed ? `${member.name} 的输出进入了「${c.title}」对应的异常分支。` : `当前轨迹未显示「${c.title}」由 ${member.name} 的输出引起。`); + report = { + id: `${row.attributionId}${index ? '-' + (index + 1) : ''}`, + caseId: c.id, caseTitle: c.title, caseDetail: c.detail, caseWorkspace: c.workspace, + workspace: c.workspace, objectName: memberName, objectKind: member ? member.kind : 'group', member: member ? member.name : null, objectLevel, version, + runId: row.cached ? null : run.id, at: atIso.slice(0, 16).replace('T', ' '), atIso, + skill, promptTemplate, cached: row.cached, policy: run.policy, + category: member && !attributed ? '非该成员问题' : row.category, + conclusion: member ? row.conclusion : row.conclusion, + confidence: row.confidence, reason, + objectTrigger: row.a.line, caseTrigger: c.triggerLine, + reasoning: [`在关联 Session 定位进化对象的触发位置 L${row.a.line}`, `核对「${c.title}」的上报位置 L${c.triggerLine} 与异常输入`, reason], + }; + } + evLatestReport.set(key, report); + return report; +} function evAttachReports(run) { + const members = evRunMembers(run); for (const row of run.model.potentialRows) { - if (run.preparing || row.skipped) continue; - const c = row.c; - const member = evReportMember(run, row); - const objectLevel = !member; - const memberKey = member ? member.name : '__object__'; - const memberName = member ? member.name : evRunGroupName(run); - const version = run.target.version; - const key = evReportCacheKey(c, memberKey, version); - let report = row.cached && evLatestReport.get(key); - if (!report) { - const atIso = row.cached ? c.createdAt : run.createdAt; - const skill = row.cached ? row.reportSkill : evRunSkill(run); - const definitions = window.V2?.user && run.workspace === V2.wsId ? v2SkillState().items : [V2_SKILL_FIXTURES.default, V2_SKILL_FIXTURES.seed]; - const promptTemplate = definitions.find(item => item.name === skill)?.prompt || null; - const attributed = row.conclusion === 'attributed'; - const reason = objectLevel - ? (attributed ? `「${c.title}」没有归属到单个成员;按进化对象整体评估为问题。` : `当前轨迹未显示「${c.title}」由单个成员引起;按进化对象整体判为非该对象问题。`) - : (attributed ? `${member.name} 的输出进入了「${c.title}」对应的异常分支。` : `当前轨迹未显示「${c.title}」由 ${member.name} 的输出引起。`); - report = { - id: row.attributionId, caseId: c.id, objectName: memberName, objectKind: member ? member.kind : 'group', member: member ? member.name : null, objectLevel, version, - runId: row.cached ? null : run.id, at: atIso.slice(0, 16).replace('T', ' '), atIso, - skill, promptTemplate, cached: row.cached, policy: run.policy, - category: row.category, conclusion: row.conclusion, confidence: row.confidence, reason, - objectTrigger: row.a.line, caseTrigger: c.triggerLine, - reasoning: [`在关联 Session 定位进化对象的触发位置 L${row.a.line}`, `核对「${c.title}」的上报位置 L${c.triggerLine} 与异常输入`, reason], - }; - } - evLatestReport.set(key, report); - Object.assign(row, { report, attributionId: report.id, category: report.category, conclusion: report.conclusion, confidence: report.confidence }); - } - run.model.attributed = run.model.potentialRows.filter(row => row.report?.conclusion === 'attributed'); - run.model.notObject = run.model.potentialRows.filter(row => row.report?.conclusion === 'not-object'); + if (run.preparing || row.skipped) { row.reports = []; row.report = null; continue; } + const own = evReportMember(run, row); + // 一个 bad case 可以同时由多个成员贡献证据:发现型 case 没有自身的成员, + // 按成员逐一评估;演示数据把“发现型且已归因”的 case 同时归到两个成员, + // 每个成员各产出一份报告。self 上报只归到自身成员。 + let targets; + if (own) targets = [own]; + else if (row.conclusion === 'attributed' && members.length > 1 && row.c.type === 'discovery') targets = members; + else if (row.conclusion === 'attributed') targets = [members.length === 1 ? members[0] : null]; + else targets = [null]; + row.reports = targets.map((member, index) => evBuildMemberReport(run, row, member, index)); + row.report = row.reports.find(report => report.conclusion === 'attributed') || row.reports[0]; + row.objectLevel = row.reports.length === 1 && !row.reports[0].member; + row.multiMember = row.reports.length > 1; + if (row.report) Object.assign(row, { attributionId: row.report.id, category: row.report.category, conclusion: row.report.conclusion, confidence: row.report.confidence }); + } + run.model.attributedReports = run.model.potentialRows.flatMap(row => row.reports || []).filter(report => report.conclusion === 'attributed'); + run.model.notObjectReports = run.model.potentialRows.flatMap(row => row.reports || []).filter(report => report.conclusion === 'not-object'); + run.model.attributed = run.model.potentialRows.filter(row => (row.reports || []).some(report => report.conclusion === 'attributed')); + run.model.notObject = run.model.potentialRows.filter(row => !(row.reports || []).some(report => report.conclusion === 'attributed')); + run.model.multiMemberCases = run.model.potentialRows.filter(row => (row.reports || []).length > 1).length; } function evMakeRun(cfg) { @@ -5587,43 +5619,65 @@

错误详情

}; run.model = evRunModel(run); evAttachReports(run); - evBuildClusters(run, run.reviewRequired ? [] : run.model.attributed); + evBuildClusters(run, run.reviewRequired ? [] : run.model.attributedReports); if (cfg.progress === 8) run.progress = evTotal(run); return run; } -function evBuildClusters(run, attributed) { - const count = Math.min(3, attributed.length); - const typeMap = { '错误': '是问题-错误', 'prompt缺失某些提示词': '是问题-prompt缺失某些提示词', '模型问题': '是问题-模型问题' }; - const patchFor = (title) => { - if (/快照/.test(title)) return EV_PATCH.bounds; +function evReportOrRow(item) { + if (!item) return null; + return item.c ? item.report : item; +} +function evClusterPatchFor(run, member, title, category) { + if (!member) { + // 对象级簇没有单一成员目录,保留对象级改动范围(全部成员目录)。 if (/来源|引用/.test(title)) return EV_PATCH.citation; if (/索引/.test(title)) return EV_PATCH.index; - if (/重复|缓存/.test(title)) return EV_PATCH.reload; - if (/分块|实体|长文/.test(title)) return EV_PATCH.chunk; + if (/快照/.test(title)) return EV_PATCH.bounds; if (/导出|结构/.test(title)) return EV_PATCH.export; - if (/计划|拆分/.test(title)) return EV_PATCH.plan; return EV_PATCH.deser; - }; + } + const subDir = (run.worktree && run.worktree.subDirs && run.worktree.subDirs[evRunMembers(run).findIndex(m => m.name === member.name)]) || `skills/${member.name}`; + const file = `${subDir}/${member.kind === 'agent' ? 'AGENT.md' : 'SKILL.md'}`; + const base = /导出|结构/.test(title) ? EV_PATCH.crExport + : /schema|结构/.test(title) ? EV_PATCH.crSchema + : /来源|引用/.test(title) ? EV_PATCH.citation + : /索引/.test(title) ? EV_PATCH.index + : /快照/.test(title) ? EV_PATCH.bounds + : /分块|实体|长文/.test(title) ? EV_PATCH.chunk + : /计划|拆分/.test(title) ? EV_PATCH.plan + : member.name === 'code-review' ? EV_PATCH.crSchema + : EV_PATCH.deser; + return { file, lines: base.lines }; +} +function evBuildClusters(run, attributed) { + const reports = (attributed || []).map(evReportOrRow).filter(Boolean); + const members = evRunMembers(run); const groups = []; - attributed.forEach(r => { - let g = groups.find(x => x.category === r.category); - if (!g) { g = { category: r.category, rows: [] }; groups.push(g); } - g.rows.push(r); - }); - run.clusters = groups.slice(0, count).map((g, i) => { - const r = g.rows[0]; + for (const report of reports) { + const member = report.member ? members.find(item => item.name === report.member) || null : null; + const key = (member ? member.name : '__object__') + '|' + report.category; + let group = groups.find(item => item.key === key); + if (!group) { group = { key, member, category: report.category, reports: [] }; groups.push(group); } + group.reports.push(report); + } + const typeMap = { '错误': '是问题-错误', 'prompt缺失某些提示词': '是问题-prompt缺失某些提示词', '模型问题': '是问题-模型问题', '流程问题': '是问题-流程问题' }; + const count = groups.length; + run.clusters = groups.slice(0, count).map((group, i) => { + const report = group.reports[0]; const tpl = EV_CLUSTER_TEMPLATES[i] || EV_CLUSTER_TEMPLATES[0]; + const caseIds = [...new Set(group.reports.map(item => item.caseId))]; return { - ...tpl, id: 'C' + (i + 1), title: r.c.title, - type: typeMap[r.category] || tpl.type, - phenomenon: r.c.detail, patch: patchFor(r.c.title), - caseIds: g.rows.map(x => x.c.id), + ...tpl, id: 'C' + (i + 1), title: report.caseTitle || tpl.title, + type: typeMap[group.category] || tpl.type, + phenomenon: report.caseDetail || tpl.phenomenon, + patch: evClusterPatchFor(run, group.member, report.caseTitle || '', group.category), + member: group.member, reportIds: group.reports.map(item => item.id), caseIds, accepted: i === 0 ? true : (i === 1 ? tpl.accepted : false), commit: i === 0 ? tpl.commit : (i === 1 ? tpl.commit : null), }; }); run.clusters.sort((a, b) => b.sev - a.sev); - run.clusters.forEach(c => { c.fullMessage = evCommitMessage(run, c); }); + run.clusters.forEach((c, i) => { c.id = 'C' + (i + 1); c.fullMessage = evCommitMessage(run, c); }); } const EV_RUNS = [ @@ -5830,22 +5884,29 @@

错误详情

for (const member of evRunMembers(run)) stats.set(member.name, { member, reports: 0, candidates: 0 }); stats.set('__object__', { member: null, reports: 0, candidates: 0 }); for (const row of run.model.potentialRows) { - const member = evReportMember(run, row); - const key = row.report?.member || (member ? member.name : '__object__'); - if (!stats.has(key)) stats.set(key, { member, reports: 0, candidates: 0 }); - const item = stats.get(key); - item.candidates += 1; - if (row.report) item.reports += 1; + const reports = row.reports || (row.report ? [row.report] : []); + const keys = new Set(reports.map(report => report.member || '__object__')); + if (!keys.size) keys.add('__object__'); + for (const key of keys) { + if (!stats.has(key)) stats.set(key, { member: key === '__object__' ? null : evRunMembers(run).find(member => member.name === key) || null, reports: 0, candidates: 0 }); + const item = stats.get(key); + item.candidates += 1; + } + for (const report of reports) { + const item = stats.get(report.member || '__object__'); + if (item) item.reports += 1; + } } - return [...stats.values()].filter(item => item.member || item.candidates > 0); + return [...stats.values()].filter(item => item.member || item.candidates > 0 || item.reports > 0); } function evAttributionSummary(run) { const stats = evAttributionStats(run); const reports = stats.reduce((total, item) => total + item.reports, 0); + const multi = run.model.multiMemberCases || 0; return `
归因成员分布 ${stats.map(item => `${evAttributionChip(item.member)}${item.reports}条报告${item.candidates} 条候选`).join('')} - ${reports} 条报告 / ${run.model.potentialRows.length} 条潜在 case · 潜在关联在进化对象级 + ${reports} 条报告 / ${run.model.potentialRows.length} 条潜在 case · ${multi} 条 case 产出多成员报告 · 潜在关联在进化对象级
`; } function evMemberForCase(run, caseId) { @@ -5860,10 +5921,11 @@

错误详情

return c ? evRunMembers(run).find(member => member.name === c.objectName) || null : null; } function evClusterMemberChips(run, cluster) { + if (cluster.member) return evMemberChip(cluster.member); const members = []; let objectLevel = false; - for (const caseId of cluster.caseIds || []) { - const member = evMemberForCase(run, caseId); + for (const report of evClusterReportRows(run, cluster)) { + const member = report.report && report.report.member ? evRunMembers(run).find(item => item.name === report.report.member) || null : null; if (member) { if (!members.some(item => item.name === member.name)) members.push(member); } else { @@ -6158,39 +6220,49 @@

自进化

const memberCopy = members.length > 1 ? `本 run 含 ${members.length} 个成员:${members.map(member => evMemberChip(member)).join(' ')}` : evEsc(run.target.name); - const rows = m.potentialRows.map(r => { - const category = r.conclusion === 'not-object' ? '非该对象问题' : r.category; - const reportMember = r.report?.member ? members.find(member => member.name === r.report.member) || null : null; - const candidateMember = evReportMember(run, r); - const targetChip = r.report ? evAttributionChip(reportMember) : evAttributionChip(candidateMember); - return ` - ${evCaseLink(r.c)} - ${targetChip}case 对象:${evEsc(r.c.objectName)} - ${r.report ? `${evEsc(r.report.id)}` : '—'} - ${r.report ? evTypeChip(category) : (r.objectLevel ? '对象级 · 未归因' : '—')} - ${evEsc(r.c.detail)} - ${r.objectLevel ? '对象级' : (r.skipped ? '跳过' : (r.cached ? '缓存' : '重算'))} - ${r.report ? (r.confidence * 100).toFixed(0) + '%' : '—'} - ${r.objectLevel && !r.report ? '未归因' : afMembership(run, r)} - ${r.report ? afVoteButtons(r.c, r.report, run) : '—'} + const reportRows = []; + for (const row of m.potentialRows) { + const reports = row.reports || (row.report ? [row.report] : []); + if (!reports.length) reportRows.push({ row, report: null, first: true, span: 1 }); + else reports.forEach((report, index) => reportRows.push({ row, report, first: index === 0, span: reports.length })); + } + const rows = reportRows.map(({ row: r, report, first, span }) => { + const category = report ? (report.conclusion === 'not-object' ? '非该对象问题' : report.category) : '非该对象问题'; + const member = report && report.member ? members.find(item => item.name === report.member) || null : null; + const targetChip = report ? evAttributionChip(member) : evAttributionChip(r.objectLevel ? null : evReportMember(run, r)); + const sourceCell = first + ? `${evCaseLink(r.c)}case 对象:${evEsc(r.c.objectName)}${span > 1 ? `${span} 份成员报告` : ''}` + : ''; + return ` + ${sourceCell} + ${targetChip}${report ? (report.objectLevel ? '对象级结论' : `归属 ${evEsc(report.member)}`) : '无报告'} + ${report ? `${evEsc(report.id)}` : '—'} + ${report ? evTypeChip(category) : (r.objectLevel ? '对象级 · 未归因' : '—')} + ${evEsc(report ? report.reason : r.c.detail)} + ${report ? (report.objectLevel ? '对象级' : (report.cached ? '缓存' : '重算')) : '跳过'} + ${report ? (report.confidence * 100).toFixed(0) + '%' : '—'} + ${report ? afMembership(run, r, report) : '无报告'} + ${report ? afVoteButtons(r.c, report, run) : '—'} `; }).join(''); + const attributedReports = m.attributedReports || []; + const objectReports = m.potentialRows.flatMap(row => row.reports || []).filter(report => report.objectLevel); return `
第 4 步 · 对象归因 ${memberCopy} · ${evEsc(run.target.version)} · Skill ${evEsc(evRunSkill(run))}
${m.potentialRows.length}潜在 bad case - ${m.potentialRows.filter(row => row.objectLevel && row.report).length}对象级已归因 - ${m.potentialRows.filter(row => row.objectLevel && !row.report).length}对象级未归因 - ${m.attributed.length}可归因 - ${m.notObject.length}非该对象问题 + ${reportRows.length}归因报告 + ${m.multiMemberCases || 0}多成员 case + ${objectReports.length}对象级报告 + ${attributedReports.length}可归因报告 + ${m.potentialRows.filter(row => !(row.reports || []).some(report => report.conclusion === 'attributed')).length}非该对象 case ${m.reused}复用缓存 - ${m.missing}尚无报告 ${m.fresh}本次新增
${evAttributionSummary(run)} ${afReviewBar(run)}
${rows || ''}
来源 bad case进化对象 · 归因成员归因报告 ID分类问题现象/描述结果来源置信度本次聚类我的反馈
没有需要归因的潜在 bad case
-

「非该对象问题」是当前对象版本的一条归因结论,不修改 bad case 本身,也不影响它与其他对象的潜在关系。归因先按进化对象整体判定;结论能定位到成员时才标成员,否则以对象级报告标「对象级」,输入包含全部成员定义,不借用其他成员。本次使用 ${evEsc(evRunSkill(run))};缓存开启时复用每例最新完成报告,缺报告项跳过;关闭缓存时按本次所选 Skill 重算。

+

每个成员独立评估并各产出一份报告:一个 bad case 可由多个成员共同贡献证据,因此同一 case 可以有多行报告;每份报告带自己的成员、分类与结论,并分别进入对应成员的聚类。对象级报告只在无法归属任何成员时出现,不借用首成员。本次使用 ${evEsc(evRunSkill(run))};缓存按(case, 成员, 版本)复用。

`; } @@ -6211,9 +6283,24 @@

自进化

} /* 第 5/6 步来源表按归因报告展示:报告 ID + 报告结论说明; bad case 只保留可跳转链接,不再用它的 ID/标题充当来源主体。 */ +function evAllReports(run) { + return run.model.potentialRows.flatMap(row => row.reports || (row.report ? [row.report] : [])); +} function evClusterReportRows(run, c) { + const reports = evAllReports(run); const rows = []; const seen = new Set(); + if ((c.reportIds || []).length) { + for (const id of c.reportIds) { + const report = reports.find(item => item.id === id); + if (!report) continue; + const x = caseById(report.caseId); + if (!x || seen.has(report.id)) continue; + seen.add(report.id); + rows.push({ c: x, report, category: report.category }); + } + return rows; + } for (const id of c.caseIds || []) { const match = run.model.potentialRows.find(row => row.c.id === id); const x = match ? match.c : caseById(id); @@ -6277,18 +6364,21 @@

自进化

function evCommitMessage(run, c) { const delta = c.eval.cand - c.eval.cur; const caseIds = (c.caseIds || []).slice(0, 4); - const memberNames = evRunMembers(run).map(member => member.name).join('、'); + const member = c.member || null; + const scopeName = member ? member.name : evRunGroupName(run); + const scopeLabel = member ? `${member.kind}:${member.name}@${run.target.version}` : `对象级(${run.title})@${run.target.version}`; + const patchOwner = member ? `仅修改成员 ${member.name} 的定义` : '对象级改动范围(无单一成员)'; return [ - `evolve(${memberNames}@${run.target.version}): 修复${c.title}`, + `evolve(${scopeName}@${run.target.version}): 修复${c.title}`, '', '## 问题', - `${memberNames}@${run.target.version} 的聚类「${c.title}」包含需要处理的来源问题:${caseIds.join('、')}。`, + `${scopeLabel} 的聚类「${c.title}」包含需要处理的来源问题:${caseIds.join('、')}。`, '', '## 分析', c.phenomenon, '', '## 改动', - `- ${c.patch.file}(补充校验与边界处理)`, + `- ${c.patch.file}(${patchOwner}:补充校验与边界处理)`, '', '## 为什么接纳', `评测集得分 ${c.eval.cur.toFixed(1)} → ${c.eval.cand.toFixed(1)}(${delta >= 0 ? '+' : ''}${delta.toFixed(1)}),候选版本有收益。`, @@ -6317,12 +6407,19 @@

自进化

`; } +function evClusterScope(run, c) { + if (!c.member) return '对象级兜底:无单一成员,按归因证据选择目录'; + const index = evRunMembers(run).findIndex(member => member.name === c.member.name); + const subDir = (run.worktree && run.worktree.subDirs && run.worktree.subDirs[index]) || `skills/${c.member.name}`; + return `${subDir}/**(仅 ${c.member.name})`; +} function evCluster(run, c, i) { const key = run.id + ':' + c.id, open = EV_STATE.expanded.has(key); const done = evRoundDone(run, i), active = evRoundActive(run, i); const state = done ? (c.accepted ? `已接纳 ${evDelta(c.eval.cand - c.eval.cur)}` : `未接纳 ${evDelta(c.eval.cand - c.eval.cur)}`) : active ? `第 ${i + 1} 轮 · 评测中` : `待执行`; + const owner = c.member ? c.member.name : '对象级(成员并集)'; return `
#${i + 1}${evEsc(c.title)}${evTypeChip(c.type)} @@ -6330,10 +6427,10 @@

自进化

${state}▶
${open ? `
-
来源归因报告(${evClusterReportCount(run, c)} 份 · 由归因结论聚类而来)
${evClusterReportTable(run, c)}
-
归因复核(逐成员源码,${run.target.version})
+
来源归因报告(${evClusterReportCount(run, c)} 份 · 同一成员内聚类)
${evClusterReportTable(run, c)}
+
归因复核(成员 ${evEsc(owner)},${run.target.version})
判定:问题真实存在 · 置信度 ${(c.conf * 100).toFixed(0)}% · 严重程度 ${c.sev.toFixed(1)}/10
- ${done || active ? `
生成的 edit patch(current → candidate)
${evDiff(c.patch)}
` : ''} + ${done || active ? `
生成的 edit patch(仅修改 ${evEsc(owner)})
改动范围:${evEsc(evClusterScope(run, c))}
${evDiff(c.patch)}
` : ''} ${done ? `
评测对比(验证集)
${evEval(c.eval, c.accepted)}
${c.accepted ? evCommitBlock(run, c) : `
未接纳:candidate 评测无收益,current 保持 ${c.eval.cur.toFixed(1)},进入下一轮。
`}
` : ''} ${active ? `
正在评测 candidate…(点右上角「模拟推进一轮」查看结果)
` : ''} @@ -6418,27 +6515,39 @@

聚类完成,没有生成问题簇

const totalReports = clusters.reduce((n, c) => n + evClusterReportCount(run, c), 0); const avgConf = clusters.length ? clusters.reduce((a, c) => a + c.conf, 0) / clusters.length : 0; const maxSev = clusters.length ? Math.max(...clusters.map(c => c.sev)) : 0; - const cards = clusters.map((c, i) => { - const key = run.id + ':' + c.id; - const open = EV_STATE.expanded.has(key); - return `
-
- #${i + 1}${evEsc(c.id)} · ${evEsc(c.title)}${evTypeChip(c.type)} - 报告 ×${evClusterReportCount(run, c)}${evClusterMemberChips(run, c)}置信度 ${(c.conf * 100).toFixed(0)}%${evSevHTML(c.sev)} - ▶ -
-
-
聚类问题描述
-

${evEsc(c.phenomenon || '暂无聚类问题描述')}

-
- ${open ? `
-
来源归因报告(${evClusterReportCount(run, c)} 份 · 由归因结论聚类而来)
${evClusterReportTable(run, c)}
-
` : ''} -
`; - }).join(''); + const memberGroups = []; + clusters.forEach((c, index) => { + const key = c.member ? c.member.name : '__object__'; + let group = memberGroups.find(item => item.key === key); + if (!group) { group = { key, member: c.member || null, items: [] }; memberGroups.push(group); } + group.items.push({ c, index }); + }); + const cards = memberGroups.map(group => `
+
${evMemberChip(group.member)}${group.items.length} 个簇${group.member ? '同成员内按根因聚类' : '对象级兜底'}
+ ${group.items.map(({ c, index }) => { + const key = run.id + ':' + c.id; + const open = EV_STATE.expanded.has(key); + return `
+
+ #${index + 1}${evEsc(c.id)} · ${evEsc(c.title)}${evTypeChip(c.type)} + 报告 ×${evClusterReportCount(run, c)}${evClusterMemberChips(run, c)}置信度 ${(c.conf * 100).toFixed(0)}%${evSevHTML(c.sev)} + ▶ +
+
+
聚类问题描述
+

${evEsc(c.phenomenon || '暂无聚类问题描述')}

+
+ ${open ? `
+
来源归因报告(${evClusterReportCount(run, c)} 份 · 同一成员内聚类而来)
${evClusterReportTable(run, c)}
+
` : ''} +
`; + }).join('')} +
`).join(''); const body = clusters.length ? `
${clusters.length}聚类问题 + ${memberGroups.filter(group => group.member).length}覆盖成员 + 0跨成员簇 ${totalReports}来源归因报告 ${(avgConf * 100).toFixed(0)}%平均置信度 ${maxSev.toFixed(1)}最高严重度 @@ -6446,9 +6555,9 @@

聚类完成,没有生成问题簇

${cards}
` : evClusterEmptyState(run); return `
-
第 5 步 · 归因聚类与严重度排序 按归因根因聚类,按严重程度降序;每簇含根因标题与聚类问题描述
+
第 5 步 · 归因聚类与严重度排序 按(归因成员 × 根因)聚类,同成员内按严重程度降序;不同成员的问题不合并
${body} -

严重程度 = 置信度 × 影响面 × 来源频次加权(0–10);非该对象问题不进入聚类。这里只做聚类与排序,不生成 patch,第 6 步按 #1→#N 顺序逐轮迭代。

+

严重程度 = 置信度 × 影响面 × 来源频次加权(0–10);非该对象问题不进入聚类。一个 bad case 若同时归因到多个成员,会分别进入各自成员的簇,不会被合并。第 6 步按成员簇逐轮生成只改该成员的 patch。

`; } @@ -9554,11 +9663,13 @@

接入契约(替换身份提供方即可)

function afAwaiting(run) { return run.reviewRequired && run.progress === 3 && afScope(run).phase === 'review'; } function afCanAdjust(run) { return afAwaiting(run) && !run.failed && !run.preparing && (!run.controlState || run.controlState === 'running') && v2CanManage(run.workspace); } function afInputs(run, scope) { - return run.model.attributed.map(r => afReportKey(r.c, r.report)).filter(key => !scope.excluded.includes(key)); + const reports = run.model.attributedReports || run.model.attributed.map(r => r.report).filter(Boolean); + return reports.map(rep => afReportKey({ workspace: rep.workspace, id: rep.caseId }, rep)).filter(key => !scope.excluded.includes(key)); } function afApplyFreeze(run, scope) { if (!['frozen', 'empty'].includes(scope.phase) || run.frozenVersion === scope.version) return; - evBuildClusters(run, run.model.attributed.filter(r => scope.members.includes(afReportKey(r.c, r.report)))); + const reports = run.model.attributedReports || run.model.attributed.map(r => r.report).filter(Boolean); + evBuildClusters(run, reports.filter(rep => scope.members.includes(afReportKey({ workspace: rep.workspace, id: rep.caseId }, rep)))); run.progress = scope.phase === 'empty' ? evTotal(run) : Math.max(run.progress, 4); run.frozenVersion = scope.version; } @@ -9695,10 +9806,10 @@

接入契约(替换身份提供方即可)

return `${Object.entries(afVoteLabel).map(([direction, label]) => ``).join('')}`; } -function afMembership(run, row) { - if (!row.report || row.report.conclusion !== 'attributed') return '无需聚类'; +function afMembership(run, row, report = row.report) { + if (!report || report.conclusion !== 'attributed') return '无需聚类'; const scope = afScope(run); - if (!scope.excluded.includes(afReportKey(row.c, row.report))) return afAwaiting(run) ? '待聚类' : '已纳入'; + if (!scope.excluded.includes(afReportKey(row.c, report))) return afAwaiting(run) ? '待聚类' : '已纳入'; return `已移出 ${afCanAdjust(run) ? `` : ''}`; } function afReviewBar(run) {