From 785dd0c54dee2bf5dc86381cb90399c2290e1354 Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Wed, 4 Nov 2026 10:36:50 +0800 Subject: [PATCH] feat(tasks): review sourced requirements against current original evidence --- .gitattributes | 1 + .gitignore | 1 + AGENTS.md | 2 + docs/PLAN-1.25.md | 2 +- docs/REQUIREMENTS-REVIEW-A.md | 17 + .../manifest.json | 354 +++++++ .../retrospective.md | 17 + .../scripts/verify-adoption-evidence.mjs | 53 + .../scripts/verify-requirements-desktop.mjs | 54 + .../source/scripts/verify-requirements-ui.mjs | 84 ++ .../source/src/client/RequirementPanel.css | 19 + .../source/src/client/RequirementPanel.tsx | 102 ++ .../source/src/client/TaskPanel.tsx | 179 ++++ .../source/src/client/types.ts | 363 +++++++ .../source/src/core/delivery-report.mjs | 288 ++++++ .../source/src/core/git-delivery.mjs | 521 ++++++++++ .../src/core/tasks/requirement-review.mjs | 190 ++++ .../source/src/server/app.mjs | 929 +++++++++++++++++ .../source/src/server/runtime.mjs | 933 ++++++++++++++++++ .../src/shared/contracts/task-control.mjs | 83 ++ .../source/tests/companion.test.mjs | 401 ++++++++ .../tests/requirement-review-api.test.mjs | 21 + .../source/tests/requirement-review.test.mjs | 172 ++++ .../validation/build-first.log | 20 + .../validation/build-requirements-final.log | 20 + .../result.json | 16 + .../verified.png | Bin 0 -> 115342 bytes .../result.json | 11 + .../validation/electron-final.log | 4 + .../validation/electron-first.log | 3 + .../validation/electron-second.log | 4 + .../validation/mobile-routes.tap | 9 + .../validation/requirements-acceptance.tap | 61 ++ .../validation/requirements-final.tap | 19 + .../validation/requirements-first.tap | 57 ++ .../validation/requirements-related.tap | 103 ++ .../validation/requirements-scoped.tap | 20 + .../desktop-stale.png | Bin 0 -> 118286 bytes .../desktop-verified.png | Bin 0 -> 117205 bytes .../narrow-stale.png | Bin 0 -> 48976 bytes .../result.json | 130 +++ .../failure.png | Bin 0 -> 183249 bytes .../result.json | 10 + .../desktop-stale.png | Bin 0 -> 121344 bytes .../desktop-verified.png | Bin 0 -> 117101 bytes .../failure.png | Bin 0 -> 23435 bytes .../result.json | 18 + .../validation/ui-final.log | 8 + .../validation/ui-first.log | 1 + .../validation/ui-second.log | 6 + .../validation/ui-third.log | 17 + findings.md | 2 + progress.md | 12 + scripts/verify-adoption-evidence.mjs | 53 + scripts/verify-requirements-desktop.mjs | 54 + scripts/verify-requirements-ui.mjs | 84 ++ src/client/RequirementPanel.css | 19 + src/client/RequirementPanel.tsx | 102 ++ src/client/TaskPanel.tsx | 3 + src/client/types.ts | 11 + src/core/delivery-report.mjs | 17 +- src/core/git-delivery.mjs | 5 + src/core/tasks/requirement-review.mjs | 190 ++++ src/server/app.mjs | 15 +- src/server/runtime.mjs | 16 + src/shared/contracts/task-control.mjs | 2 +- task_plan.md | 4 +- tests/companion.test.mjs | 5 + tests/requirement-review-api.test.mjs | 21 + tests/requirement-review.test.mjs | 172 ++++ 70 files changed, 6103 insertions(+), 7 deletions(-) create mode 100644 docs/REQUIREMENTS-REVIEW-A.md create mode 100644 docs/requirements-review-a-evidence/manifest.json create mode 100644 docs/requirements-review-a-evidence/retrospective.md create mode 100644 docs/requirements-review-a-evidence/source/scripts/verify-adoption-evidence.mjs create mode 100644 docs/requirements-review-a-evidence/source/scripts/verify-requirements-desktop.mjs create mode 100644 docs/requirements-review-a-evidence/source/scripts/verify-requirements-ui.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/client/RequirementPanel.css create mode 100644 docs/requirements-review-a-evidence/source/src/client/RequirementPanel.tsx create mode 100644 docs/requirements-review-a-evidence/source/src/client/TaskPanel.tsx create mode 100644 docs/requirements-review-a-evidence/source/src/client/types.ts create mode 100644 docs/requirements-review-a-evidence/source/src/core/delivery-report.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/core/git-delivery.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/core/tasks/requirement-review.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/server/app.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/server/runtime.mjs create mode 100644 docs/requirements-review-a-evidence/source/src/shared/contracts/task-control.mjs create mode 100644 docs/requirements-review-a-evidence/source/tests/companion.test.mjs create mode 100644 docs/requirements-review-a-evidence/source/tests/requirement-review-api.test.mjs create mode 100644 docs/requirements-review-a-evidence/source/tests/requirement-review.test.mjs create mode 100644 docs/requirements-review-a-evidence/validation/build-first.log create mode 100644 docs/requirements-review-a-evidence/validation/build-requirements-final.log create mode 100644 docs/requirements-review-a-evidence/validation/electron-4a37e4be-2efc-456d-9e5a-ca680ed17ac1/result.json create mode 100644 docs/requirements-review-a-evidence/validation/electron-4a37e4be-2efc-456d-9e5a-ca680ed17ac1/verified.png create mode 100644 docs/requirements-review-a-evidence/validation/electron-7e0fe298-edd7-48f1-a2ec-40e15294f74b/result.json create mode 100644 docs/requirements-review-a-evidence/validation/electron-final.log create mode 100644 docs/requirements-review-a-evidence/validation/electron-first.log create mode 100644 docs/requirements-review-a-evidence/validation/electron-second.log create mode 100644 docs/requirements-review-a-evidence/validation/mobile-routes.tap create mode 100644 docs/requirements-review-a-evidence/validation/requirements-acceptance.tap create mode 100644 docs/requirements-review-a-evidence/validation/requirements-final.tap create mode 100644 docs/requirements-review-a-evidence/validation/requirements-first.tap create mode 100644 docs/requirements-review-a-evidence/validation/requirements-related.tap create mode 100644 docs/requirements-review-a-evidence/validation/requirements-scoped.tap create mode 100644 docs/requirements-review-a-evidence/validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/desktop-stale.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/desktop-verified.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/narrow-stale.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/result.json create mode 100644 docs/requirements-review-a-evidence/validation/ui-b16d50fd-3185-4257-b6e2-d404bcd016b2/failure.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-b16d50fd-3185-4257-b6e2-d404bcd016b2/result.json create mode 100644 docs/requirements-review-a-evidence/validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/desktop-stale.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/desktop-verified.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/failure.png create mode 100644 docs/requirements-review-a-evidence/validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/result.json create mode 100644 docs/requirements-review-a-evidence/validation/ui-final.log create mode 100644 docs/requirements-review-a-evidence/validation/ui-first.log create mode 100644 docs/requirements-review-a-evidence/validation/ui-second.log create mode 100644 docs/requirements-review-a-evidence/validation/ui-third.log create mode 100644 scripts/verify-adoption-evidence.mjs create mode 100644 scripts/verify-requirements-desktop.mjs create mode 100644 scripts/verify-requirements-ui.mjs create mode 100644 src/client/RequirementPanel.css create mode 100644 src/client/RequirementPanel.tsx create mode 100644 src/core/tasks/requirement-review.mjs create mode 100644 tests/requirement-review-api.test.mjs create mode 100644 tests/requirement-review.test.mjs diff --git a/.gitattributes b/.gitattributes index bb34221f..7b9376a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -250,3 +250,4 @@ docs/working-memory-u-git-index.txt binary docs/working-memory-u-release-identity.json -text docs/tianshu-research-evidence/** -text +docs/requirements-review-a-evidence/** binary diff --git a/.gitignore b/.gitignore index 7882da39..e2e39c4b 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ !/docs/reading-s-evidence/**/*.log !/docs/live-delivery-t-evidence/**/*.log +!/docs/requirements-review-a-evidence/**/*.log diff --git a/AGENTS.md b/AGENTS.md index 516882f0..f0e91ce4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,5 +1,7 @@ # Agent Workbench项目执行规范 +当前接续已获用户授权开发要求与证据复核、单轮shadow观察。研究原未提交内容已验证并提交ce3afb2f;要求复核A已开发、相关53/53/网页7组/Electron3组及构建通过,见docs/REQUIREMENTS-REVIEW-A.md,独立发行/安装/正式升级未完成,正式仍1.24.8/原Provider。下一B只记录外显事实,不改变停止/权限/预算;真实模型预算0,保留V网络partial、T/R/P/O原失败、重复读取和Purge未知,不续跑旧样本、不委派、不推送、不读取/重存Key。下方“当前新增研究只读”属于研究时点。 + V按一次诊断partial在预检前结束,真实请求0;原正式状态精确保持,46份证据离线通过,见docs/QA-LIVE-DELIVERY-V.md。当前用户新增Tianshu-harness深度源码研究:固定2d0b22e,只读机制/原理/逻辑与本产品差异,不运行第三方安装服务或导入其配置,不改正式Provider/Key,不委派、不推送;真实交付另冻新样本,不续跑V/T/R/P/O。下方U“下一V”和V执行中段落为历史状态。 U已本地交付1.24.8/source7e77fd65/候选20261103235313371:同SHA/原范围页聚合、完整小源码/最新纯读组保留、修改前当前检查事实与routine/latest去重完成。114相关、569输入独立重建22/22、三归档/便携、12实际安装和安装副本16+9文件流程,以及源码/便携/安装三载荷各7请求工作记忆夹具通过。正式原PID36552/Provider、65项目81会话6377记录13484事件及outbox/3720工件、全部原表行/导出/工件和公开模型中心在网页/原生回看后再次精确保持,9229关闭。本轮真实请求0,原T九测试仍失败,未证明真实交付或Purge收益。证据620份/100126636字节离线核验通过,身份见docs/working-memory-u-release-identity.json,回顾见docs/RETROSPECTIVE-WORKING-MEMORY-U.md。下一按docs/LIVE-DELIVERY-V-PLAN.md另冻新诊断/单次预检/Node,旧T/R/P/O不续跑;Node后才React/Python/Purge,1.25及更新性能独立排期。不委派、不提取/复制/解密/重存Key、不推送。 diff --git a/docs/PLAN-1.25.md b/docs/PLAN-1.25.md index 52c886d8..c6aedde4 100644 --- a/docs/PLAN-1.25.md +++ b/docs/PLAN-1.25.md @@ -1,6 +1,6 @@ # 1.25 计划:任务要求与交付复核 -状态:后续方案,尚未实现。1.24独立发行、实际安装、正式状态保持与回顾已完成;下一按本计划逐切片实施,不能把方案写成现有能力。 +状态:分切片开发中。要求来源、逐项修订和实际证据复核的首个开发切片见[要求复核 A](REQUIREMENTS-REVIEW-A.md),已做相关及实际入口验证;自动草案提取、完整范围约定与诊断闭环继续排期。尚未独立发行/安装/正式升级,正式仍1.24.8,不代表1.25已交付。 1.24增加的是当前文件与来源的核对。文件SHA、采用原因和检查通过仍不能单独证明所有业务要求已满足。下一阶段把任务要求、实际成果及尚未验证事项联系起来,让用户知道“完成了哪些、依据是什么、哪里还需要体验”。 diff --git a/docs/REQUIREMENTS-REVIEW-A.md b/docs/REQUIREMENTS-REVIEW-A.md new file mode 100644 index 00000000..61f24bf9 --- /dev/null +++ b/docs/REQUIREMENTS-REVIEW-A.md @@ -0,0 +1,17 @@ +# 要求与证据复核 A:开发切片回顾 + +本阶段把用户要求、原文来源和实际证据接到现有 Task,已完成开发验证。本地正式安装仍为 1.24.8;本切片尚未独立发行、安装或正式升级,不能标作 1.25 已交付。原 Tianshu 采用计划是研究时的冻结方案,当前实施状态以本文和后续阶段记录为准。 + +用户在任务面板的“要求与证据”记录原文范围、验收条件和证据类别。原目标及每次追加都有独立身份、时间和来源 SHA,相同文字不会合并成一个消息实例。每项单独修订,旧要求、失败和工件保留。新增来源先列为未审阅;未改动要求的有效文件事实保留。没有自动提取或模型自签验收。 + +实际证据复核沿用原 TaskPlanManager、FileResults、检查和浏览器校验。核对当前项目/Task/Run、原调用与参数、工件原字节、选定文件当前 SHA、当前检查和页面构建;非空说明、旧 Task 或伪造 ID 不算证据。“所选证据已核对”“用户已确认”“待复核”“复核失败”“依据失效”“按约定未执行”分别显示。用户确认包含原输入指纹和体验说明,源码变化后需重核。跳过检查只接受当前明确 no-test 约定,不计为通过。 + +Git 预览和发布重新核对要求绑定;模型答复、手动结束任务与无测试文件应用也保留待复核门。旧任务未配置逐项要求时仍明确显示未记录,不把已有能力倒写为业务验收。工程检查、文件成果和页面权限硬门保留。手机没有新增要求写入或确认权限;本阶段只验证桌面网页在 390px 的响应布局及原手机权限回归,没有声称真机验收。 + +验证记录:相关首轮 70 项中 69 通过,唯一新用例误取成果返回的 id(应为 result_id);修正后新增及 HTTP 专项 11/11、增加逐文件来源和实际 Git 发布绑定后 12/12。最终要求/HTTP/成果/手机相关 53/53,包含追加来源、相同文字、跨项目/旧 Task、伪造/缺失/篡改工件、要求修订、当前源码变化、并发修订、重开宿主与原消息不变。实际网页七组、Electron 三组通过;TypeScript 和完整构建通过。手机新增路由拒绝另有定向验证。原失败日志、截图与最终结果一起封存,未覆盖原件。 + +回顾发现:新的原文来源与证据层补齐了原计划不表达的业务要求复核;没有复制另一套执行计划或 Git 系统。新增文件核对只改变对应要求,不自动宣布其业务含义成立。保存接线首错、390px 任务栏重开、迟到拦截已取消请求和隐藏 Electron 截图超时均如实保留;按实际 API/导航/窗口规则修正。最终桌面与窄屏截图已目视检查,内容沿用现有工作台字体、颜色和任务侧栏。 + +限制与下一步:范围/禁止操作和未知要求仍需用户明确记录,自动草案提取、全面业务语义判断及诊断闭环尚未实现。B 将只观察单轮外显事实;停止/权限/预算保护不因 shadow 改动。独立源码/不可变发行/安装/保留状态正式升级及进一步体验验收继续排期。真实模型请求为 0,正式 Provider/Key 未操作;V 网络 partial、T/R/P/O 失败、重复读取与 Purge 收益未验证保持,旧样本不续跑。 + +证据位于 `requirements-review-a-evidence/`。运行 `node scripts/verify-adoption-evidence.mjs docs/requirements-review-a-evidence` 只核对封存字节;加 `--source-ref <本切片提交>` 可核对 Git 源码,不重放原工具、检查或模型请求。 diff --git a/docs/requirements-review-a-evidence/manifest.json b/docs/requirements-review-a-evidence/manifest.json new file mode 100644 index 00000000..367fcd97 --- /dev/null +++ b/docs/requirements-review-a-evidence/manifest.json @@ -0,0 +1,354 @@ +{ + "kind": "adoption-stage-evidence", + "stage": "requirements-review-a", + "status": "development_slice_validated_not_released", + "realModelRequests": 0, + "officialServiceChanged": false, + "sourceFiles": [ + { + "path": "src/core/tasks/requirement-review.mjs", + "snapshot": "source/src/core/tasks/requirement-review.mjs" + }, + { + "path": "src/client/RequirementPanel.tsx", + "snapshot": "source/src/client/RequirementPanel.tsx" + }, + { + "path": "src/client/RequirementPanel.css", + "snapshot": "source/src/client/RequirementPanel.css" + }, + { + "path": "src/client/TaskPanel.tsx", + "snapshot": "source/src/client/TaskPanel.tsx" + }, + { + "path": "src/client/types.ts", + "snapshot": "source/src/client/types.ts" + }, + { + "path": "src/core/delivery-report.mjs", + "snapshot": "source/src/core/delivery-report.mjs" + }, + { + "path": "src/core/git-delivery.mjs", + "snapshot": "source/src/core/git-delivery.mjs" + }, + { + "path": "src/server/app.mjs", + "snapshot": "source/src/server/app.mjs" + }, + { + "path": "src/server/runtime.mjs", + "snapshot": "source/src/server/runtime.mjs" + }, + { + "path": "src/shared/contracts/task-control.mjs", + "snapshot": "source/src/shared/contracts/task-control.mjs" + }, + { + "path": "tests/requirement-review.test.mjs", + "snapshot": "source/tests/requirement-review.test.mjs" + }, + { + "path": "tests/requirement-review-api.test.mjs", + "snapshot": "source/tests/requirement-review-api.test.mjs" + }, + { + "path": "tests/companion.test.mjs", + "snapshot": "source/tests/companion.test.mjs" + }, + { + "path": "scripts/verify-requirements-ui.mjs", + "snapshot": "source/scripts/verify-requirements-ui.mjs" + }, + { + "path": "scripts/verify-requirements-desktop.mjs", + "snapshot": "source/scripts/verify-requirements-desktop.mjs" + }, + { + "path": "scripts/verify-adoption-evidence.mjs", + "snapshot": "source/scripts/verify-adoption-evidence.mjs" + } + ], + "files": [ + { + "path": "retrospective.md", + "bytes": 3655, + "sha256": "fdc7cac35a691f14c62e757faa91311b7e1436e769ce9b8901107e6c9749291e" + }, + { + "path": "source/scripts/verify-adoption-evidence.mjs", + "bytes": 4224, + "sha256": "26e00cc6666d91ff58cddf754a7e2ec00c8aecea88ad2504eb69c95a4d8af566" + }, + { + "path": "source/scripts/verify-requirements-desktop.mjs", + "bytes": 5128, + "sha256": "a07213b4ec9fb0ffbfe834980406b37f71ca766eff388ef9420d67d300218634" + }, + { + "path": "source/scripts/verify-requirements-ui.mjs", + "bytes": 7320, + "sha256": "1f05744a94c58e3ded6b59b33bc0244b591856c664c71e3ddd3efa8b8d2cca5e" + }, + { + "path": "source/src/client/RequirementPanel.css", + "bytes": 1885, + "sha256": "b0d4511585c088d2a35f077a8e8a6934d7fe293d10c86ccc31a2b1fc727b6034" + }, + { + "path": "source/src/client/RequirementPanel.tsx", + "bytes": 13742, + "sha256": "5a457e43b05d1bd599c4c64cacc1645dc9d39ae7fa534aeee6f968cf03c4ab2c" + }, + { + "path": "source/src/client/TaskPanel.tsx", + "bytes": 24179, + "sha256": "25e4289226d0ec66f2f1803a8af0416272bf5b70d721355b7bbafd4bf6dd5c9b" + }, + { + "path": "source/src/client/types.ts", + "bytes": 42122, + "sha256": "dde9d34c6cd713dfafb9ff3f7679266d7db194c9440a85edc1c3e9d730293eed" + }, + { + "path": "source/src/core/delivery-report.mjs", + "bytes": 28149, + "sha256": "3ae6714b9c73d8914031ceaab1f65a48ad8b27b41bb14e211f9f64dcff4104ea" + }, + { + "path": "source/src/core/git-delivery.mjs", + "bytes": 41782, + "sha256": "83f1e32429060b805855a3100d6b72299d522eeeb7c93a4bd25b3bb9bb17d0b2" + }, + { + "path": "source/src/core/tasks/requirement-review.mjs", + "bytes": 16538, + "sha256": "05680004e70f2c9b215b480e58c12b4d28c3fc91d08173550cdeb0d524adc18f" + }, + { + "path": "source/src/server/app.mjs", + "bytes": 76366, + "sha256": "027267159419846d2fc63d42f8c0d2dc0d17341436872183a2dbbbd0bb6c4345" + }, + { + "path": "source/src/server/runtime.mjs", + "bytes": 91837, + "sha256": "5c585308da13597c08cd544319f2e5941818bf7638338d29a25a7dcfd8a02652" + }, + { + "path": "source/src/shared/contracts/task-control.mjs", + "bytes": 6840, + "sha256": "3338e0fe5ea6e7304cee401e5b0c6de624ddaeccd49b85adf6ce76d2fc372d55" + }, + { + "path": "source/tests/companion.test.mjs", + "bytes": 32426, + "sha256": "bc4c4478c69987ac22e7fb3d59c65a9fa8c03c677a2a104fe44931b3adf34663" + }, + { + "path": "source/tests/requirement-review-api.test.mjs", + "bytes": 2018, + "sha256": "990cadc188a2f7b93b71ac2c60f5325a6898837d8bad3e001e38066323067020" + }, + { + "path": "source/tests/requirement-review.test.mjs", + "bytes": 15159, + "sha256": "39ad8606cd3b17b5e9b6db8ac53a17510d22439ce4d4e000db17d47faea1ae8e" + }, + { + "path": "validation/build-first.log", + "bytes": 1090, + "sha256": "7a3da76a0e7a60f7df0f80a880de232077d3a008a859e4b5c07728060376e058" + }, + { + "path": "validation/build-requirements-final.log", + "bytes": 1090, + "sha256": "dc744ded38fc0480e93a5d4935560a9c99ab5b3ed9358e6dff8e916846b1f711" + }, + { + "path": "validation/electron-4a37e4be-2efc-456d-9e5a-ca680ed17ac1/result.json", + "bytes": 524, + "sha256": "4a6cb8511ddfdf9cf5ce0348a01b4a52f1ade5b0c589526f997dc1634ca18748" + }, + { + "path": "validation/electron-4a37e4be-2efc-456d-9e5a-ca680ed17ac1/verified.png", + "bytes": 115342, + "sha256": "1a4688db95f67f7633636d1b673a389a09611a29f993ff8ac06997101c747612" + }, + { + "path": "validation/electron-7e0fe298-edd7-48f1-a2ec-40e15294f74b/result.json", + "bytes": 528, + "sha256": "429d7373861a12e1b8406a097cf1a118d6f7fbe689890661ee088a8306745402" + }, + { + "path": "validation/electron-final.log", + "bytes": 777, + "sha256": "8e1489ebdf879c9d9d161c36ba73e1bd31881f97e7322c22748907580c579378" + }, + { + "path": "validation/electron-first.log", + "bytes": 735, + "sha256": "9e1d50d47890b605ff04f6416310bbd8bb3cebdb0939623cb2e6c8e90a81fd24" + }, + { + "path": "validation/electron-second.log", + "bytes": 777, + "sha256": "9f764d0300214c819b26deb8333774535c7cc0ecb3ae54e36d4a62e6b27fdab6" + }, + { + "path": "validation/mobile-routes.tap", + "bytes": 222, + "sha256": "45a5c999b53013c37485ee8edfcd2b1620bef7d1a295beec9906a344441691a9" + }, + { + "path": "validation/requirements-acceptance.tap", + "bytes": 6198, + "sha256": "8f38f5fb5a57f859176f265ef9fd26a20ae72af0354809167e43ad765555b061" + }, + { + "path": "validation/requirements-final.tap", + "bytes": 1473, + "sha256": "d7ea497b2c0558946008656ea27c0dbb6a810faabdab45da40c681b365e32911" + }, + { + "path": "validation/requirements-first.tap", + "bytes": 3389, + "sha256": "60e83642a0e4eea101fdbc712b531df8bfa95e03e0f30f22b04668d7ce14ee4d" + }, + { + "path": "validation/requirements-related.tap", + "bytes": 9641, + "sha256": "7287e611352e234263e330fdaeb19a2f2a3a842545c5f1dbe7bb6b7d2fd8e7ef" + }, + { + "path": "validation/requirements-scoped.tap", + "bytes": 1572, + "sha256": "7d54f3d5558037f547c6a6a60c00cb8a7c451522e945783d98d92aa978628da8" + }, + { + "path": "validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/desktop-stale.png", + "bytes": 118286, + "sha256": "00fb276a4a240fa8ac843b88776959be52e715da460280a719bbb0145d138b69" + }, + { + "path": "validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/desktop-verified.png", + "bytes": 117205, + "sha256": "7ba589d2bff35fa30a6a58c6a43fa99f9791f5f111eb318362695c67ee5d4919" + }, + { + "path": "validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/narrow-stale.png", + "bytes": 48976, + "sha256": "e3ab5c711f245e35a072ef2153991956598464169b3c6bf26b9867275079f9f9" + }, + { + "path": "validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/result.json", + "bytes": 5140, + "sha256": "16093fcebbf36b2d591d53f9026b0b5035366622485154a020927cf62c5064cb" + }, + { + "path": "validation/ui-b16d50fd-3185-4257-b6e2-d404bcd016b2/failure.png", + "bytes": 183249, + "sha256": "5d786918ee329d9d447db86c610ee56c398e8eb674ef642f49fdadb871b1cfe7" + }, + { + "path": "validation/ui-b16d50fd-3185-4257-b6e2-d404bcd016b2/result.json", + "bytes": 683, + "sha256": "4be129e5fefd97275543e3d37df5894c04b1aa6d83b08fda70e7ef4d86a775c1" + }, + { + "path": "validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/desktop-stale.png", + "bytes": 121344, + "sha256": "716fc8ca4dddf48b554baaa8534018b52daa4e2a1b6bbcbf2b6320e591dc2918" + }, + { + "path": "validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/desktop-verified.png", + "bytes": 117101, + "sha256": "de2a6f977cd7e03ec465fc9f4b83224831ee906324ef867a2e6d61a078e03cb8" + }, + { + "path": "validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/failure.png", + "bytes": 23435, + "sha256": "ec7985043ee807486e3c60a9169e0cd15f3dad15036d5984f5943c4d1059ccd6" + }, + { + "path": "validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/result.json", + "bytes": 1779, + "sha256": "8bbde16e849793e00e53677574b2c437030a17491cb8a24a4b9cf1cb69e5fefd" + }, + { + "path": "validation/ui-final.log", + "bytes": 1684, + "sha256": "89c4736d14d4d6677aa7266a87f82c346c2628b53e8e5d102f05ea196a67b848" + }, + { + "path": "validation/ui-first.log", + "bytes": 778, + "sha256": "58081a4880283656cfcaf9ac0b4a9c13e45b2e03485d5feadc38c5eb85217fee" + }, + { + "path": "validation/ui-second.log", + "bytes": 2200, + "sha256": "800fcb7e39d36b59bcec613f1f1e40b9a763abcda910ad47569531d0ba725700" + }, + { + "path": "validation/ui-third.log", + "bytes": 733, + "sha256": "6bf5686273f9cf91b166b431dcccb29af9115a21d39d18a5e18eb48dbccfd12f" + } + ], + "bytes": 1299321, + "testRuns": [ + { + "path": "validation/requirements-first.tap", + "tests": 10, + "passed": 8, + "failed": 2 + }, + { + "path": "validation/requirements-related.tap", + "tests": 70, + "passed": 69, + "failed": 1 + }, + { + "path": "validation/requirements-acceptance.tap", + "tests": 53, + "passed": 53, + "failed": 0 + }, + { + "path": "validation/mobile-routes.tap", + "tests": 1, + "passed": 1, + "failed": 0 + } + ], + "uiRuns": [ + { + "path": "validation/ui-b16d50fd-3185-4257-b6e2-d404bcd016b2/result.json", + "success": false, + "passed": 0 + }, + { + "path": "validation/ui-be243cdc-aace-4a11-9528-559b5aa6a275/result.json", + "success": false, + "passed": 5 + }, + { + "path": "validation/ui-4ef3fe47-6893-4edf-8115-192e5e6f37d5/result.json", + "success": true, + "passed": 7 + }, + { + "path": "validation/electron-7e0fe298-edd7-48f1-a2ec-40e15294f74b/result.json", + "success": false, + "passed": 2 + }, + { + "path": "validation/electron-4a37e4be-2efc-456d-9e5a-ca680ed17ac1/result.json", + "success": true, + "passed": 3 + } + ] +} diff --git a/docs/requirements-review-a-evidence/retrospective.md b/docs/requirements-review-a-evidence/retrospective.md new file mode 100644 index 00000000..61f24bf9 --- /dev/null +++ b/docs/requirements-review-a-evidence/retrospective.md @@ -0,0 +1,17 @@ +# 要求与证据复核 A:开发切片回顾 + +本阶段把用户要求、原文来源和实际证据接到现有 Task,已完成开发验证。本地正式安装仍为 1.24.8;本切片尚未独立发行、安装或正式升级,不能标作 1.25 已交付。原 Tianshu 采用计划是研究时的冻结方案,当前实施状态以本文和后续阶段记录为准。 + +用户在任务面板的“要求与证据”记录原文范围、验收条件和证据类别。原目标及每次追加都有独立身份、时间和来源 SHA,相同文字不会合并成一个消息实例。每项单独修订,旧要求、失败和工件保留。新增来源先列为未审阅;未改动要求的有效文件事实保留。没有自动提取或模型自签验收。 + +实际证据复核沿用原 TaskPlanManager、FileResults、检查和浏览器校验。核对当前项目/Task/Run、原调用与参数、工件原字节、选定文件当前 SHA、当前检查和页面构建;非空说明、旧 Task 或伪造 ID 不算证据。“所选证据已核对”“用户已确认”“待复核”“复核失败”“依据失效”“按约定未执行”分别显示。用户确认包含原输入指纹和体验说明,源码变化后需重核。跳过检查只接受当前明确 no-test 约定,不计为通过。 + +Git 预览和发布重新核对要求绑定;模型答复、手动结束任务与无测试文件应用也保留待复核门。旧任务未配置逐项要求时仍明确显示未记录,不把已有能力倒写为业务验收。工程检查、文件成果和页面权限硬门保留。手机没有新增要求写入或确认权限;本阶段只验证桌面网页在 390px 的响应布局及原手机权限回归,没有声称真机验收。 + +验证记录:相关首轮 70 项中 69 通过,唯一新用例误取成果返回的 id(应为 result_id);修正后新增及 HTTP 专项 11/11、增加逐文件来源和实际 Git 发布绑定后 12/12。最终要求/HTTP/成果/手机相关 53/53,包含追加来源、相同文字、跨项目/旧 Task、伪造/缺失/篡改工件、要求修订、当前源码变化、并发修订、重开宿主与原消息不变。实际网页七组、Electron 三组通过;TypeScript 和完整构建通过。手机新增路由拒绝另有定向验证。原失败日志、截图与最终结果一起封存,未覆盖原件。 + +回顾发现:新的原文来源与证据层补齐了原计划不表达的业务要求复核;没有复制另一套执行计划或 Git 系统。新增文件核对只改变对应要求,不自动宣布其业务含义成立。保存接线首错、390px 任务栏重开、迟到拦截已取消请求和隐藏 Electron 截图超时均如实保留;按实际 API/导航/窗口规则修正。最终桌面与窄屏截图已目视检查,内容沿用现有工作台字体、颜色和任务侧栏。 + +限制与下一步:范围/禁止操作和未知要求仍需用户明确记录,自动草案提取、全面业务语义判断及诊断闭环尚未实现。B 将只观察单轮外显事实;停止/权限/预算保护不因 shadow 改动。独立源码/不可变发行/安装/保留状态正式升级及进一步体验验收继续排期。真实模型请求为 0,正式 Provider/Key 未操作;V 网络 partial、T/R/P/O 失败、重复读取与 Purge 收益未验证保持,旧样本不续跑。 + +证据位于 `requirements-review-a-evidence/`。运行 `node scripts/verify-adoption-evidence.mjs docs/requirements-review-a-evidence` 只核对封存字节;加 `--source-ref <本切片提交>` 可核对 Git 源码,不重放原工具、检查或模型请求。 diff --git a/docs/requirements-review-a-evidence/source/scripts/verify-adoption-evidence.mjs b/docs/requirements-review-a-evidence/source/scripts/verify-adoption-evidence.mjs new file mode 100644 index 00000000..7f6e7028 --- /dev/null +++ b/docs/requirements-review-a-evidence/source/scripts/verify-adoption-evidence.mjs @@ -0,0 +1,53 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import assert from 'node:assert/strict'; +import { createHash } from 'node:crypto'; +import { execFileSync } from 'node:child_process'; + +const [directory, ...options] = process.argv.slice(2); +if (!directory || options.some((value, index) => value !== '--index' && value !== '--source-ref' && options[index - 1] !== '--source-ref')) + throw new Error('Usage: node scripts/verify-adoption-evidence.mjs [--index] [--source-ref ]'); +const root = path.resolve(directory), gitRoot = process.cwd(), useIndex = options.includes('--index'); +const sourceRef = options.includes('--source-ref') ? options[options.indexOf('--source-ref') + 1] : null; +if (sourceRef) assert.ok(sourceRef === ':' || /^[a-f0-9]{7,40}$/.test(sourceRef)); +const sha = bytes => createHash('sha256').update(bytes).digest('hex'); +const git = object => execFileSync('git', ['show', object], { cwd: gitRoot, windowsHide: true, maxBuffer: 16 * 1024 * 1024 }); +const contained = rel => { + assert.ok(typeof rel === 'string' && rel && !rel.includes('\\') && !path.isAbsolute(rel) && !rel.split('/').some(part => !part || part === '..')); + const file = path.resolve(root, rel); assert.ok(file.startsWith(root + path.sep)); assert.ok(fs.lstatSync(file).isFile()); return file; +}; +const manifestBytes = fs.readFileSync(path.join(root, 'manifest.json')), manifest = JSON.parse(manifestBytes); +assert.equal(manifest.kind, 'adoption-stage-evidence'); assert.equal(manifest.realModelRequests, 0); assert.equal(manifest.officialServiceChanged, false); +const names = new Set(); let bytes = 0; +for (const row of manifest.files) { + assert.ok(!names.has(row.path)); names.add(row.path); const data = fs.readFileSync(contained(row.path)); + assert.equal(data.length, row.bytes, row.path); assert.equal(sha(data), row.sha256, row.path); bytes += data.length; + if (row.path.endsWith('.png')) assert.equal(data.subarray(0, 8).toString('hex'), '89504e470d0a1a0a'); + if (useIndex) assert.equal(sha(git(':' + path.relative(gitRoot, path.join(root, row.path)).replaceAll('\\', '/'))), row.sha256); +} +assert.equal(bytes, manifest.bytes); +const walk = dir => fs.readdirSync(dir, { withFileTypes: true }).flatMap(row => { + const file = path.join(dir, row.name); assert.equal(fs.lstatSync(file).isSymbolicLink(), false); + return row.isDirectory() ? walk(file) : [path.relative(root, file).replaceAll('\\', '/')]; +}); +assert.deepEqual(walk(root).filter(name => name !== 'manifest.json').sort(), [...names].sort()); +if (useIndex) assert.equal(sha(git(':' + path.relative(gitRoot, path.join(root, 'manifest.json')).replaceAll('\\', '/'))), sha(manifestBytes)); +for (const check of manifest.testRuns ?? []) { + const log = fs.readFileSync(contained(check.path), 'utf8'); + for (const [label, count] of Object.entries({ tests: check.tests, pass: check.passed, fail: check.failed })) + assert.match(log, new RegExp('(?:ℹ |# )' + label + ' ' + count + '(?:\\r?\\n|$)')); +} +for (const check of manifest.uiRuns ?? []) { + const result = JSON.parse(fs.readFileSync(contained(check.path), 'utf8')); + assert.equal(result.success, check.success); assert.equal(result.passed.length, check.passed); assert.equal(result.realModelRequests, 0); +} +if (sourceRef) for (const row of manifest.sourceFiles) { + assert.ok(names.has(row.snapshot)); assert.ok(row.path && !row.path.includes('..') && !path.isAbsolute(row.path)); + const original = fs.readFileSync(contained(row.snapshot)); const recorded = git(sourceRef === ':' ? ':' + row.path : sourceRef + ':' + row.path); + // Source snapshots preserve original checkout bytes. The repository's text + // attributes store LF; accept only that declared text representation change. + const gitText = Buffer.from(original.toString('utf8').replaceAll('\r\n', '\n')); + assert.equal(sha(recorded), sha(original) === sha(recorded) ? sha(original) : sha(gitText), 'Source ref differs: ' + row.path); +} +console.log(JSON.stringify({ ok: true, stage: manifest.stage, files: names.size, bytes, testRuns: manifest.testRuns?.length ?? 0, + uiRuns: manifest.uiRuns?.length ?? 0, sourceFiles: manifest.sourceFiles.length, indexChecked: useIndex, sourceRef, realModelRequests: 0 })); diff --git a/docs/requirements-review-a-evidence/source/scripts/verify-requirements-desktop.mjs b/docs/requirements-review-a-evidence/source/scripts/verify-requirements-desktop.mjs new file mode 100644 index 00000000..e4ea1b4a --- /dev/null +++ b/docs/requirements-review-a-evidence/source/scripts/verify-requirements-desktop.mjs @@ -0,0 +1,54 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import net from 'node:net'; +import assert from 'node:assert/strict'; +import { randomUUID } from 'node:crypto'; +import { _electron } from 'playwright'; +import { fixture, until } from '../tests/helpers.mjs'; +import { beginPlanTask, completeRead } from '../tests/fixtures/task-plan-fixture.mjs'; +import { HostController } from '../src/core/desktop/host-controller.mjs'; +import { desktopExecutableIdentity } from '../src/core/desktop/app-installation.mjs'; +import { projectEnvironment } from '../src/core/process-environment.mjs'; + +const root = path.resolve('.qa/requirements-progress', 'electron-' + randomUUID()); fs.mkdirSync(root, { recursive: true }); +const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t); +beginPlanTask(f, '解释当前工程依据,保留用户原文和原读取。'); completeRead(f); f.session.title = 'Electron要求证据原任务'; f.store.save(f.session); f.store.close(); +const socket = net.createServer(); await new Promise(resolve => socket.listen(0, '127.0.0.1', resolve)); const port = socket.address().port; await new Promise(resolve => socket.close(resolve)); +assert.notEqual(port, 4318); +const controller = new HostController({ appRoot: process.cwd(), dataRoot: f.data, port, nodePath: process.execPath, timeoutMs: 60000 }); +const passed = [], errors = [], screenshots = []; let application, result; +const mark = name => { passed.push(name); console.log('PASS ' + name); }; +try { + await controller.start(); assert.equal((await controller.api('/bootstrap')).config.hasKey, false); + const executable = desktopExecutableIdentity(process.cwd()).path; + application = await _electron.launch({ executablePath: executable, + args: [...(executable.toLowerCase().endsWith('agentworkbench.exe') ? [] : [path.resolve('dist-desktop/main.cjs')]), '--app-root', process.cwd(), '--data-root', f.data, '--node', process.execPath, '--port', String(port), '--hidden-window'], + cwd: process.cwd(), env: projectEnvironment(), timeout: 60000 }); + const page = await application.firstWindow(); page.on('pageerror', error => errors.push(error.message)); + const window = await application.browserWindow(page); await window.evaluate(win => win.setSize(1440, 1080)); + await page.locator('.connection.connected').waitFor(); assert.equal(await page.evaluate(() => typeof window.process), 'undefined'); + await page.getByLabel('当前项目').selectOption(f.project.id); await page.locator('.session-list button').filter({ hasText: f.session.title }).click(); + await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); + const panel = page.getByLabel('要求与证据', { exact: true }); await until(() => panel.getByRole('button', { name: '记录要求', exact: true }).isEnabled()); + await panel.getByRole('button', { name: '记录要求', exact: true }).click(); + const editor = page.getByRole('dialog', { name: '记录用户要求', exact: true }); + await editor.getByLabel('要求名称', { exact: true }).fill('原生窗口核对工程说明'); await editor.getByLabel('要求验收条件', { exact: true }).fill('实际读取当前文件,保留原来源'); + await editor.getByRole('button', { name: '保存要求', exact: true }).click(); await editor.waitFor({ state: 'hidden' }); mark('sandboxed actual Electron saves a sourced requirement'); + const row = panel.locator('.requirement-list > li').first(); await row.getByRole('combobox').selectOption({ index: 1 }); + await row.getByRole('button', { name: '复核所选证据', exact: true }).click(); await until(async () => (await row.locator('.requirement-state').textContent()) === '所选证据已核对'); + mark('actual Electron verifies the original tool result'); + await page.reload(); await page.locator('.connection.connected').waitFor(); + if (!await panel.isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); + await until(async () => (await row.locator('.requirement-state').textContent()) === '所选证据已核对'); + await window.evaluate(win => { win.showInactive(); win.setContentSize(1440, 1080); }); + await until(() => page.evaluate(() => innerWidth === 1440)); + await panel.scrollIntoViewIfNeeded(); const screenshot = path.join(root, 'verified.png'); await page.screenshot({ path: screenshot }); screenshots.push(screenshot); + mark('renderer reload restores the same Task and requirement proof'); assert.deepEqual(errors, []); + result = { success: true, passed, errors, screenshots, actualElectron: true, installationValidated: false, realModelRequests: 0, officialServiceTouched: false }; +} catch (error) { result = { success: false, passed, errors, screenshots, error: error.stack, realModelRequests: 0 }; } +finally { + if (application) await application.close(); if (await controller.health()) await controller.stop(); + for (const dispose of disposers.reverse()) await dispose(); + fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2)); +} +console.log(JSON.stringify({ root, ...result })); if (!result.success) process.exitCode = 1; diff --git a/docs/requirements-review-a-evidence/source/scripts/verify-requirements-ui.mjs b/docs/requirements-review-a-evidence/source/scripts/verify-requirements-ui.mjs new file mode 100644 index 00000000..5e7ed75b --- /dev/null +++ b/docs/requirements-review-a-evidence/source/scripts/verify-requirements-ui.mjs @@ -0,0 +1,84 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import assert from 'node:assert/strict'; +import { randomUUID } from 'node:crypto'; +import { chromium } from 'playwright'; +import { fixture, launchWorkbench, until } from '../tests/helpers.mjs'; +import { beginPlanTask, completeRead } from '../tests/fixtures/task-plan-fixture.mjs'; + +const directory = path.resolve('.qa/requirements-progress', 'ui-' + randomUUID()); fs.mkdirSync(directory, { recursive: true }); +const disposers = [], t = { after: fn => disposers.push(fn) }, f = fixture(t); +beginPlanTask(f, '研究现有README.md,说明原工程依据,不修改参考文件。'); const read = completeRead(f); +f.session.title = '要求复核原工程'; f.store.save(f.session); +const other = f.store.createSession(f.project.id), originalSession = f.session; f.session = other; beginPlanTask(f, '另一个独立研究目标'); +other.title = '另一任务的独立目标'; f.store.save(other); f.session = originalSession; f.store.close(); +const host = await launchWorkbench(t, f.data); assert.notEqual(new URL(host.url).port, '4318'); assert.equal(host.bootstrap.config.hasKey, false); +const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1080 } }); +const passed = [], screenshots = [], errors = []; +page.on('pageerror', error => errors.push(error.message)); +const panel = () => page.getByLabel('要求与证据', { exact: true }), row = () => panel().locator('.requirement-list > li').first(); +const mark = name => { passed.push(name); console.log('PASS ' + name); }; +const shot = async name => { const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, scale: 'css' }); screenshots.push(file); }; +async function select(session) { + if (!await page.getByLabel('当前项目').isVisible()) await page.getByRole('button', { name: '展开项目栏', exact: true }).click(); + await page.getByLabel('当前项目').selectOption(f.project.id); + await page.locator('.session-list button').filter({ hasText: session.title }).click(); + if (!await panel().isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); + await panel().getByRole('button', { name: '记录要求', exact: true }).waitFor(); + await until(async () => await panel().getByRole('button', { name: '记录要求', exact: true }).isEnabled()); +} +async function verify() { + await row().getByRole('combobox').selectOption(read.id); + await row().getByRole('button', { name: '复核所选证据', exact: true }).click(); + await until(async () => (await row().locator('.requirement-state').textContent()) === '所选证据已核对'); +} +let result; +try { + await page.goto(host.url); await select(f.session); + await panel().getByRole('button', { name: '记录要求', exact: true }).click(); + const editor = page.getByRole('dialog', { name: '记录用户要求', exact: true }); + await editor.getByLabel('要求名称', { exact: true }).fill('解释当前工程的实际依据'); + await editor.getByLabel('要求验收条件', { exact: true }).fill('保留README原读取和可核对结论,参考文件保持原字节'); + await editor.getByRole('button', { name: '保存要求', exact: true }).click(); await editor.waitFor({ state: 'hidden' }); + assert.equal(await row().locator('.requirement-state').textContent(), '待复核'); mark('manual source selection creates pending requirement, never automatic acceptance'); + await verify(); mark('actual original read proof verified through UI'); + await panel().scrollIntoViewIfNeeded(); await shot('desktop-verified'); + await page.reload(); await select(f.session); await until(async () => (await row().locator('.requirement-state').textContent()) === '所选证据已核对'); + mark('saved requirement and proof survive page refresh'); + await row().getByRole('button', { name: '修订此要求', exact: true }).click(); + await editor.getByLabel('要求验收条件', { exact: true }).fill('追加核对当前说明,旧复核记录保留'); + await editor.getByRole('button', { name: '保存要求', exact: true }).click(); await editor.waitFor({ state: 'hidden' }); + await until(async () => (await row().locator('.requirement-state').textContent()) === '待复核'); + assert.match(await panel().textContent(), /原复核历史.*1 条/s); mark('requirement revision invalidates its proof and preserves original history'); + await verify(); + const file = path.join(f.projectRoot, 'README.md'), original = fs.readFileSync(file); fs.appendFileSync(file, '\nChanged externally in owned fixture\n'); + await panel().getByRole('button', { name: '刷新复核', exact: true }).click(); + await until(async () => (await row().locator('.requirement-state').textContent()) === '依据已失效'); + await row().getByRole('button', { name: '复核所选证据', exact: true }).click(); + await until(async () => (await panel().textContent()).includes('原读取对应旧文件SHA')); + await panel().scrollIntoViewIfNeeded(); await shot('desktop-stale'); mark('source mutation and stale original read are visible failures with preserved history'); + fs.writeFileSync(file, original); + await page.setViewportSize({ width: 390, height: 844 }); + if (!await panel().isVisible()) await page.getByRole('button', { name: '查看任务记录', exact: true }).click(); + await panel().scrollIntoViewIfNeeded(); await shot('narrow-stale'); + assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true); mark('390px viewport keeps requirement controls usable without page overflow'); + await page.setViewportSize({ width: 1440, height: 1080 }); + let release = null, held = false; + await page.route('**/requirements?taskId=' + f.session.taskId, async route => { + held = true; await new Promise(resolve => { release = resolve; }); + try { await route.continue(); } catch (error) { if (!/Route is already handled|Invalid InterceptionId/.test(error.message)) errors.push(error.message); } + }); + await panel().getByRole('button', { name: '刷新复核', exact: true }).click(); await until(() => held); + await select(other); release(); await page.unroute('**/requirements?taskId=' + f.session.taskId); + await until(async () => (await panel().textContent()).includes('尚未逐项记录要求')); + assert.ok(!(await panel().textContent()).includes('解释当前工程的实际依据')); mark('late response for original Task cannot replace the newly selected task'); + assert.deepEqual(errors, []); + const requirements = await host.api('/sessions/' + f.session.id + '/requirements?taskId=' + f.session.taskId); + result = { success: true, passed, screenshots, errors, requirements, realModelRequests: 0, officialServiceTouched: false, companionWritePermissionsAdded: false }; +} catch (error) { + await shot('failure').catch(() => {}); result = { success: false, passed, screenshots, errors, error: error.stack, realModelRequests: 0 }; +} finally { + await browser.close(); for (const dispose of disposers.reverse()) await dispose(); + fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2)); +} +console.log(JSON.stringify({ directory, ...result, requirements: undefined })); if (!result.success) process.exitCode = 1; diff --git a/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.css b/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.css new file mode 100644 index 00000000..ab6fc8bb --- /dev/null +++ b/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.css @@ -0,0 +1,19 @@ +.requirement-list { list-style: none; padding: 0; margin: 0; } +.requirement-list > li { padding: 14px 0; border-top: 1px solid #dce7e2; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; } +.requirement-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; } +.requirement-heading strong { font-size: 13px; } +.requirement-state { color: #674917; background: #fbf2df; padding: 2px 6px; border-radius: 3px; flex-shrink: 0; font-size: 11px; } +.requirement-evidence_verified, .requirement-user_confirmed { color: #154b4a; background: #edf3f1; } +.requirement-list summary, .requirement-history summary { cursor: pointer; color: #526a70; } +.requirement-list blockquote, .requirement-quote { margin: 9px 0; border-left: 2px solid #bbcfc7; padding: 6px 12px; white-space: pre-wrap; font-size: 12px; max-height: 150px; overflow: auto; } +.requirement-list code { font-size: 10px; overflow-wrap: anywhere; } +.requirement-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 7px 0; } +.requirement-confirm label { display: grid; gap: 6px; } +.requirement-confirm textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px; border: 1px solid #cbded3; border-radius: 5px; margin-bottom: 8px; } +.requirement-history { font-size: 11px; margin-top: 12px; } +.requirement-history p { display: grid; gap: 4px; } +.requirement-editor { max-height: 72vh; overflow: auto; } +.requirement-offsets { display: flex; gap: 12px; margin: 12px 0; } +.requirement-offsets label { min-width: 0; font-size: 12px; } +.requirement-panel button:focus-visible, .requirement-panel textarea:focus-visible, .requirement-editor :is(input, select, textarea):focus-visible { outline: 2px solid #4664d9; outline-offset: 2px; } +@media (max-width: 600px) { .requirement-heading { flex-direction: column; gap: 4px; } .requirement-panel .button { min-height: 36px; } } diff --git a/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.tsx b/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.tsx new file mode 100644 index 00000000..03b14ab7 --- /dev/null +++ b/docs/requirements-review-a-evidence/source/src/client/RequirementPanel.tsx @@ -0,0 +1,102 @@ +import { useEffect, useRef, useState } from 'react'; +import { Check, FileText, Plus, RefreshCw } from 'lucide-react'; +import { api } from './api'; +import { Modal } from './components'; +import type { RequirementItem, RequirementView, Session, TaskPlanStep } from './types'; +import './RequirementPanel.css'; + +const states: Record = { pending: '待复核', failed: '复核未通过', stale: '依据已失效', unverified: '原记录待核对', + evidence_verified: '所选证据已核对', user_confirmed: '用户已确认', not_requested: '按约定未执行' }; +const kinds: Record = { analysis: '研究与读取', changes: '已应用改动', results: '当前文件', checks: '工程检查', browser: '页面断言' }; +const clean = (row: RequirementItem) => ({ key: row.key, title: row.title, criterion: row.criterion, kind: row.kind, method: row.method, + source: { kind: row.source.kind, id: row.source.id, start: row.source.start, end: row.source.end }, + ...(row.kind === 'analysis' ? { tools: row.tools } : ['changes', 'results'].includes(row.kind) ? { paths: row.paths } + : row.kind === 'checks' ? { checks: row.checks } : { viewport_width: row.viewport_width, actions: row.actions }) }); +const scope = (kind: TaskPlanStep['kind']) => kind === 'analysis' ? { tools: ['read_file'] } : ['changes', 'results'].includes(kind) + ? { paths: [] } : kind === 'checks' ? { checks: ['test', 'build'] } : { viewport_width: 1280, actions: ['assert_visible'] }; + +export function RequirementPanel({ session, busy, onSession, onError, openArtifact }: { + session: Session; busy: boolean; onSession: (value: Session) => void; onError: (error: unknown) => void; openArtifact: (id: string) => void; +}) { + const task = session.execution?.task, run = session.execution?.run; + const identity = `${session.projectId}/${session.id}/${task?.id}/${run?.id}`; + const selected = useRef(identity); selected.current = identity; + const generation = useRef(0), mutation = useRef(false); + const [view, setView] = useState(null), [loading, setLoading] = useState(false), [saving, setSaving] = useState(false); + const [draft, setDraft] = useState(null), [picked, setPicked] = useState>({}), [notes, setNotes] = useState>({}); + const [notice, setNotice] = useState(''); + const disabled = busy || saving || ['running', 'awaiting_approval', 'stopping'].includes(session.status); + useEffect(() => { generation.current++; setView(null); setDraft(null); setPicked({}); setNotes({}); setNotice(''); setSaving(false); mutation.current = false; + return () => { generation.current++; }; }, [identity]); + useEffect(() => { const timer = setTimeout(() => { void load(); }, 120); return () => clearTimeout(timer); }, [identity, session.revision, session.status]); + async function load() { + if (!task || mutation.current) return; + const scopeId = identity, request = ++generation.current; setLoading(true); + try { const result = await api(`/sessions/${session.id}/requirements?taskId=${task.id}`); + if (selected.current === scopeId && generation.current === request) setView(result); + } catch (error) { if (selected.current === scopeId && generation.current === request) onError(error); } + finally { if (selected.current === scopeId && generation.current === request) setLoading(false); } + } + async function mutate(action: string, input: object) { + if (!task || !run || !view || mutation.current) return; + mutation.current = true; generation.current++; setSaving(true); setNotice(''); const scopeId = identity; + try { + const reply = await api<{ session: Session; requirements: RequirementView; verification?: { status: string; message?: string } }>(`/sessions/${session.id}/${action}`, + { taskId: task.id, runId: run.id, expected_revision: view.revision, ...input }); + if (selected.current !== scopeId) return; + setView(reply.requirements); onSession(reply.session); + setNotice(reply.verification?.status === 'error' ? reply.verification.message ?? '复核未通过,原失败已保留。' : action === 'requirements' ? '要求与原文来源已保存。' : '本次复核已记录。'); + if (action === 'requirements') setDraft(null); + } catch (error) { if (selected.current === scopeId) onError(error); } + finally { if (selected.current === scopeId) { mutation.current = false; setSaving(false); setLoading(false); } } + } + function edit(row?: RequirementItem) { + const source = view?.sources[0]; if (!source) return; + setDraft(row ? { ...clean(row), depends_on: [] } : { key: 'req_' + crypto.randomUUID().slice(0, 8), title: '', criterion: '', kind: 'analysis', method: 'evidence', + source: { kind: source.kind, id: source.id, start: 0, end: source.text.length }, depends_on: [], ...scope('analysis') }); + } + const source = view?.sources.find(row => row.id === draft?.source.id && row.kind === draft?.source.kind); + return
+

要求与证据

{view?.items.length ?? 0} 项
+

逐项保留用户原文与实际依据,工程证据和用户体验分别记录。

+
+
+ {notice &&

{notice}

} + {view?.error &&

{view.error}

} + {!!view?.unreviewed_sources?.length &&

有 {view.unreviewed_sources.length} 份用户来源尚未审阅。核对原目标和追加要求后保存要求;旧复核记录保留。

} + {view && !view.items.length &&

尚未逐项记录要求。模型的完成答复保留在原会话中。

} +
    {view?.items.map(row =>
  1. +
    {row.title}{states[row.status ?? 'pending'] ?? row.status}
    +

    {row.criterion}

    +
    用户原文 · {row.source.kind === 'goal' ? '原目标' : '追加要求'} · 要求修订 {row.revision} +
    {row.source.quote}
    {row.source.id} [{row.source.start}, {row.source.end})
    + {row.error &&

    {row.error}

    }{row.last_rejection &&

    原复核失败:{row.last_rejection.message}

    } + {row.user_note &&

    用户确认:{row.user_note}

    } +
    + {row.proof_artifact_id && }
    + {row.method === 'evidence' &&
    +
    } + {row.method === 'user' &&