feat: seal isolated worker recovery, parent integration and review console
This commit is contained in:
+3
-2
@@ -5,5 +5,6 @@
|
||||
*.jpg binary
|
||||
*.ico binary
|
||||
tests/fixtures/legacy-workbench-0.1/dist-server/server.mjs binary
|
||||
docs/workers-*.tap -text
|
||||
docs/workers-*.log -text
|
||||
docs/workers-*.tap binary
|
||||
docs/workers-*.log binary
|
||||
docs/workers-*-log.txt binary
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Agent Workbench 界面方向
|
||||
|
||||
以下为当前1.11纸白/海松界面的已实现基线。用户要求增强专业感和稳定性后,1.12采用工程控制台方向;具体布局、状态语义、颜色/字体、桌面/窄屏验收见[下一阶段设计与执行方案](docs/PLAN-1.12.md)。该方案尚未替换当前已部署样式,实施时继续核对真实交互与证据归属。
|
||||
当前正式1.12.1已采用工程控制台方向,模型中心的布局、状态语义、颜色/字体和桌面/窄屏验收见[1.12设计与执行方案](docs/PLAN-1.12.md)。1.13隔离协作沿用白/浅蓝、深蓝文字、蓝色操作和细边框,新增固定父目标与两个真实执行通道;实施与验收见[1.13方案](docs/PLAN-1.13.md)。以下保留1.11纸白/海松界面的历史设计基线,不作为当前部署状态。
|
||||
|
||||
面向在 Windows 本机开发、研究与维护项目的人。界面的核心工作是把任务、依据、工具执行和待审查改动放在同一个可操作空间。
|
||||
|
||||
|
||||
+11
-1
@@ -10,4 +10,14 @@
|
||||
|
||||
原TAP见worker-core-first、worker-core-diagnosis、worker-core-ownership-fix、worker-core-output-diagnosis、worker-core-final、worker-core-regression;前四份是原失败/诊断,不能登记为最终通过。核心使用自有声明模型夹具,真实执行Git、文件审查应用和npm检查,真实模型请求为0。
|
||||
|
||||
待完成:父成果/冲突/合并审查、停止与崩溃专项、HTTP与控制台实际验收、三个本地工程样本、完整独立源码/便携与保留正式状态发行。
|
||||
## 切片二:停止恢复、父成果审查与控制台
|
||||
|
||||
父归集复核原成果、当前源码/索引/HEAD/检查原日志与提案链,重叠及父已有修改显示具体冲突。父Task生成新的封存批次,应用前重新核对来源,应用后必须父工程真实检查与本地Git交付;中断封存按原绑定恢复。
|
||||
|
||||
停止等待所属请求及检查进程,迟到/未报告响应保留累计用量;续接不重置token、步数、工具次数和原总时限。部分创建、未知写入及宿主崩溃先核对原输入/SHA和现场,再显式继续或保留现场结束;历史unknown和原工件保留,不补造完成结果。Windows按原创建身份记录和核对进程树,仍存活时拒绝解除核对,恢复不会根据历史PID自动终止进程。
|
||||
|
||||
最新整合原轮64/65,唯一失败是QA清理漏掉快照后新生后代,产品正确拒绝存活PID;修正自有夹具清理并等待结束后,真实宿主崩溃专项1/1通过。未将两轮拼成65/65。原失败TAP和成功专项分别保留,最终独立源码完整回归仍待验。
|
||||
|
||||
控制台第三轮桌面/390px完整10节点通过,0页面异常/请求失败;计划、独立工作区、子审批/真实检查、父批次/检查/Git、具体冲突、停止、迟到历史错误隔离和原证据核对/保留现场均已操作。原目录workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236;前两次验收器文案/异步弹窗等待失败保留,不改写结果。桌面截图已目视检查。
|
||||
|
||||
待完成:三个有明确功能断言的本地工程样本、统一1.13版本、完整UI/独立源码/便携与保留正式状态发行。真实模型请求仍为0,不将自有Provider夹具视为真实模型语义验收。
|
||||
|
||||
@@ -0,0 +1,709 @@
|
||||
{
|
||||
"passed": true,
|
||||
"version": "1.12.1",
|
||||
"capabilityStage": "1.13 isolated workers",
|
||||
"evidenceKind": "owned fixture and real local tools/UI",
|
||||
"realModelRequests": 0,
|
||||
"assertions": [
|
||||
"desktop/390px editor seals the actual parent goal, two scopes and shared budget without model calls or source writes",
|
||||
"explicit workspace confirmation creates two distinct Git checkouts and keeps every original source/staging byte",
|
||||
"each lane navigates to its original child task, hides unsupported actions and applies only an explicitly reviewed child batch",
|
||||
"both UI approvals run real three-test/build checks and collect the original hashed outputs before any parent write",
|
||||
"parent UI review applies a new two-file batch and accepts completion only after a fresh real parent check and local Git delivery",
|
||||
"390px conflict review names the real overlapping path, leaves parent files untouched and explicitly retains the original child results",
|
||||
"mobile parent stop waits for both held requests, preserves estimated unknown usage and retains the original deadline",
|
||||
"switching historical groups quarantines a deliberately late previous-group error and its preview",
|
||||
"recovery UI requires reading the original record and rejects changed source instead of acknowledging stale evidence",
|
||||
"explicit recovery retention preserves changed owner source and unknown usage, closes the original goal and unlocks the next plan"
|
||||
],
|
||||
"screenshots": [
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\mobile-worker-plan.png",
|
||||
"sha256": "d36ab1b1d2d5e50e05e3ac582721abf854df95cd5cc9f7b2b5d7c0a19b34c899"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\desktop-workers-collected.png",
|
||||
"sha256": "f5fe929806706ade9d64383b5b3a652e29d7772ffc32663e6bd0fc7c6ec08edd"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\mobile-workers-conflict.png",
|
||||
"sha256": "bb4840a29fb5a8281df4e6ab28120cf704a001d10d982c8e889863c0cb6ab95e"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\mobile-workers-recovery-retained.png",
|
||||
"sha256": "6757bbaf88ec5b0326734960db9812f412c07c4fd7ff14b9aa9dbc0a7d928ae0"
|
||||
}
|
||||
],
|
||||
"exports": [
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-e26c7506-80a7-49fc-bf49-c3cb21757b1e-after-5165158e-b40b-481d-abd3-c58df9754eb3.json",
|
||||
"sha256": "c9c2e8017a42fc6f46f4ac0c578145c082119fe1796ded4fca90ff69009c9fc9"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-5d3493b9-9836-488f-b063-4e18397f8e9b-after-5165158e-b40b-481d-abd3-c58df9754eb3.json",
|
||||
"sha256": "9ca88cc0094ab4802156c2cc538481e71db374c58c13561393be91d6ea058807"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-29824c41-3400-428e-abb3-21b9ab397252-after-5165158e-b40b-481d-abd3-c58df9754eb3.json",
|
||||
"sha256": "0f93785e01a32622c0f8bc40040233a992becb08f68c9f6d1cf52a702403c470"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-e26c7506-80a7-49fc-bf49-c3cb21757b1e-after-1f45b734-a633-4913-8c93-27211a84d56d.json",
|
||||
"sha256": "459a72adc4935d3a89b50f1612f20dab3168696327e8be45a23b6491d6b7c72f"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-1f7b6bdb-0cf8-4ac1-ba10-002cc30108bf-after-1f45b734-a633-4913-8c93-27211a84d56d.json",
|
||||
"sha256": "aac7af429b50580beee2cc25295f8973674a56f6b0d47bcee54c441b5d102813"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-e9c6d534-b439-453a-8165-c02c078a99d7-after-1f45b734-a633-4913-8c93-27211a84d56d.json",
|
||||
"sha256": "e7c79013665400863b65922d6fafb015b0cb3d382503f021213e20da1602bbd4"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-e26c7506-80a7-49fc-bf49-c3cb21757b1e-after-1a9f6fe7-8552-4744-a17c-04228b1c9d5f.json",
|
||||
"sha256": "e721107754df6727c697fd69f106a47ab0f0d3a803e5ea7a4395544f380a4bdd"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-27f4d89c-ee1e-4c93-8aa1-98bb73adabce-after-1a9f6fe7-8552-4744-a17c-04228b1c9d5f.json",
|
||||
"sha256": "f6014a0ce53aa718bdc3bb0497b6a1ef44d3dc6c48f50a1b295bc1e72b98af66"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\session-bef1597c-e2c8-4a0f-953b-9a55bb865e58-after-1a9f6fe7-8552-4744-a17c-04228b1c9d5f.json",
|
||||
"sha256": "0d023b06341aca0806d82b7627907052538c3ae0a3e9120969d81f23fdfd1b24"
|
||||
}
|
||||
],
|
||||
"groups": [
|
||||
"5165158e-b40b-481d-abd3-c58df9754eb3",
|
||||
"1f45b734-a633-4913-8c93-27211a84d56d",
|
||||
"1a9f6fe7-8552-4744-a17c-04228b1c9d5f"
|
||||
],
|
||||
"fixtureRequests": 22,
|
||||
"inputs": [
|
||||
{
|
||||
"path": "dist-client\\assets\\index-Ck6k2AkM.css",
|
||||
"sha256": "c434c3913fa7e301581d954f27658819e87a18d814d7a9015266ee5d41f072a9"
|
||||
},
|
||||
{
|
||||
"path": "dist-client\\assets\\index-Cxe0yWpO.js",
|
||||
"sha256": "c14f53d014c211383020f5317096535bb3f8f57c03e3a5e5959e8403629b8a82"
|
||||
},
|
||||
{
|
||||
"path": "dist-client\\favicon.svg",
|
||||
"sha256": "538fa42445dfd8e78135717e2f30dada6d790d5c05b9011ae7a9bf80d416ae1d"
|
||||
},
|
||||
{
|
||||
"path": "dist-client\\index.html",
|
||||
"sha256": "9011ae0394b0901370c8e797780829f333a663d0c7238942bfdb441b6cbcd36c"
|
||||
},
|
||||
{
|
||||
"path": "dist-server\\hot-upgrade.mjs",
|
||||
"sha256": "afa4e20e711732a252c59f7f95b4c439ae5bf7679a2a7b2577b4c4c9af549b70"
|
||||
},
|
||||
{
|
||||
"path": "dist-server\\server.mjs",
|
||||
"sha256": "4ecb32874954c1a6e63b436a143a68798a0808941b3d8122f43d43a746e8e8a5"
|
||||
},
|
||||
{
|
||||
"path": "package-lock.json",
|
||||
"sha256": "89318a78d080b8d5b4a2a4d9188e687f0b42620c0ac6451b6cfc908b7aeb051b"
|
||||
},
|
||||
{
|
||||
"path": "package.json",
|
||||
"sha256": "3d89c54106223fcb89c1a9fd98e5755ee0f06fcb018128ed18570093a15b3144"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\Start-Workbench.ps1",
|
||||
"sha256": "36d8ab194974369afa47ff717e60cad763432ee1f1abb6ccc4e6b1b6b11da253"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\Stop-Workbench.ps1",
|
||||
"sha256": "f6d12d32006c17fcb20192a73b762592f900ddfcda0cabda6f202e37405d1331"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\build-server.mjs",
|
||||
"sha256": "67e4ae3f5bd9214bfbf2596e3fb9c2af465ec7364293d37da07c7810c789d15e"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\bundle-browser.mjs",
|
||||
"sha256": "c9bd500e469d5aa60a69a35d5863a5f2d56b336cbd8f2d5268b5e05f0687d23b"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\bundle-rea.mjs",
|
||||
"sha256": "90fbc4af57eb2e92d4d92de5be5ac26eb8c99f132efdafe8f3e133ec1db7ffbe"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\engine-fixtures.mjs",
|
||||
"sha256": "8ca536f1a6f4edb6a03b0508e6f175879eeb39a835149f4f6c8ba806e07266e8"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\inspect-ui.mjs",
|
||||
"sha256": "81a6e6f96aae44b60c9f382e53d54f673868b3705a4c3eb1d0107c11ff790b88"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\live-react-client.mjs",
|
||||
"sha256": "6c01ae7b2be7e2b82831c718e72bebe353bab864f97373ed95c5d478ac28b32b"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\package.mjs",
|
||||
"sha256": "22ffb0a5dc23d654ac4bf6e9d261fc6dd034d4f17a402b5a5356bc08f24365b2"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\python-check-runner.py",
|
||||
"sha256": "17bd6fd64ad93b8f806e0f5d325e75fd4534c065f4fcb597ad45fb9152caf657"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\qa-evidence.mjs",
|
||||
"sha256": "d887eb11f5e0a4f64540db1bcb693d2b2adbdbd97ed8f7a0abfb46be1ad544e2"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\qa-python-requirements.txt",
|
||||
"sha256": "bf4dc0555928a3facf67b3370001388d4b65e69a071c339f8b201310bde4486a"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\research-fixtures.mjs",
|
||||
"sha256": "ba1f5644045ddba894a787cc4d9fa85c9a7e00730e3ea2e9b18d594a43498a8c"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\tune-styles.mjs",
|
||||
"sha256": "8909eaaff060753745d7d6945377689ca531d784390cdd7d84acf97551d7b1c0"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\upgrade-running.mjs",
|
||||
"sha256": "fd3d8e026b2b135ad6b145a4235918385511e0d8d6f58a8fdd059d686098e943"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-all-ui.mjs",
|
||||
"sha256": "681e94b0457b3035e3972de70e555055efd469eeaf0ce7884f39f427bafdceda"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-archives.py",
|
||||
"sha256": "66e5d6b31e04e4c143bf73860635f0da2ea1f707822ca638bc4197a397ca4dde"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-browser-ui.mjs",
|
||||
"sha256": "c4a99fcf45fc0e1d39024937d481119965349c486422a14b3084264539c4157a"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-browser.mjs",
|
||||
"sha256": "8ccbe961ce26363079fc8ea30559e57ee78f88926b438e1004d5b3528beacb76"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-change-sets-ui.mjs",
|
||||
"sha256": "87c60f25d2d4c226fecd35c253a68368a3c53e33aa2b8b332c72760490705866"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-context-ui.mjs",
|
||||
"sha256": "f78fed61f844edaa674db9c768247a45b7eb434fe94b1b29b3a5e3798922272a"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-delivery-ui.mjs",
|
||||
"sha256": "eae0e07b901f0a3da4d595bbc8e214e032d7da45d7d8ea033c034ad45dc34c3d"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-diagnostics-ui.mjs",
|
||||
"sha256": "476d284fc1b8c086f8d7f44013a44d200ec5b5df2d8b58e52caaedd46e569ab0"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-engines-ui.mjs",
|
||||
"sha256": "b1ae2b6274d2584ba190faa1818f53f1bc775430f9140cb68ca77d9952756f2e"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-engines.mjs",
|
||||
"sha256": "c1f0d9949230527cc4933a90e64a68053ef8bc040b14384119998a5a2f223b4d"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-execution-ui.mjs",
|
||||
"sha256": "f78149dda36baea05cd1f7c36dab0301e3c1c94df70cefb1bb12f51313d383be"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-index-ui.mjs",
|
||||
"sha256": "04f1b925aff59f06583325d18e69a6160bfae98e87254b3ee2e6fd0dabccdbfb"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-browser.mjs",
|
||||
"sha256": "b1bb7e3ac8ac6c1abec0c90b996bbde0a335e87acb956a05918fc31245ee0b33"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-delivery.mjs",
|
||||
"sha256": "4c45acd05841ddf2a6e0a04ee1d0a9f4c003e34d794318bfe3892a29d474117e"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-engineering.mjs",
|
||||
"sha256": "2e42a1347069c56beb4022627f760a2088751d4f0829606b49d2edd0833d934c"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-model.mjs",
|
||||
"sha256": "848495e2488125eb5e79c9d8b121025f9f740551535dc8529b415b4246da455b"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-session.mjs",
|
||||
"sha256": "f71f22f2355d499afa501f9ba37a04f8b8cf5d404fdfe95b65cc1d324775ac9b"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-live-task-plans.mjs",
|
||||
"sha256": "577fc325a6b13f7cd21fb8b1ab96f8940afe94e65bffa74046b47af572b1c510"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-mcp-recovery-ui.mjs",
|
||||
"sha256": "b11e321e0d92efb57d8e76b612c053e6a0229f0f3641721c606a28a61fe12a18"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-mcp-ui.mjs",
|
||||
"sha256": "c3c93d4ea8109dce1bfb4c91bf3a8b11dc2c7bbee3986c55ed2a4fcde0446d34"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-model-center-ui.mjs",
|
||||
"sha256": "d4c13f9e328172f973143f7333cdc4f5627c7d33f188f59a6588c1cbd1f8745a"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-project-memory-ui.mjs",
|
||||
"sha256": "b197345800d805ca3e52094ea660f8eb8d4d90defde2c49dc1a17a4b97270bdb"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-python-ui.mjs",
|
||||
"sha256": "676e4222a25ca68ed5bbb6661b9f7ec5eac4abaa9de70d9a5eb07a3429ba2457"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-rea.mjs",
|
||||
"sha256": "cdca5f73ee9f5b2b1fc4cd58ce98a7c0fcd551164879ae3192d67edd8e69491d"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-react-delivery.mjs",
|
||||
"sha256": "51a6c000d6ff148204d500b8505e2f7589f55a68947b9eabd4097ed0e477d118"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-release.mjs",
|
||||
"sha256": "480d101518119dc1dda7bc4e520b60079d583212d07626a49c11ffa8279ebcef"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-research-ui.mjs",
|
||||
"sha256": "0844a6d22e843123afc0d133302096a08c35b9cb7d9dd3bafacf85a2a50b260d"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-skills-ui.mjs",
|
||||
"sha256": "2139b2caa764c17752edb13f8cc43e0d4643e9c0d4d47c34e6c95b0374efd974"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-source-package.mjs",
|
||||
"sha256": "0ed25b24eff2f95fa6c890b22ad72c6b7318bb8e80b1c46993036f0a7bc50ff0"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-task-checkpoints-ui.mjs",
|
||||
"sha256": "2af7d9abf21b2a13a618ed080e324f61c21a42a386d09c5bd62c7bdf70ec5de2"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-task-plans-ui.mjs",
|
||||
"sha256": "7a0d5a0c5c59040bd203c65453a0ff9c6282e9bd46c14b573a67a59a8920a5fa"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-tests.mjs",
|
||||
"sha256": "3e9140831477df004d39187e240ce8e27e8680d051a9353dc6b9b17de81994f4"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-ui.mjs",
|
||||
"sha256": "d9e7b3e8eb0ff80168acfd5d320685db6d4e1f53827cac4b96cffd5e54c758b6"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-workers-ui.mjs",
|
||||
"sha256": "0630855581368c708ad71489449d440798e13fbc7a6ec4235770fb7d584b7b0d"
|
||||
},
|
||||
{
|
||||
"path": "scripts\\verify-workspaces-ui.mjs",
|
||||
"sha256": "fdf5900e0936b681d030f18a7a5245beacf8ab091b79a495ca823df65e8bb4a7"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\App.tsx",
|
||||
"sha256": "8f3fc2b126e2507c1fb9ce61075c8b407d23c0854832d941fea5d53f138d28f1"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\BrowserPanel.css",
|
||||
"sha256": "3032abddc1cfeea3100cb4b34bb2e9e25e965f470c4fd38c73d564dfc80f3450"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\BrowserPanel.tsx",
|
||||
"sha256": "24a7479a2740ac72de22dadb556565904fb4525117cddc2a08ab1b766437ce30"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ChangeSetPanel.css",
|
||||
"sha256": "c1ac9307b78e4e42159398e499074d85da395faf7c88f2f485c6b7901d142459"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ChangeSetPanel.tsx",
|
||||
"sha256": "b3a3b3e73bf74a23c08f74d124fe98c6b45e0c048d3fabb745fd488140d58f61"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ChangesInspector.tsx",
|
||||
"sha256": "5799507f52e1414ec573eb1d0452bb3c173728836d3c1644c760b31cab4a3ee4"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\CodeIndexPanel.css",
|
||||
"sha256": "76f6f2b32e25df3b3f4c8761273de4963b7b25dff01cbe97b2f5171ec8358286"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\CodeIndexPanel.tsx",
|
||||
"sha256": "2574080bbb0aa9ff05571ef406dadd3c008f792cf2443ff1f779f0975a6d97d4"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\DeliveryPanel.css",
|
||||
"sha256": "8c12813290c171b616ffb36c002395fc40ff2c7d5b63cd2f13613be435a2d3c6"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\DeliveryPanel.tsx",
|
||||
"sha256": "23a9c1519c6b94508f2cabaedd47ccf43f0cdae26d5f956d81b3c26f37f6d531"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\DiagnosticsPanel.tsx",
|
||||
"sha256": "a5746d019da37c99af60c69f556b007ea307e2f3a02fcde504b547ed468dd07f"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\EnginePanel.css",
|
||||
"sha256": "5a0fc3b6fab7038751f346cdd40e6b4540e8886c0f0c54478c09c18eeaeec1d3"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\EnginePanel.tsx",
|
||||
"sha256": "d36f3058ab8e0a5d327f68f6894d34fc4b1f721949c873e1356dcb28907a4e07"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\McpJobHistory.tsx",
|
||||
"sha256": "207ba78dce96c85dedf7ff34f7678dff1e925118fb93dd1d5a144f38c7aaf618"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\McpPanel.css",
|
||||
"sha256": "e1c89f3229acb0bb739fcf91e605d09f7d8f38f4f367da1f11835b2b9452538d"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\McpPanel.tsx",
|
||||
"sha256": "f1ea14216c4340f6cd76b267763a468bf0d311dd6f8b273afe3ee9cf6768a260"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ModelCenter.css",
|
||||
"sha256": "99f81bc87f634fa77bedd00247500b99314412db36574a58e6e382cca19f903f"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ModelCenter.tsx",
|
||||
"sha256": "bde2746b5e2d3595a5459dff3f6154c44d67853cc57bd8aa3c744428bac3823a"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ProjectMemory.css",
|
||||
"sha256": "0d6c9a23afafa77e7230edd9294299a3d233aa7b49c191d522ee9c106839a1f1"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ProjectMemoryPanel.tsx",
|
||||
"sha256": "b7c140f126bc2d48df00fe4111517e3ea2f43926d52797d26733e1f2522f6a03"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\RequestContextPanel.tsx",
|
||||
"sha256": "9b7bd92ff4afc6a8e4c1fd129dea053acb8b135330582643beef62608b737e79"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ResearchPanel.css",
|
||||
"sha256": "f24f8eb283c0b419037adcd680bc1bbe84002abf661bfda94891dcea5fc92682"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\ResearchPanel.tsx",
|
||||
"sha256": "cae237fc267a491db18f24f88e0b6926a635225886bfa58683a37f6d4586c8e1"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\SkillCenter.css",
|
||||
"sha256": "d9f79bba3be7369a0231434aa29fe061e0c5d1f792aeb7e15e3f2a7744165242"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\SkillCenter.tsx",
|
||||
"sha256": "b227ffdccf1d90ac969f1e4e2a56c592b7c9eac13746bf0c90ee9d9e702e9f10"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\TaskCheckpointPanel.tsx",
|
||||
"sha256": "77b552924379531eff51c81c5bf4e2512c1201f39641245c781a468e6a7e397a"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\TaskPanel.css",
|
||||
"sha256": "6dc737d84406fafd2f1b36ba1eaf02c8b0f59594b30a1fadcf2d3451ada285db"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\TaskPanel.tsx",
|
||||
"sha256": "cb781e0c81f4f24b822b4b7472bd4d14cc6591f78a96558f259bc0bd587cb3ec"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\TaskPlanPanel.css",
|
||||
"sha256": "e47eb1195a61400d60817de793893d9e4924f334bdf452ffb744ed69741c43fc"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\TaskPlanPanel.tsx",
|
||||
"sha256": "3ead0b021ae550b0bc3891b8e852c297f05f895ce3516f693a91d23456ebc1f1"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\WorkerPanel.css",
|
||||
"sha256": "d3015e518db15d8b70f222b01e2feaeecdbb1cb1778dd7f8704b8daac5f6d7f4"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\WorkerPanel.tsx",
|
||||
"sha256": "3400ab04a97117c95b8b8d97ffb6cf7d4c3081a64c8e77252c4992cf46af95d5"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\WorkspacePanel.css",
|
||||
"sha256": "d8c4558f6c559ff8b4bbc7723aca08e4e37f8fef8f5b8d5619faec8332314ba3"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\WorkspacePanel.tsx",
|
||||
"sha256": "c91d097edd5e044f72583bdccd39848f35a5b82c4d9abf7c09648e21ecfdb8c2"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\api.ts",
|
||||
"sha256": "6e706020502cc3e079ddc46f4f843571cfb883852fb7ea21bd2c3c9ff463d56c"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\components.tsx",
|
||||
"sha256": "7b735a151ceb1889702f3127a15a8a2918f6fba7140304c3b81b5662f1b43741"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\control-console.css",
|
||||
"sha256": "bbb0f00ff90ea4c8d0f969b4fa95df4e95413b97ab28a204a893a99671a10bc7"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\main.tsx",
|
||||
"sha256": "6dec6d76306f0e47b1a9e77004377daa5312270d519a685f169c025a9e071792"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\styles.css",
|
||||
"sha256": "2712f7bb0a0145a6945ea904ba95a1a189831fef40108bdc4300400cd4d20218"
|
||||
},
|
||||
{
|
||||
"path": "src\\client\\types.ts",
|
||||
"sha256": "1f911158c3b271f52e2ec77c7ec75f67ce8a3bb54211fd597d85190242159c2d"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\browser\\browser-driver.mjs",
|
||||
"sha256": "d63e3ae49bdec13f2f86923c21d4af4d7f1ea1b07c768be3cc85b4833836bdd2"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\browser\\browser-manager.mjs",
|
||||
"sha256": "0efc0e30f19a8649c964e1193c455d6cc6f32bfd4a4a5e18fc6ff8014d67b820"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\browser\\build-snapshot.mjs",
|
||||
"sha256": "2424f37847e72621327b5c0157f9fc03c1e7dd266ca71292b4b70571f17170a9"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\check-runner.mjs",
|
||||
"sha256": "e5038a223039686e35838366c0a23ea5055b2da8c843a255101b137e1106e752"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\context\\project-index.mjs",
|
||||
"sha256": "acaa896eca725bcce13a6d34a46267ce70a8a824eac8ca2ffccb91c4d18bd304"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\context\\read-budget.mjs",
|
||||
"sha256": "7544a22f8a0f2aeb9f06cd3d43f9eae77cc3141503930571a8c170b1ff4bb0cd"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\context\\request-plan.mjs",
|
||||
"sha256": "3d8c158f8b0d7e696a311f642a95f184cf69d38db9859498dbb8d2db6ab85108"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\context\\tool-feedback.mjs",
|
||||
"sha256": "7523f2ef18d9fea975d15e665c8c122293fdf52f3c7093ad08e16b8a83b6c95f"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\context\\working-set.mjs",
|
||||
"sha256": "61220be2142fff4194b633cf85e39f87c0a71ddf0745ce1406a5bc54977bdb0a"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\delivery-report.mjs",
|
||||
"sha256": "a0bb895459be2805684b881f80674f5592c2d55c285adcc30a0657c3a9c7bb5d"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\engine-manager.mjs",
|
||||
"sha256": "ec29a945c84ee79a41d30ac3a70296281bdd7d7898cc727a85bb6d78af62f015"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\engines\\deepseek-adapter.mjs",
|
||||
"sha256": "b5d3e3f1ba74b8d15b002594f13652bbc98761226a3e5e3fb408071762958fa9"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\engines\\deepseek-installation.mjs",
|
||||
"sha256": "5bca6da6d1fd972405762b81a4be7936ac597337e310aec2a7d88aa9e5cce7a9"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\git-delivery.mjs",
|
||||
"sha256": "106d7f6384f69ecff0cd68ba89f0a45876d37cc0bce537b75490e78e1aae8ca6"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\git-process.mjs",
|
||||
"sha256": "80547ec8928610ac4df5a05c5aef12d1aab0dca9e7b1def2773fc745f5adf5f5"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\memory\\project-memory.mjs",
|
||||
"sha256": "9c7da0ef9c7f36b431015fd4414f55304f8d5e25a61bc527fb7e3be0b7971e51"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\models\\config-import.mjs",
|
||||
"sha256": "70e5884606565d930685b0d0b55f73d9ceaf00dd3525f0fe6d2fdad2f87366bf"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\models\\model-hub.mjs",
|
||||
"sha256": "652581d91c8c0e9f1059880aa6ee31016790e06e53e20fff18d36c2c56bad379"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\owned-process-tree.mjs",
|
||||
"sha256": "b1742eb2b3db3f661815cd5b3d806197082bcadb7b0ba20a91837590b2a394f4"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\process-environment.mjs",
|
||||
"sha256": "05f7ca9bad79ed96a184c96643edffc320aef45567e888341531448f23c89702"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\project-inspector.mjs",
|
||||
"sha256": "9e81ed2928fc5dcdb20915a406a8cdc69068deb04fd9d36d0792a86598405782"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\python-project.mjs",
|
||||
"sha256": "74e09a96f2e1970b155d37af176379807add0d5a05f72ccd9491d4d494d58707"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\python-runtime.mjs",
|
||||
"sha256": "9e9f1b9128295f46404839ad95eaf8bcad60a8c4964756e7c1a1b21cc4add0d7"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\research-manager.mjs",
|
||||
"sha256": "15981370de1f02db4acec2c3e1450d068236e1f6ab70f677ec8617aa968fc2dc"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\skills\\skill-registry.mjs",
|
||||
"sha256": "63e435d65e3dfe7dff1b1711590b5a4a5ca2efddaa67822087de06facdadf3bb"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\storage\\artifact-store.mjs",
|
||||
"sha256": "2934d31a28da215f7ea73a3b5e56d106b723b34539ea8605d523b121762e488a"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\storage\\legacy-import.mjs",
|
||||
"sha256": "aa6a6b95d4049c5091d39e8c65ee301a0d6e533e081da59c87f2733bfb5a15ed"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\storage\\state-database.mjs",
|
||||
"sha256": "2a38f7564df44c4ee5183d850064be1d46fba7e072e2b87f73afb8e1a85a1517"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tasks\\task-checkpoint-manager.mjs",
|
||||
"sha256": "2f50f9de2e6b8c90376028ed2814eb795633e1ea917ab944a977299220ad820f"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tasks\\task-plan-manager.mjs",
|
||||
"sha256": "4feafa9462ab57f694854c79c846a9ba58fe9313b343341f2ca2a334255eec24"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tasks\\worker-manager.mjs",
|
||||
"sha256": "66f5ff323eaa745e58c23e50e3defce5f32cfe9061c4ecf11913fc2bf52a0576"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tools\\mcp-contract.mjs",
|
||||
"sha256": "4860792132e2d18caa075ddca8c24687b3692c005a1c6c4c81933e6dc9e0a6bc"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tools\\mcp-registry.mjs",
|
||||
"sha256": "8f52b11ba37d1c350aa279e4890a0c5b00fff3b77fc4f2211a4ea1c07bbadebc"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tools\\mcp-stdio.mjs",
|
||||
"sha256": "1c1081b9356855db5c8964ac5b9f5fb2c79fef5323ff1f933447a06f77cac447"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tools\\rea-adapter.mjs",
|
||||
"sha256": "36f7d2a095fcaef4e1ca056a1f2475e0b15fe1fc48d0179589b41abadf39c6c4"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\tools\\research-output.mjs",
|
||||
"sha256": "b9d53487192f12b0d2b0f0922c918b5b3d88a276777cd64903395800ff07c1c0"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\workspaces\\change-sets.mjs",
|
||||
"sha256": "c5a9e2886d7ea586f3f4290b167b8aa7d941009a1fd930af1b20c018cbcebc66"
|
||||
},
|
||||
{
|
||||
"path": "src\\core\\workspaces\\git-workspaces.mjs",
|
||||
"sha256": "0276d2b877acdb065717f7c93154d6999d56a9358b93e50bae7e2c7afc191806"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\app.mjs",
|
||||
"sha256": "be19dab9e2652f914c9fd266b8186c424fd8154b2f55fcbc4dcbf9d6ab36e606"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\diagnostics.mjs",
|
||||
"sha256": "55bd70f30f0e6666374965ea96e59b98fd85d223dacb863377a36c2be427c3fa"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\files.mjs",
|
||||
"sha256": "2a51d87311c896e4adbae9f59f26ce9a4eb70fa1d68e5bb31193069380846816"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\hot-upgrade.mjs",
|
||||
"sha256": "5fc691140bc7b380a0fbf412c4a709a684057896a7d8cdb58db55ac96d8f68f7"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\index.mjs",
|
||||
"sha256": "16b9d751870188d185ca6b03429376f19b5e7b94fd91a6ce401a096fae74ef64"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\provider.mjs",
|
||||
"sha256": "3072dd4dfaa4053e75bd57916a60a39a98c29bc2b08fe4fbbc0ff4002aa61749"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\runtime.mjs",
|
||||
"sha256": "288f322b40db5f3a0815061bcb6bcc151f9364c72f0864f8b52b94293e5667d5"
|
||||
},
|
||||
{
|
||||
"path": "src\\server\\store.mjs",
|
||||
"sha256": "e3e67e9cb5f64e70545bfa7be76fbf3ff6afb50c039d580a51bff24db59ac90b"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\browser.mjs",
|
||||
"sha256": "af8f71616097dbbb08bde31bf1cc42c90708802f17ad89b4ba220351fb30f439"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\change-sets.mjs",
|
||||
"sha256": "01586cdcffe00129c2b61e4cbf4a622b22306cd5a893620f4a7db441f978f1da"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\delivery-review.mjs",
|
||||
"sha256": "1b17efdfa2549801db72eabe439907419a4d85ea07e4d010563db2d483d565f9"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\engines.mjs",
|
||||
"sha256": "8d52facab1b7c1941637ae86756e73a7050467be04a0e036259bff6aad42c42b"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\execution.mjs",
|
||||
"sha256": "49ba58f91c967c0ae77318be024c227e6db9bf31333e8d9de4947053e10efbfa"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\model-request.mjs",
|
||||
"sha256": "3744dfa7302dde72d1c24c54e7c00672ff063b45786add2fb19d46233b759e78"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\research.mjs",
|
||||
"sha256": "eb970b52f923d7dbfd8e7da49381ce135b8a2ae9d04c0d4321958a2e93d12003"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\task-plan-tools.mjs",
|
||||
"sha256": "b14392919e1b551751a6c311004d9d200bc494a7873987c8c0f34a8c4bec1ec1"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\task-plans.mjs",
|
||||
"sha256": "c312f4511f495b90ec8983e5c8ecc357e85f67d97b8deda2d052651c3f491adb"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\workers.mjs",
|
||||
"sha256": "4b87565f528dea9b3fe19bfab02586fcdb9e17c6cd230085a47cab65dc929453"
|
||||
},
|
||||
{
|
||||
"path": "src\\shared\\contracts\\workspaces.mjs",
|
||||
"sha256": "4cd6873ca73de9dac5e73f3aaabe062674c5ca1d50c28a2e2b6eb9e138c32be9"
|
||||
}
|
||||
],
|
||||
"pageErrors": [],
|
||||
"requestFailures": [],
|
||||
"url": "http://127.0.0.1:54541",
|
||||
"sourceRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\test-2r96QA",
|
||||
"createdAt": "2026-10-30T17:55:06.490Z",
|
||||
"originalFixture": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-c912d9ca-869f-4bf3-a2c3-d7a7b8765236\\original-fixture"
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
TAP version 13
|
||||
# warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
|
||||
# warning: in the working copy of 'src/two.mjs', LF will be replaced by CRLF the next time Git touches it
|
||||
# Subtest: sealed batches preserve bytes until review, then apply and explicitly restore BOM/CRLF/new files
|
||||
ok 1 - sealed batches preserve bytes until review, then apply and explicitly restore BOM/CRLF/new files
|
||||
---
|
||||
duration_ms: 2415.5287
|
||||
type: 'test'
|
||||
...
|
||||
# Switched to a new branch 'owner-branch'
|
||||
# Subtest: a conflict in the last file or Git branch prevents writing every file in the batch
|
||||
ok 2 - a conflict in the last file or Git branch prevents writing every file in the batch
|
||||
---
|
||||
duration_ms: 2607.0837
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: duplicate canonical paths, ancestor collisions, links, dependencies and Windows aliases never form a batch
|
||||
ok 3 - duplicate canonical paths, ancestor collisions, links, dependencies and Windows aliases never form a batch
|
||||
---
|
||||
duration_ms: 1115.5078
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: fingerprints, changed proposals and corrupt snapshot artifacts cannot write or restore any target
|
||||
ok 4 - fingerprints, changed proposals and corrupt snapshot artifacts cannot write or restore any target
|
||||
---
|
||||
duration_ms: 2016.1182
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a failure after replacement restores only batch bytes and never retries an old application
|
||||
ok 5 - a failure after replacement restores only batch bytes and never retries an old application
|
||||
---
|
||||
duration_ms: 1669.7178
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: rollback preserves owner edits, blocks other project writers, and explicit acknowledgement releases recovery
|
||||
ok 6 - rollback preserves owner edits, blocks other project writers, and explicit acknowledgement releases recovery
|
||||
---
|
||||
duration_ms: 2116.784
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: an unattempted owner-created file identical to a suggestion remains external and is never removed
|
||||
ok 7 - an unattempted owner-created file identical to a suggestion remains external and is never removed
|
||||
---
|
||||
duration_ms: 1636.1192
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: active batch requests are serialized and cancellation leaves a verifiable ended batch
|
||||
ok 8 - active batch requests are serialized and cancellation leaves a verifiable ended batch
|
||||
---
|
||||
duration_ms: 1777.0761
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: batch application and rollback preserve unrelated Git index and worktree bytes
|
||||
ok 9 - batch application and rollback preserve unrelated Git index and worktree bytes
|
||||
---
|
||||
duration_ms: 3189.6226
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: recovery reuses exact staged bytes but retains a conflicting temporary file for owner inspection
|
||||
ok 10 - recovery reuses exact staged bytes but retains a conflicting temporary file for owner inspection
|
||||
---
|
||||
duration_ms: 2630.6958
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: one Task can seal pending proposals from earlier Runs while snapshots retain each source Run
|
||||
ok 11 - one Task can seal pending proposals from earlier Runs while snapshots retain each source Run
|
||||
---
|
||||
duration_ms: 1951.2531
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: engineering inspection preserves a dirty Git baseline and treats project rules as data
|
||||
ok 12 - engineering inspection preserves a dirty Git baseline and treats project rules as data
|
||||
---
|
||||
duration_ms: 2460.1328
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: real npm tests and build produce counted results, log artifacts and persistent verification
|
||||
ok 13 - real npm tests and build produce counted results, log artifacts and persistent verification
|
||||
---
|
||||
duration_ms: 2208.5491
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: an actual failing test retains the nonzero exit code and failed count
|
||||
ok 14 - an actual failing test retains the nonzero exit code and failed count
|
||||
---
|
||||
duration_ms: 2240.4434
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: zero tests, skipped tests and unrecognized stdout cannot become verification passes
|
||||
ok 15 - zero tests, skipped tests and unrecognized stdout cannot become verification passes
|
||||
---
|
||||
duration_ms: 7405.1584
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a successful build with no selected tests does not verify the task
|
||||
ok 16 - a successful build with no selected tests does not verify the task
|
||||
---
|
||||
duration_ms: 1766.4653
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: stale check plans and forged script names execute no project commands
|
||||
ok 17 - stale check plans and forged script names execute no project commands
|
||||
---
|
||||
duration_ms: 1193.6821
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: applying a later proposal invalidates the prior passed engineering snapshot
|
||||
ok 18 - applying a later proposal invalidates the prior passed engineering snapshot
|
||||
---
|
||||
duration_ms: 2544.6772
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: stopping an actual check terminates its child process and blocks concurrent jobs
|
||||
ok 19 - stopping an actual check terminates its child process and blocks concurrent jobs
|
||||
---
|
||||
duration_ms: 2081.289
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: check timeout records a failure with its actual termination result
|
||||
ok 20 - check timeout records a failure with its actual termination result
|
||||
---
|
||||
duration_ms: 2345.912
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: source edits during a successful check make the result stale
|
||||
ok 21 - source edits during a successful check make the result stale
|
||||
---
|
||||
duration_ms: 3124.6105
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: bounded large logs retain the test footer and readable artifact instead of inventing counts
|
||||
ok 22 - bounded large logs retain the test footer and readable artifact instead of inventing counts
|
||||
---
|
||||
duration_ms: 1548.0254
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: model-selected checks require a run-bound decision and denial creates no check job
|
||||
ok 23 - model-selected checks require a run-bound decision and denial creates no check job
|
||||
---
|
||||
duration_ms: 2346.602
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: check APIs expose owned plans and jobs and preserve the authoritative results across restart
|
||||
ok 24 - check APIs expose owned plans and jobs and preserve the authoritative results across restart
|
||||
---
|
||||
duration_ms: 3288.2461
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: reviewed changes continue the original task without reopening a generic completed run
|
||||
ok 25 - reviewed changes continue the original task without reopening a generic completed run
|
||||
---
|
||||
duration_ms: 3300.4038
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: concurrent review-continuation API requests accept one run and retain the goal after restart
|
||||
ok 26 - concurrent review-continuation API requests accept one run and retain the goal after restart
|
||||
---
|
||||
duration_ms: 5515.8201
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: the model reads owned failure logs without running the check again
|
||||
ok 27 - the model reads owned failure logs without running the check again
|
||||
---
|
||||
duration_ms: 3389.6731
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: process exit at check queued preserves results and never replays commands
|
||||
ok 28 - process exit at check queued preserves results and never replays commands
|
||||
---
|
||||
duration_ms: 1606.8239
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: process exit at check result_committed preserves results and never replays commands
|
||||
ok 29 - process exit at check result_committed preserves results and never replays commands
|
||||
---
|
||||
duration_ms: 1919.5495
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: HTTP worker identities require a current sealed plan, reject overrides and close unused plans without touching source
|
||||
ok 30 - HTTP worker identities require a current sealed plan, reject overrides and close unused plans without touching source
|
||||
---
|
||||
duration_ms: 12131.7969
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: HTTP unknown recovery only accepts the original evidence SHA and preserves changed source for explicit retention
|
||||
ok 31 - HTTP unknown recovery only accepts the original evidence SHA and preserves changed source for explicit retention
|
||||
---
|
||||
duration_ms: 17180.3888
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: verified isolated outputs form a new parent batch, rerun real checks and commit only reviewed source
|
||||
ok 32 - verified isolated outputs form a new parent batch, rerun real checks and commit only reviewed source
|
||||
---
|
||||
duration_ms: 39727.8177
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: overlapping worker paths are explicit conflicts even if each independent task checks successfully
|
||||
ok 33 - overlapping worker paths are explicit conflicts even if each independent task checks successfully
|
||||
---
|
||||
duration_ms: 25406.1033
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: source edits after isolated work preserve the owner file and invalidate collection without proposing a merge
|
||||
ok 34 - source edits after isolated work preserve the owner file and invalidate collection without proposing a merge
|
||||
---
|
||||
duration_ms: 24004.5637
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: changed child bytes after parent preview block the entire batch before any parent write
|
||||
ok 35 - changed child bytes after parent preview block the entire batch before any parent write
|
||||
---
|
||||
duration_ms: 35339.0053
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: corrupt original check logs cannot become collected outputs or a parent review
|
||||
ok 36 - corrupt original check logs cannot become collected outputs or a parent review
|
||||
---
|
||||
duration_ms: 24565.954
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: stopping a parent accounts late responses and executes none of their proposed tools
|
||||
ok 37 - stopping a parent accounts late responses and executes none of their proposed tools
|
||||
---
|
||||
duration_ms: 12038.2961
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unreported interrupted requests reserve estimated usage and the total deadline cannot reset on resume
|
||||
ok 38 - unreported interrupted requests reserve estimated usage and the total deadline cannot reset on resume
|
||||
---
|
||||
duration_ms: 12112.6327
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a response exceeding the cumulative token allocation stops before registering or executing its tools
|
||||
ok 39 - a response exceeding the cumulative token allocation stops before registering or executing its tools
|
||||
---
|
||||
duration_ms: 11129.352
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: cumulative tool allocation rejects the entire returned batch before any tool side effect
|
||||
ok 40 - cumulative tool allocation rejects the entire returned batch before any tool side effect
|
||||
---
|
||||
duration_ms: 11113.242
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: single response 16 tool ceiling rejects the entire returned batch before any tool side effect
|
||||
ok 41 - single response 16 tool ceiling rejects the entire returned batch before any tool side effect
|
||||
---
|
||||
duration_ms: 11409.1335
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: consumed request steps remain consumed across explicit worker resumes
|
||||
ok 42 - consumed request steps remain consumed across explicit worker resumes
|
||||
---
|
||||
duration_ms: 12498.5045
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a saved completed response with missing usage is conservatively accounted exactly once during recovery
|
||||
ok 43 - a saved completed response with missing usage is conservatively accounted exactly once during recovery
|
||||
---
|
||||
duration_ms: 9664.4461
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: an unexecuted second workspace plan resumes its original identity without recreating the first checkout
|
||||
ok 44 - an unexecuted second workspace plan resumes its original identity without recreating the first checkout
|
||||
---
|
||||
duration_ms: 10761.2218
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a verified interrupted parent proposal resumes sealing without duplicating or replacing its original change
|
||||
ok 45 - a verified interrupted parent proposal resumes sealing without duplicating or replacing its original change
|
||||
---
|
||||
duration_ms: 39057.3641
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: recovery attaches a sealed parent batch saved before its group reference without creating another batch
|
||||
ok 46 - recovery attaches a sealed parent batch saved before its group reference without creating another batch
|
||||
---
|
||||
duration_ms: 32270.65
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: explicitly retaining an unexecuted parent merge cancels its batch and frees the next parent goal
|
||||
ok 47 - explicitly retaining an unexecuted parent merge cancels its batch and frees the next parent goal
|
||||
---
|
||||
duration_ms: 37970.6885
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unknown collaboration blocks ordinary proposals but permits only original batch recovery and rollback
|
||||
ok 48 - unknown collaboration blocks ordinary proposals but permits only original batch recovery and rollback
|
||||
---
|
||||
duration_ms: 40257.3541
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: after a restart the batch application lazily reinstates the worker result guard before any parent write
|
||||
ok 49 - after a restart the batch application lazily reinstates the worker result guard before any parent write
|
||||
---
|
||||
duration_ms: 34417.7522
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unknown original tool inputs must match before acknowledgement, and reviewed checkpoint IDs preserve the unknown fact
|
||||
ok 50 - unknown original tool inputs must match before acknowledgement, and reviewed checkpoint IDs preserve the unknown fact
|
||||
---
|
||||
duration_ms: 12009.7832
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
ok 51 - a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
---
|
||||
duration_ms: 10596.0455
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
not ok 52 - a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
---
|
||||
duration_ms: 17110.0072
|
||||
type: 'test'
|
||||
location: 'D:\\Ai-project\\REA逆向\\Agent-Workbench\\tests\\workers-recovery.test.mjs:212:1'
|
||||
failureType: 'testCodeFailure'
|
||||
error: '原检查子进程PID仍存活:32864;不能按历史PID自动终止或解除核对。'
|
||||
code: 'ERR_ASSERTION'
|
||||
name: 'AssertionError'
|
||||
expected: true
|
||||
operator: '=='
|
||||
stack: |-
|
||||
evidence (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:31:10)
|
||||
process.processTicksAndRejections (node:internal/process/task_queues:104:5)
|
||||
async TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:237:3)
|
||||
async Test.run (node:internal/test_runner/test:1409:7)
|
||||
async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
...
|
||||
# Subtest: a persisted child initialization resumes the original control run after a failure before its worker record
|
||||
ok 53 - a persisted child initialization resumes the original control run after a failure before its worker record
|
||||
---
|
||||
duration_ms: 10800.6159
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: failed request intent persistence never dispatches a worker request or changes source
|
||||
ok 54 - failed request intent persistence never dispatches a worker request or changes source
|
||||
---
|
||||
duration_ms: 9824.9886
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: failed usage persistence rolls back the uncommitted usage and conservatively reserves one unknown request without tools
|
||||
ok 55 - failed usage persistence rolls back the uncommitted usage and conservatively reserves one unknown request without tools
|
||||
---
|
||||
duration_ms: 9797.1499
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a child file change after observation prevents acknowledgement even when the tool inputs did not change
|
||||
ok 56 - a child file change after observation prevents acknowledgement even when the tool inputs did not change
|
||||
---
|
||||
duration_ms: 9323.7521
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: worker scopes and allocated budgets reject aliases, extra permissions and aggregate overflow
|
||||
ok 57 - worker scopes and allocated budgets reject aliases, extra permissions and aggregate overflow
|
||||
---
|
||||
duration_ms: 594.0688
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: two sequential Git workspaces freeze a new parent goal, separate owned tasks and preserve all source bytes
|
||||
ok 58 - two sequential Git workspaces freeze a new parent goal, separate owned tasks and preserve all source bytes
|
||||
---
|
||||
duration_ms: 10238.914
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: real isolated changes, approvals and npm checks produce original owned outputs, not model completion claims
|
||||
ok 59 - real isolated changes, approvals and npm checks produce original owned outputs, not model completion claims
|
||||
---
|
||||
duration_ms: 28457.4712
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: forged worker tools cannot execute terminal or Git even when absent from the advertised tool list
|
||||
ok 60 - forged worker tools cannot execute terminal or Git even when absent from the advertised tool list
|
||||
---
|
||||
duration_ms: 11412.5893
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a completion-only model pauses each worker without fabricated changes or checks
|
||||
ok 61 - a completion-only model pauses each worker without fabricated changes or checks
|
||||
---
|
||||
duration_ms: 13517.5117
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: restart retains frozen scope and marks interrupted parent and workers unknown without sending requests
|
||||
ok 62 - restart retains frozen scope and marks interrupted parent and workers unknown without sending requests
|
||||
---
|
||||
duration_ms: 11910.9256
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: managed worktree preserves source index and dirty files, opens a distinct project and binds Run identity
|
||||
ok 63 - managed worktree preserves source index and dirty files, opens a distinct project and binds Run identity
|
||||
---
|
||||
duration_ms: 5296.7531
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: stale review, branch/path collisions and forged ownership do not run worktree creation
|
||||
ok 64 - stale review, branch/path collisions and forged ownership do not run worktree creation
|
||||
---
|
||||
duration_ms: 3337.6751
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: workspace project verification is read-only and rejects physical Git identity changes
|
||||
ok 65 - workspace project verification is read-only and rejects physical Git identity changes
|
||||
---
|
||||
duration_ms: 4760.2293
|
||||
type: 'test'
|
||||
...
|
||||
1..65
|
||||
# tests 65
|
||||
# suites 0
|
||||
# pass 64
|
||||
# fail 1
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 406954.7052
|
||||
@@ -0,0 +1,16 @@
|
||||
TAP version 13
|
||||
# Subtest: a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
ok 1 - a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
---
|
||||
duration_ms: 20712.6642
|
||||
type: 'test'
|
||||
...
|
||||
1..1
|
||||
# tests 1
|
||||
# suites 0
|
||||
# pass 1
|
||||
# fail 0
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 20830.0168
|
||||
@@ -0,0 +1,31 @@
|
||||
✔ verified isolated outputs form a new parent batch, rerun real checks and commit only reviewed source (32354.6225ms)
|
||||
✔ overlapping worker paths are explicit conflicts even if each independent task checks successfully (20520.9193ms)
|
||||
✔ source edits after isolated work preserve the owner file and invalidate collection without proposing a merge (19350.1699ms)
|
||||
✔ changed child bytes after parent preview block the entire batch before any parent write (26327.5504ms)
|
||||
✔ corrupt original check logs cannot become collected outputs or a parent review (20050.7436ms)
|
||||
✔ worker scopes and allocated budgets reject aliases, extra permissions and aggregate overflow (475.1014ms)
|
||||
✔ two sequential Git workspaces freeze a new parent goal, separate owned tasks and preserve all source bytes (8173.8692ms)
|
||||
✔ real isolated changes, approvals and npm checks produce original owned outputs, not model completion claims (20389.5842ms)
|
||||
✔ forged worker tools cannot execute terminal or Git even when absent from the advertised tool list (8743.2692ms)
|
||||
✔ a completion-only model pauses each worker without fabricated changes or checks (10429.9843ms)
|
||||
✖ restart retains frozen scope and marks interrupted parent and workers unknown without sending requests (8671.6191ms)
|
||||
ℹ tests 11
|
||||
ℹ suites 0
|
||||
ℹ pass 10
|
||||
ℹ fail 1
|
||||
ℹ cancelled 0
|
||||
ℹ skipped 0
|
||||
ℹ todo 0
|
||||
ℹ duration_ms 175717.3501
|
||||
|
||||
✖ failing tests:
|
||||
|
||||
test at tests\workers.test.mjs:87:1
|
||||
✖ restart retains frozen scope and marks interrupted parent and workers unknown without sending requests (8671.6191ms)
|
||||
ReferenceError [Error]: COLLABORATION_CLOSED is not defined
|
||||
at Store.recover (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/src/server/store.mjs:312:7)
|
||||
at new Store (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/src/server/store.mjs:91:45)
|
||||
at TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers.test.mjs:92:37)
|
||||
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
|
||||
at async Test.run (node:internal/test_runner/test:1409:7)
|
||||
at async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
@@ -0,0 +1,39 @@
|
||||
TAP version 13
|
||||
# Subtest: a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
ok 1 - a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
---
|
||||
duration_ms: 10053.5463
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
not ok 2 - a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
---
|
||||
duration_ms: 12748.1457
|
||||
type: 'test'
|
||||
location: 'D:\\Ai-project\\REA逆向\\Agent-Workbench\\tests\\workers-recovery.test.mjs:212:1'
|
||||
failureType: 'testCodeFailure'
|
||||
error: |-
|
||||
The expression evaluated to a falsy value:
|
||||
|
||||
assert.ok(pids.some(info => alive(info.pid)))
|
||||
|
||||
code: 'ERR_ASSERTION'
|
||||
name: 'AssertionError'
|
||||
expected: true
|
||||
actual: false
|
||||
operator: '=='
|
||||
stack: |-
|
||||
TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:229:105)
|
||||
process.processTicksAndRejections (node:internal/process/task_queues:104:5)
|
||||
async Test.run (node:internal/test_runner/test:1409:7)
|
||||
async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
...
|
||||
1..2
|
||||
# tests 2
|
||||
# suites 0
|
||||
# pass 1
|
||||
# fail 1
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 22918.372
|
||||
@@ -0,0 +1,63 @@
|
||||
TAP version 13
|
||||
# Subtest: a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
ok 1 - a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
---
|
||||
duration_ms: 10729.0316
|
||||
type: 'test'
|
||||
...
|
||||
# ����: û���ҵ����� "41612"��
|
||||
# Subtest: a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
not ok 2 - a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
---
|
||||
duration_ms: 14181.3564
|
||||
type: 'test'
|
||||
location: 'D:\\Ai-project\\REA逆向\\Agent-Workbench\\tests\\workers-recovery.test.mjs:212:1'
|
||||
failureType: 'testCodeFailure'
|
||||
error: |-
|
||||
Command failed: taskkill.exe /PID 41612 /T /F
|
||||
����: û���ҵ����� "41612"��
|
||||
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
genericNodeError (node:internal/errors:986:15)
|
||||
wrappedFn (node:internal/errors:540:14)
|
||||
checkExecSyncError (node:child_process:943:11)
|
||||
execFileSync (node:child_process:979:15)
|
||||
TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:232:168)
|
||||
process.processTicksAndRejections (node:internal/process/task_queues:104:5)
|
||||
async Test.run (node:internal/test_runner/test:1409:7)
|
||||
async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
...
|
||||
# Subtest: a persisted child initialization resumes the original control run after a failure before its worker record
|
||||
ok 3 - a persisted child initialization resumes the original control run after a failure before its worker record
|
||||
---
|
||||
duration_ms: 9655.4487
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: failed request intent persistence never dispatches a worker request or changes source
|
||||
ok 4 - failed request intent persistence never dispatches a worker request or changes source
|
||||
---
|
||||
duration_ms: 9973.2989
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: failed usage persistence rolls back the uncommitted usage and conservatively reserves one unknown request without tools
|
||||
ok 5 - failed usage persistence rolls back the uncommitted usage and conservatively reserves one unknown request without tools
|
||||
---
|
||||
duration_ms: 10131.9971
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a child file change after observation prevents acknowledgement even when the tool inputs did not change
|
||||
ok 6 - a child file change after observation prevents acknowledgement even when the tool inputs did not change
|
||||
---
|
||||
duration_ms: 9726.078
|
||||
type: 'test'
|
||||
...
|
||||
1..6
|
||||
# tests 6
|
||||
# suites 0
|
||||
# pass 5
|
||||
# fail 1
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 64513.5934
|
||||
@@ -0,0 +1,132 @@
|
||||
TAP version 13
|
||||
# Subtest: stopping a parent accounts late responses and executes none of their proposed tools
|
||||
ok 1 - stopping a parent accounts late responses and executes none of their proposed tools
|
||||
---
|
||||
duration_ms: 10135.9933
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unreported interrupted requests reserve estimated usage and the total deadline cannot reset on resume
|
||||
ok 2 - unreported interrupted requests reserve estimated usage and the total deadline cannot reset on resume
|
||||
---
|
||||
duration_ms: 10092.1896
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a response exceeding the cumulative token allocation stops before registering or executing its tools
|
||||
ok 3 - a response exceeding the cumulative token allocation stops before registering or executing its tools
|
||||
---
|
||||
duration_ms: 9855.2897
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: cumulative tool allocation rejects the entire returned batch before any tool side effect
|
||||
ok 4 - cumulative tool allocation rejects the entire returned batch before any tool side effect
|
||||
---
|
||||
duration_ms: 9914.3346
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: single response 16 tool ceiling rejects the entire returned batch before any tool side effect
|
||||
ok 5 - single response 16 tool ceiling rejects the entire returned batch before any tool side effect
|
||||
---
|
||||
duration_ms: 9628.7781
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: consumed request steps remain consumed across explicit worker resumes
|
||||
ok 6 - consumed request steps remain consumed across explicit worker resumes
|
||||
---
|
||||
duration_ms: 10491.8798
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a saved completed response with missing usage is conservatively accounted exactly once during recovery
|
||||
ok 7 - a saved completed response with missing usage is conservatively accounted exactly once during recovery
|
||||
---
|
||||
duration_ms: 8764.1331
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: an unexecuted second workspace plan resumes its original identity without recreating the first checkout
|
||||
ok 8 - an unexecuted second workspace plan resumes its original identity without recreating the first checkout
|
||||
---
|
||||
duration_ms: 9508.4738
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a verified interrupted parent proposal resumes sealing without duplicating or replacing its original change
|
||||
ok 9 - a verified interrupted parent proposal resumes sealing without duplicating or replacing its original change
|
||||
---
|
||||
duration_ms: 30026.5006
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: recovery attaches a sealed parent batch saved before its group reference without creating another batch
|
||||
ok 10 - recovery attaches a sealed parent batch saved before its group reference without creating another batch
|
||||
---
|
||||
duration_ms: 26704.7496
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: explicitly retaining an unexecuted parent merge cancels its batch and frees the next parent goal
|
||||
ok 11 - explicitly retaining an unexecuted parent merge cancels its batch and frees the next parent goal
|
||||
---
|
||||
duration_ms: 26521.4112
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unknown collaboration blocks ordinary proposals but permits only original batch recovery and rollback
|
||||
ok 12 - unknown collaboration blocks ordinary proposals but permits only original batch recovery and rollback
|
||||
---
|
||||
duration_ms: 29624.038
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: after a restart the batch application lazily reinstates the worker result guard before any parent write
|
||||
ok 13 - after a restart the batch application lazily reinstates the worker result guard before any parent write
|
||||
---
|
||||
duration_ms: 25831.1949
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: unknown original tool inputs must match before acknowledgement, and reviewed checkpoint IDs preserve the unknown fact
|
||||
ok 14 - unknown original tool inputs must match before acknowledgement, and reviewed checkpoint IDs preserve the unknown fact
|
||||
---
|
||||
duration_ms: 10816.9308
|
||||
type: 'test'
|
||||
...
|
||||
# Subtest: a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
not ok 15 - a parent stop observes and waits for a manually approved child check and its real descendant process
|
||||
---
|
||||
duration_ms: 24214.5723
|
||||
type: 'test'
|
||||
location: 'D:\\Ai-project\\REA逆向\\Agent-Workbench\\tests\\workers-recovery.test.mjs:195:1'
|
||||
failureType: 'testCodeFailure'
|
||||
error: 'Timed out waiting for test state.'
|
||||
code: 'ERR_TEST_FAILURE'
|
||||
stack: |-
|
||||
until (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/helpers.mjs:37:38)
|
||||
async TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:200:3)
|
||||
async Test.run (node:internal/test_runner/test:1409:7)
|
||||
async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
...
|
||||
# Subtest: a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
not ok 16 - a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool
|
||||
---
|
||||
duration_ms: 11490.0004
|
||||
type: 'test'
|
||||
location: 'D:\\Ai-project\\REA逆向\\Agent-Workbench\\tests\\workers-recovery.test.mjs:211:1'
|
||||
failureType: 'testCodeFailure'
|
||||
error: |-
|
||||
The expression evaluated to a falsy value:
|
||||
|
||||
assert.ok(pids.some(info => alive(info.pid)))
|
||||
|
||||
code: 'ERR_ASSERTION'
|
||||
name: 'AssertionError'
|
||||
expected: true
|
||||
actual: false
|
||||
operator: '=='
|
||||
stack: |-
|
||||
TestContext.<anonymous> (file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/tests/workers-recovery.test.mjs:226:105)
|
||||
process.processTicksAndRejections (node:internal/process/task_queues:104:5)
|
||||
async Test.run (node:internal/test_runner/test:1409:7)
|
||||
async Test.processPendingSubtests (node:internal/test_runner/test:974:7)
|
||||
...
|
||||
1..16
|
||||
# tests 16
|
||||
# suites 0
|
||||
# pass 14
|
||||
# fail 2
|
||||
# cancelled 0
|
||||
# skipped 0
|
||||
# todo 0
|
||||
# duration_ms 263747.7797
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"passed": false,
|
||||
"version": "1.12.1",
|
||||
"error": "Error: expect(locator).toContainText(expected) failed\n\nLocator: getByRole('dialog', { name: '多文件变更集审查', exact: true })\nExpected substring: \"全部文件已应用\"\nReceived string: \"多文件变更集审查本任务 254f24fa · 1 个文件已完成整批文件的实际建议字节已核对,全部应用完成。src/a.mjs建议内容5d8f65d2774esrc/a.mjs提案差异新建文件定位首处改动NEW1+export const value = 1;审查指纹2dd0848f386464c7d661f3f91a089eecbb94768da37ef3e70c47b14ce1fab54eGit基线workbench/worker-1-feece4b2-355 · 10b88095badd应用前会核对所有文件及原审查指纹。回退本批已写入文件\"\nTimeout: 10000ms\n\nCall log:\n - Expect \"toContainText\" getByRole('dialog', { name: '多文件变更集审查', exact: true }) with timeout 10000ms\n - waiting for getByRole('dialog', { name: '多文件变更集审查', exact: true })\n 4 × locator resolved to <div role=\"dialog\" aria-modal=\"true\" aria-label=\"多文件变更集审查\" class=\"modal modal-wide\">…</div>\n - unexpected value \"多文件变更集审查本任务 254f24fa · 1 个文件准备完成整批范围已封存,项目文件尚未改变。src/a.mjs原文件新文件src/a.mjs提案差异新建文件定位首处改动NEW1+export const value = 1;审查指纹2dd0848f386464c7d661f3f91a089eecbb94768da37ef3e70c47b14ce1fab54eGit基线workbench/worker-1-feece4b2-355 · 10b88095badd应用前会核对所有文件及原审查指纹。撤销未执行批次确认应用全部 1 项\"\n - locator resolved to <div role=\"dialog\" aria-modal=\"true\" aria-label=\"多文件变更集审查\" class=\"modal modal-wide\">…</div>\n - unexpected value \"多文件变更集审查本任务 254f24fa · 1 个文件应用中整批预检通过,正在记录逐文件写入。src/a.mjs原文件新文件src/a.mjs提案差异新建文件定位首处改动NEW1+export const value = 1;审查指纹2dd0848f386464c7d661f3f91a089eecbb94768da37ef3e70c47b14ce1fab54eGit基线workbench/worker-1-feece4b2-355 · 10b88095badd文件批次正在执行,结果会持续更新。\"\n 18 × locator resolved to <div role=\"dialog\" aria-modal=\"true\" aria-label=\"多文件变更集审查\" class=\"modal modal-wide\">…</div>\n - unexpected value \"多文件变更集审查本任务 254f24fa · 1 个文件已完成整批文件的实际建议字节已核对,全部应用完成。src/a.mjs建议内容5d8f65d2774esrc/a.mjs提案差异新建文件定位首处改动NEW1+export const value = 1;审查指纹2dd0848f386464c7d661f3f91a089eecbb94768da37ef3e70c47b14ce1fab54eGit基线workbench/worker-1-feece4b2-355 · 10b88095badd应用前会核对所有文件及原审查指纹。回退本批已写入文件\"\n\n at captureRawStack (D:\\Ai-project\\REA逆向\\Agent-Workbench\\node_modules\\playwright-core\\lib\\coreBundle.js:9282:17)\n at callMatcherAsStep (D:\\Ai-project\\REA逆向\\Agent-Workbench\\node_modules\\playwright\\lib\\matchers\\expect.js:13316:57)\n at Object.toContainText (D:\\Ai-project\\REA逆向\\Agent-Workbench\\node_modules\\playwright\\lib\\matchers\\expect.js:13308:23)\n at applyUi (D:\\Ai-project\\REA逆向\\Agent-Workbench\\scripts\\verify-workers-ui.mjs:38:24)\n at async file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/scripts/verify-workers-ui.mjs:75:5",
|
||||
"assertions": [
|
||||
"desktop/390px editor seals the actual parent goal, two scopes and shared budget without model calls or source writes",
|
||||
"explicit workspace confirmation creates two distinct Git checkouts and keeps every original source/staging byte"
|
||||
],
|
||||
"screenshots": [
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-fab7e89e-fe11-4954-a82a-87519c5254b0\\mobile-worker-plan.png",
|
||||
"sha256": "d36ab1b1d2d5e50e05e3ac582721abf854df95cd5cc9f7b2b5d7c0a19b34c899"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-fab7e89e-fe11-4954-a82a-87519c5254b0\\workers-ui-failure.png",
|
||||
"sha256": "2f3c127ba6182b88f94b185ecbe354c30b3be4705ac12152422db82a5f4853cb"
|
||||
}
|
||||
],
|
||||
"pageErrors": [],
|
||||
"requestFailures": [],
|
||||
"sourceRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\test-EaUZXt",
|
||||
"originalFixture": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-fab7e89e-fe11-4954-a82a-87519c5254b0\\original-fixture"
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"passed": false,
|
||||
"version": "1.12.1",
|
||||
"error": "locator.click: Timeout 30000ms exceeded.\nCall log:\n\u001b[2m - waiting for getByLabel('隔离协作控制台', { exact: true }).getByRole('button', { name: '确认核对并保留现场结束', exact: true })\u001b[22m\n\n at D:\\Ai-project\\REA逆向\\Agent-Workbench\\scripts\\verify-workers-ui.mjs:131:75",
|
||||
"assertions": [
|
||||
"desktop/390px editor seals the actual parent goal, two scopes and shared budget without model calls or source writes",
|
||||
"explicit workspace confirmation creates two distinct Git checkouts and keeps every original source/staging byte",
|
||||
"each lane navigates to its original child task, hides unsupported actions and applies only an explicitly reviewed child batch",
|
||||
"both UI approvals run real three-test/build checks and collect the original hashed outputs before any parent write",
|
||||
"parent UI review applies a new two-file batch and accepts completion only after a fresh real parent check and local Git delivery",
|
||||
"390px conflict review names the real overlapping path, leaves parent files untouched and explicitly retains the original child results",
|
||||
"mobile parent stop waits for both held requests, preserves estimated unknown usage and retains the original deadline",
|
||||
"switching historical groups quarantines a deliberately late previous-group error and its preview",
|
||||
"recovery UI requires reading the original record and rejects changed source instead of acknowledging stale evidence"
|
||||
],
|
||||
"screenshots": [
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-39fdccc3-fb60-4286-ba1f-3a0bbbbabbc2\\mobile-worker-plan.png",
|
||||
"sha256": "d36ab1b1d2d5e50e05e3ac582721abf854df95cd5cc9f7b2b5d7c0a19b34c899"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-39fdccc3-fb60-4286-ba1f-3a0bbbbabbc2\\desktop-workers-collected.png",
|
||||
"sha256": "c3275bccf06e3aedfed71e6a1d9900230538a0ee60853f26bf08aa85ac32cff4"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-39fdccc3-fb60-4286-ba1f-3a0bbbbabbc2\\mobile-workers-conflict.png",
|
||||
"sha256": "dd9a701f416a0e60b683e7e9476415b0bca45b3190aed2173e3c571810648f4b"
|
||||
},
|
||||
{
|
||||
"file": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-39fdccc3-fb60-4286-ba1f-3a0bbbbabbc2\\workers-ui-failure.png",
|
||||
"sha256": "f53ca2499ac8840523505367e945ed791321a11b1e568a39c9668151d6273c1b"
|
||||
}
|
||||
],
|
||||
"pageErrors": [],
|
||||
"requestFailures": [],
|
||||
"sourceRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\test-LRBQUh",
|
||||
"originalFixture": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\workers-ui-39fdccc3-fb60-4286-ba1f-3a0bbbbabbc2\\original-fixture"
|
||||
}
|
||||
+18
@@ -2,6 +2,21 @@
|
||||
|
||||
## 2026-10-31 1.13 隔离worker接续
|
||||
|
||||
- 第三轮控制台10节点完整通过,原目录workers-ui-c912d9ca。桌面两通道、父成果和冲突层级清楚;截图时面板已滚动,顶部标题未在图内,实际布局保留标题与停止入口。继续三个真实功能工程样本,不能把未被测试引用的新a/b模块当功能完成。
|
||||
- 宿主崩溃QA清理竞态修正后真实专项1/1通过;整合64/65原记录保持,不拼接成一轮65/65。原进程身份/CIM仅包含PID、父PID、创建时间和程序路径,不读取命令行、环境或真实Key。
|
||||
- 接续一次Windows rg再次把通配符当字面路径;改为具体目录加-g过滤。大段组合diff被截断,下一轮按模块分开检查,不将截断段登记为完整审查。
|
||||
- 一次文档补丁误用progress的不存在标题锚点,被整体拒绝且无写入;已读取实际标题,再按完整锚点一次更新。
|
||||
- 本次接续实测HEAD=3abc0e8;父归集/合并5项在停止恢复补强前通过,最新未提交源码尚未最终验收。优先修复恢复批次门控、重启后合并来源守卫、已封存响应未入账的崩溃窗口和实际close事件;之后验证部分创建/合并、保留现场与HTTP边界。
|
||||
- 首轮最新合并/核心复验10/11,恢复第二遍补强漏导入COLLABORATION_CLOSED,真实重开Store报ReferenceError;已补导入。该轮默认Node记者输出为spec,保存原.log而不标TAP;后续显式--test-reporter=tap保留原字节。Windows通配符的又一次字面查询已改为tests目录加-g过滤。
|
||||
- 恢复专项第一轮14/16:14项预算、迟到、部分创建/合并、来源守卫和输入核对通过;真实进程两项夹具的内嵌JS换行转义错误导致心跳缺失,宿主退出也早于测试实际进入。改为不含嵌套换行的心跳程序,并等待实际心跳后再退出宿主,原失败TAP保留,先复验这两项。
|
||||
- 进程复验1/2:实际停止与子心跳结束通过;宿主实际退出后原npm根PID已经消失,不能用根PID推断所有子进程结束。新增仅含PID/父PID/创建时间/程序路径的只读树记录,运行时保存观察到的子进程,恢复按原创建身份核对存活子进程,不读取命令行/环境、不按历史PID杀进程。原失败继续保留,按新实现验收。
|
||||
- 子进程树与四项追加专项5/6;宿主崩溃后存活子进程拒绝核对的产品断言已通过,失败来自QA清理祖先进程后再清理已退出后代的竞态。清理现等待原已退出PID,不能把不存在进程当产品失败;CIM输出固定UTF-8且无效JSON保留核对失败,不产生未处理异常。
|
||||
- 首轮真实控制台通过计划/工作区两个节点;实际子文件应用已经完成,验收器误要求「全部文件已应用」,现有文案为「全部应用完成」。按实际文案和collection的groupFingerprint字段修正验收器,原失败报告、截图及完整自有夹具保留在workers-ui-fab7e89e目录,未修改产品文案来配合测试。
|
||||
- 控制台第二轮9个节点通过,最后保留现场步骤中验收器在异步原记录尚未打开时按Escape,关闭了父控制台。现先等待原记录实际显示再关闭;workers-ui-39fdccc3完整失败证据保留,修正后继续全流程。
|
||||
- 最新整合65项64通过,唯一失败来自宿主崩溃QA在原树快照后新生的后代未清完;产品再次正确拒绝仍存活的子PID。QA清理改为按原创建身份只读取得当前所属后代并等待全部结束,再核对恢复;原TAP保存workers-focused-before-qa-cleanup.tap,产品代码不为迁就验收而放开存活门控。
|
||||
- 一次补丁把worker-manager.mjs拆成两个更新操作,工具拒绝整个补丁且没有写入;随后将同一文件的修改合并为一个操作。
|
||||
- 一次恢复读取误用了不存在的tasks/task-checkpoints.mjs;按实际模块路径继续。大段历史输出已缩小,不把截断内容当完整依据。
|
||||
|
||||
- 开发分支feat/isolated-workers-1.13基于f0fcefd,现仅有task_plan与PLAN-1.13规划改动,产品仍为1.12.1;正式服务保持,不使用真实Key或付费模型。
|
||||
- Runtime已有Task/Run、审批、所属检查及停止流程;WorkspaceManager创建绑定来源/HEAD与Git登记,同一仓库创建必须串行。拟复用宿主Provider和两个受限子运行,独立Git worktree不宣称为OS沙箱。
|
||||
- beginRun对failed/paused旧Task会复用;父协作必须创建明确的新Task,稳定冻结父子身份、写入范围、模型快照和总预算。子运行完成需实际应用修改及当前检查,文字回复不代替成果。
|
||||
@@ -15,6 +30,9 @@
|
||||
- WorkerManager使用私有创建器和显式父操作排除,普通Workspace/Check/Git操作仍应纳入协作活动,不能扩大排除范围。源码没有shared/contracts/checks.mjs,原检查核验为core/delivery-report.mjs的verifiedCheck;已按实际函数复用。
|
||||
- 一次Runtime补丁使用了不存在的换行锚点导致整体拒绝,核对无局部写入后按实际单行函数重新应用。核心尚未验收,不登记为可交付。
|
||||
- 首轮专项实际暴露worker行更新runId违反SQLite不可迁移归属契约,导致子运行启动后控制记录保存失败;已改为稳定控制runId和单独currentRunId,保持旧归属。保存/启动失败会先停止并等待已创建子运行;父调度不能忽略Promise拒绝或把仍running记录当paused。原失败与诊断TAP单独保留。
|
||||
- 切片一提交1a847c1,3abc0e8将六份原TAP恢复为与Git索引相同的原字节。CRLF原日志会被普通diff误报空白,改为本阶段原日志binary属性,保留原字节并避免编辑性检查误处理历史输出。
|
||||
- 父归集/合并代码已写入:每次核对原子成果、当前源码/账本/检查原日志与父来源,生成新的父提案及封存批次;Node检查数量再与原日志对照。合并保留父文本换行/BOM,重叠和已有修改显式拒绝。第一项实际父检查/Git交付用例已通过,其余专项尚在执行。
|
||||
- 采用webapp-testing的渲染后侦察/交互/日志/截图核验流程,使用仓库已有Node Playwright和独立Edge/数据宿主;QA Python没有Playwright,不为界面验收引入新运行器或真实连接。
|
||||
|
||||
## 2026-10-30 项目所属stdio MCP接续
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
## 2026-10-31 1.13 隔离执行阶段
|
||||
|
||||
- 停止/恢复与父成果合并切片完成:整合65项原轮64通过,产品正确拒绝活进程,QA清理竞态修正后真实宿主崩溃1/1;第三轮协作控制台桌面/390px完整10节点通过,0页面/请求异常,原失败均保留。桌面截图已目视复核,继续有明确功能断言的Node/React/Python工程,版本尚未提升/发行,正式1.12.1保持。
|
||||
- 接续3abc0e8,原父归集5项通过及全部未提交实现保持;当前仍1.12.1源码/正式服务,不重复已完成切片。继续先完成停止/恢复守卫与专项,再HTTP/桌面及390px、三种实际工程和独立发行/保留Provider升级,每个节点回顾及本地提交。
|
||||
- 最新第一轮合并/核心10/11;漏导入恢复状态常量已定位并修正,原spec输出保留。新增迟到响应/累计预算/真实进程树/宿主退出/部分创建与合并/核对输入专项,继续按新源码复验,不覆盖最初失败。
|
||||
|
||||
- 接续上一段未提交规划,已核对f0fcefd基线与feat/isolated-workers-1.13分支;保存六步执行计划与PLAN-1.13,尚无产品代码、版本或新发行。
|
||||
- 继续使用planning-with-files并沿用已读frontend-design方向;按核心契约、受限执行、成果审查、控制台与独立发行切片推进,每个切片回顾及小步本地提交。
|
||||
- 本阶段不主动委派助手子代理,不读取真实连接凭据、不发真实模型请求。独立本地模型夹具与实际Git/文件/检查/页面分别验收。
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { chromium, expect } from 'playwright/test';
|
||||
import { fixture, until } from '../tests/helpers.mjs';
|
||||
import { workerHttp } from '../tests/fixtures/workers-http.mjs';
|
||||
import { workerDefinition, ownerBytes, applyWorkerProposals, approveWorkerChecks } from '../tests/fixtures/workers-project.mjs';
|
||||
|
||||
if (process.argv.includes('--help')) { console.log('node scripts/verify-workers-ui.mjs — owned local fixture, real isolated Git/checks/review, desktop/390px, conflicts, stop, recovery and late source errors'); process.exit(0); }
|
||||
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version, prefix = version === '1.13.0' ? 'workers' : 'workers-development';
|
||||
const directory = path.resolve('.qa', 'workers-ui-' + randomUUID()); fs.mkdirSync(directory, { recursive: true });
|
||||
const disposers = [], t = { after: dispose => disposers.push(dispose) }, f = fixture(t), host = await workerHttp(f);
|
||||
assert.notEqual(new URL(host.url).port, '4318');
|
||||
const hash = bytes => createHash('sha256').update(bytes).digest('hex');
|
||||
function inputs() {
|
||||
const files = ['package.json', 'package-lock.json'];
|
||||
const walk = root => { for (const entry of fs.readdirSync(root, { withFileTypes: true })) { const file = path.join(root, entry.name); if (entry.isDirectory()) walk(file); else if (entry.isFile()) files.push(file); } };
|
||||
for (const root of ['src', 'scripts', 'dist-client', 'dist-server']) walk(root);
|
||||
return files.sort().map(file => ({ path: file, sha256: hash(fs.readFileSync(file)) }));
|
||||
}
|
||||
const frozen = inputs(), pageErrors = [], requestFailures = [], assertions = [], screenshots = [], exports = [], groups = [];
|
||||
const browser = await chromium.launch({ channel: 'msedge', headless: true }), page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||
page.on('pageerror', error => pageErrors.push(error.message)); page.on('requestfailed', request => requestFailures.push(request.url() + ': ' + request.failure()?.errorText));
|
||||
const panel = () => page.getByLabel('隔离协作控制台', { exact: true }), groupState = id => f.store.core.collaboration.get(id);
|
||||
const mark = text => { assertions.push(text); console.log('PASS ' + text); };
|
||||
async function screenshot(name) { const file = path.join(directory, name + '.png'); await page.screenshot({ path: file, scale: 'css' }); screenshots.push({ file, sha256: hash(fs.readFileSync(file)) }); }
|
||||
async function openWorkers() { await page.getByRole('button', { name: '隔离协作', exact: true }).click(); await expect(panel()).toBeVisible(); await expect(panel().getByRole('button', { name: '刷新', exact: true })).toBeEnabled(); }
|
||||
async function parentFromChild() { await openWorkers(); await panel().getByRole('button', { name: '返回父目标', exact: true }).click(); await expect.poll(() => page.evaluate(() => localStorage.getItem('awb-session'))).toBe(f.session.id); await openWorkers(); }
|
||||
async function confirmStart() { await panel().getByRole('button', { name: /开始两个子任务|继续未完成子任务/ }).click(); await page.getByRole('dialog', { name: '确认受限子执行', exact: true }).getByRole('button', { name: '确认开始', exact: true }).click(); }
|
||||
async function applyUi(count, prepared = false) {
|
||||
if (await page.getByRole('button', { name: '查看改动', exact: true }).isVisible()) await page.getByRole('button', { name: '查看改动', exact: true }).click();
|
||||
else await page.locator('.inspector-tabs').getByRole('button', { name: /^改动/ }).click();
|
||||
await page.getByRole('button', { name: prepared ? '审查变更集' : '组合审查', exact: true }).click();
|
||||
if (!prepared) await page.getByRole('dialog', { name: '选择要一起审查的提案', exact: true }).getByRole('button', { name: '封存审查范围', exact: true }).click();
|
||||
const review = page.getByRole('dialog', { name: '多文件变更集审查', exact: true });
|
||||
await review.getByRole('button', { name: '确认应用全部 ' + count + ' 项', exact: true }).click();
|
||||
await expect(review).toContainText('全部应用完成', { timeout: 10000 }); await page.keyboard.press('Escape');
|
||||
}
|
||||
async function runFixture(definition) {
|
||||
const group = await host.manager.plan(f.session, definition); groups.push(group.id);
|
||||
await (await host.manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
await (await host.manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
await applyWorkerProposals(f, host.runtime, group); await approveWorkerChecks(f, host.runtime, group, host.manager.start(f.session, group.id, group.fingerprint));
|
||||
assert.equal(group.status, 'ready_to_collect', group.summary); await (await host.manager.collect(f.session, group.id, group.fingerprint)).promise; return group;
|
||||
}
|
||||
let result, releaseHeld;
|
||||
try {
|
||||
await page.addInitScript(({ projectId, sessionId }) => { localStorage.setItem('awb-project', projectId); localStorage.setItem('awb-session', sessionId); }, { projectId: f.project.id, sessionId: f.session.id });
|
||||
await page.goto(host.url); await page.waitForLoadState('networkidle'); await openWorkers();
|
||||
await expect(panel().getByRole('button', { name: '封存分工计划', exact: true })).toBeDisabled();
|
||||
await panel().getByLabel('父目标', { exact: true }).fill('两个独立模块经审查、父工程检查和本地 Git 后交付');
|
||||
for (const [index, relative] of ['src/a.mjs', 'src/b.mjs'].entries()) {
|
||||
const lane = panel().locator('fieldset').nth(index); await lane.getByLabel('任务名称', { exact: true }).fill('worker-' + (index + 1));
|
||||
await lane.getByLabel('独立子目标', { exact: true }).fill('实现并验证独立模块 ' + (index + 1)); await lane.getByLabel('允许修改的文件或目录', { exact: true }).fill(relative);
|
||||
}
|
||||
await page.setViewportSize({ width: 390, height: 844 }); await screenshot('mobile-worker-plan'); assert.ok(await page.locator('body').evaluate(node => node.scrollWidth <= 390));
|
||||
await page.setViewportSize({ width: 1440, height: 1000 }); const initial = ownerBytes(f);
|
||||
await panel().getByRole('button', { name: '封存分工计划', exact: true }).click(); await expect(panel()).toContainText('计划已封存');
|
||||
const group = [...f.store.core.collaboration.values()].at(-1); groups.push(group.id); assert.equal(host.requests.length, 0); assert.deepEqual(ownerBytes(f), initial);
|
||||
mark('desktop/390px editor seals the actual parent goal, two scopes and shared budget without model calls or source writes');
|
||||
|
||||
await panel().getByRole('button', { name: '创建两个工作区', exact: true }).click(); await page.keyboard.press('Escape'); assert.equal(group.status, 'planned');
|
||||
await panel().getByRole('button', { name: '创建两个工作区', exact: true }).click();
|
||||
await page.getByRole('dialog', { name: '确认创建隔离工作区', exact: true }).getByRole('button', { name: '确认创建', exact: true }).click();
|
||||
await expect.poll(() => group.status, { timeout: 20000 }).toBe('ready'); await expect(panel().locator('.worker-lane')).toHaveCount(2); assert.deepEqual(ownerBytes(f), initial);
|
||||
mark('explicit workspace confirmation creates two distinct Git checkouts and keeps every original source/staging byte');
|
||||
|
||||
await confirmStart(); await expect.poll(() => group.status, { timeout: 15000 }).toBe('awaiting_review');
|
||||
assert.equal(f.session.changes.length, 0);
|
||||
for (let index = 0; index < 2; index++) {
|
||||
await panel().locator('.worker-lane').nth(index).getByRole('button', { name: '审查子任务改动', exact: true }).click();
|
||||
await expect.poll(() => page.evaluate(() => localStorage.getItem('awb-session'))).toBe(group.children[index].sessionId);
|
||||
for (const name of ['项目技能', '项目MCP工具', '本地代理引擎', 'REA 工件研究']) await expect(page.getByRole('button', { name, exact: true })).toBeDisabled();
|
||||
await applyUi(1); assert.equal(f.store.session(group.children[index].sessionId).changes[0].status, 'applied'); await parentFromChild();
|
||||
}
|
||||
assert.deepEqual(ownerBytes(f), initial); mark('each lane navigates to its original child task, hides unsupported actions and applies only an explicitly reviewed child batch');
|
||||
|
||||
await confirmStart(); await expect.poll(() => group.children.filter(child => f.store.session(child.sessionId).status === 'awaiting_approval').length, { timeout: 15000 }).toBe(2);
|
||||
for (let index = 0; index < 2; index++) {
|
||||
await panel().locator('.worker-lane').nth(index).getByRole('button', { name: '查看并审批检查', exact: true }).click();
|
||||
await expect(page.locator('.approval-card')).toContainText('npm'); await page.locator('.approval-card').getByRole('button', { name: '确认执行', exact: true }).click(); await parentFromChild();
|
||||
}
|
||||
await expect.poll(() => group.status, { timeout: 25000 }).toBe('ready_to_collect');
|
||||
await panel().getByRole('button', { name: '核对成果', exact: true }).click(); await expect.poll(() => group.status, { timeout: 15000 }).toBe('collected');
|
||||
await screenshot('desktop-workers-collected');
|
||||
await panel().getByRole('button', { name: '查看原成果记录', exact: true }).click(); await expect(page.getByRole('dialog', { name: '原成果核对记录', exact: true })).toContainText('groupFingerprint'); await page.keyboard.press('Escape');
|
||||
mark('both UI approvals run real three-test/build checks and collect the original hashed outputs before any parent write');
|
||||
|
||||
await panel().getByRole('button', { name: '准备合并审查', exact: true }).click(); await expect.poll(() => group.status, { timeout: 15000 }).toBe('merge_prepared');
|
||||
await panel().getByRole('button', { name: '打开父工程变更集审查', exact: true }).click(); await applyUi(2, true); assert.deepEqual(ownerBytes(f), initial);
|
||||
const plan = await host.runtime.checkRunner().plan(f.session), check = await (await host.runtime.checkRunner().start(f.session, plan.id)).promise; assert.equal(check.status, 'passed', check.summary);
|
||||
const delivery = await host.runtime.gitDelivery().plan(f.session, { message: 'UI reviewed isolated workers' }); await (await host.runtime.gitDelivery().start(f.session, delivery.id)).promise;
|
||||
await openWorkers(); await panel().getByRole('button', { name: '核对检查与 Git 交付', exact: true }).click(); await expect.poll(() => group.status).toBe('completed'); assert.ok(group.delivery.commit); assert.deepEqual(ownerBytes(f).files, initial.files);
|
||||
mark('parent UI review applies a new two-file batch and accepts completion only after a fresh real parent check and local Git delivery');
|
||||
|
||||
const conflict = await runFixture({ ...workerDefinition(['src/shared.mjs', 'src/shared.mjs']), goal: '重叠修改必须保持具体冲突' }); assert.equal(conflict.status, 'conflict');
|
||||
await panel().getByRole('button', { name: '刷新', exact: true }).click(); await panel().getByLabel('选择协作记录', { exact: true }).selectOption(conflict.id);
|
||||
await page.setViewportSize({ width: 390, height: 844 }); await expect(panel().locator('.worker-conflicts')).toContainText('src/shared.mjs');
|
||||
assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/shared.mjs')), false); assert.ok(await page.locator('body').evaluate(node => node.scrollWidth <= 390));
|
||||
await panel().locator('.worker-review').scrollIntoViewIfNeeded(); await screenshot('mobile-workers-conflict');
|
||||
await panel().getByRole('button', { name: '结束协作并保留现场', exact: true }).click(); await page.getByRole('dialog', { name: '确认保留现场', exact: true }).getByRole('button', { name: '确认保留现场结束', exact: true }).click(); await expect.poll(() => conflict.status).toBe('resolved_external');
|
||||
mark('390px conflict review names the real overlapping path, leaves parent files untouched and explicitly retains the original child results');
|
||||
|
||||
const stopped = await host.manager.plan(f.session, { ...workerDefinition(['src/stop-a.mjs', 'src/stop-b.mjs']), goal: '停止和原输入核对保持任务归属' }); groups.push(stopped.id); await (await host.manager.prepare(f.session, stopped.id, stopped.fingerprint)).promise;
|
||||
const complete = host.provider.complete; let held = 0;
|
||||
host.provider.complete = async (config, messages, project, signal) => new Promise((resolve, reject) => { held++; signal.addEventListener('abort', () => reject(Object.assign(new Error('Owned held UI request stopped'), { name: 'AbortError' })), { once: true }); });
|
||||
await panel().getByRole('button', { name: '刷新', exact: true }).click(); await panel().getByLabel('选择协作记录', { exact: true }).selectOption(stopped.id);
|
||||
await confirmStart(); await expect.poll(() => held).toBe(2); await panel().getByRole('button', { name: '停止全部', exact: true }).click(); await expect.poll(() => stopped.status, { timeout: 10000 }).toBe('paused'); host.provider.complete = complete;
|
||||
assert.equal(stopped.usage.unknownRequests, 2); assert.equal(host.runtime.hasActivity(), false); const deadline = stopped.deadline;
|
||||
mark('mobile parent stop waits for both held requests, preserves estimated unknown usage and retains the original deadline');
|
||||
|
||||
await panel().getByLabel('选择协作记录', { exact: true }).selectOption(group.id);
|
||||
let heldRoute; await page.route('**/api/sessions/' + f.session.id + '/collaborations/' + group.id + '/collection', async route => { heldRoute = route; await new Promise(resolve => { releaseHeld = resolve; }); await route.fulfill({ status: 500, contentType: 'application/json', body: '{"error":"Owned late previous-group error"}' }); });
|
||||
await panel().getByRole('button', { name: '查看原成果记录', exact: true }).click(); await expect.poll(() => !!heldRoute).toBe(true);
|
||||
await panel().getByLabel('选择协作记录', { exact: true }).selectOption(stopped.id); releaseHeld(); releaseHeld = null; await page.unrouteAll({ behavior: 'wait' });
|
||||
await expect(page.getByText('Owned late previous-group error', { exact: true })).toHaveCount(0); await expect(page.getByRole('dialog', { name: '原成果核对记录', exact: true })).toHaveCount(0);
|
||||
mark('switching historical groups quarantines a deliberately late previous-group error and its preview');
|
||||
|
||||
stopped.status = 'unknown'; stopped.requiresVerification = true; f.store.save(f.session); await panel().getByRole('button', { name: '刷新', exact: true }).click();
|
||||
await panel().getByRole('button', { name: '核对原输入与现场', exact: true }).click(); await expect.poll(() => stopped.evidence?.sha256, { timeout: 10000 }).toBeTruthy();
|
||||
await expect(panel().getByRole('button', { name: '确认核对并继续', exact: true })).toBeDisabled();
|
||||
await panel().getByRole('button', { name: '查看核对记录', exact: true }).click(); await expect(page.getByRole('dialog', { name: '原输入与现场核对', exact: true })).toContainText('worker-recovery-observation'); await page.keyboard.press('Escape');
|
||||
fs.appendFileSync(path.join(f.projectRoot, 'owner-unstaged.txt'), 'Owner changed after the observed UI evidence\n');
|
||||
await panel().getByRole('button', { name: '确认核对并继续', exact: true }).click(); await page.getByRole('dialog', { name: '确认原结果核对', exact: true }).getByRole('button', { name: '确认核对并继续', exact: true }).click();
|
||||
await expect(panel().getByRole('alert')).toContainText('现场在核对后发生变化'); assert.equal(stopped.requiresVerification, true);
|
||||
mark('recovery UI requires reading the original record and rejects changed source instead of acknowledging stale evidence');
|
||||
|
||||
const oldSha = stopped.evidence.sha256; await panel().getByRole('button', { name: '核对原输入与现场', exact: true }).click(); await expect.poll(() => stopped.evidence.sha256).not.toBe(oldSha);
|
||||
await panel().getByRole('button', { name: '查看核对记录', exact: true }).click(); await expect(page.getByRole('dialog', { name: '原输入与现场核对', exact: true })).toBeVisible(); await page.keyboard.press('Escape');
|
||||
await panel().getByRole('button', { name: '确认核对并保留现场结束', exact: true }).click(); await page.getByRole('dialog', { name: '确认保留现场', exact: true }).getByRole('button', { name: '确认保留现场结束', exact: true }).click();
|
||||
await expect.poll(() => stopped.status).toBe('resolved_external'); assert.equal(stopped.deadline, deadline); assert.match(fs.readFileSync(path.join(f.projectRoot, 'owner-unstaged.txt'), 'utf8'), /Owner changed/);
|
||||
await screenshot('mobile-workers-recovery-retained'); await panel().getByRole('button', { name: '创建下一父目标', exact: true }).click(); await expect(panel().getByLabel('父目标', { exact: true })).toBeEditable();
|
||||
mark('explicit recovery retention preserves changed owner source and unknown usage, closes the original goal and unlocks the next plan');
|
||||
for (const id of groups) { const record = groupState(id); for (const sessionId of [record.sessionId, ...record.children.map(child => child.sessionId)]) {
|
||||
const file = path.join(directory, 'session-' + sessionId + '-after-' + id + '.json'), value = await host.api('/sessions/' + sessionId + '/export'); fs.writeFileSync(file, JSON.stringify(value, null, 2)); exports.push({ file, sha256: hash(fs.readFileSync(file)) });
|
||||
} }
|
||||
assert.deepEqual(inputs(), frozen); assert.deepEqual(pageErrors, []); assert.deepEqual(requestFailures, []);
|
||||
result = { passed: true, version, capabilityStage: '1.13 isolated workers', evidenceKind: 'owned fixture and real local tools/UI', realModelRequests: 0, assertions, screenshots, exports, groups,
|
||||
fixtureRequests: host.requests.length + held, inputs: frozen, pageErrors, requestFailures, url: host.url, sourceRoot: f.root, createdAt: new Date().toISOString() };
|
||||
} catch (error) { result = { passed: false, version, error: error.stack, assertions, screenshots, pageErrors, requestFailures, sourceRoot: f.root }; await screenshot('workers-ui-failure').catch(() => {}); throw error; }
|
||||
finally {
|
||||
releaseHeld?.(); await browser.close(); await host.runtime.stopAll(); f.store.storage.database.exec('PRAGMA wal_checkpoint(TRUNCATE)');
|
||||
const copy = path.join(directory, 'original-fixture'); fs.cpSync(f.root, copy, { recursive: true }); if (result) result.originalFixture = copy;
|
||||
fs.writeFileSync(path.join(directory, 'result.json'), JSON.stringify(result, null, 2)); if (result?.passed) fs.writeFileSync(path.join('docs', prefix + '-ui-validation.json'), JSON.stringify(result, null, 2));
|
||||
for (const dispose of disposers.reverse()) await dispose(); console.log('EVIDENCE ' + directory);
|
||||
}
|
||||
+16
-7
@@ -13,6 +13,7 @@ import { ModelCenter } from './ModelCenter';
|
||||
import { ProjectMemoryPanel } from './ProjectMemoryPanel';
|
||||
import { SkillCenter } from './SkillCenter';
|
||||
import { McpPanel } from './McpPanel';
|
||||
import { WorkerPanel } from './WorkerPanel';
|
||||
|
||||
const activeStates = ['running', 'awaiting_approval', 'stopping'];
|
||||
const activeMcpStates = ['queued', 'connecting', 'discovering', 'calling', 'closing', 'stopping'];
|
||||
@@ -73,6 +74,7 @@ export default function App() {
|
||||
const [memoryOpen, setMemoryOpen] = useState(false);
|
||||
const [skillsOpen, setSkillsOpen] = useState(false);
|
||||
const [mcpOpen, setMcpOpen] = useState(false);
|
||||
const [workersOpen, setWorkersOpen] = useState(false);
|
||||
const [researchDocs, setResearchDocs] = useState<ResearchDoc[]>([]);
|
||||
const [report, setReport] = useState<{ title: string; content: string } | null>(null);
|
||||
const chatEnd = useRef<HTMLDivElement>(null);
|
||||
@@ -99,8 +101,10 @@ export default function App() {
|
||||
|| session.execution?.researchJobs?.some(value => ['queued', 'connecting', 'analyzing', 'stopping'].includes(value.status)) === true
|
||||
|| session.execution?.engineJobs?.some(value => ['queued', 'starting', 'initializing', 'checking', 'stopping'].includes(value.status)) === true
|
||||
|| session.execution?.mcpJobs?.some(value => activeMcpStates.includes(value.status)) === true
|
||||
|| session.execution?.collaborations?.some(value => ['preparing', 'starting', 'running', 'stopping', 'collecting', 'merge_preparing', 'reconciling'].includes(value.status)) === true
|
||||
|| session.execution?.browserJobs?.some(value => ['queued', 'snapshotting', 'launching', 'running', 'closing'].includes(value.status)) === true);
|
||||
const anyRunning = isRunning || briefs.some(item => activeStates.includes(item.status));
|
||||
const restrictedWorker = !!session?.execution?.workers?.length;
|
||||
const pending = session?.changes.filter(change => ['pending', 'conflict'].includes(change.status)) || [];
|
||||
const reviewedRun = session?.execution?.run;
|
||||
const canContinueReview = !!session && pending.length === 0 && !isRunning
|
||||
@@ -230,6 +234,7 @@ export default function App() {
|
||||
}
|
||||
async function submit() {
|
||||
if (!composer.trim() || sending || isRunning || (sessionId && !session)) return;
|
||||
if (restrictedWorker || session?.execution?.collaborations?.some(value => !['completed', 'discarded', 'resolved_external'].includes(value.status))) { setWorkersOpen(true); return; }
|
||||
if (config.mode === 'compatible' && !config.model) { openSettings(); notify('请先填写模型名称。'); return; }
|
||||
setSending(true);
|
||||
const content = composer.trim();
|
||||
@@ -335,12 +340,14 @@ export default function App() {
|
||||
catch (error) { failure(error); } finally { setDiagnosticsBusy(false); }
|
||||
}
|
||||
async function resumeSession() {
|
||||
if (session?.execution?.workers?.length || session?.execution?.collaborations?.some(value => !['completed', 'discarded', 'resolved_external'].includes(value.status))) { setWorkersOpen(true); return; }
|
||||
if (!session || resuming || isRunning) return;
|
||||
setResuming(true);
|
||||
try { acceptSession(await api<Session>('/sessions/' + session.id + '/resume', {})); }
|
||||
catch (error) { failure(error); } finally { setResuming(false); }
|
||||
}
|
||||
async function continueReviewed() {
|
||||
if (session?.execution?.workers?.length || session?.execution?.collaborations?.some(value => !['completed', 'discarded', 'resolved_external'].includes(value.status))) { setWorkersOpen(true); return; }
|
||||
if (!session || resuming || isRunning) return; setResuming(true);
|
||||
try { acceptSession(await api<Session>('/sessions/' + session.id + '/continue-reviewed', {})); }
|
||||
catch (error) { failure(error); } finally { setResuming(false); }
|
||||
@@ -495,8 +502,8 @@ export default function App() {
|
||||
<aside className="project-sidebar">
|
||||
<div className="brand"><span className="brand-mark">AW</span><div><strong>Agent Workbench</strong><span>本地编程工作台 · 正式版</span></div><IconButton label="收起项目栏" onClick={() => setSidebarOpen(false)}><PanelLeftClose size={16} /></IconButton></div>
|
||||
<div className="project-selector"><span className="field-eyebrow">当前项目</span><div className="project-select-row"><FolderOpen size={17} /><select aria-label="当前项目" value={projectId} onChange={event => chooseProject(event.target.value)}>{projects.map(project => <option key={project.id} value={project.id}>{project.name}{project.id === exampleId ? '(示例)' : ''}</option>)}{!projects.length && <option value="">选择一个项目</option>}</select><IconButton label="打开项目" onClick={() => setProjectOpen(true)}><Plus size={15} /></IconButton></div>{selectedProject && <span className="project-root" title={selectedProject.root}>{selectedProject.root}</span>}{projectId === exampleId && <span className="example-tag">当前为自带示例,可打开自己的项目开始开发</span>}</div>
|
||||
<div className="sidebar-section sessions-section"><div className="section-label"><span>任务会话</span><IconButton label="新建任务" disabled={creatingSession} onClick={() => newSession().catch(failure)}><Plus size={15} /></IconButton></div>
|
||||
<button type="button" className="new-task-button" disabled={creatingSession} onClick={() => newSession().catch(failure)}><Plus size={15} />新建任务<span>↵</span></button>
|
||||
<div className="sidebar-section sessions-section"><div className="section-label"><span>任务会话</span><IconButton label="新建任务" disabled={creatingSession || restrictedWorker} onClick={() => newSession().catch(failure)}><Plus size={15} /></IconButton></div>
|
||||
<button type="button" className="new-task-button" disabled={creatingSession || restrictedWorker} onClick={() => newSession().catch(failure)}><Plus size={15} />新建任务<span>↵</span></button>
|
||||
<div className="session-list">{projectSessions.slice(0, 15).map(item => <div key={item.id} className={'session-item ' + (item.id === sessionId ? 'selected' : '')}>
|
||||
<button type="button" className="session-select" onClick={() => chooseSession(item.id)}><MessageSquare size={14} /><span>{item.title}</span>{item.changeCount > 0 && <b>{item.changeCount}</b>}</button>
|
||||
{!activeStates.includes(item.status) && <IconButton label={'归档会话 ' + item.title} onClick={() => api('/sessions/' + item.id + '/archive', {}).then(() => { if (item.id === selectedSessionRef.current) selectSession(''); }).catch(failure)}><Trash2 size={12} /></IconButton>}
|
||||
@@ -508,7 +515,7 @@ export default function App() {
|
||||
if (file.kind === 'directory') setCollapsed(previous => { const next = new Set(previous); if (next.has(file.path)) next.delete(file.path); else next.add(file.path); return next; }); else loadFile(file.path);
|
||||
}}>{file.kind === 'directory' ? <><span className="tree-chevron">{collapsed.has(file.path) ? <ChevronRight size={11} /> : <ChevronDown size={11} />}</span><Folder size={14} /></> : <><span className="tree-chevron" /><File size={13} /></>}<span>{filter ? file.path : file.name}</span></button>)}{filter && !visibleFiles.length && <p className="sidebar-hint">没有匹配的文件。</p>}</div>
|
||||
</div>
|
||||
<div className="sidebar-footer"><button onClick={openResearch}><BookOpenText size={16} />机制研究与设计<ChevronRight size={13} /></button><button onClick={() => setMemoryOpen(true)} disabled={!selectedProject}><Brain size={16} />项目记忆<ChevronRight size={13} /></button><button onClick={() => openDiagnostics()}><Activity size={16} />运行诊断<ChevronRight size={13} /></button><button onClick={openSettings}><Settings2 size={16} />模型连接<ChevronRight size={13} /></button><div className={'connection ' + (ready ? 'connected' : '')}><span />{ready ? '本地服务已连接' : '正在连接本地服务'}<small>v{version}</small></div></div>
|
||||
<div className="sidebar-footer"><button onClick={openResearch}><BookOpenText size={16} />机制研究与设计<ChevronRight size={13} /></button><button onClick={() => setMemoryOpen(true)} disabled={!selectedProject || restrictedWorker}><Brain size={16} />项目记忆<ChevronRight size={13} /></button><button onClick={() => openDiagnostics()}><Activity size={16} />运行诊断<ChevronRight size={13} /></button><button onClick={openSettings}><Settings2 size={16} />模型连接<ChevronRight size={13} /></button><div className={'connection ' + (ready ? 'connected' : '')}><span />{ready ? '本地服务已连接' : '正在连接本地服务'}<small>v{version}</small></div></div>
|
||||
</aside>
|
||||
<main className="task-pane">
|
||||
<header className="work-header"><div className="work-title">{(!sidebarOpen || mobile) && <IconButton label="展开项目栏" onClick={() => setSidebarOpen(true)}><PanelLeftOpen size={18} /></IconButton>}<span className="header-symbol"><Code2 size={17} /></span><div><span className="header-breadcrumb">{selectedProject?.name || '工作空间'} <ChevronRight size={12} /> 任务</span><h1>{session?.title || '让任务走到完成'}</h1></div></div>
|
||||
@@ -516,11 +523,12 @@ export default function App() {
|
||||
</header>
|
||||
<div className="task-toolbar"><span className="task-local"><GitBranch size={13} />本地项目</span>{session ? <Status value={session.status} /> : <span className="subtle">等待新任务</span>}<div className="toolbar-actions">
|
||||
<IconButton label="运行诊断" onClick={() => openDiagnostics()}><Activity size={15} /></IconButton>
|
||||
<IconButton label="项目技能" onClick={() => setSkillsOpen(true)} disabled={!selectedProject}><BookOpenText size={15} /></IconButton>
|
||||
<IconButton label="项目MCP工具" onClick={() => setMcpOpen(true)} disabled={!selectedProject}><Puzzle size={15} /></IconButton>
|
||||
<IconButton label="项目技能" onClick={() => setSkillsOpen(true)} disabled={!selectedProject || restrictedWorker}><BookOpenText size={15} /></IconButton>
|
||||
<IconButton label="项目MCP工具" onClick={() => setMcpOpen(true)} disabled={!selectedProject || restrictedWorker}><Puzzle size={15} /></IconButton>
|
||||
<IconButton label="查看任务记录" onClick={() => showInspector('task')}><ClipboardCheck size={15} /></IconButton>
|
||||
<IconButton label="本地代理引擎" onClick={() => setEngineOpen(true)} disabled={!session}><Link2 size={15} /></IconButton>
|
||||
<IconButton label="REA 工件研究" onClick={() => void openRea()} disabled={!selectedProject || creatingSession}><BookOpenText size={15} /></IconButton>
|
||||
<IconButton label="隔离协作" onClick={() => setWorkersOpen(true)} disabled={!session}><GitBranch size={15} /></IconButton>
|
||||
<IconButton label="本地代理引擎" onClick={() => setEngineOpen(true)} disabled={!session || restrictedWorker}><Link2 size={15} /></IconButton>
|
||||
<IconButton label="REA 工件研究" onClick={() => void openRea()} disabled={!selectedProject || creatingSession || restrictedWorker}><BookOpenText size={15} /></IconButton>
|
||||
{narrow && <><IconButton label="查看文件" onClick={() => showInspector('file')}><FileCode2 size={16} /></IconButton><IconButton label="查看改动" onClick={() => showInspector('changes')}><GitBranch size={16} /></IconButton><IconButton label="查看执行轨迹" onClick={() => showInspector('trace')}><SquareTerminal size={16} /></IconButton></>}
|
||||
{pending.length > 0 && <button className="text-button review-toolbar" onClick={() => { setChangeId(pending[0].id); showInspector('changes'); }}><FileCode2 size={13} />审核 {pending.length} 项</button>}
|
||||
{session && <><IconButton label="导出会话" onClick={() => exportSession(session.id).catch(failure)}><ArrowDownToLine size={15} /></IconButton>
|
||||
@@ -565,6 +573,7 @@ export default function App() {
|
||||
{memoryOpen && selectedProject && <Modal title="项目记忆" description="项目事实与决策绑定源码指纹,变化后自动要求重新核对。" wide onClose={() => setMemoryOpen(false)}><ProjectMemoryPanel key={selectedProject.id + ':' + (session?.id ?? '')} project={selectedProject} session={session?.projectId === selectedProject.id ? session : null} /></Modal>}
|
||||
{skillsOpen && selectedProject && <Modal title="项目技能" description="管理当前项目的技能来源、版本与启用状态。" wide onClose={() => setSkillsOpen(false)}><SkillCenter key={selectedProject.id} projectId={selectedProject.id} busy={isRunning} /></Modal>}
|
||||
{mcpOpen && selectedProject && <Modal title="项目 MCP 工具" description="实际探测本地 stdio 服务,选择可以请求的工具,并核对每次运行原记录。" wide onClose={() => setMcpOpen(false)}><McpPanel key={selectedProject.id + ':' + (session?.id ?? '')} projectId={selectedProject.id} session={session?.projectId === selectedProject.id ? session : null} busy={isRunning} onSession={acceptSession} onError={session ? failureFor(session) : failure} /></Modal>}
|
||||
{workersOpen && session && <Modal title="隔离协作" description="固定父子目标、独立工作区、预算与原成果审查。" wide onClose={() => setWorkersOpen(false)}><WorkerPanel key={session.id} session={session} config={config} busy={isRunning} onSession={acceptSession} onNavigate={async (projectId, sessionId) => { setWorkersOpen(false); await navigateWorkspace(projectId, sessionId); }} onReview={() => { setWorkersOpen(false); showInspector('changes'); }} /></Modal>}
|
||||
{toast && <div className="toast" role="status"><span>{toast}</span><IconButton label="关闭提示" onClick={() => setToast('')}><X size={14} /></IconButton></div>}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
.worker-console { --worker-ink: #153047; --worker-muted: #587087; --worker-line: #c7d3de; --worker-blue: #2560a3; --worker-wash: #edf3fa; --worker-alert: #925619; color: var(--worker-ink); font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif; display: grid; gap: 20px; min-width: 0; }
|
||||
.worker-console h2, .worker-console h3, .worker-console p { margin: 0; }
|
||||
.worker-console h2 { font-size: 21px; line-height: 1.4; font-weight: 650; letter-spacing: -.3px; }
|
||||
.worker-console h3 { font-size: 16px; line-height: 1.5; }
|
||||
.worker-console p { line-height: 1.65; }
|
||||
.worker-console code { font-family: 'Cascadia Code', Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
|
||||
.worker-console-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.worker-console-heading p:not(.worker-eyebrow) { color: var(--worker-muted); margin-top: 5px; font-size: 13px; }
|
||||
.worker-console .worker-eyebrow { color: var(--worker-blue); font-size: 11px; letter-spacing: .08em; font-weight: 650; margin-bottom: 5px; }
|
||||
.worker-error { padding: 12px 15px; border: 1px solid #dfc4a7; border-left: 3px solid var(--worker-alert); background: #fff8ee; color: #794d21; overflow-wrap: anywhere; font-size: 13px; }
|
||||
.worker-history { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; font-size: 12px; color: var(--worker-muted); }
|
||||
.worker-console input, .worker-console textarea, .worker-console select { width: 100%; border: 1px solid var(--worker-line); border-radius: 5px; background: #fff; padding: 9px 10px; color: var(--worker-ink); font-size: 13px; font-family: inherit; min-width: 0; }
|
||||
.worker-console textarea { resize: vertical; line-height: 1.6; }
|
||||
.worker-console input:focus-visible, .worker-console textarea:focus-visible, .worker-console select:focus-visible, .worker-console button:focus-visible { outline: 2px solid var(--worker-blue); outline-offset: 3px; }
|
||||
.worker-plan-form { display: grid; gap: 18px; }
|
||||
.worker-plan-form label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; }
|
||||
.worker-lanes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: stretch; }
|
||||
.worker-lanes fieldset { border: 1px solid var(--worker-line); border-top: 3px solid var(--worker-blue); border-radius: 6px; padding: 16px; display: grid; gap: 13px; min-width: 0; }
|
||||
.worker-lanes legend { padding: 0 8px; font-size: 12px; color: var(--worker-muted); }
|
||||
.worker-budget-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
|
||||
.worker-parent { border: 1px solid var(--worker-line); background: var(--worker-wash); border-radius: 6px; padding: 18px 20px; display: grid; gap: 12px; }
|
||||
.worker-parent-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
|
||||
.worker-parent h3, .worker-goal { overflow-wrap: anywhere; white-space: pre-wrap; }
|
||||
.worker-parent > p { font-size: 13px; color: var(--worker-muted); }
|
||||
.worker-parent dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 18px; border-top: 1px solid var(--worker-line); padding-top: 12px; margin: 0; }
|
||||
.worker-parent dl div { min-width: 0; }
|
||||
.worker-parent dt { font-size: 11px; color: var(--worker-muted); margin-bottom: 4px; }
|
||||
.worker-parent dd { font-size: 12px; margin: 0; overflow-wrap: anywhere; }
|
||||
.worker-lane { border: 1px solid var(--worker-line); border-top: 3px solid var(--worker-blue); border-radius: 6px; padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
|
||||
.worker-lane-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--worker-muted); }
|
||||
.worker-status { display: inline-flex; align-items: center; background: #e2ecf6; color: var(--worker-blue); border: 1px solid #c2d5e8; border-radius: 3px; padding: 3px 7px; font-size: 11px; line-height: 1.4; white-space: nowrap; font-weight: 600; }
|
||||
.worker-status.attention { color: var(--worker-alert); border-color: #dec6a8; background: #fff6e9; }
|
||||
.worker-goal { font-size: 13px; flex: 1; }
|
||||
.worker-scope { border-left: 2px solid var(--worker-line); padding-left: 10px; display: grid; gap: 5px; }
|
||||
.worker-scope > span, .worker-meter { font-size: 11px; color: var(--worker-muted); }
|
||||
.worker-summary { color: var(--worker-muted); font-size: 12px; overflow-wrap: anywhere; }
|
||||
.worker-proof { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--worker-blue); }
|
||||
.worker-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
|
||||
.worker-primary-actions { padding-top: 16px; border-top: 1px solid var(--worker-line); }
|
||||
.worker-console .button { font-size: 12px; min-height: 36px; }
|
||||
.worker-console .worker-stop { background: #fff8ee; border-color: #dfc4a7; color: #794d21; }
|
||||
.worker-review { border-left: 3px solid var(--worker-blue); padding: 2px 0 2px 15px; display: grid; gap: 12px; }
|
||||
.worker-review-title { display: flex; align-items: center; gap: 8px; }
|
||||
.worker-review > p { color: var(--worker-muted); font-size: 12px; }
|
||||
.worker-conflicts { padding: 0; margin: 0; list-style: none; display: grid; gap: 7px; }
|
||||
.worker-conflicts li { display: grid; gap: 4px; padding: 10px; background: #fff8ee; border: 1px solid #dfc4a7; font-size: 12px; overflow-wrap: anywhere; }
|
||||
.worker-note, .worker-boundary { color: var(--worker-muted); font-size: 11px; }
|
||||
.worker-boundary { display: flex; align-items: flex-start; gap: 7px; padding-top: 12px; border-top: 1px solid var(--worker-line); }
|
||||
.worker-boundary svg { flex: 0 0 auto; margin-top: 2px; }
|
||||
.worker-origin { display: flex; gap: 13px; padding: 20px; background: var(--worker-wash); border: 1px solid var(--worker-line); border-radius: 6px; }
|
||||
.worker-origin div { display: grid; gap: 12px; min-width: 0; }
|
||||
.worker-origin p { font-size: 13px; overflow-wrap: anywhere; }
|
||||
.worker-confirm { display: grid; gap: 18px; }
|
||||
.worker-confirm p { line-height: 1.7; font-size: 13px; }
|
||||
.worker-confirm strong { display: block; margin-top: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.worker-record { display: grid; gap: 12px; min-width: 0; }
|
||||
.worker-record pre { font: 12px/1.6 'Cascadia Code', Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 65vh; overflow: auto; padding: 14px; background: #f5f8fb; border: 1px solid #c7d3de; }
|
||||
@media (max-width: 620px) { .worker-console { gap: 16px; } .worker-console h2 { font-size: 18px; } .worker-lanes { grid-template-columns: minmax(0, 1fr); } .worker-budget-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .worker-parent { padding: 14px; } .worker-parent dl { grid-template-columns: minmax(0, 1fr); } .worker-actions .button { min-height: 42px; } .worker-console-heading { gap: 10px; } .worker-history { grid-template-columns: minmax(0, 1fr); gap: 6px; } }
|
||||
@@ -0,0 +1,105 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { ArrowUpRight, Check, GitBranch, LoaderCircle, Play, RefreshCw, ShieldCheck, Square } from 'lucide-react';
|
||||
import { api, downloadBlob } from './api';
|
||||
import { Modal } from './components';
|
||||
import type { CollaborationGroup, Config, Session, WorkerView } from './types';
|
||||
import './WorkerPanel.css';
|
||||
|
||||
const active = ['preparing', 'starting', 'running', 'stopping', 'collecting', 'merge_preparing', 'reconciling'];
|
||||
const labels: Record<string, string> = { planned: '计划已封存', unprepared: '待创建', partially_prepared: '部分工作区已创建', ready: '就绪', preparing: '创建工作区', starting: '启动中', running: '执行中', stopping: '停止中', collecting: '核对成果', merge_preparing: '准备合并审查', reconciling: '核对现场', completed: '完成', ready_to_collect: '待核对成果', collected: '成果可审查', conflict: '需要处理冲突', merge_prepared: '等待合并审查', failed: '需要处理', paused: '已暂停', awaiting_review: '等待改动审查', needs_review: '等待改动审查', unknown: '结果待核对', stale: '来源已变化', discarded: '计划已撤销', resolved_external: '已保留现场' };
|
||||
const number = (value?: number) => (value ?? 0).toLocaleString('zh-CN');
|
||||
const statusLabel = (value: string) => value === 'awaiting_approval' ? '等待检查审批' : labels[value] ?? value;
|
||||
const splitPaths = (value: string) => value.split(/[\n,,]/).map(path => path.trim()).filter(Boolean);
|
||||
|
||||
export function WorkerPanel({ session, config, busy, onSession, onNavigate, onReview }: {
|
||||
session: Session; config: Config; busy: boolean; onSession: (value: Session) => void;
|
||||
onNavigate: (projectId: string, sessionId: string) => Promise<void>; onReview: () => void;
|
||||
}) {
|
||||
const [view, setView] = useState<WorkerView | null>(null), [selectedId, setSelectedId] = useState('');
|
||||
const [error, setError] = useState(''), [action, setAction] = useState(''), [loading, setLoading] = useState(false);
|
||||
const [goal, setGoal] = useState(''), [creating, setCreating] = useState(false);
|
||||
const [drafts, setDrafts] = useState([{ label: '核心实现', goal: '', paths: '' }, { label: '独立模块', goal: '', paths: '' }]);
|
||||
const [tokens, setTokens] = useState(config.maxRunTokens), [steps, setSteps] = useState(Math.min(200, config.maxSteps * 2));
|
||||
const [duration, setDuration] = useState(Math.floor(config.maxRunDurationMs / 60000)), [toolCalls, setToolCalls] = useState(96);
|
||||
const [confirmation, setConfirmation] = useState<{ group: CollaborationGroup; operation: string; workerId?: string; retain?: boolean } | null>(null);
|
||||
const [preview, setPreview] = useState<{ title: string; content: string; groupId: string } | null>(null), [readEvidenceSha, setReadEvidenceSha] = useState('');
|
||||
const scope = useRef(0), requestId = useRef(0), fetchPending = useRef<number | null>(null), selectedGroup = useRef('');
|
||||
const load = useCallback(async (quiet = false) => {
|
||||
if (fetchPending.current !== null) return;
|
||||
const generation = scope.current, request = ++requestId.current; fetchPending.current = request;
|
||||
if (!quiet) setLoading(true);
|
||||
try { const result = await api<WorkerView>('/sessions/' + session.id + '/collaborations'); if (generation === scope.current && request === requestId.current) setView(result); }
|
||||
catch (failure) { if (generation === scope.current) setError(failure instanceof Error ? failure.message : String(failure)); }
|
||||
finally { if (fetchPending.current === request) fetchPending.current = null; if (generation === scope.current) setLoading(false); }
|
||||
}, [session.id]);
|
||||
useEffect(() => { scope.current++; fetchPending.current = null; setView(null); setSelectedId(''); setCreating(false); void load(); return () => { scope.current++; requestId.current++; }; }, [load]);
|
||||
useEffect(() => { void load(true); }, [session.revision, load]);
|
||||
const group = view?.groups.find(value => value.id === selectedId) ?? view?.groups.at(-1), running = !!group && active.includes(group.status);
|
||||
selectedGroup.current = group?.id ?? '';
|
||||
useEffect(() => { setError(''); setAction(''); setConfirmation(null); setPreview(null); setReadEvidenceSha(''); }, [session.id, group?.id, group?.evidence?.sha256]);
|
||||
useEffect(() => { if (!running) return; const timer = setInterval(() => void load(true), 1500); return () => clearInterval(timer); }, [running, load]);
|
||||
async function execute(group: CollaborationGroup, operation: string, extra: Record<string, unknown> = {}) {
|
||||
if (selectedGroup.current !== group.id) return;
|
||||
const generation = scope.current; setAction(operation); setError(''); setConfirmation(null);
|
||||
try {
|
||||
const result = await api<{ session: Session }>('/sessions/' + session.id + '/collaborations/' + group.id + '/' + operation, { fingerprint: group.fingerprint, ...extra });
|
||||
if (generation !== scope.current || selectedGroup.current !== group.id) return;
|
||||
onSession(result.session); await load(true);
|
||||
} catch (failure) { if (generation === scope.current && selectedGroup.current === group.id) setError(failure instanceof Error ? failure.message : String(failure)); }
|
||||
finally { if (generation === scope.current && selectedGroup.current === group.id) setAction(''); }
|
||||
}
|
||||
async function create() {
|
||||
const generation = scope.current; setAction('plan'); setError('');
|
||||
try {
|
||||
const result = await api<{ group: CollaborationGroup; session: Session }>('/sessions/' + session.id + '/collaborations', {
|
||||
goal, children: drafts.map(child => ({ label: child.label, goal: child.goal, paths: splitPaths(child.paths) })),
|
||||
budget: { maxTokens: tokens, maxSteps: steps, maxToolCalls: toolCalls, maxDurationMs: duration * 60000 },
|
||||
});
|
||||
if (generation !== scope.current) return;
|
||||
setSelectedId(result.group.id); setCreating(false); onSession(result.session); await load(true);
|
||||
} catch (failure) { if (generation === scope.current) setError(failure instanceof Error ? failure.message : String(failure)); }
|
||||
finally { if (generation === scope.current) setAction(''); }
|
||||
}
|
||||
async function showRecord(group: CollaborationGroup, kind: 'collection' | 'evidence') {
|
||||
const generation = scope.current; setAction('record'); setError('');
|
||||
try { const result = await api<unknown>('/sessions/' + session.id + '/collaborations/' + group.id + '/' + kind); if (generation === scope.current && selectedGroup.current === group.id) { setPreview({ title: kind === 'collection' ? '原成果核对记录' : '原输入与现场核对', content: JSON.stringify(result, null, 2), groupId: group.id }); if (kind === 'evidence') setReadEvidenceSha(group.evidence?.sha256 ?? ''); } }
|
||||
catch (failure) { if (generation === scope.current && selectedGroup.current === group.id) setError(failure instanceof Error ? failure.message : String(failure)); }
|
||||
finally { if (generation === scope.current && selectedGroup.current === group.id) setAction(''); }
|
||||
}
|
||||
const canPlan = !!view && !view.worker && !busy && !action && view.groups.every(value => ['completed', 'discarded', 'resolved_external'].includes(value.status));
|
||||
return <div className="worker-console" aria-label="隔离协作控制台">
|
||||
<div className="worker-console-heading"><div><p className="worker-eyebrow">工程执行 / 隔离协作</p><h2>一个目标,两个独立执行通道</h2><p>分工和预算固定,成果核对后进入父工程审查。</p></div><button className="button secondary" disabled={loading || !!action} onClick={() => void load()}><RefreshCw size={14} />刷新</button></div>
|
||||
{error && <div className="worker-error" role="alert">{error}</div>}
|
||||
{loading && !view && <p role="status"><LoaderCircle className="spin" size={16} />正在读取当前任务记录</p>}
|
||||
{view?.worker ? <div className="worker-origin"><ShieldCheck size={22} /><div><h3>当前是受限子任务:{view.worker.label}</h3><p>固定范围:{view.worker.paths.join('、')}。开始、停止全部与成果合并在父目标中处理。</p><button className="button secondary" onClick={() => void onNavigate(view.worker!.parentProjectId, view.worker!.parentSessionId)}>返回父目标<ArrowUpRight size={14} /></button></div></div> : <>
|
||||
{!!view?.groups.length && <label className="worker-history">协作记录<select value={group?.id ?? ''} onChange={event => { setSelectedId(event.target.value); setCreating(false); }} aria-label="选择协作记录">{view.groups.map(value => <option key={value.id} value={value.id}>{statusLabel(value.status)} · {value.goal.slice(0, 40)}</option>)}</select></label>}
|
||||
{(!group || creating) && <div className="worker-plan-form">
|
||||
<label>父目标<textarea value={goal} onChange={event => setGoal(event.target.value)} placeholder="描述需要交付的结果与验收要求" maxLength={20000} rows={3} /></label>
|
||||
<div className="worker-lanes">{drafts.map((child, index) => <fieldset key={index}><legend>子任务 {index + 1}</legend><label>任务名称<input value={child.label} maxLength={64} onChange={event => setDrafts(values => values.map((value, i) => i === index ? { ...value, label: event.target.value } : value))} /></label><label>独立子目标<textarea value={child.goal} maxLength={8000} rows={3} onChange={event => setDrafts(values => values.map((value, i) => i === index ? { ...value, goal: event.target.value } : value))} /></label><label>允许修改的文件或目录<textarea value={child.paths} rows={2} placeholder="例如 src/parser.mjs,每行一个相对路径" onChange={event => setDrafts(values => values.map((value, i) => i === index ? { ...value, paths: event.target.value } : value))} /></label></fieldset>)}</div>
|
||||
<div className="worker-budget-form"><label>总 token 预算<input type="number" min={1000} max={config.maxRunTokens} value={tokens} onChange={event => setTokens(Number(event.target.value))} /></label><label>总请求轮次<input type="number" min={2} max={200} value={steps} onChange={event => setSteps(Number(event.target.value))} /></label><label>总工具次数<input type="number" min={2} max={512} value={toolCalls} onChange={event => setToolCalls(Number(event.target.value))} /></label><label>总时限(分钟)<input type="number" min={1} max={Math.floor(config.maxRunDurationMs / 60000)} value={duration} onChange={event => setDuration(Number(event.target.value))} /></label></div>
|
||||
<p className="worker-note">两份预算各分一半,续接沿用累计用量与原时限。来源只检出已提交 HEAD,原暂存和未提交修改保留。</p>
|
||||
<div className="worker-actions"><button className="button" disabled={!canPlan || !goal.trim() || drafts.some(child => !child.goal.trim() || !splitPaths(child.paths).length)} onClick={() => void create()}><ShieldCheck size={15} />封存分工计划</button>{creating && <button className="button secondary" onClick={() => setCreating(false)}>返回原协作</button>}</div>
|
||||
</div>}
|
||||
{group && !creating && <>
|
||||
<section className="worker-parent"><div className="worker-parent-top"><span className={'worker-status ' + (group.requiresVerification || group.status === 'conflict' ? 'attention' : '')}>{statusLabel(group.status)}</span><code>{group.source.identity.branch} · {group.source.identity.head.slice(0, 12)}</code></div><h3>{group.goal}</h3><p>{group.summary}</p><dl><div><dt>模型</dt><dd>{group.model.mode === 'demo' ? '离线演示' : group.model.model}</dd></div><div><dt>总预算</dt><dd>{number(group.budget.maxTokens)} tokens / {group.budget.maxSteps} 轮 / {group.budget.maxToolCalls} 次工具</dd></div><div><dt>累计用量</dt><dd>{number(group.usage?.accountedTokens)} tokens / {group.usage?.steps ?? 0} 轮 / {group.usage?.toolCalls ?? 0} 次工具</dd></div><div><dt>原修改</dt><dd>{group.source.changedPaths.length ? group.source.changedPaths.map(value => value.path).join('、') : '无未提交修改'}</dd></div></dl></section>
|
||||
<div className="worker-lanes">{(group.workers ?? []).map((child, index) => <section className="worker-lane" key={child.id}><div className="worker-lane-title"><span>通道 {index + 1}</span><span className={'worker-status ' + (child.requiresVerification ? 'attention' : '')}>{statusLabel(child.sessionStatus === 'awaiting_approval' ? 'awaiting_approval' : child.status)}</span></div><h3>{child.label}</h3><p className="worker-goal">{child.goal}</p><div className="worker-scope"><span>允许修改</span>{child.paths.map(path => <code key={path}>{path}</code>)}</div><p className="worker-meter">{number(child.usage?.accountedTokens)} / {number(child.budget.maxTokens)} tokens · {child.usage?.steps ?? 0}/{child.budget.maxSteps} 轮</p><p className="worker-summary">{child.summary ?? '先创建独立工作区,再开始子任务。'}</p>{child.result && <div className="worker-proof"><Check size={14} />{child.result.paths.length} 个原改动 · 当前检查已封存</div>}<div className="worker-actions">{child.status !== 'unprepared' && <button className="button secondary" onClick={() => void onNavigate(child.projectId, child.sessionId)}>{child.sessionStatus === 'awaiting_approval' ? '查看并审批检查' : child.sessionStatus === 'needs_review' ? '审查子任务改动' : '打开子任务'}<ArrowUpRight size={13} /></button>}{['ready', 'paused', 'failed', 'awaiting_review'].includes(child.status) && !running && child.sessionStatus !== 'needs_review' && <button className="text-button" disabled={!!action || config.mode === 'demo' || group.requiresVerification} onClick={() => setConfirmation({ group, operation: 'start', workerId: child.id })}><Play size={13} />继续子任务</button>}</div></section>)}</div>
|
||||
<section className="worker-review"><div className="worker-review-title"><GitBranch size={18} /><h3>父工程成果审查</h3></div>{group.collection ? <><p>{group.collection.paths.length} 个路径已核对,原记录 <code>{group.collection.sha256.slice(0, 16)}</code></p>{group.collection.conflicts.length > 0 && <ul className="worker-conflicts">{group.collection.conflicts.map((conflict, i) => <li key={i}><code>{conflict.path}</code><span>{conflict.reason}</span></li>)}</ul>}<button className="text-button" disabled={!!action} onClick={() => void showRecord(group, 'collection')}>查看原成果记录</button></> : <p>等待两个子任务完成实际修改与检查。重叠路径、来源变化或原证据失效会阻止合并。</p>}{group.merge?.changeSetId && <button className="button secondary" onClick={onReview}>打开父工程变更集审查<ArrowUpRight size={14} /></button>}</section>
|
||||
<div className="worker-actions worker-primary-actions">
|
||||
{['planned', 'partially_prepared'].includes(group.status) && <button className="button" disabled={!!action || busy} onClick={() => setConfirmation({ group, operation: 'prepare' })}><GitBranch size={15} />创建两个工作区</button>}
|
||||
{['ready', 'paused', 'awaiting_review'].includes(group.status) && <button className="button" disabled={!!action || running || config.mode === 'demo' || group.requiresVerification || group.workers?.some(child => child.sessionStatus === 'needs_review')} onClick={() => setConfirmation({ group, operation: 'start' })}><Play size={15} />{group.status === 'ready' ? '开始两个子任务' : '继续未完成子任务'}</button>}
|
||||
{running && <button className="button worker-stop" disabled={action === 'stop'} onClick={() => void execute(group, 'stop')}><Square size={14} />停止全部</button>}
|
||||
{['ready_to_collect', 'collected', 'conflict'].includes(group.status) && <button className="button secondary" disabled={!!action || running} onClick={() => void execute(group, 'collect')}><ShieldCheck size={15} />核对成果</button>}
|
||||
{group.status === 'collected' && <button className="button" disabled={!!action} onClick={() => void execute(group, 'merge')}><GitBranch size={15} />准备合并审查</button>}
|
||||
{group.merge?.changeSetId && <button className="button secondary" disabled={!!action || busy} onClick={() => void execute(group, 'finalize')}>核对检查与 Git 交付</button>}
|
||||
{group.requiresVerification && <><button className="button secondary" disabled={!!action || running} onClick={() => void execute(group, 'reconcile')}>核对原输入与现场</button>{group.evidence && <><button className="text-button" disabled={!!action} onClick={() => void showRecord(group, 'evidence')}>查看核对记录</button><button className="button secondary" disabled={!!action || readEvidenceSha !== group.evidence.sha256} onClick={() => setConfirmation({ group, operation: 'acknowledge' })}>确认核对并继续</button><button className="text-button" disabled={!!action || readEvidenceSha !== group.evidence.sha256} onClick={() => setConfirmation({ group, operation: 'acknowledge', retain: true })}>确认核对并保留现场结束</button></>}</>}
|
||||
{!running && !group.requiresVerification && !['completed', 'discarded', 'resolved_external'].includes(group.status) && <button className="text-button" disabled={!!action} onClick={() => setConfirmation({ group, operation: 'discard' })}>结束协作并保留现场</button>}
|
||||
{canPlan && <button className="button secondary" onClick={() => setCreating(true)}>创建下一父目标</button>}
|
||||
</div>
|
||||
{config.mode === 'demo' && ['ready', 'paused'].includes(group.status) && <p className="worker-note">当前为离线演示。请先配置可用模型,再新建使用该模型快照的协作计划。</p>}
|
||||
</>}
|
||||
</>}
|
||||
<p className="worker-boundary"><ShieldCheck size={14} />独立工作区与受限工具用于约束任务;审批的工程程序仍以本机账户执行。</p>
|
||||
{confirmation && <Modal title={confirmation.operation === 'start' ? '确认受限子执行' : confirmation.operation === 'prepare' ? '确认创建隔离工作区' : confirmation.operation === 'acknowledge' && !confirmation.retain ? '确认原结果核对' : '确认保留现场'} onClose={() => setConfirmation(null)}><div className="worker-confirm"><p>{confirmation.operation === 'start' ? '将请求已封存模型并使用剩余累计预算。每项工程检查仍在对应子任务中审批;旧工具不会重放。' : confirmation.operation === 'prepare' ? '按已封存 HEAD 串行创建两个独立 Git 工作区。原暂存与未提交修改保持在来源工程。' : confirmation.operation === 'acknowledge' && !confirmation.retain ? '按已阅读的原输入与现场记录解除核对门控。原未知结果保留,继续需要新检查和审批。' : '保留实际工作区、原任务、改动与报告,撤销未执行计划并结束本次协作;本次不记为交付完成。'}<strong>{confirmation.group.goal}</strong></p><button className="button" disabled={!!action || confirmation.operation === 'acknowledge' && readEvidenceSha !== confirmation.group.evidence?.sha256} onClick={() => void execute(confirmation.group, confirmation.operation, { ...(confirmation.workerId ? { workerId: confirmation.workerId } : {}), ...(confirmation.operation === 'acknowledge' ? { evidenceSha256: readEvidenceSha, retain: !!confirmation.retain } : {}) })}>确认{confirmation.operation === 'start' ? '开始' : confirmation.operation === 'prepare' ? '创建' : confirmation.operation === 'acknowledge' && !confirmation.retain ? '核对并继续' : '保留现场结束'}</button></div></Modal>}
|
||||
{preview && <Modal title={preview.title} wide onClose={() => setPreview(null)}><div className="worker-record"><button className="button secondary" onClick={() => downloadBlob(new Blob([preview.content], { type: 'application/json' }), 'agent-workbench-collaboration-' + preview.groupId + '.json')}>导出原记录</button><pre>{preview.content}</pre></div></Modal>}
|
||||
</div>;
|
||||
}
|
||||
+21
-1
@@ -160,7 +160,27 @@ export interface TaskPlanView {
|
||||
contract_artifact_id?: string; contract_sha256?: string; checked_at?: string; error?: string;
|
||||
}
|
||||
export interface TaskPlanReply { session: Session; plan: TaskPlanView; verification?: { status: string; reused?: boolean; proof_id: string; message?: string } }
|
||||
export interface ExecutionSnapshot { schemaVersion: number; task: Task | null; run: Run | null; runs: RunBrief[]; progress: { totalTools: number; completedTools: number; requiresVerification: { id: string; tool: string; state: string; callId: string }[] }; artifacts: Artifact[]; checks: CheckJob[]; mcpJobs?: McpJob[]; plans?: CheckPlan[]; deliveries?: DeliveryJob[]; deliveryPlans?: DeliveryPlan[]; changeSets?: ChangeSet[]; contextPlans?: ContextPlan[]; workspaces?: WorkspaceRecord[]; researchTargets?: ResearchTarget[]; researchJobs?: ResearchJob[]; engineJobs?: EngineJob[]; browserPlans?: BrowserPlan[]; browserJobs?: BrowserJob[]; taskPlans?: TaskPlanRecord[]; taskProofs?: { id: string; planId: string; stepKey: string; status: string }[]; workspaceIdentity?: WorkspaceIdentity; accountedTaskTokens: number }
|
||||
export interface ExecutionSnapshot { schemaVersion: number; task: Task | null; run: Run | null; runs: RunBrief[]; progress: { totalTools: number; completedTools: number; requiresVerification: { id: string; tool: string; state: string; callId: string }[] }; artifacts: Artifact[]; checks: CheckJob[]; mcpJobs?: McpJob[]; plans?: CheckPlan[]; deliveries?: DeliveryJob[]; deliveryPlans?: DeliveryPlan[]; changeSets?: ChangeSet[]; contextPlans?: ContextPlan[]; workspaces?: WorkspaceRecord[]; researchTargets?: ResearchTarget[]; researchJobs?: ResearchJob[]; engineJobs?: EngineJob[]; browserPlans?: BrowserPlan[]; browserJobs?: BrowserJob[]; taskPlans?: TaskPlanRecord[]; taskProofs?: { id: string; planId: string; stepKey: string; status: string }[]; collaborations?: CollaborationGroup[]; workers?: WorkerRecord[]; workspaceIdentity?: WorkspaceIdentity; accountedTaskTokens: number }
|
||||
export interface WorkerBudget { maxTokens: number; maxSteps: number; maxToolCalls: number }
|
||||
export interface WorkerDefinition { id: string; label: string; goal: string; paths: string[]; budget: WorkerBudget; workspaceId: string; projectId: string; sessionId: string; taskId: string }
|
||||
export interface WorkerRecord extends WorkerDefinition {
|
||||
collaborationId: string; parentProjectId: string; parentSessionId: string; parentTaskId: string; parentRunId: string;
|
||||
runId: string; currentRunId: string | null; runIds: string[]; baseCommit: string; fingerprint: string; status: string; requiresVerification: boolean;
|
||||
startedAt: string | null; finishedAt: string | null; summary: string; result: { artifactId: string; sha256: string; checkJobId: string; paths: string[] } | null;
|
||||
usage?: Usage & { accountedTokens: number; steps: number; toolCalls: number }; sessionStatus?: string;
|
||||
}
|
||||
export interface WorkerConflict { path: string; reason: string; workerIds: string[] }
|
||||
export interface CollaborationGroup {
|
||||
id: string; taskId: string; runId: string; projectId: string; sessionId: string; goal: string; fingerprint: string;
|
||||
status: string; phase?: string; requiresVerification: boolean; summary: string; createdAt: string; startedAt: string | null; finishedAt: string | null; deadline: number | null;
|
||||
model: { mode: string; model: string; baseUrl: string }; budget: WorkerBudget & { maxDurationMs: number };
|
||||
source: { identity: { root: string; head: string; branch: string; indexSha256: string }; dirty: boolean; changedPaths: { path: string; status: string }[] };
|
||||
children: WorkerDefinition[]; workers?: WorkerRecord[]; usage?: { accountedTokens: number; steps: number; toolCalls: number; unknownRequests: number };
|
||||
collection: { artifactId: string; sha256: string; conflicts: WorkerConflict[]; paths: string[] } | null;
|
||||
merge: { changeSetId?: string; fingerprint?: string; changeIds?: string[] } | null;
|
||||
evidence?: { artifactId: string; sha256: string } | null;
|
||||
}
|
||||
export interface WorkerView { groups: CollaborationGroup[]; worker: WorkerRecord | null }
|
||||
export interface McpTool { name: string; description: string; inputSchema: Record<string, unknown>; unsupported?: string }
|
||||
export interface McpRegistration {
|
||||
id: string; projectId: string; name: string; launch: { executable: { path: string; sha256: string; bytes: number }; entry: { path: string; sha256: string; bytes: number } | null; args: string[]; environment: string; identityScope: string };
|
||||
|
||||
+54
-12
@@ -3,13 +3,14 @@ import path from 'node:path';
|
||||
import { spawn, execFile } from 'node:child_process';
|
||||
import { createHash, randomUUID } from 'node:crypto';
|
||||
import { StringDecoder } from 'node:string_decoder';
|
||||
import { readOwnedProcessTree } from './owned-process-tree.mjs';
|
||||
import { inspectProject, createCheckList } from './project-inspector.mjs';
|
||||
import { safePath } from '../server/files.mjs';
|
||||
import { assertChangeSetsResolved } from '../shared/contracts/change-sets.mjs';
|
||||
import { assertWorkspacesResolved } from '../shared/contracts/workspaces.mjs';
|
||||
import { verifyWorkspaceProject } from './workspaces/git-workspaces.mjs';
|
||||
import { assertMcpResolved } from './tools/mcp-contract.mjs';
|
||||
import { assertWorkersResolved } from '../shared/contracts/workers.mjs';
|
||||
import { assertWorkersResolved, workerForSession } from '../shared/contracts/workers.mjs';
|
||||
import { bindPythonChecks, preparePythonInvocation, pythonEnvironment, readPythonEvidence, pythonResultBinding } from './python-runtime.mjs';
|
||||
import { projectEnvironment } from './process-environment.mjs';
|
||||
|
||||
@@ -65,6 +66,7 @@ export class CheckRunner {
|
||||
|
||||
async plan(session, names) {
|
||||
assertWorkersResolved(this.store, session.projectId);
|
||||
if (workerForSession(this.store, session)?.status === 'completed') throw conflict('子成果已经封存,请读取原检查记录;重新执行需要新的受限任务。');
|
||||
assertChangeSetsResolved(this.store, session.projectId);
|
||||
assertWorkspacesResolved(this.store, session.projectId, { includePrepared: true });
|
||||
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
|
||||
@@ -105,6 +107,7 @@ export class CheckRunner {
|
||||
|
||||
async start(session, planId, { signal, source = 'user' } = {}) {
|
||||
assertWorkersResolved(this.store, session.projectId);
|
||||
if (workerForSession(this.store, session)?.status === 'completed') throw conflict('子成果已经封存,不重新运行原检查。');
|
||||
assertMcpResolved(this.store, session.projectId);
|
||||
assertChangeSetsResolved(this.store, session.projectId, { includePrepared: true });
|
||||
assertWorkspacesResolved(this.store, session.projectId, { includePrepared: true });
|
||||
@@ -130,6 +133,7 @@ export class CheckRunner {
|
||||
|
||||
async execute(session, plan, job, run, signal) {
|
||||
const task = this.store.core.task.get(job.taskId);
|
||||
let unrecordedProcess = null;
|
||||
try {
|
||||
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
|
||||
const before = await inspectProject(this.store.project(session.projectId));
|
||||
@@ -144,7 +148,9 @@ export class CheckRunner {
|
||||
signal.throwIfAborted();
|
||||
job.currentCheck = { id: check.id, name: check.name, command: check.command, startedAt: at() };
|
||||
this.store.save(session, { type: 'check.command_started', detail: { jobId: job.id, checkId: check.id } });
|
||||
const result = await this.executeCheck(check, this.store.project(session.projectId), signal);
|
||||
const onSpawn = task.workerId ? processInfo => { unrecordedProcess = processInfo; job.currentCheck.process = processInfo; this.store.save(session, { type: 'worker.check_process_owned', detail: { jobId: job.id, pid: processInfo.pid } }); } : null;
|
||||
const result = await this.executeCheck(check, this.store.project(session.projectId), signal, onSpawn);
|
||||
unrecordedProcess = result.process ?? unrecordedProcess;
|
||||
const text = this.redact(result.stdout + (result.stderr ? '\n--- stderr ---\n' + result.stderr : ''));
|
||||
const artifact = this.store.artifactStore.write(session, run, text, { kind: 'check-log', mediaType: 'text/plain' });
|
||||
this.store.core.artifact.set(artifact.id, artifact);
|
||||
@@ -159,6 +165,7 @@ export class CheckRunner {
|
||||
}
|
||||
job.results.push({ id: randomUUID(), name: check.name, kind: check.kind, command: check.command, ...record, logArtifactId: artifact.id, logExcerpt: text.slice(-8000) });
|
||||
this.store.save(session, { type: 'check.result', detail: { jobId: job.id, checkId: check.id, status: record.status, artifactId: artifact.id } });
|
||||
unrecordedProcess = null;
|
||||
if (record.status === 'stale') { job.stale = true; break; }
|
||||
if (['cancelled', 'unknown'].includes(record.status)) break;
|
||||
const after = await inspectProject(this.store.project(session.projectId));
|
||||
@@ -166,8 +173,8 @@ export class CheckRunner {
|
||||
}
|
||||
const final = await inspectProject(this.store.project(session.projectId));
|
||||
job.stale ||= final.sourceFingerprint !== job.sourceFingerprint;
|
||||
if (signal.aborted || job.results.some(result => result.status === 'cancelled')) job.status = 'cancelled';
|
||||
else if (job.results.some(result => result.status === 'unknown')) { job.status = 'unknown'; job.requiresVerification = true; }
|
||||
if (job.results.some(result => result.status === 'unknown')) { job.status = 'unknown'; job.requiresVerification = true; }
|
||||
else if (signal.aborted || job.results.some(result => result.status === 'cancelled')) job.status = 'cancelled';
|
||||
else if (job.stale) job.status = 'stale';
|
||||
else if (job.results.some(result => result.status === 'failed')) job.status = 'failed';
|
||||
else if (!final.scope.complete || job.results.length !== plan.checks.length || job.results.some(result => result.status !== 'passed') || !job.results.some(result => result.kind === 'test' && result.tests?.passed > 0)) job.status = 'unverified';
|
||||
@@ -177,6 +184,10 @@ export class CheckRunner {
|
||||
job.status = signal.aborted ? 'cancelled' : error.status === 409 ? 'stale' : 'failed';
|
||||
job.stale = error.status === 409; job.summary = this.redact(error.message ?? String(error));
|
||||
} finally {
|
||||
if (unrecordedProcess) {
|
||||
job.unreportedProcesses ??= []; job.unreportedProcesses.push(unrecordedProcess);
|
||||
job.status = 'unknown'; job.requiresVerification = true; job.summary = '所属检查进程没有完整持久结果,保留进程归属供原输入核对。';
|
||||
}
|
||||
job.currentCheck = null;
|
||||
job.finishedAt = at();
|
||||
task.verification = { status: job.status, checkJobId: job.id, fingerprint: job.fingerprint, sourceFingerprint: job.sourceFingerprint, checkedAt: job.finishedAt };
|
||||
@@ -186,7 +197,7 @@ export class CheckRunner {
|
||||
return job;
|
||||
}
|
||||
|
||||
async executeCheck(check, project, signal) {
|
||||
async executeCheck(check, project, signal, onSpawn = null) {
|
||||
const started = Date.now();
|
||||
let invocation;
|
||||
const isPython = check.engine === 'python';
|
||||
@@ -196,23 +207,47 @@ export class CheckRunner {
|
||||
const env = isPython ? pythonEnvironment() : projectEnvironment({ NO_COLOR: '1', CI: '1' });
|
||||
const child = spawn(invocation.executable, invocation.args, { cwd: safePath(project), env, windowsHide: true, detached: process.platform !== 'win32', stdio: [isPython ? 'pipe' : 'ignore', 'pipe', 'pipe'] });
|
||||
const streams = { stdout: { head: '', tail: '', characters: 0, decoder: new StringDecoder('utf8') }, stderr: { head: '', tail: '', characters: 0, decoder: new StringDecoder('utf8') } };
|
||||
let settled = false, timedOut = false, terminating = false, killTimer;
|
||||
let settled = false, timedOut = false, terminating = false, killTimer, ownershipError = null, treeKill = null, closedResult = null, rootClosed = false, treeTimer = null, treePending = null;
|
||||
const processInfo = onSpawn ? { pid: child.pid ?? null, hostPid: process.pid, executable: invocation.executable, argsSha256: createHash('sha256').update(JSON.stringify(invocation.args)).digest('hex'), cwd: project.root, startedAt: at() } : null;
|
||||
const append = (name, text) => { const value = streams[name]; value.characters += text.length; value.head = (value.head + text).slice(0, 240000); value.tail = (value.tail + text).slice(-240000); };
|
||||
const captured = name => { const value = streams[name]; return value.characters <= 240000 ? value.head : value.characters <= 480000 ? value.head + value.tail.slice(value.head.length - value.characters) : value.head + '\n[中间日志超出保存上限,保留开头和结尾]\n' + value.tail; };
|
||||
const finish = (code, error, unknown = false) => {
|
||||
if (settled) return; settled = true; clearTimeout(timeout); clearTimeout(killTimer); signal.removeEventListener('abort', terminate);
|
||||
const stdout = captured('stdout'), stderr = captured('stderr') + (error ? '\n' + error.message : '');
|
||||
const captureTree = async (publish = true) => {
|
||||
const snapshot = await readOwnedProcessTree(processInfo);
|
||||
if (!snapshot.supported) return snapshot;
|
||||
if (snapshot.root) processInfo.rootCreatedAt ??= snapshot.root.createdAt;
|
||||
const known = new Map((processInfo.descendants ?? []).map(value => [value.pid + ':' + value.createdAt, value]));
|
||||
for (const value of snapshot.processes) if (value.pid !== processInfo.pid) known.set(value.pid + ':' + value.createdAt, value);
|
||||
processInfo.descendants = [...known.values()].sort((a, b) => a.pid - b.pid);
|
||||
processInfo.treeObservedAt = at(); processInfo.treeRemainingPids = snapshot.processes.map(value => value.pid);
|
||||
if (publish && !settled) onSpawn(processInfo);
|
||||
return snapshot;
|
||||
};
|
||||
const monitorTree = () => {
|
||||
if (settled || treePending) return;
|
||||
treePending = captureTree().catch(error => { ownershipError = error; processInfo.treeObservationError = error.message; terminate(); }).finally(() => { treePending = null; });
|
||||
};
|
||||
const finish = async (code, error, unknown = false) => {
|
||||
if (onSpawn && terminating && treeKill && !treeKill.done && !unknown) { closedResult = { code, error }; return; }
|
||||
if (onSpawn && treeKill?.error) unknown = true;
|
||||
if (settled) return; settled = true; clearTimeout(timeout); clearTimeout(killTimer); clearInterval(treeTimer); signal.removeEventListener('abort', terminate);
|
||||
if (onSpawn && process.platform === 'win32' && processInfo.pid) {
|
||||
await treePending;
|
||||
try { const snapshot = await captureTree(false); if (snapshot.processes.length) unknown = true; }
|
||||
catch (failure) { ownershipError = failure; processInfo.treeObservationError = failure.message; unknown = true; }
|
||||
}
|
||||
const stdout = captured('stdout'), stderr = captured('stderr') + (error ? '\n' + error.message : '') + (ownershipError ? '\n' + ownershipError.message : '');
|
||||
let collectedEvidence = null, collectedResult = null, evidenceError = null, cleanupError = null;
|
||||
if (isPython && !unknown && code !== null && !error) {
|
||||
try { const saved = readPythonEvidence(invocation, code); collectedEvidence = saved.text; collectedResult = saved.result; } catch (failure) { evidenceError = failure.message; }
|
||||
}
|
||||
const tests = check.kind === 'test' ? isPython ? collectedResult?.tests ?? null : parseTestEvidence(streams.stdout.tail, check.framework) : null;
|
||||
const status = unknown ? 'unknown' : signal.aborted ? 'cancelled'
|
||||
: timedOut || error || code !== 0 || evidenceError || tests?.failed > 0 || collectedResult?.collectionErrors > 0 ? 'failed'
|
||||
: timedOut || error || ownershipError || code !== 0 || evidenceError || tests?.failed > 0 || collectedResult?.collectionErrors > 0 ? 'failed'
|
||||
: (check.kind === 'test' && (!tests || tests.total === 0 || tests.passed !== tests.total || tests.cancelled > 0 || collectedResult?.collectionSkipped > 0)
|
||||
|| isPython && collectedResult?.compilation?.total === 0) ? 'unverified' : 'passed';
|
||||
if (isPython && !unknown) { try { invocation.dispose(); } catch (failure) { cleanupError = failure.message; } }
|
||||
resolve({ status, exitCode: code, durationMs: Date.now() - started, tests, stdout, stderr, timedOut, truncated: streams.stdout.characters > 480000 || streams.stderr.characters > 480000,
|
||||
...(onSpawn ? { process: { ...processInfo, rootExited: rootClosed, treeTermination: terminating ? unknown ? 'unknown' : 'confirmed' : 'not_requested' } } : {}),
|
||||
...(isPython ? { engine: 'python', python: pythonResultBinding(invocation), collectedEvidence, checkInput: invocation.input.toString('utf8'),
|
||||
compilation: collectedResult?.compilation ?? null, collectionErrors: collectedResult?.collectionErrors ?? null,
|
||||
collectionSkipped: collectedResult?.collectionSkipped ?? null, evidenceValidated: !!collectedResult, evidenceError, cleanupError,
|
||||
@@ -223,13 +258,20 @@ export class CheckRunner {
|
||||
};
|
||||
const terminate = () => {
|
||||
if (settled || terminating) return; terminating = true;
|
||||
if (child.pid) { if (process.platform === 'win32') execFile('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true }, () => {}); else { try { process.kill(-child.pid, 'SIGTERM'); } catch { child.kill('SIGTERM'); } } }
|
||||
if (child.pid) { if (process.platform === 'win32') {
|
||||
if (onSpawn) treeKill = { done: false, error: null };
|
||||
execFile('taskkill.exe', ['/PID', String(child.pid), '/T', '/F'], { windowsHide: true }, error => {
|
||||
if (!treeKill) return; treeKill.done = true; treeKill.error = error;
|
||||
if (closedResult) finish(closedResult.code, closedResult.error);
|
||||
});
|
||||
} else { try { process.kill(-child.pid, 'SIGTERM'); } catch { child.kill('SIGTERM'); } } }
|
||||
killTimer = setTimeout(() => finish(null, null, true), 5000);
|
||||
};
|
||||
const timeout = setTimeout(() => { timedOut = true; terminate(); }, this.timeoutMs);
|
||||
signal.addEventListener('abort', terminate, { once: true });
|
||||
for (const name of ['stdout', 'stderr']) { child[name].on('data', bytes => append(name, streams[name].decoder.write(bytes))); child[name].on('end', () => append(name, streams[name].decoder.end())); }
|
||||
child.once('error', error => finish(null, error)); child.once('close', code => finish(code));
|
||||
child.once('error', error => finish(null, error)); child.once('close', code => { rootClosed = true; finish(code); });
|
||||
if (onSpawn) child.once('spawn', () => { processInfo.pid = child.pid; try { onSpawn(processInfo); if (process.platform === 'win32') { monitorTree(); treeTimer = setInterval(monitorTree, 1200); } } catch (error) { ownershipError = error; terminate(); } });
|
||||
if (isPython) { child.stdin.on('error', () => {}); child.stdin.end(invocation.input); }
|
||||
if (signal.aborted) terminate();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { execFile } from 'node:child_process';
|
||||
import { gitEnvironment } from './git-process.mjs';
|
||||
|
||||
// Read only: recovery never terminates a process based on a historical PID.
|
||||
// Command lines and environments are deliberately excluded from the inventory.
|
||||
export async function readOwnedProcessTree(info) {
|
||||
if (process.platform !== 'win32') return { processes: [], supported: false };
|
||||
if (!Number.isSafeInteger(info.pid) || info.pid <= 0 || !Number.isFinite(Date.parse(info.startedAt))) throw new Error('原检查进程身份无效。');
|
||||
const script = "$ErrorActionPreference='Stop'; [Console]::OutputEncoding=New-Object System.Text.UTF8Encoding($false); @(Get-CimInstance Win32_Process | ForEach-Object { [pscustomobject]@{ pid=[int]$_.ProcessId; parentPid=[int]$_.ParentProcessId; createdAt=$_.CreationDate.ToUniversalTime().ToString('o'); executable=$_.ExecutablePath } }) | ConvertTo-Json -Compress";
|
||||
const inventory = await new Promise((resolve, reject) => execFile('powershell.exe', ['-NoProfile', '-NonInteractive', '-Command', script],
|
||||
{ windowsHide: true, timeout: 8000, maxBuffer: 2 * 1024 * 1024, env: gitEnvironment() }, (error, stdout) => {
|
||||
if (error) reject(new Error('原检查进程树无法只读核对:' + error.message.slice(0, 1200)));
|
||||
else { try { resolve(JSON.parse(stdout)); } catch { reject(new Error('原检查进程树输出格式无效,不能声明进程已结束。')); } }
|
||||
}));
|
||||
const all = Array.isArray(inventory) ? inventory : [inventory], selected = new Map(), seeds = new Set(), since = Date.parse(info.startedAt) - 3000;
|
||||
const same = (actual, original) => actual.pid === original.pid && actual.createdAt === original.createdAt;
|
||||
const root = all.find(value => value.pid === info.pid);
|
||||
const rootMatches = root && (info.rootCreatedAt ? root.createdAt === info.rootCreatedAt
|
||||
: Date.parse(root.createdAt) >= since && Date.parse(root.createdAt) <= Date.parse(info.startedAt) + 3000);
|
||||
if (rootMatches) { selected.set(root.pid, root); seeds.add(root.pid); }
|
||||
else if (!root) seeds.add(info.pid);
|
||||
for (const original of info.descendants ?? []) {
|
||||
const actual = all.find(value => same(value, original));
|
||||
if (actual) { selected.set(actual.pid, actual); seeds.add(actual.pid); }
|
||||
else if (!all.some(value => value.pid === original.pid)) seeds.add(original.pid);
|
||||
}
|
||||
for (let depth = 0; depth < 32; depth++) {
|
||||
let added = false;
|
||||
for (const value of all) if (seeds.has(value.parentPid) && !selected.has(value.pid) && Date.parse(value.createdAt) >= since) {
|
||||
selected.set(value.pid, value); seeds.add(value.pid); added = true;
|
||||
if (selected.size > 256) throw new Error('原检查进程树超过256项,不能省略进程后声明结束。');
|
||||
}
|
||||
if (!added) break;
|
||||
if (depth === 31) throw new Error('原检查进程树超过32层,结束状态仍需核对。');
|
||||
}
|
||||
return { supported: true, processes: [...selected.values()].sort((a, b) => a.pid - b.pid), root: rootMatches ? root : null };
|
||||
}
|
||||
@@ -10,6 +10,11 @@ import { assertMcpResolved } from '../tools/mcp-contract.mjs';
|
||||
import { inspectProject } from '../project-inspector.mjs';
|
||||
import { safePath, readText, proposeFile } from '../../server/files.mjs';
|
||||
import { verifiedCheck } from '../delivery-report.mjs';
|
||||
import { ChangeSetManager } from '../workspaces/change-sets.mjs';
|
||||
import { parseTestEvidence } from '../check-runner.mjs';
|
||||
import { verifyPlanEvidence } from '../context/request-plan.mjs';
|
||||
import { repairToolPairs } from '../../server/store.mjs';
|
||||
import { readOwnedProcessTree } from '../owned-process-tree.mjs';
|
||||
|
||||
const at = () => new Date().toISOString();
|
||||
const sourceIdentity = source => Object.fromEntries(['root', 'head', 'reference', 'branch', 'gitDir', 'commonDir', 'indexSha256',
|
||||
@@ -31,10 +36,14 @@ export class WorkerManager {
|
||||
return record ? { ...record, usage: workerUsage(this.store, record), sessionStatus: this.store.session(record.sessionId).status } : { ...child, status: 'unprepared', usage: null };
|
||||
}) })), worker: workerForProject(this.store, session.projectId) };
|
||||
}
|
||||
isActive(sessionId) { return [...this.active.values()].some(value => value.sessionId === sessionId); }
|
||||
childActive(id) { return this.runtime.active.has(id) || !!this.runtime.checks?.isActive(id) || !!this.runtime.changeSets?.isActive(id) || !!this.workspaces?.isActive(id); }
|
||||
isActive(sessionId) { return [...this.active.values()].some(value => value.sessionId === sessionId)
|
||||
|| [...this.store.core.collaboration.values()].some(group => group.sessionId === sessionId && !COLLABORATION_CLOSED.has(group.status) && group.children.some(child => this.childActive(child.sessionId))); }
|
||||
projectActive(projectId, excludeGroupId = null) {
|
||||
return [...this.active.entries()].some(([id, value]) => id !== excludeGroupId && (value.projectId === projectId
|
||||
|| ['preparing', 'collecting', 'reconciling', 'merge_preparing'].includes(value.group.status) && value.group.children.some(child => child.projectId === projectId)));
|
||||
|| ['preparing', 'collecting', 'reconciling', 'merge_preparing'].includes(value.group.status) && value.group.children.some(child => child.projectId === projectId)))
|
||||
|| [...this.store.core.collaboration.values()].some(group => group.id !== excludeGroupId && group.projectId === projectId
|
||||
&& !COLLABORATION_CLOSED.has(group.status) && group.children.some(child => this.childActive(child.sessionId)));
|
||||
}
|
||||
assertIdle(session) {
|
||||
if (this.runtime.projectHasActivity(session.projectId)) throw workerConflict('项目已有执行或协作操作,请等待结束。');
|
||||
@@ -42,9 +51,9 @@ export class WorkerManager {
|
||||
assertChangeSetsResolved(this.store, session.projectId, { includePrepared: true });
|
||||
if (session.changes.some(change => ['pending', 'conflict'].includes(change.status))) throw workerConflict('请先审查当前待处理改动,再创建协作目标。');
|
||||
}
|
||||
own(session, id, fingerprint = null) {
|
||||
own(session, id, fingerprint = null, { current = true } = {}) {
|
||||
const group = this.store.owned('collaboration', id, session.id);
|
||||
if (group.taskId !== session.taskId || group.runId !== session.runId || group.projectId !== session.projectId
|
||||
if (current && (group.taskId !== session.taskId || group.runId !== session.runId) || group.projectId !== session.projectId
|
||||
|| workerHash(collaborationSeal(group)) !== group.fingerprint || fingerprint !== null && fingerprint !== group.fingerprint) throw workerConflict('父任务或原协作分工指纹已变化,请核对原记录。');
|
||||
const artifact = this.store.owned('artifact', group.planArtifactId, session.id);
|
||||
if (artifact.kind !== 'collaboration-plan' || artifact.taskId !== group.taskId || artifact.runId !== group.runId
|
||||
@@ -118,20 +127,24 @@ export class WorkerManager {
|
||||
for (const child of group.children) {
|
||||
signal.throwIfAborted();
|
||||
const existing = this.store.core.workspace.get(child.workspaceId);
|
||||
if (existing && existing.status !== 'ready') throw workerConflict('原工作区记录需要核对,不能再次执行创建。');
|
||||
if (existing && !(existing.status === 'ready' || existing.status === 'prepared' && !existing.creationAttempted && !existing.requiresVerification)) throw workerConflict('原工作区记录需要核对,不能再次执行创建。');
|
||||
if (!existing) {
|
||||
this.save(session, group, 'workspace_intent');
|
||||
const workspace = await this.workspaces.prepare(session, child.label, { id: child.workspaceId, childProjectId: child.projectId, childSessionId: child.sessionId });
|
||||
signal.throwIfAborted();
|
||||
const result = await (await this.workspaces.start(session, workspace.id, workspace.fingerprint)).promise;
|
||||
if (result.status !== 'ready') throw workerConflict(result.summary);
|
||||
} else if (existing.status === 'prepared') {
|
||||
const result = await (await this.workspaces.start(session, existing.id, existing.fingerprint)).promise;
|
||||
if (result.status !== 'ready') throw workerConflict(result.summary);
|
||||
}
|
||||
await this.initializeChild(group, child); this.save(session, group, 'workspace_registered');
|
||||
await this.faultInjector?.('workspace_registered', group, child); signal.throwIfAborted();
|
||||
}
|
||||
await this.sourceFor(group); group.status = 'ready'; group.summary = '两个独立工作区已核对,来源HEAD、索引和已有修改保持。可以开始受限子任务。';
|
||||
} catch (error) {
|
||||
const uncertain = group.children.some(child => { const workspace = this.store.core.workspace.get(child.workspaceId); return workspace && workspace.status !== 'ready'; });
|
||||
const uncertain = group.children.some(child => { const workspace = this.store.core.workspace.get(child.workspaceId); return workspace && (workspace.status !== 'ready'
|
||||
|| !this.store.core.worker.has(child.id) && this.store.sessions.get(child.sessionId)?.taskId); });
|
||||
group.status = uncertain ? 'unknown' : signal.aborted ? 'partially_prepared' : 'stale'; group.requiresVerification = uncertain;
|
||||
group.summary = this.runtime.provider.redact(error.message ?? String(error));
|
||||
}
|
||||
@@ -151,14 +164,20 @@ export class WorkerManager {
|
||||
if (this.store.core.worker.has(child.id)) { workerForSession(this.store, this.store.session(child.sessionId)); return; }
|
||||
const project = this.store.project(child.projectId), session = this.store.session(child.sessionId);
|
||||
await verifyWorkspaceProject(this.store, project);
|
||||
if (session.taskId || session.messages.length || session.changes.length) throw workerConflict('新工作区已有其他任务记录,不能覆盖其身份。');
|
||||
const config = { ...group.config, maxTaskTokens: child.budget.maxTokens }, task = createTask(session, child.goal, config);
|
||||
task.id = child.taskId; task.origin = 'isolated-worker'; task.workspaceIdentity = projectWorkspaceIdentity(project);
|
||||
task.budget.maxTokens = child.budget.maxTokens; task.workerId = child.id;
|
||||
task.constraints = ['允许修改范围:' + child.paths.join('、'), '只接受原提案应用和当前工程检查;禁止独立Git提交、任意终端及外部工具。'];
|
||||
const run = createRun(session, task, config); run.workspaceIdentity = projectWorkspaceIdentity(project);
|
||||
this.store.core.task.set(task.id, task); this.store.core.run.set(run.id, run);
|
||||
session.taskId = task.id; session.runId = run.id; session.status = 'paused'; this.store.finishRun(session, run, 'worker_prepared');
|
||||
if (session.messages.length || session.changes.length) throw workerConflict('新工作区已有其他任务记录,不能覆盖其身份。');
|
||||
const config = { ...group.config, maxTaskTokens: child.budget.maxTokens };
|
||||
let task = this.store.core.task.get(session.taskId), run = this.store.core.run.get(session.runId);
|
||||
if (session.taskId) {
|
||||
if (task?.id !== child.taskId || task.goal !== child.goal || task.workerId !== child.id || task.origin !== 'isolated-worker'
|
||||
|| run?.taskId !== task.id || run.stopReason !== 'worker_prepared' || !run.finishedAt) throw workerConflict('子任务初始化有其他或不完整记录,请保留现场核对。');
|
||||
} else {
|
||||
task = createTask(session, child.goal, config); task.id = child.taskId; task.origin = 'isolated-worker'; task.workspaceIdentity = projectWorkspaceIdentity(project);
|
||||
task.budget.maxTokens = child.budget.maxTokens; task.workerId = child.id;
|
||||
task.constraints = ['允许修改范围:' + child.paths.join('、'), '只接受原提案应用和当前工程检查;禁止独立Git提交、任意终端及外部工具。'];
|
||||
run = createRun(session, task, config); run.workspaceIdentity = projectWorkspaceIdentity(project);
|
||||
this.store.core.task.set(task.id, task); this.store.core.run.set(run.id, run);
|
||||
session.taskId = task.id; session.runId = run.id; session.status = 'paused'; this.store.finishRun(session, run, 'worker_prepared');
|
||||
}
|
||||
const { files, inspection } = await this.inventory(project), git = await this.workspaces.snapshot(project);
|
||||
if (git.head !== group.source.identity.head || git.dirty) throw workerConflict('子工作区初始HEAD或源码不符合封存来源。');
|
||||
const worker = { schemaVersion: 1, ...child, collaborationId: group.id, parentProjectId: group.projectId, parentSessionId: group.sessionId,
|
||||
@@ -271,6 +290,7 @@ export class WorkerManager {
|
||||
if (git.head !== worker.baseCommit || git.indexSha256 !== baseline.git.indexSha256 || git.reference !== baseline.git.reference
|
||||
|| git.gitDir !== baseline.git.gitDir || git.commonDir !== baseline.git.commonDir
|
||||
|| JSON.stringify(git.configuration) !== JSON.stringify(baseline.git.configuration)) throw workerConflict('子任务HEAD、索引或Git配置已变化,独立提交或暂存不能作为原成果');
|
||||
if (git.changedPathCount > 32 || git.changedPaths.some(file => !after.has(workerPathKey(file.path)))) throw workerConflict('实际Git修改包含删除、链接、排除文件或超出32文件范围,不能遗漏后合并');
|
||||
const paths = [...new Set([...before.keys(), ...after.keys()])].filter(key => before.get(key)?.sha256 !== after.get(key)?.sha256);
|
||||
if (!paths.length || paths.length > 32) throw workerConflict('可交付成果需要1到32个实际文本改动');
|
||||
let bytes = 0;
|
||||
@@ -302,7 +322,14 @@ export class WorkerManager {
|
||||
}).sort((a, b) => a.path.localeCompare(b.path));
|
||||
const check = verifiedCheck(this.store, session, inspection);
|
||||
if (!check) throw workerConflict('缺少与当前源码一致、日志完整且测试数量明确的通过记录');
|
||||
this.runtime.checkRunner().planFor(session, check.planId);
|
||||
const plan = this.runtime.checkRunner().planFor(session, check.planId);
|
||||
for (const result of check.results) if (result.kind === 'test' && result.engine !== 'python') {
|
||||
const spec = plan.checks.find(value => value.name === result.name);
|
||||
const evidence = parseTestEvidence(this.store.artifactStore.read(this.store.owned('artifact', result.logArtifactId, session.id)), spec?.framework);
|
||||
if (JSON.stringify(evidence) !== JSON.stringify(result.tests)) throw workerConflict('检查数量与原日志不一致');
|
||||
}
|
||||
const cache = new Map();
|
||||
for (const request of this.store.core.context_plan.values()) if (request.taskId === worker.taskId) verifyPlanEvidence(this.store, session, request, cache);
|
||||
const latest = await this.inventory(project);
|
||||
if (latest.inspection.sourceFingerprint !== inspection.sourceFingerprint || JSON.stringify(latest.files) !== JSON.stringify(current)) throw workerConflict('核验期间子工程发生变化');
|
||||
return { schemaVersion: 1, workerId: worker.id, collaborationId: worker.collaborationId, workerFingerprint: worker.fingerprint,
|
||||
@@ -314,6 +341,319 @@ export class WorkerManager {
|
||||
...(result.metricsArtifactId ? { metricsArtifactId: result.metricsArtifactId, metricsSha256: result.metricsSha256 } : {}),
|
||||
})) }, usage: workerUsage(this.store, worker), runIds: worker.runIds };
|
||||
}
|
||||
async verifiedResult(group, child) {
|
||||
const worker = this.store.core.worker.get(child.id), session = this.store.session(child.sessionId);
|
||||
if (!worker || worker.status !== 'completed' || worker.requiresVerification || !worker.result) throw workerConflict('子任务尚未完成原成果封存:' + child.label);
|
||||
const artifact = this.store.owned('artifact', worker.result.artifactId, session.id);
|
||||
if (artifact.kind !== 'worker-result' || artifact.taskId !== worker.taskId || artifact.runId !== worker.currentRunId || artifact.sha256 !== worker.result.sha256) throw workerConflict('子成果工件归属或原散列不一致:' + child.label);
|
||||
const original = JSON.parse(this.store.artifactStore.read(artifact));
|
||||
if (workerHash(original) !== worker.result.fingerprint || original.workerId !== worker.id || original.collaborationId !== group.id
|
||||
|| original.workerFingerprint !== worker.fingerprint || original.taskId !== worker.taskId) throw workerConflict('子成果与原分工不一致:' + child.label);
|
||||
const current = await this.output(session, worker);
|
||||
if (JSON.stringify(original) !== JSON.stringify(current)) throw workerConflict('子工程、检查、账本或原成果已变化:' + child.label);
|
||||
return { worker, artifact, output: original };
|
||||
}
|
||||
async collectionFor(session, group) {
|
||||
await this.sourceFor(group);
|
||||
const proofs = [];
|
||||
for (const child of group.children) proofs.push(await this.verifiedResult(group, child));
|
||||
const conflicts = [], targets = [], project = this.store.project(group.projectId);
|
||||
const all = proofs.flatMap(proof => proof.output.files.map(file => ({ ...file, workerId: proof.worker.id, label: proof.worker.label })));
|
||||
for (let index = 0; index < all.length; index++) {
|
||||
const file = all[index], key = workerPathKey(file.path);
|
||||
for (const other of all.slice(index + 1)) {
|
||||
const otherKey = workerPathKey(other.path);
|
||||
if (key === otherKey || key.startsWith(otherKey + '/') || otherKey.startsWith(key + '/')) conflicts.push({ path: file.path, workerIds: [file.workerId, other.workerId], reason: '两个子成果修改同一路径或文件/目录相互包含;需要明确分工后重新审查。' });
|
||||
}
|
||||
const dirty = group.source.changedPaths.find(value => [value.path, value.originalPath].filter(Boolean).some(relative => {
|
||||
const dirtyKey = workerPathKey(relative); return key === dirtyKey || key.startsWith(dirtyKey + '/') || dirtyKey.startsWith(key + '/');
|
||||
}));
|
||||
if (dirty) { conflicts.push({ path: file.path, workerIds: [file.workerId], reason: '父工程已有暂存、未提交或未跟踪修改:' + dirty.path }); continue; }
|
||||
try {
|
||||
const target = safePath(project, file.path, true), exists = fs.existsSync(target);
|
||||
if (exists !== (file.before !== null)) throw workerConflict('父文件存在状态与子HEAD不一致,不能覆盖已有内容。');
|
||||
const original = exists ? readText(project, file.path) : null, before = original ? fs.readFileSync(target) : null;
|
||||
const childBefore = file.before === null ? null : Buffer.from(file.before, 'base64'), after = Buffer.from(file.after, 'base64');
|
||||
if (workerHash(after) !== file.sha256 || childBefore && workerHash(childBefore) !== file.beforeSha256) throw workerConflict('子成果原字节不一致。');
|
||||
const normalized = value => value.replace(/^\uFEFF/, '').replaceAll('\r\n', '\n');
|
||||
if (before && normalized(before.toString('utf8')) !== normalized(childBefore.toString('utf8'))) throw workerConflict('父工程原内容与子HEAD不一致。');
|
||||
let content = new TextDecoder('utf8', { fatal: true }).decode(after);
|
||||
if (original) {
|
||||
const source = original.content;
|
||||
if (/\r\n/.test(source) && !/(?<!\r)\n/.test(source)) content = content.replace(/\r\n|\n/g, '\r\n');
|
||||
else if (!/\r\n/.test(source)) content = content.replaceAll('\r\n', '\n');
|
||||
if (original.bom) content = '\uFEFF' + content.replace(/^\uFEFF/, '');
|
||||
} else if (after.subarray(0, 3).equals(Buffer.from([0xef, 0xbb, 0xbf]))) content = '\uFEFF' + content;
|
||||
targets.push({ path: file.path, workerId: file.workerId, label: file.label, beforeSha256: original?.sha256 ?? null,
|
||||
sha256: workerHash(Buffer.from(content, 'utf8')), childSha256: file.sha256, content });
|
||||
} catch (error) { conflicts.push({ path: file.path, workerIds: [file.workerId], reason: this.runtime.provider.redact(error.message ?? String(error)) }); }
|
||||
}
|
||||
if (all.length > 32 || targets.reduce((sum, file) => sum + Buffer.byteLength(file.content, 'utf8'), 0) > 2 * 1024 * 1024) conflicts.push({ path: '(整批)', workerIds: group.children.map(child => child.id), reason: '合并超过32文件或2MB建议内容,请缩小交付范围。' });
|
||||
await this.sourceFor(group);
|
||||
return { schemaVersion: 1, collaborationId: group.id, groupFingerprint: group.fingerprint, projectId: group.projectId,
|
||||
sessionId: session.id, taskId: group.taskId, runId: group.runId, source: group.source.identity,
|
||||
workers: proofs.map(proof => ({ workerId: proof.worker.id, artifactId: proof.artifact.id, sha256: proof.artifact.sha256, fingerprint: proof.worker.fingerprint,
|
||||
checkJobId: proof.output.check.id, paths: proof.output.files.map(file => file.path) })),
|
||||
paths: all.map(file => file.path).sort(), conflicts, targets: targets.sort((a, b) => a.path.localeCompare(b.path)) };
|
||||
}
|
||||
collect(session, id, fingerprint) {
|
||||
const group = this.own(session, id, fingerprint);
|
||||
if (!['ready_to_collect', 'collected', 'conflict'].includes(group.status) || group.requiresVerification || group.merge) throw workerConflict('先完成两个子任务,已有合并审查不能重新归集。');
|
||||
return this.launch(session, group, 'collecting', async signal => {
|
||||
try {
|
||||
const collection = await this.collectionFor(session, group); signal.throwIfAborted();
|
||||
const artifact = this.store.artifactStore.write(session, this.store.owned('run', group.runId, session.id), collection, { kind: 'worker-collection' });
|
||||
this.store.core.artifact.set(artifact.id, artifact);
|
||||
group.collection = { artifactId: artifact.id, sha256: artifact.sha256, fingerprint: workerHash(collection), conflicts: collection.conflicts, paths: collection.paths };
|
||||
group.status = collection.conflicts.length ? 'conflict' : 'collected';
|
||||
group.summary = collection.conflicts.length ? '原成果已封存,存在具体路径冲突;父工程未改变。' : '原子成果、当前检查和来源均已核对,可以准备父Task的独立变更集审查。';
|
||||
} catch (error) { group.status = signal.aborted ? 'ready_to_collect' : 'stale'; group.summary = this.runtime.provider.redact(error.message ?? String(error)); }
|
||||
this.save(session, group, group.status); return group;
|
||||
});
|
||||
}
|
||||
async readCollection(session, group) {
|
||||
this.own(session, group.id, null, { current: false });
|
||||
if (!group.collection) throw workerConflict('当前协作尚未封存成果归集。');
|
||||
const artifact = this.store.owned('artifact', group.collection.artifactId, session.id);
|
||||
if (artifact.kind !== 'worker-collection' || artifact.taskId !== group.taskId || artifact.runId !== group.runId || artifact.sha256 !== group.collection.sha256) throw workerConflict('成果归集工件归属或散列不一致。');
|
||||
const record = JSON.parse(this.store.artifactStore.read(artifact));
|
||||
if (record.collaborationId !== group.id || record.groupFingerprint !== group.fingerprint || workerHash(record) !== group.collection.fingerprint) throw workerConflict('成果归集与原协作不一致。');
|
||||
return record;
|
||||
}
|
||||
async verifyCollection(session, group) {
|
||||
const original = await this.readCollection(session, group), current = await this.collectionFor(session, group);
|
||||
if (JSON.stringify(original) !== JSON.stringify(current) || current.conflicts.length) throw workerConflict('来源、原成果或检查证据已变化,不能使用旧合并审查。');
|
||||
return original;
|
||||
}
|
||||
prepareMerge(session, id, fingerprint) {
|
||||
const group = this.own(session, id, fingerprint);
|
||||
if (group.status !== 'collected' || group.merge && group.merge.status !== 'proposing' || group.requiresVerification) throw workerConflict('只有没有冲突的原成果可以准备一次父合并审查。');
|
||||
return this.launch(session, group, 'merge_preparing', async signal => {
|
||||
try {
|
||||
const collection = await this.verifyCollection(session, group); signal.throwIfAborted();
|
||||
if (session.changes.some(change => ['pending', 'conflict'].includes(change.status) && change.sourceBinding?.collaborationId !== group.id)) throw workerConflict('父Task已有未处理提案,不能混入子成果。');
|
||||
group.merge ??= { collectionSha256: group.collection.sha256, changeIds: [], status: 'proposing' };
|
||||
const recovered = this.mergeProposals(session, group, collection);
|
||||
group.merge.changeIds = recovered.map(change => change.id); this.save(session, group, 'merge_intent');
|
||||
for (const file of collection.targets) {
|
||||
signal.throwIfAborted();
|
||||
if (recovered.some(change => change.path === file.path)) continue;
|
||||
const proof = collection.workers.find(value => value.workerId === file.workerId);
|
||||
const result = proposeFile(this.store, session, { path: file.path, base_sha256: file.beforeSha256, content: file.content, reason: '合并已核验子任务「' + file.label + '」的原成果' },
|
||||
{ sourceBinding: { collaborationId: group.id, workerId: file.workerId, resultArtifactId: proof.artifactId, resultSha256: proof.sha256, collectionSha256: group.collection.sha256 } });
|
||||
if (!result.change_id) throw workerConflict('原成果没有形成新的父提案,不能补造合并成功。');
|
||||
group.merge.changeIds.push(result.change_id); this.save(session, group, 'merge_proposal');
|
||||
await this.faultInjector?.('merge_proposal', group, file);
|
||||
}
|
||||
await this.verifyCollection(session, group); signal.throwIfAborted();
|
||||
const manager = new ChangeSetManager(this.store, { projectBusy: (projectId, exceptId) => this.runtime.projectHasActivity(projectId, exceptId, { excludeGroupId: group.id }) });
|
||||
const set = await manager.prepare(session, group.merge.changeIds, { collaborationBinding: { id: group.id, fingerprint: group.fingerprint,
|
||||
collectionArtifactId: group.collection.artifactId, collectionSha256: group.collection.sha256 } });
|
||||
group.merge.changeSetId = set.id; group.merge.fingerprint = set.fingerprint; group.merge.status = 'prepared';
|
||||
group.status = 'merge_prepared'; group.summary = '父Task独立提案与原字节变更集已封存,等待明确审查应用;父工程尚未修改。';
|
||||
session.status = 'needs_review';
|
||||
} catch (error) {
|
||||
group.status = group.merge ? 'unknown' : 'stale'; group.requiresVerification = !!group.merge;
|
||||
group.summary = this.runtime.provider.redact(error.message ?? String(error));
|
||||
}
|
||||
this.save(session, group, group.status); return group;
|
||||
});
|
||||
}
|
||||
mergeProposals(session, group, collection) {
|
||||
const changes = session.changes.filter(change => change.sourceBinding?.collaborationId === group.id);
|
||||
if (new Set(changes.map(change => workerPathKey(change.path))).size !== changes.length
|
||||
|| group.merge.collectionSha256 !== group.collection.sha256
|
||||
|| group.merge.changeIds.some(id => !changes.some(change => change.id === id))) throw workerConflict('原合并提案账本不连续,不能补造或重放。');
|
||||
for (const change of changes) {
|
||||
const target = collection.targets.find(file => file.path === change.path), proof = collection.workers.find(worker => worker.workerId === target?.workerId);
|
||||
if (!target || !proof || change.taskId !== group.taskId || change.runId !== group.runId || change.status !== 'pending' || change.changeSetId
|
||||
|| change.baseSha256 !== target.beforeSha256 || change.sha256 !== target.sha256 || workerHash(change.content) !== target.sha256
|
||||
|| change.sourceBinding.workerId !== target.workerId || change.sourceBinding.resultArtifactId !== proof.artifactId
|
||||
|| change.sourceBinding.resultSha256 !== proof.sha256 || change.sourceBinding.collectionSha256 !== group.collection.sha256) throw workerConflict('原父提案与封存子成果不一致,不能续封合并。');
|
||||
}
|
||||
return collection.targets.flatMap(file => changes.filter(change => change.path === file.path));
|
||||
}
|
||||
async recoverMerge(session, group) {
|
||||
if (!group.merge) return;
|
||||
const sets = [...this.store.core.change_set.values()].filter(set => set.collaborationBinding?.id === group.id || set.id === group.merge.changeSetId);
|
||||
if (sets.length > 1) throw workerConflict('原协作存在多个父批次,不能猜测或重放。');
|
||||
if (sets.length) {
|
||||
const set = sets[0], binding = set.collaborationBinding;
|
||||
if (set.sessionId !== session.id || set.taskId !== group.taskId || binding?.fingerprint !== group.fingerprint
|
||||
|| binding.collectionArtifactId !== group.collection?.artifactId || binding.collectionSha256 !== group.collection?.sha256
|
||||
|| !['prepared', 'completed'].includes(set.status) || set.requiresVerification
|
||||
|| JSON.stringify(set.files.map(file => file.changeId)) !== JSON.stringify(group.merge.changeIds)) throw workerConflict('父批次仍需原恢复流程核对或只能保留现场结束。');
|
||||
this.runtime.changeSetManager().snapshots(session, set);
|
||||
group.merge.changeSetId = set.id; group.merge.fingerprint = set.fingerprint; group.merge.status = 'prepared';
|
||||
} else {
|
||||
const collection = await this.verifyCollection(session, group);
|
||||
group.merge.changeIds = this.mergeProposals(session, group, collection).map(change => change.id); group.merge.status = 'proposing';
|
||||
}
|
||||
}
|
||||
async verifyMerge(session, set) {
|
||||
const linked = this.groups(session).find(group => group.merge?.changeSetId === set.id);
|
||||
if (!set.collaborationBinding && !linked) return;
|
||||
const group = this.own(session, set.collaborationBinding?.id ?? linked.id, set.collaborationBinding?.fingerprint ?? linked.fingerprint);
|
||||
if (group.status !== 'merge_prepared' || group.requiresVerification || group.merge?.changeSetId !== set.id || group.merge.fingerprint !== set.fingerprint
|
||||
|| set.collaborationBinding?.collectionArtifactId !== group.collection?.artifactId || set.collaborationBinding?.collectionSha256 !== group.collection?.sha256
|
||||
|| JSON.stringify(set.files.map(file => file.changeId)) !== JSON.stringify(group.merge.changeIds)) throw workerConflict('父变更集与原协作/归集记录不一致,不能应用。');
|
||||
const collection = await this.verifyCollection(session, group);
|
||||
for (const file of set.files) {
|
||||
const target = collection.targets.find(value => value.path === file.path), change = session.changes.find(value => value.id === file.changeId);
|
||||
if (!target || target.sha256 !== file.sha256 || target.beforeSha256 !== file.baseSha256
|
||||
|| change.sourceBinding?.collaborationId !== group.id || change.sourceBinding?.workerId !== target.workerId
|
||||
|| change.sourceBinding?.collectionSha256 !== group.collection.sha256) throw workerConflict('父提案的原子成果绑定失效。');
|
||||
}
|
||||
}
|
||||
async finalize(session, id, fingerprint) {
|
||||
const group = this.own(session, id, fingerprint); this.assertIdle(session);
|
||||
if (group.status !== 'merge_prepared' || !group.merge?.changeSetId) throw workerConflict('先审查应用原父变更集,再核对交付。');
|
||||
const set = this.store.owned('change_set', group.merge.changeSetId, session.id);
|
||||
if (set.status !== 'completed' || set.requiresVerification || set.fingerprint !== group.merge.fingerprint) throw workerConflict('原父变更集没有完整审查应用结果。');
|
||||
this.runtime.changeSetManager().snapshots(session, set);
|
||||
const inspection = await inspectProject(this.store.project(group.projectId)), check = verifiedCheck(this.store, session, inspection);
|
||||
if (!check) throw workerConflict('合并后父工程需要当前源码的真实通过检查。');
|
||||
for (const file of set.files) if (readText(this.store.project(group.projectId), file.path).sha256 !== file.sha256) throw workerConflict('父合并文件已变化,请先审查实际修复与重新归集。');
|
||||
const delivery = [...this.store.core.delivery_job.values()].find(job => job.taskId === group.taskId && job.sessionId === session.id
|
||||
&& job.status === 'completed' && !job.requiresVerification && job.commit === inspection.git.head && job.sourceFingerprint === inspection.sourceFingerprint);
|
||||
if (!delivery || !delivery.reportArtifactId) throw workerConflict('父工程尚未完成当前成果的本地Git交付。');
|
||||
const report = this.store.owned('artifact', delivery.reportArtifactId, session.id); this.store.artifactStore.read(report);
|
||||
for (const child of group.children) await this.verifiedResult(group, child);
|
||||
group.delivery = { jobId: delivery.id, commit: delivery.commit, checkJobId: check.id, reportArtifactId: report.id, reportSha256: report.sha256 };
|
||||
group.status = 'completed'; group.finishedAt = at(); group.summary = '两个隔离子成果已审查合并,父工程重新检查通过并完成本地Git交付。';
|
||||
session.status = 'completed'; this.save(session, group, 'completed'); return group;
|
||||
}
|
||||
async observe(group) {
|
||||
const source = await this.workspaces.snapshot(this.store.project(group.projectId)), children = [];
|
||||
for (const child of group.children) {
|
||||
const workspace = this.store.core.workspace.get(child.workspaceId), worker = this.store.core.worker.get(child.id);
|
||||
if (alive(workspace?.ownerPid) || alive(workspace?.gitPid) || alive(worker?.ownerPid)) throw workerConflict('历史所属PID仍存活,请先人工核对进程归属;工作台不会按历史PID停止进程。');
|
||||
let inventory = null, inventoryError = null;
|
||||
if (worker) {
|
||||
this.baseline(this.store.session(child.sessionId), worker);
|
||||
try { inventory = await this.inventory(this.store.project(child.projectId)); } catch (error) { inventoryError = error.message; }
|
||||
}
|
||||
const checks = [];
|
||||
for (const job of [...this.store.core.check_job.values()].filter(value => value.taskId === child.taskId)) {
|
||||
const processes = [job.currentCheck?.process, ...(job.unreportedProcesses ?? []), ...job.results.map(result => result.process)].filter(Boolean);
|
||||
if (processes.some(processInfo => !processInfo.rootExited && alive(processInfo.pid))) throw workerConflict('原检查PID仍存活,结束状态需要人工核对;不能自动重试或按历史PID终止。');
|
||||
if (job.requiresVerification || job.status === 'unknown') for (const processInfo of processes) {
|
||||
const tree = await readOwnedProcessTree(processInfo);
|
||||
if (tree.processes.length) throw workerConflict('原检查子进程PID仍存活:' + tree.processes.map(value => value.pid).join('、') + ';不能按历史PID自动终止或解除核对。');
|
||||
}
|
||||
checks.push({ id: job.id, status: job.status, requiresVerification: !!job.requiresVerification, processes,
|
||||
results: job.results.map(result => ({ id: result.id, status: result.status, logArtifactId: result.logArtifactId,
|
||||
logSha256: this.store.core.artifact.get(result.logArtifactId)?.sha256 ?? null })) });
|
||||
}
|
||||
const session = this.store.sessions.get(child.sessionId);
|
||||
const tools = [...this.store.core.tool.values()].filter(value => value.taskId === child.taskId && value.requiresVerification).map(tool => {
|
||||
const call = session?.providerMessages.flatMap(message => message.tool_calls ?? []).find(call => call.id === tool.callId);
|
||||
const input = call?.function.arguments;
|
||||
if (typeof input !== 'string' || workerHash(input) !== tool.argsSha256) throw workerConflict('原未知工具的输入哈希不一致,请保留现场。');
|
||||
return { id: tool.id, callId: tool.callId, tool: tool.tool, state: tool.state, argsSha256: tool.argsSha256,
|
||||
input: this.runtime.provider.redact(input).slice(0, 24000), inputTruncated: input.length > 24000, resultArtifactId: tool.resultArtifactId };
|
||||
});
|
||||
const changes = (session?.changes ?? []).filter(change => change.taskId === child.taskId).map(change => {
|
||||
let sha256 = null, error = null;
|
||||
try { const target = safePath(this.store.project(child.projectId), change.path, true); sha256 = fs.existsSync(target) ? readText(this.store.project(child.projectId), change.path).sha256 : null; }
|
||||
catch (failure) { error = failure.message; }
|
||||
return { id: change.id, path: change.path, status: change.status, baseSha256: change.baseSha256, proposedSha256: change.sha256, actualSha256: sha256, error };
|
||||
});
|
||||
children.push({ id: child.id, workspaceId: child.workspaceId, workspaceStatus: workspace?.status ?? 'absent',
|
||||
workerStatus: worker?.status ?? 'absent', taskId: child.taskId, sessionId: child.sessionId, projectId: child.projectId,
|
||||
inventoryFingerprint: inventory ? workerHash(inventory.files) : null, sourceFingerprint: inventory?.inspection.sourceFingerprint ?? null, inventoryError,
|
||||
tools, checks, changes, changeSets: [...this.store.core.change_set.values()].filter(set => set.taskId === child.taskId).map(set => ({ id: set.id, status: set.status, requiresVerification: !!set.requiresVerification, observationFingerprint: set.observationFingerprint ?? null })) });
|
||||
}
|
||||
const parent = this.store.session(group.sessionId);
|
||||
return { schemaVersion: 1, kind: 'worker-recovery-observation', collaborationId: group.id, groupFingerprint: group.fingerprint,
|
||||
projectId: group.projectId, sessionId: group.sessionId, taskId: group.taskId, runId: group.runId, source: sourceIdentity(source), children,
|
||||
parentChanges: parent.changes.filter(change => change.sourceBinding?.collaborationId === group.id).map(change => ({ id: change.id, path: change.path, status: change.status, sha256: change.sha256 })),
|
||||
parentChangeSets: [...this.store.core.change_set.values()].filter(set => set.taskId === group.taskId).map(set => ({ id: set.id, status: set.status, requiresVerification: !!set.requiresVerification })),
|
||||
note: '原输入及当前现场供用户核对;未报告的检查或工具结果保持未知,不补造完成、不执行模型或旧工具。' };
|
||||
}
|
||||
reconcile(session, id, fingerprint) {
|
||||
const group = this.own(session, id, fingerprint);
|
||||
if (!group.requiresVerification || group.status !== 'unknown') throw workerConflict('只有原结果未知的协作需要现场核对。');
|
||||
return this.launch(session, group, 'reconciling', async signal => {
|
||||
this.preparingGroupId = group.id;
|
||||
try {
|
||||
for (const child of group.children) {
|
||||
const workspace = this.store.core.workspace.get(child.workspaceId);
|
||||
if (workspace?.status === 'unknown') await this.workspaces.reconcile(session, workspace.id, workspace.fingerprint);
|
||||
if (workspace?.status === 'ready' && !this.store.core.worker.has(child.id)) await this.initializeChild(group, child);
|
||||
}
|
||||
const observed = await this.observe(group); signal.throwIfAborted();
|
||||
const artifact = this.store.artifactStore.write(session, this.store.owned('run', group.runId, session.id), observed, { kind: 'worker-recovery' });
|
||||
this.store.core.artifact.set(artifact.id, artifact); group.evidence = { artifactId: artifact.id, sha256: artifact.sha256 };
|
||||
group.summary = '原输入与现场核对已封存,请阅读后明确确认;不会自动发送模型、重放工具或补造检查通过。';
|
||||
} catch (error) { group.summary = this.runtime.provider.redact(error.message ?? String(error)); }
|
||||
group.status = 'unknown'; group.requiresVerification = true; this.save(session, group, 'observed'); return group;
|
||||
});
|
||||
}
|
||||
readEvidence(session, group) {
|
||||
this.own(session, group.id, null, { current: false });
|
||||
const artifact = this.store.owned('artifact', group.evidence?.artifactId, session.id);
|
||||
if (artifact.kind !== 'worker-recovery' || artifact.taskId !== group.taskId || artifact.runId !== group.runId || artifact.sha256 !== group.evidence.sha256) throw workerConflict('原核对工件不属于当前父协作。');
|
||||
const record = JSON.parse(this.store.artifactStore.read(artifact));
|
||||
if (record.groupFingerprint !== group.fingerprint || record.collaborationId !== group.id) throw workerConflict('核对记录与原协作不一致。');
|
||||
return record;
|
||||
}
|
||||
async acknowledge(session, id, fingerprint, evidenceSha256, retain = false) {
|
||||
const group = this.own(session, id, fingerprint);
|
||||
if (group.status !== 'unknown' || !group.requiresVerification || typeof evidenceSha256 !== 'string' || evidenceSha256 !== group.evidence?.sha256) throw workerConflict('请先阅读原输入与现场核对工件,再提交原SHA256。');
|
||||
const started = this.launch(session, group, 'reconciling', async signal => {
|
||||
this.preparingGroupId = group.id;
|
||||
try {
|
||||
const original = this.readEvidence(session, group), current = await this.observe(group); signal.throwIfAborted();
|
||||
if (JSON.stringify(original) !== JSON.stringify(current)) throw workerConflict('原输入或现场在核对后发生变化,请重新核对。');
|
||||
const unresolvedSets = current.children.some(child => child.changeSets.some(set => set.requiresVerification)) || current.parentChangeSets.some(set => set.requiresVerification);
|
||||
if (unresolvedSets) throw workerConflict('原文件批次仍待核对或回退,请先在所属任务记录处理实际原字节。');
|
||||
const merged = group.merge?.changeSetId && this.store.core.change_set.get(group.merge.changeSetId)?.status === 'completed';
|
||||
if (!retain && !merged && JSON.stringify(current.source) !== JSON.stringify(group.source.identity)) throw workerConflict('父来源已经变化,只能明确保留现场后重新规划。');
|
||||
if (current.children.some(child => !['ready', 'absent', 'prepared', 'discarded', 'resolved_external'].includes(child.workspaceStatus))) throw workerConflict('原工作区仍需专门核对,不能开始子执行或结束恢复。');
|
||||
if (!retain && current.children.some(child => ['discarded', 'resolved_external'].includes(child.workspaceStatus))) throw workerConflict('原工作区没有核对为可执行,只能明确保留现场结束。');
|
||||
if (!retain) await this.recoverMerge(session, group);
|
||||
for (const child of group.children) {
|
||||
const worker = this.store.core.worker.get(child.id); if (!worker) continue;
|
||||
const childSession = this.store.session(child.sessionId);
|
||||
for (const tool of this.store.core.tool.values()) if (tool.taskId === child.taskId && tool.requiresVerification) {
|
||||
tool.originalState = tool.state; tool.state = 'resolved_external'; tool.requiresVerification = false;
|
||||
tool.review = { source: 'user', evidenceSha256, reviewedAt: at(), result: 'unknown-preserved' };
|
||||
const run = this.store.core.run.get(tool.runId);
|
||||
if (run) {
|
||||
run.checkpoint.requiresVerification = run.checkpoint.requiresVerification.filter(id => id !== tool.id);
|
||||
run.checkpoint.pendingToolIds = run.checkpoint.pendingToolIds.filter(id => id !== tool.id);
|
||||
run.checkpoint.reviewedUnknownToolIds ??= []; if (!run.checkpoint.reviewedUnknownToolIds.includes(tool.id)) run.checkpoint.reviewedUnknownToolIds.push(tool.id);
|
||||
}
|
||||
}
|
||||
for (const job of this.store.core.check_job.values()) if (job.taskId === child.taskId && (job.requiresVerification || job.status === 'unknown')) {
|
||||
job.originalStatus = job.status; job.status = 'resolved_external'; job.requiresVerification = false; job.review = { evidenceSha256, reviewedAt: at() };
|
||||
this.store.core.task.get(child.taskId).verification = { status: 'needs_checks', checkJobId: job.id };
|
||||
}
|
||||
if (worker.requiresVerification || ['unknown', 'running', 'stopping'].includes(worker.status)) {
|
||||
worker.requiresVerification = false; worker.status = retain ? 'resolved_external' : 'paused'; worker.ownerPid = null;
|
||||
worker.summary = '用户已核对原未知输入与现场;原结果保持未知,重新检查需要新计划与审批。';
|
||||
childSession.providerMessages = repairToolPairs(childSession.providerMessages, callId => this.store.savedToolResult(childSession.id, callId)).messages;
|
||||
childSession.providerMessages.push({ role: 'user', content: worker.summary + ' 核对记录SHA256:' + evidenceSha256 });
|
||||
childSession.status = childSession.changes.some(change => ['pending', 'conflict'].includes(change.status)) ? 'needs_review' : 'paused';
|
||||
this.store.putRecord('worker', childSession, worker, 'worker.reviewed_unknown');
|
||||
}
|
||||
}
|
||||
group.requiresVerification = false;
|
||||
if (retain) {
|
||||
this.retain(session, group);
|
||||
group.status = 'resolved_external'; group.finishedAt = at();
|
||||
} else group.status = merged || group.merge?.changeSetId ? 'merge_prepared'
|
||||
: group.merge ? 'collected'
|
||||
: group.children.some(child => !this.store.core.worker.has(child.id)) ? 'partially_prepared'
|
||||
: group.children.every(child => this.store.core.worker.get(child.id).status === 'completed') ? 'ready_to_collect'
|
||||
: group.children.some(child => this.store.session(child.sessionId).status === 'needs_review') ? 'awaiting_review' : group.startedAt ? 'paused' : 'ready';
|
||||
group.summary = retain ? '用户已明确保留原工作区、任务与未知结果,结束协作;没有声明交付成功。' : '原未知结果已按用户核对保留,可以显式继续;累计预算和原时限保持。';
|
||||
session.status = 'paused'; this.save(session, group, 'reviewed_unknown'); return group;
|
||||
} catch (error) { group.status = 'unknown'; group.requiresVerification = true; this.save(session, group, 'review_failed'); throw error; }
|
||||
});
|
||||
return started.promise;
|
||||
}
|
||||
async stopParent(sessionId) {
|
||||
const running = [...this.active.values()].filter(value => value.sessionId === sessionId && value.controller);
|
||||
for (const value of running) {
|
||||
@@ -323,11 +663,36 @@ export class WorkerManager {
|
||||
await Promise.allSettled(value.group.children.map(child => this.runtime.stop(child.sessionId)));
|
||||
await value.promise;
|
||||
}
|
||||
for (const group of this.store.core.collaboration.values()) if (group.sessionId === sessionId && !COLLABORATION_CLOSED.has(group.status)
|
||||
&& group.children.some(child => this.childActive(child.sessionId))) {
|
||||
await Promise.allSettled(group.children.filter(child => this.store.sessions.has(child.sessionId)).map(child => this.runtime.stop(child.sessionId)));
|
||||
group.summary = '父任务已等待所属子执行与检查结束,已完成记录保留。'; this.save(this.store.session(sessionId), group, 'stopped');
|
||||
}
|
||||
}
|
||||
async stopAll() { await Promise.all([...new Set([...this.active.values()].map(value => value.sessionId).concat([...this.store.core.collaboration.values()]
|
||||
.filter(group => !COLLABORATION_CLOSED.has(group.status) && group.children.some(child => this.childActive(child.sessionId))).map(group => group.sessionId)))].map(id => this.stopParent(id))); }
|
||||
retain(session, group) {
|
||||
const sessions = [session, ...group.children.flatMap(child => this.store.sessions.has(child.sessionId) ? [this.store.session(child.sessionId)] : [])];
|
||||
for (const child of group.children) {
|
||||
const workspace = this.store.core.workspace.get(child.workspaceId);
|
||||
if (workspace?.status === 'prepared' && !workspace.creationAttempted) this.workspaces.discard(session, workspace.id, workspace.fingerprint);
|
||||
}
|
||||
const manager = new ChangeSetManager(this.store, { projectBusy: (projectId, exceptId) => this.runtime.projectHasActivity(projectId, exceptId, { excludeGroupId: group.id }) });
|
||||
for (const owned of sessions) {
|
||||
for (const set of this.store.core.change_set.values()) if (set.sessionId === owned.id && set.taskId === owned.taskId && !set.attemptedAt && ['prepared', 'stale'].includes(set.status)) {
|
||||
manager.snapshots(owned, set); manager.discard(owned, set.id, set.fingerprint);
|
||||
}
|
||||
for (const change of owned.changes) if ((owned !== session || change.sourceBinding?.collaborationId === group.id) && ['pending', 'conflict'].includes(change.status) && !change.changeSetId) change.status = 'rejected';
|
||||
const worker = workerForProject(this.store, owned.projectId);
|
||||
if (worker && worker.status !== 'completed') { worker.status = 'resolved_external'; worker.requiresVerification = false; worker.ownerPid = null; }
|
||||
owned.status = 'paused'; this.store.save(owned, { type: 'worker.retained' });
|
||||
}
|
||||
}
|
||||
async stopAll() { await Promise.all([...new Set([...this.active.values()].map(value => value.sessionId))].map(id => this.stopParent(id))); }
|
||||
discard(session, id, fingerprint) {
|
||||
const group = this.own(session, id, fingerprint);
|
||||
if (this.active.has(group.id) || group.requiresVerification || group.merge?.changeSetId) throw workerConflict('协作仍在执行、待核对或已有合并审查,请先处理原记录。');
|
||||
if (this.runtime.projectHasActivity(group.projectId) || group.requiresVerification || group.children.some(child => this.store.core.worker.get(child.id)?.requiresVerification)
|
||||
|| [...this.store.core.change_set.values()].some(set => (set.taskId === group.taskId || group.children.some(child => child.taskId === set.taskId)) && set.requiresVerification)) throw workerConflict('协作仍在执行或原批次待核对,请先处理原记录。');
|
||||
this.retain(session, group);
|
||||
group.status = group.children.some(child => this.store.core.workspace.has(child.workspaceId)) ? 'resolved_external' : 'discarded';
|
||||
group.finishedAt = at(); group.summary = '已明确保留原工作区、任务和成果,结束本次协作;未删除、重置或声明交付完成。';
|
||||
session.status = 'paused'; this.save(session, group, 'discarded'); return group;
|
||||
|
||||
@@ -14,6 +14,7 @@ const conflict = message => Object.assign(new Error(message), { status: 409 });
|
||||
const key = value => process.platform === 'win32' ? value.toLowerCase() : value;
|
||||
const gitBaseline = inspection => ({ available: inspection.git.available, head: inspection.git.head ?? null, branch: inspection.git.branch ?? null });
|
||||
const sealed = set => ({ id: set.id, sessionId: set.sessionId, projectId: set.projectId, taskId: set.taskId, runId: set.runId,
|
||||
...(set.collaborationBinding ? { collaborationBinding: set.collaborationBinding } : {}),
|
||||
root: set.root, baseline: set.baseline, files: set.files.map(file => ({ changeId: file.changeId, path: file.path,
|
||||
baseExists: file.baseExists, baseSha256: file.baseSha256, sha256: file.sha256, baseBytes: file.baseBytes, bytes: file.bytes,
|
||||
mode: file.mode, reason: file.reason, sourceRunId: file.sourceRunId, snapshotArtifactId: file.snapshotArtifactId })) });
|
||||
@@ -70,8 +71,8 @@ function base64(value) {
|
||||
}
|
||||
|
||||
export class ChangeSetManager {
|
||||
constructor(store, { projectBusy = () => false, faultInjector = null } = {}) {
|
||||
this.store = store; this.projectBusy = projectBusy; this.faultInjector = faultInjector;
|
||||
constructor(store, { projectBusy = () => false, faultInjector = null, beforeApply = null } = {}) {
|
||||
this.store = store; this.projectBusy = projectBusy; this.faultInjector = faultInjector; this.beforeApply = beforeApply;
|
||||
this.active = new Map(); this.projects = new Map();
|
||||
}
|
||||
projectActive(id) { return this.projects.has(id); }
|
||||
@@ -81,8 +82,8 @@ export class ChangeSetManager {
|
||||
await new Promise(resolve => setImmediate(resolve));
|
||||
}
|
||||
save(session, set, phase) { this.store.save(session, { type: 'change_set.' + phase, detail: { changeSetId: set.id } }); }
|
||||
requireIdle(session, { source = 'user', exceptId = null, includePrepared = false } = {}) {
|
||||
assertWorkersResolved(this.store, session.projectId);
|
||||
requireIdle(session, { source = 'user', exceptId = null, includePrepared = false, recoveryTaskId = null } = {}) {
|
||||
assertWorkersResolved(this.store, session.projectId, { recoveryTaskId });
|
||||
assertMcpResolved(this.store, session.projectId);
|
||||
if (this.projectActive(session.projectId) || this.projectBusy(session.projectId, source === 'agent' ? session.id : null)) {
|
||||
throw conflict('同一项目正在执行任务、检查、提交或文件批次,请等待结束后再操作。');
|
||||
@@ -128,7 +129,7 @@ export class ChangeSetManager {
|
||||
for (let index = 0; index < set.files.length; index++) set.files[index].state = observations[index].state;
|
||||
return observations;
|
||||
}
|
||||
async prepare(session, changeIds, { source = 'user' } = {}) {
|
||||
async prepare(session, changeIds, { source = 'user', collaborationBinding = null } = {}) {
|
||||
if (!Array.isArray(changeIds) || !changeIds.length || changeIds.length > 32 || new Set(changeIds).size !== changeIds.length) throw conflict('变更集需要1到32个不同的提案ID。');
|
||||
this.requireIdle(session, { source });
|
||||
const task = this.store.owned('task', session.taskId, session.id), run = this.store.owned('run', session.runId, session.id);
|
||||
@@ -152,6 +153,7 @@ export class ChangeSetManager {
|
||||
const inspection = await inspectProject(project);
|
||||
if (session.taskId !== task.id || session.runId !== run.id) throw conflict('准备变更集期间任务已切换。');
|
||||
const set = { id: randomUUID(), sessionId: session.id, projectId: project.id, taskId: task.id, runId: run.id, root: project.root,
|
||||
...(collaborationBinding ? { collaborationBinding: structuredClone(collaborationBinding) } : {}),
|
||||
schemaVersion: 1, status: 'prepared', requiresVerification: false, source, createdAt: at(), baseline: gitBaseline(inspection), files: [],
|
||||
policy: 'reviewed-byte-snapshots', summary: '整批范围已封存,项目文件尚未改变。' };
|
||||
let budget = 0;
|
||||
@@ -191,6 +193,7 @@ export class ChangeSetManager {
|
||||
const operation = this.claim(session, set);
|
||||
try {
|
||||
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
|
||||
await this.beforeApply?.(session, set);
|
||||
const snapshots = this.snapshots(session, set, { pending: true });
|
||||
const project = this.store.project(session.projectId), inspection = await inspectProject(project);
|
||||
if (set.taskId !== session.taskId || JSON.stringify(gitBaseline(inspection)) !== JSON.stringify(set.baseline)) throw conflict('任务或Git HEAD/分支已变化,未写入任何文件。');
|
||||
@@ -308,7 +311,7 @@ export class ChangeSetManager {
|
||||
async reconcile(session, id) {
|
||||
const set = this.own(session, id);
|
||||
if (!set.attemptedAt || !['unknown', 'partial', 'completed', 'rolled_back', 'interrupted'].includes(set.status)) throw conflict('这个批次尚未执行或已结束外部改动确认,无需恢复核对。');
|
||||
this.requireIdle(session, { exceptId: set.id });
|
||||
this.requireIdle(session, { exceptId: set.id, recoveryTaskId: set.taskId });
|
||||
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
|
||||
this.snapshots(session, set);
|
||||
return this.settle(session, set, this.inspect(session, set), set.direction === 'rollback' ? 'rollback' : 'apply');
|
||||
@@ -316,7 +319,7 @@ export class ChangeSetManager {
|
||||
async rollback(session, id, fingerprint) {
|
||||
const set = this.own(session, id, fingerprint, { current: true });
|
||||
if (typeof fingerprint !== 'string' || !set.attemptedAt || !['completed', 'partial', 'unknown'].includes(set.status)) throw conflict('只有已执行且已审查指纹的批次可以回退。');
|
||||
this.requireIdle(session, { exceptId: set.id });
|
||||
this.requireIdle(session, { exceptId: set.id, recoveryTaskId: set.taskId });
|
||||
const snapshots = this.snapshots(session, set), operation = this.claim(session, set);
|
||||
try {
|
||||
await verifyWorkspaceProject(this.store, this.store.project(session.projectId));
|
||||
@@ -334,7 +337,7 @@ export class ChangeSetManager {
|
||||
acknowledge(session, id, fingerprint, observationFingerprint) {
|
||||
const set = this.own(session, id, fingerprint, { current: true });
|
||||
if (typeof fingerprint !== 'string' || set.status !== 'partial' || !set.requiresVerification || typeof observationFingerprint !== 'string') throw conflict('请先核对这个批次的当前文件,再确认保留外部改动。');
|
||||
this.requireIdle(session, { exceptId: set.id }); this.snapshots(session, set);
|
||||
this.requireIdle(session, { exceptId: set.id, recoveryTaskId: set.taskId }); this.snapshots(session, set);
|
||||
const observations = this.inspect(session, set);
|
||||
if (set.observationFingerprint !== observationFingerprint || observations.some(value => !['before', 'external'].includes(value.state))) throw conflict('当前文件变化或仍有本批次建议内容未回退,请先重新核对/回退。');
|
||||
set.status = 'resolved_external'; set.requiresVerification = false; set.finishedAt = at();
|
||||
@@ -348,7 +351,7 @@ export class ChangeSetManager {
|
||||
discard(session, id, fingerprint) {
|
||||
const set = this.own(session, id, fingerprint, { current: true });
|
||||
if (typeof fingerprint !== 'string' || !['prepared', 'stale'].includes(set.status) || set.attemptedAt) throw conflict('只有尚未执行的封存批次可以撤销。');
|
||||
this.requireIdle(session, { exceptId: set.id });
|
||||
this.requireIdle(session, { exceptId: set.id, recoveryTaskId: set.taskId });
|
||||
set.status = 'cancelled'; set.finishedAt = at(); set.summary = '已撤销未执行批次,文件提案仍可重新审查。';
|
||||
for (const file of set.files) { const change = session.changes.find(value => value.id === file.changeId); if (change?.changeSetId === set.id) delete change.changeSetId; }
|
||||
this.save(session, set, 'cancelled'); return set;
|
||||
|
||||
+38
-2
@@ -10,6 +10,7 @@ import { publicEngineJob } from '../shared/contracts/engines.mjs';
|
||||
import { verifyBrowserJob } from '../core/browser/browser-manager.mjs';
|
||||
import { ConfigImporter } from '../core/models/config-import.mjs';
|
||||
import { ProjectMemoryManager } from '../core/memory/project-memory.mjs';
|
||||
import { workerForProject, workerConflict, assertWorkersResolved } from '../shared/contracts/workers.mjs';
|
||||
|
||||
export function createSessionPublisher(clients) {
|
||||
return session => {
|
||||
@@ -85,6 +86,7 @@ return async (request, response) => {
|
||||
if (method === 'GET' && !action) return json(response, registry.view(projectId));
|
||||
if (method === 'GET' && action === 'content') return json(response, registry.content(projectId, url.searchParams.get('id'), Number(url.searchParams.get('revision'))));
|
||||
if (method === 'POST') {
|
||||
if (workerForProject(store, projectId)) throw workerConflict('受限子项目不能修改Skills登记,请返回父项目。');
|
||||
const input = await body(request);
|
||||
if (!action) return json(response, registry.register(projectId, input), 201);
|
||||
if (action === 'toggle') return json(response, registry.toggle(projectId, input));
|
||||
@@ -95,7 +97,7 @@ return async (request, response) => {
|
||||
if (mcpMatch) {
|
||||
const registry = runtime.mcpRegistry(), projectId = mcpMatch[1];
|
||||
if (method === 'GET' && !mcpMatch[2]) return json(response, registry.view(projectId));
|
||||
if (method === 'POST') { const input = await body(request);
|
||||
if (method === 'POST') { if (workerForProject(store, projectId)) throw workerConflict('受限子项目不能修改MCP登记,请返回父项目。'); const input = await body(request);
|
||||
return json(response, mcpMatch[2] ? registry.configure(projectId, input) : registry.register(projectId, input), mcpMatch[2] ? 200 : 201); }
|
||||
}
|
||||
const projectMemoryMatch = route.match(/^\/api\/projects\/([a-f0-9-]+)\/memories$/i);
|
||||
@@ -112,11 +114,13 @@ return async (request, response) => {
|
||||
const sessionMemoryArchiveMatch = route.match(/^\/api\/sessions\/([a-f0-9-]+)\/memories\/([a-f0-9-]+)\/archive$/i);
|
||||
if (sessionMemoryArchiveMatch && method === 'POST') {
|
||||
const session = store.session(sessionMemoryArchiveMatch[1]);
|
||||
if (workerForProject(store, session.projectId)) throw workerConflict('受限子任务不能修改项目记忆,请返回父项目。');
|
||||
await body(request);
|
||||
return json(response, memories.archive(session, sessionMemoryArchiveMatch[2]));
|
||||
}
|
||||
if (sessionMemoryMatch && method === 'POST') {
|
||||
const session = store.session(sessionMemoryMatch[1]);
|
||||
if (workerForProject(store, session.projectId)) throw workerConflict('受限子任务不能修改项目记忆,请返回父项目。');
|
||||
const input = await body(request);
|
||||
return json(response, await memories.create(session, input), 201);
|
||||
}
|
||||
@@ -232,6 +236,7 @@ return async (request, response) => {
|
||||
if (method === 'GET' && route === '/api/sessions') return json(response, store.listSessions());
|
||||
if (method === 'POST' && route === '/api/sessions') {
|
||||
const input = await body(request);
|
||||
if (workerForProject(store, input.projectId)) throw workerConflict('隔离项目使用原受限子会话,请从父协作打开。');
|
||||
await verifyWorkspaceProject(store, store.project(input.projectId));
|
||||
return json(response, store.publicSession(store.createSession(input.projectId)), 201);
|
||||
}
|
||||
@@ -239,6 +244,37 @@ return async (request, response) => {
|
||||
if (sessionMatch) {
|
||||
const id = sessionMatch[1], action = sessionMatch[2] ?? '';
|
||||
const session = store.session(id);
|
||||
if (method === 'POST' && workerForProject(store, session.projectId)
|
||||
&& /^(?:mcp|engines|research|workspaces|delivery|browser|task-plans|task-proofs|task-checkpoints|collaborations)(?:\/|-|$)/.test(action)) throw workerConflict('受限子任务只开放原目标的读取、范围内改动和已审批检查;此操作请返回父项目。');
|
||||
if (method === 'GET' && action === 'collaborations') return json(response, runtime.workerManager().view(session));
|
||||
if (method === 'POST' && action === 'collaborations') {
|
||||
const group = await runtime.workerManager().plan(session, await body(request));
|
||||
return json(response, { group, session: store.publicSession(session) }, 201);
|
||||
}
|
||||
const collaboration = action.match(/^collaborations\/([a-f0-9-]+)\/(prepare|start|stop|collect|merge|finalize|discard|reconcile|acknowledge|collection|evidence)$/);
|
||||
if (collaboration) {
|
||||
const manager = runtime.workerManager();
|
||||
if (method === 'GET' && ['collection', 'evidence'].includes(collaboration[2])) {
|
||||
const group = manager.own(session, collaboration[1], null, { current: false });
|
||||
return json(response, collaboration[2] === 'collection' ? await manager.readCollection(session, group) : manager.readEvidence(session, group));
|
||||
}
|
||||
if (method === 'POST' && !['collection', 'evidence'].includes(collaboration[2])) {
|
||||
const input = await body(request);
|
||||
if (Object.keys(input).some(key => !['fingerprint', 'workerId', 'evidenceSha256', 'retain'].includes(key))) throw workerConflict('协作操作字段无效,不能添加命令或模型配置。');
|
||||
const group = manager.own(session, collaboration[1], input.fingerprint);
|
||||
let result;
|
||||
if (collaboration[2] === 'prepare') result = manager.prepare(session, group.id, input.fingerprint);
|
||||
else if (collaboration[2] === 'start') result = manager.start(session, group.id, input.fingerprint, input.workerId ?? null);
|
||||
else if (collaboration[2] === 'stop') { await runtime.stop(session.id); result = group; }
|
||||
else if (collaboration[2] === 'collect') result = manager.collect(session, group.id, input.fingerprint);
|
||||
else if (collaboration[2] === 'merge') result = manager.prepareMerge(session, group.id, input.fingerprint);
|
||||
else if (collaboration[2] === 'finalize') result = await manager.finalize(session, group.id, input.fingerprint);
|
||||
else if (collaboration[2] === 'discard') result = manager.discard(session, group.id, input.fingerprint);
|
||||
else if (collaboration[2] === 'reconcile') result = manager.reconcile(session, group.id, input.fingerprint);
|
||||
else result = await manager.acknowledge(session, group.id, input.fingerprint, input.evidenceSha256, input.retain === true);
|
||||
return json(response, { group: result.group ?? result, session: store.publicSession(session) }, result.promise ? 202 : 200);
|
||||
}
|
||||
}
|
||||
if (method === 'GET' && !action) return json(response, store.publicSession(session));
|
||||
if (method === 'GET' && action === 'execution') return json(response, store.executionSnapshot(session));
|
||||
if (method === 'GET' && action === 'mcp/jobs') return json(response, runtime.mcpRegistry().jobs(session));
|
||||
@@ -545,7 +581,7 @@ return async (request, response) => {
|
||||
}
|
||||
if (method === 'POST' && ['proposals', 'patch-proposals'].includes(action)) {
|
||||
const input = await body(request);
|
||||
if (runtime.checks?.projectActive(session.projectId) || runtime.deliveries?.projectActive(session.projectId) || runtime.changeSets?.projectActive(session.projectId) || runtime.workspaces?.projectActive(session.projectId)) throw Object.assign(new Error('工程检查、Git交付、文件批次或工作区正在执行,请等待结束后再编辑文件。'), { status: 409 });
|
||||
if (runtime.workers?.projectActive(session.projectId) || runtime.checks?.projectActive(session.projectId) || runtime.deliveries?.projectActive(session.projectId) || runtime.changeSets?.projectActive(session.projectId) || runtime.workspaces?.projectActive(session.projectId)) throw Object.assign(new Error('协作、工程检查、Git交付、文件批次或工作区正在执行,请等待结束后再编辑文件。'), { status: 409 });
|
||||
assertWorkspacesResolved(store, session.projectId, { includePrepared: true });
|
||||
await verifyWorkspaceProject(store, store.project(session.projectId));
|
||||
if (action === 'patch-proposals') proposePatch(store, session, input);
|
||||
|
||||
@@ -127,7 +127,7 @@ export function searchFiles(project, args) {
|
||||
scope: '有数量/体积上限的文本搜索;无结果不表示所有文件都已搜索。' };
|
||||
}
|
||||
|
||||
export function proposeFile(store, session, args, { patch = null } = {}) {
|
||||
export function proposeFile(store, session, args, { patch = null, sourceBinding = null } = {}) {
|
||||
assertWorkersResolved(store, session.projectId);
|
||||
assertWorkerWriteScope(store, session, args.path);
|
||||
assertMcpResolved(store, session.projectId);
|
||||
@@ -150,6 +150,7 @@ export function proposeFile(store, session, args, { patch = null } = {}) {
|
||||
id: randomUUID(), path: args.path, reason: String(args.reason ?? '建议修改').slice(0, 600), status: 'pending',
|
||||
baseExists: !!original, baseSha256: original?.sha256 ?? null, baseContent,
|
||||
...(patch ? { editKind: 'exact-patch', patch } : {}),
|
||||
...(sourceBinding ? { sourceBinding: structuredClone(sourceBinding) } : {}),
|
||||
content, sha256: hash(Buffer.from(content, 'utf8')), diff: parts, createdAt: now(),
|
||||
additions: parts.filter(part => part.added).reduce((sum, part) => sum + (part.count ?? 0), 0),
|
||||
deletions: parts.filter(part => part.removed).reduce((sum, part) => sum + (part.count ?? 0), 0),
|
||||
|
||||
@@ -139,7 +139,7 @@ export class Runtime {
|
||||
|| !!this.deliveries?.projectActive(projectId) || !!this.changeSets?.projectActive(projectId) || !!this.research?.projectActive(projectId) || !!this.engines?.projectActive(projectId) || !!this.browser?.projectActive(projectId) || !!this.taskPlans?.projectActive(projectId) });
|
||||
}
|
||||
changeSetManager() {
|
||||
return this.changeSets ??= new ChangeSetManager(this.store, { projectBusy: (projectId, exceptId) =>
|
||||
return this.changeSets ??= new ChangeSetManager(this.store, { beforeApply: (session, set) => this.workerManager().verifyMerge(session, set), projectBusy: (projectId, exceptId) =>
|
||||
!!this.workers?.projectActive(projectId) || [...this.active.entries()].some(([id, run]) => id !== exceptId && run.project.id === projectId)
|
||||
|| !!this.checks?.projectActive(projectId) || !!this.deliveries?.projectActive(projectId) || !!this.workspaces?.projectActive(projectId) || !!this.research?.projectActive(projectId) || !!this.engines?.projectActive(projectId) || !!this.browser?.projectActive(projectId) || !!this.taskPlans?.projectActive(projectId) });
|
||||
}
|
||||
@@ -270,6 +270,7 @@ export class Runtime {
|
||||
let response, requestStarted = false, responseAccounted = false;
|
||||
try {
|
||||
signal.throwIfAborted(); checkBudget(run.record, task);
|
||||
if (run.worker) { planned.record.workerDispatchedAt = now(); this.store.save(session, { type: 'worker.request_intent' }); }
|
||||
requestStarted = true;
|
||||
response = await this.provider.complete(config, planned.messages, run.project, signal, progress => {
|
||||
if (!requestEvent) requestEvent = this.store.event(session, { kind: 'model', runId: run.id, source: 'model_connection', label: '请求模型服务', phase: 'running', startedAt: now(), contextPlanId: planned.record.id });
|
||||
@@ -290,17 +291,19 @@ export class Runtime {
|
||||
this.requestPlanner().finish(session, planned.record, { response, attempts: planned.record.requestAttempts });
|
||||
if (run.worker) {
|
||||
this.store.recordResponse(session, run.record, response.usage, planned.record.estimatedInputTokens + Math.ceil(Buffer.byteLength(JSON.stringify(response.message), 'utf8') / 3) + 8);
|
||||
responseAccounted = true; this.store.save(session);
|
||||
planned.record.workerUsageAccounted = true; this.store.save(session); responseAccounted = true;
|
||||
}
|
||||
} catch (error) {
|
||||
this.requestPlanner().finish(session, planned.record, { error: Object.assign(new Error(this.provider.redact(error.message ?? String(error))), { name: signal.aborted ? 'AbortError' : error.name }), attempts: planned.record.requestAttempts });
|
||||
if (run.worker && requestStarted && !responseAccounted) {
|
||||
this.store.recordResponse(session, run.record, null, planned.record.estimatedInputTokens + config.maxOutputTokens);
|
||||
planned.record.workerUsageAccounted = true;
|
||||
this.store.save(session, { type: 'worker.request_usage_unknown' });
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
signal.throwIfAborted();
|
||||
if (run.worker) checkBudget(run.record, task);
|
||||
const message = response.message;
|
||||
const calls = message.tool_calls ?? [];
|
||||
if (run.worker && (calls.length > 16 || workerUsage(this.store, run.worker).toolCalls + calls.length > run.worker.budget.maxToolCalls)) throw new BudgetExceeded('worker_tool_limit', '子任务工具次数超出固定累计预算或单次16项上限;这批工具未执行,原响应和用量已保存。');
|
||||
|
||||
+28
-3
@@ -13,7 +13,7 @@ import { ENGINE_ACTIVE, publicEngineJob } from '../shared/contracts/engines.mjs'
|
||||
import { BROWSER_ACTIVE } from '../shared/contracts/browser.mjs';
|
||||
import { publicBrowserPlan } from '../core/browser/browser-manager.mjs';
|
||||
import { MCP_ACTIVE } from '../core/tools/mcp-contract.mjs';
|
||||
import { COLLABORATION_ACTIVE } from '../shared/contracts/workers.mjs';
|
||||
import { COLLABORATION_ACTIVE, COLLABORATION_CLOSED } from '../shared/contracts/workers.mjs';
|
||||
|
||||
export const now = () => new Date().toISOString();
|
||||
|
||||
@@ -191,8 +191,17 @@ export class Store extends EventEmitter {
|
||||
for (const step of this.core.step.values()) if (step.sessionId === session.id && ['running', 'waiting'].includes(step.status)) {
|
||||
step.status = 'interrupted'; step.finishedAt = now(); changed = true;
|
||||
}
|
||||
for (const plan of this.core.context_plan.values()) if (plan.sessionId === session.id && ['prepared', 'requesting'].includes(plan.status)) {
|
||||
plan.status = 'interrupted'; plan.finishedAt = now(); plan.error = '进程中断,未保存完整模型响应;不自动发送请求或重放工具。'; changed = true;
|
||||
for (const plan of this.core.context_plan.values()) if (plan.sessionId === session.id) {
|
||||
if (plan.workerDispatchedAt && !plan.workerUsageAccounted) {
|
||||
const run = this.core.run.get(plan.runId);
|
||||
if (run && this.core.task.get(run.taskId)?.workerId) {
|
||||
this.recordResponse(session, run, null, plan.estimatedInputTokens + (run.model.maxOutputTokens ?? 2048));
|
||||
plan.workerUsageAccounted = true; plan.workerUsageRecovered = true; changed = true;
|
||||
}
|
||||
}
|
||||
if (['prepared', 'requesting'].includes(plan.status)) {
|
||||
plan.status = 'interrupted'; plan.finishedAt = now(); plan.error = '进程中断,未保存完整模型响应;不自动发送请求或重放工具。'; changed = true;
|
||||
}
|
||||
}
|
||||
for (const job of this.core.check_job.values()) if (job.sessionId === session.id && ['queued', 'running', 'waiting'].includes(job.status)) {
|
||||
job.requiresVerification = job.status !== 'queued'; job.status = job.requiresVerification ? 'unknown' : 'interrupted'; job.finishedAt = now();
|
||||
@@ -295,6 +304,18 @@ export class Store extends EventEmitter {
|
||||
}
|
||||
if (changed) this.save(session, { type: 'session.recovered' });
|
||||
}
|
||||
for (const group of this.core.collaboration.values()) {
|
||||
const unresolved = group.children.some(child => this.core.worker.get(child.id)?.requiresVerification
|
||||
|| this.core.workspace.get(child.workspaceId)?.requiresVerification
|
||||
|| ['tool', 'check_job', 'change_set'].some(kind => [...this.core[kind].values()].some(record => record.taskId === child.taskId && record.requiresVerification)))
|
||||
|| [...this.core.change_set.values()].some(set => set.taskId === group.taskId && set.requiresVerification);
|
||||
if (!COLLABORATION_CLOSED.has(group.status) && unresolved && (!group.requiresVerification || group.status !== 'unknown')) {
|
||||
group.status = 'unknown'; group.requiresVerification = true; group.finishedAt = now();
|
||||
group.summary = '所属子执行或父批次仍有未知结果,原协作需要核对;不自动重放。';
|
||||
const session = this.session(group.sessionId); session.status = 'paused'; session.recoveryNotice = group.summary;
|
||||
this.save(session, { type: 'collaboration.recovered_children' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
save(session, { type = 'session.updated', detail = {} } = {}) {
|
||||
@@ -507,6 +528,10 @@ export class Store extends EventEmitter {
|
||||
|
||||
savedToolResult(sessionId, callId) {
|
||||
const record = [...this.core.tool.values()].find(value => value.sessionId === sessionId && value.callId === callId);
|
||||
if (record?.state === 'resolved_external' && record.review?.result === 'unknown-preserved') return {
|
||||
status: 'unknown', requires_verification: false, invocation_id: record.id, evidence_sha256: record.review.evidenceSha256,
|
||||
message: '原结果保持未知,用户已核对原输入与现场;此调用不会重放,重新检查须使用新计划与审批。',
|
||||
};
|
||||
if (!record || !['completed', 'failed', 'denied', 'interrupted', 'unknown'].includes(record.state)) return null;
|
||||
if (record.resultArtifactId) {
|
||||
try { return JSON.parse(this.artifactStore.read(this.core.artifact.get(record.resultArtifactId))); }
|
||||
|
||||
@@ -103,11 +103,13 @@ export function assertWorkerTool(store, session, tool, args) {
|
||||
if (!WORKER_TOOLS.has(tool)) throw workerConflict('受限子任务不开放这个工具:' + tool);
|
||||
if (tool === 'propose_file' || tool === 'propose_patch') assertWorkerWriteScope(store, session, args.path);
|
||||
}
|
||||
export function assertWorkersResolved(store, projectId) {
|
||||
export function assertWorkersResolved(store, projectId, { recoveryTaskId = null } = {}) {
|
||||
const group = [...(store.core.collaboration?.values() ?? [])].find(value => value.requiresVerification
|
||||
&& (value.projectId === projectId || value.children.some(child => child.projectId === projectId)));
|
||||
&& (value.projectId === projectId || value.children.some(child => child.projectId === projectId))
|
||||
&& !(recoveryTaskId && (value.projectId === projectId && value.taskId === recoveryTaskId
|
||||
|| value.children.some(child => child.projectId === projectId && child.taskId === recoveryTaskId))));
|
||||
const worker = workerForProject(store, projectId);
|
||||
if (group || worker?.requiresVerification) throw workerConflict('协作执行结果待核对,请返回父任务查看原输入和现场,不会自动重放。');
|
||||
if (group || worker?.requiresVerification && worker.taskId !== recoveryTaskId) throw workerConflict('协作执行结果待核对,请返回父任务查看原输入和现场,不会自动重放。');
|
||||
}
|
||||
export function workerUsage(store, worker) {
|
||||
const task = store.core.task.get(worker.taskId), runs = [...store.core.run.values()].filter(run => run.taskId === worker.taskId);
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
|
||||
1. [complete] Task/Run、独立Git工作区、审批、预算、检查及持久归属契约已复用,PLAN-1.13已封存。工作区不宣称为OS沙箱。
|
||||
2. [complete] 父子记录、不可变范围/预算/模型、预分配身份、两个串行工作区与并行受限执行已实现;核心6/6、文件批次/检查/工作区32/32通过并保存原失败。源码仍1.12.1,不登记为发行。
|
||||
3. [in_progress] 受限工具/审批及真实检查完成门槛已接入;继续停止传播、所属进程、迟到响应、预算/崩溃/未知核对专项,原任务/结果保持。
|
||||
4. [pending] 收集实际diff与当前检查证据;来源/范围/输入变化及重叠修改阻止合并;父任务按现有封存变更集进行显式审查及检查/Git交付。
|
||||
5. [pending] 协作控制台桌面/390px与Node/React/Python三个独立实际工程样本,覆盖正常、修复、冲突、停止及恢复;声明夹具与真实模型语义分别记录。
|
||||
3. [complete] 停止传播、原创建身份的检查进程树、迟到/未知用量与累计预算、部分创建及宿主退出核对已实现。整合原轮64/65,唯一QA清理竞态修正后真实宿主崩溃专项1/1;未拼称同轮65/65,最终独立源码待验。
|
||||
4. [complete] 原子成果、当前文件/检查原日志、Git及提案链核对、具体路径冲突、父封存批次与应用前复核、父检查/Git完成门槛已接入并实际验证。部分归集封存中断按原绑定恢复,未知不造完成结果。
|
||||
5. [in_progress] 第三轮桌面/390px协作控制台10节点完整通过,0页面/请求异常,原失败和截图保留并目视复核;继续Node/React/Python三个有明确功能断言的工程样本,真实模型语义仍单独待验。
|
||||
6. [pending] 切片回顾及本地提交后,完整UI/独立源码/不可变源码与便携验收、保留当前Provider/全部历史正式升级;封存1.13报告并更新下一阶段起点。
|
||||
|
||||
## 2026-10-30 当前任务:里程碑回顾、漏洞修复与后续计划封存
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { Store } from '../../src/server/store.mjs';
|
||||
import { Runtime } from '../../src/server/runtime.mjs';
|
||||
import { Provider } from '../../src/server/provider.mjs';
|
||||
const [data, groupId] = process.argv.slice(2), store = new Store(data), provider = new Provider(), runtime = new Runtime(store, provider);
|
||||
provider.complete = async (config, messages, project) => {
|
||||
const session = [...store.sessions.values()].find(value => value.projectId === project.id);
|
||||
const plan = [...store.core.check_plan.values()].find(value => value.taskId === session.taskId);
|
||||
return { message: { role: 'assistant', tool_calls: [{ id: randomUUID(), type: 'function', function: { name: 'run_checks', arguments: JSON.stringify({ plan_id: plan.id }) } }] }, usage: { total_tokens: 123 } };
|
||||
};
|
||||
const save = store.save;
|
||||
store.save = function(session, event) { const result = save.call(this, session, event); if (event?.type === 'worker.check_process_owned') {
|
||||
const info = [...store.core.check_job.values()].find(job => job.id === event.detail.jobId)?.currentCheck?.process;
|
||||
process.send?.({ kind: 'owned-check', descendants: info?.descendants?.length ?? 0 });
|
||||
} return result; };
|
||||
const group = store.core.collaboration.get(groupId), parent = store.session(group.sessionId);
|
||||
const started = runtime.workerManager().start(parent, group.id, group.fingerprint);
|
||||
const timer = setInterval(() => { for (const child of group.children) for (const approval of store.session(child.sessionId).approvals.filter(value => value.status === 'pending')) runtime.decide(child.sessionId, approval.id, true); }, 20);
|
||||
await started.promise; clearInterval(timer); store.close();
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
import http from 'node:http';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { createRequestHandler, createSessionPublisher } from '../../src/server/app.mjs';
|
||||
import { prepareWorkerFixture } from './workers-project.mjs';
|
||||
import { workspace } from '../helpers.mjs';
|
||||
|
||||
export async function workerHttp(f, options = {}) {
|
||||
const context = prepareWorkerFixture(f, options);
|
||||
f.store.saveConfig({ mode: 'compatible', model: 'owned-worker-model', baseUrl: 'http://127.0.0.1:1/v1' });
|
||||
context.provider.setKey('self-owned-local-worker-fixture');
|
||||
const token = randomUUID(), clients = new Set(), server = http.createServer(), started = Date.now();
|
||||
f.store.on('update', createSessionPublisher(clients));
|
||||
server.on('request', createRequestHandler({ appDirectory: workspace, server, store: f.store, provider: context.provider, runtime: context.runtime,
|
||||
token, clients, started, getPort: () => server.address().port, exampleProject: f.project.id, shutdown: () => {} }));
|
||||
await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));
|
||||
const url = 'http://127.0.0.1:' + server.address().port;
|
||||
f.onCleanup(async () => { await context.runtime.stopAll(); for (const response of clients) response.destroy(); server.closeAllConnections(); await new Promise(resolve => server.close(resolve)); });
|
||||
const raw = async (route, input, supplied = token) => {
|
||||
const response = await fetch(url + '/api' + route, { method: input === undefined ? 'GET' : 'POST', headers: { 'Content-Type': 'application/json', 'X-Workbench-Token': supplied, Connection: 'close' }, ...(input === undefined ? {} : { body: JSON.stringify(input) }) });
|
||||
return { status: response.status, value: await response.json() };
|
||||
};
|
||||
const api = async (route, input) => { const result = await raw(route, input); if (result.status >= 400) throw Object.assign(new Error(result.value.error ?? JSON.stringify(result.value)), { status: result.status }); return result.value; };
|
||||
return { ...context, url, token, raw, api };
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fixture, until } from './helpers.mjs';
|
||||
import { workerHttp } from './fixtures/workers-http.mjs';
|
||||
import { workerDefinition, ownerBytes } from './fixtures/workers-project.mjs';
|
||||
|
||||
test('HTTP worker identities require a current sealed plan, reject overrides and close unused plans without touching source', async t => {
|
||||
const f = fixture(t), host = await workerHttp(f), route = '/sessions/' + f.session.id, initial = ownerBytes(f);
|
||||
assert.notEqual(new URL(host.url).port, '4318');
|
||||
assert.equal((await host.raw(route + '/collaborations', workerDefinition(), 'incorrect-token')).status, 403);
|
||||
assert.equal((await host.raw(route + '/collaborations', { ...workerDefinition(), command: 'outside command' })).status, 409);
|
||||
const planned = await host.api(route + '/collaborations', workerDefinition()), group = planned.group;
|
||||
assert.equal(group.status, 'planned'); assert.equal(group.taskId, planned.session.taskId);
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/prepare', { fingerprint: '0'.repeat(64) })).status, 409);
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/prepare', { fingerprint: group.fingerprint, command: 'forged' })).status, 409);
|
||||
await host.api(route + '/collaborations/' + group.id + '/prepare', { fingerprint: group.fingerprint });
|
||||
await until(() => f.store.core.collaboration.get(group.id).status === 'ready', 20000);
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/prepare', { fingerprint: group.fingerprint })).status, 409);
|
||||
const child = group.children[0], childRoute = '/sessions/' + child.sessionId;
|
||||
assert.equal((await host.raw('/sessions', { projectId: child.projectId })).status, 409);
|
||||
for (const [route, input] of [
|
||||
['/projects/' + child.projectId + '/skills', { name: 'forged', path: path.join(f.projectRoot, 'README.md') }],
|
||||
['/projects/' + child.projectId + '/mcp', { executable: process.execPath }],
|
||||
[childRoute + '/memories', { title: 'forged', text: 'unscoped' }],
|
||||
[childRoute + '/workspaces', { label: 'nested' }], [childRoute + '/collaborations', workerDefinition()],
|
||||
[childRoute + '/engines/deepseek/start', {}], [childRoute + '/delivery-plans', {}], [childRoute + '/task-checkpoints', {}],
|
||||
]) assert.equal((await host.raw(route, input)).status, 409, route);
|
||||
assert.deepEqual(ownerBytes(f), initial); assert.equal(host.requests.length, 0);
|
||||
await host.api(route + '/collaborations/' + group.id + '/discard', { fingerprint: group.fingerprint });
|
||||
const next = await host.api(route + '/collaborations', { ...workerDefinition(), goal: 'Next parent goal' }); assert.notEqual(next.group.taskId, group.taskId);
|
||||
assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/a.mjs')), false);
|
||||
});
|
||||
|
||||
test('HTTP unknown recovery only accepts the original evidence SHA and preserves changed source for explicit retention', async t => {
|
||||
const f = fixture(t), host = await workerHttp(f), route = '/sessions/' + f.session.id;
|
||||
const { group } = await host.api(route + '/collaborations', workerDefinition()); await host.api(route + '/collaborations/' + group.id + '/prepare', { fingerprint: group.fingerprint });
|
||||
await until(() => f.store.core.collaboration.get(group.id).status === 'ready', 20000);
|
||||
const current = f.store.core.collaboration.get(group.id); current.status = 'unknown'; current.requiresVerification = true; f.store.save(f.session);
|
||||
await host.api(route + '/collaborations/' + group.id + '/reconcile', { fingerprint: group.fingerprint }); await until(() => current.evidence);
|
||||
const original = await host.api(route + '/collaborations/' + group.id + '/evidence'); assert.equal(original.groupFingerprint, group.fingerprint);
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/acknowledge', { fingerprint: group.fingerprint, evidenceSha256: '0'.repeat(64) })).status, 409);
|
||||
fs.appendFileSync(path.join(f.projectRoot, 'owner-unstaged.txt'), 'New owner work after evidence\n');
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/acknowledge', { fingerprint: group.fingerprint, evidenceSha256: current.evidence.sha256 })).status, 409);
|
||||
const before = current.evidence.sha256; await host.api(route + '/collaborations/' + group.id + '/reconcile', { fingerprint: group.fingerprint }); await until(() => current.evidence.sha256 !== before);
|
||||
assert.equal((await host.raw(route + '/collaborations/' + group.id + '/acknowledge', { fingerprint: group.fingerprint, evidenceSha256: current.evidence.sha256 })).status, 409);
|
||||
const ended = await host.api(route + '/collaborations/' + group.id + '/acknowledge', { fingerprint: group.fingerprint, evidenceSha256: current.evidence.sha256, retain: true });
|
||||
assert.equal(ended.group.status, 'resolved_external'); assert.equal(host.requests.length, 0); assert.match(fs.readFileSync(path.join(f.projectRoot, 'owner-unstaged.txt'), 'utf8'), /New owner work/);
|
||||
await host.api(route + '/collaborations', { ...workerDefinition(), goal: 'Next parent goal after retention' });
|
||||
assert.deepEqual(await host.api(route + '/collaborations/' + group.id + '/evidence'), host.manager.readEvidence(f.session, current));
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fixture } from './helpers.mjs';
|
||||
import { completedWorkers, ownerBytes } from './fixtures/workers-project.mjs';
|
||||
import { deliveryGit, writeDeliveryFile } from './fixtures/delivery-project.mjs';
|
||||
|
||||
test('verified isolated outputs form a new parent batch, rerun real checks and commit only reviewed source', async t => {
|
||||
const f = fixture(t), { runtime, manager, group, original } = await completedWorkers(f);
|
||||
assert.equal(group.status, 'ready_to_collect', group.summary);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'collected', group.summary);
|
||||
const collection = await manager.readCollection(f.session, group); assert.equal(collection.conflicts.length, 0);
|
||||
assert.deepEqual(collection.paths, ['src/a.mjs', 'src/b.mjs']);
|
||||
await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'merge_prepared', group.summary); assert.deepEqual(ownerBytes(f), original);
|
||||
const set = f.store.core.change_set.get(group.merge.changeSetId);
|
||||
assert.equal(set.taskId, group.taskId); assert.equal(set.files.length, 2);
|
||||
for (const file of set.files) {
|
||||
const proposed = f.session.changes.find(change => change.id === file.changeId), child = group.children.find(child => child.id === proposed.sourceBinding.workerId);
|
||||
assert.equal(proposed.taskId, group.taskId); assert.equal(proposed.sourceBinding.collaborationId, group.id);
|
||||
assert.equal(f.store.session(child.sessionId).changes.some(change => change.id === proposed.id), false);
|
||||
assert.equal(fs.existsSync(path.join(f.projectRoot, file.path)), false);
|
||||
}
|
||||
await assert.rejects(manager.finalize(f.session, group.id, group.fingerprint), /待处理|审查|应用/);
|
||||
await (await runtime.changeSetManager().start(f.session, set.id, set.fingerprint)).promise;
|
||||
assert.equal(set.status, 'completed', set.summary); assert.deepEqual(ownerBytes(f), original);
|
||||
await assert.rejects(manager.finalize(f.session, group.id, group.fingerprint), /真实通过检查/);
|
||||
const plan = await runtime.checkRunner().plan(f.session), check = await (await runtime.checkRunner().start(f.session, plan.id)).promise;
|
||||
assert.equal(check.status, 'passed', check.summary);
|
||||
await assert.rejects(manager.finalize(f.session, group.id, group.fingerprint), /Git交付/);
|
||||
const gitPlan = await runtime.gitDelivery().plan(f.session, { message: 'Reviewed isolated worker integration' });
|
||||
await (await runtime.gitDelivery().start(f.session, gitPlan.id)).promise;
|
||||
const result = await manager.finalize(f.session, group.id, group.fingerprint);
|
||||
assert.equal(result.status, 'completed'); assert.ok(result.delivery.commit);
|
||||
assert.deepEqual(ownerBytes(f).files, original.files);
|
||||
assert.equal(deliveryGit(f, ['show', ':owner-staged.txt']), 'Owner staged change: keep this exact staged content\n');
|
||||
assert.equal(deliveryGit(f, ['diff', '--cached', '--name-only']).trim(), 'owner-staged.txt');
|
||||
});
|
||||
|
||||
test('overlapping worker paths are explicit conflicts even if each independent task checks successfully', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f, { paths: ['src/shared.mjs', 'src/shared.mjs'] });
|
||||
assert.equal(group.status, 'ready_to_collect', group.summary);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'conflict', group.summary); assert.ok(group.collection.conflicts.some(value => value.path === 'src/shared.mjs' && value.workerIds.length === 2));
|
||||
assert.throws(() => manager.prepareMerge(f.session, group.id, group.fingerprint), /没有冲突/);
|
||||
assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/shared.mjs')), false);
|
||||
});
|
||||
|
||||
test('source edits after isolated work preserve the owner file and invalidate collection without proposing a merge', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f);
|
||||
writeDeliveryFile(f, 'owner-unstaged.txt', 'New owner work after worker execution\n');
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'stale'); assert.match(group.summary, /来源|已有修改/);
|
||||
assert.equal(group.merge, null); assert.equal(f.session.changes.length, 0);
|
||||
assert.equal(fs.readFileSync(path.join(f.projectRoot, 'owner-unstaged.txt'), 'utf8'), 'New owner work after worker execution\n');
|
||||
});
|
||||
|
||||
test('changed child bytes after parent preview block the entire batch before any parent write', async t => {
|
||||
const f = fixture(t), { runtime, manager, group } = await completedWorkers(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
const set = f.store.core.change_set.get(group.merge.changeSetId), child = group.children[1];
|
||||
fs.writeFileSync(path.join(f.store.project(child.projectId).root, 'src/b.mjs'), 'export const value = 99;\n');
|
||||
await assert.rejects(runtime.changeSetManager().start(f.session, set.id, set.fingerprint), /原提案|已应用|变化|不一致/);
|
||||
assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/a.mjs')), false); assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/b.mjs')), false);
|
||||
});
|
||||
|
||||
test('corrupt original check logs cannot become collected outputs or a parent review', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f), worker = f.store.core.worker.get(group.children[0].id);
|
||||
const check = f.store.core.check_job.get(worker.result.checkJobId), artifact = f.store.core.artifact.get(check.results[0].logArtifactId);
|
||||
fs.appendFileSync(path.join(f.store.artifactStore.root, artifact.relative), 'altered original log');
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'stale'); assert.equal(group.merge, null); assert.equal(f.session.changes.length, 0);
|
||||
});
|
||||
@@ -0,0 +1,289 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { spawn, execFileSync } from 'node:child_process';
|
||||
import { fixture, call, until, workspace } from './helpers.mjs';
|
||||
import { Store } from '../src/server/store.mjs';
|
||||
import { Runtime } from '../src/server/runtime.mjs';
|
||||
import { readOwnedProcessTree } from '../src/core/owned-process-tree.mjs';
|
||||
import { Provider } from '../src/server/provider.mjs';
|
||||
import { workerUsage } from '../src/shared/contracts/workers.mjs';
|
||||
import { proposeFile } from '../src/server/files.mjs';
|
||||
import { prepareWorkerFixture, workerDefinition, completedWorkers, ownerBytes } from './fixtures/workers-project.mjs';
|
||||
import { deliveryGit, writeDeliveryFile } from './fixtures/delivery-project.mjs';
|
||||
|
||||
const alive = pid => { try { process.kill(pid, 0); return true; } catch { return false; } };
|
||||
async function ready(t, options = {}, definition = workerDefinition()) {
|
||||
const f = fixture(t), context = prepareWorkerFixture(f, options), group = await context.manager.plan(f.session, definition);
|
||||
await (await context.manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'ready', group.summary); return { f, ...context, group };
|
||||
}
|
||||
function reopen(f, id) {
|
||||
f.store.close(); const store = new Store(f.data), provider = new Provider(), requests = [];
|
||||
provider.complete = async () => { requests.push('unexpected'); throw new Error('Recovery must never request a model'); };
|
||||
const runtime = new Runtime(store, provider), manager = runtime.workerManager(), group = store.core.collaboration.get(id), session = store.session(group.sessionId);
|
||||
f.onCleanup(() => store.close()); f.onCleanup(() => runtime.stopAll());
|
||||
return { store, provider, requests, runtime, manager, group, session };
|
||||
}
|
||||
async function evidence(manager, session, group) {
|
||||
await (await manager.reconcile(session, group.id, group.fingerprint)).promise;
|
||||
assert.ok(group.evidence, group.summary); return manager.readEvidence(session, group);
|
||||
}
|
||||
function longCheckProject(f) {
|
||||
writeDeliveryFile(f, 'test/add.test.mjs', "import test from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import { spawn } from 'node:child_process'; import { add } from '../src/add.mjs';\nconst child = spawn(process.execPath, ['-e', \"const fs = require('node:fs'); setInterval(() => fs.appendFileSync('.awb-heartbeat', 'tick'), 30);\"], { windowsHide: true, stdio: 'ignore' }); fs.writeFileSync('.awb-child-pid', String(child.pid));\ntest('owned long running functional check', async () => { assert.equal(add(2, 3), 5); await new Promise(resolve => setTimeout(resolve, 45000)); child.kill(); });\n");
|
||||
deliveryGit(f, ['add', '--', 'test/add.test.mjs']); deliveryGit(f, ['commit', '--no-gpg-sign', '-m', 'Own a cancellable check tree']);
|
||||
}
|
||||
|
||||
test('stopping a parent accounts late responses and executes none of their proposed tools', async t => {
|
||||
const releases = [], context = await ready(t, { respond: ({ project }) => new Promise(resolve => releases.push(() => resolve({
|
||||
message: { role: 'assistant', tool_calls: [call(randomUUID(), 'propose_file', { path: 'src/a.mjs', content: 'late', reason: 'late' })] }, usage: { total_tokens: 91 },
|
||||
}))) });
|
||||
const { f, manager, runtime, group } = context, initial = ownerBytes(f);
|
||||
const started = manager.start(f.session, group.id, group.fingerprint); await until(() => releases.length === 2);
|
||||
const stopping = runtime.stop(f.session.id); await until(() => group.status === 'stopping');
|
||||
for (const release of releases) release(); await stopping; await started.promise;
|
||||
assert.equal(group.status, 'paused', group.summary); assert.equal(runtime.hasActivity(), false); assert.deepEqual(ownerBytes(f), initial);
|
||||
for (const child of group.children) {
|
||||
const worker = f.store.core.worker.get(child.id), session = f.store.session(child.sessionId);
|
||||
assert.equal(session.changes.length, 0); assert.equal(workerUsage(f.store, worker).totalTokens, 91); assert.equal(workerUsage(f.store, worker).requests, 1);
|
||||
assert.equal(workerUsage(f.store, worker).toolCalls, 0); assert.equal(fs.existsSync(path.join(f.store.project(child.projectId).root, 'src/a.mjs')), false);
|
||||
}
|
||||
});
|
||||
|
||||
test('unreported interrupted requests reserve estimated usage and the total deadline cannot reset on resume', async t => {
|
||||
const { f, manager, group, requests } = await ready(t, { respond: ({ signal }) => new Promise((resolve, reject) => {
|
||||
const stop = () => reject(Object.assign(new Error('Owned fixture aborted without upstream usage'), { name: 'AbortError' }));
|
||||
signal.addEventListener('abort', stop, { once: true }); if (signal.aborted) stop();
|
||||
}) }, { ...workerDefinition(), budget: { maxDurationMs: 1000 } });
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
const deadline = group.deadline; assert.equal(requests.length, 2); assert.ok(Date.now() >= deadline);
|
||||
for (const child of group.children) { const usage = workerUsage(f.store, f.store.core.worker.get(child.id)); assert.equal(usage.unknownRequests, 1); assert.ok(usage.estimatedUnknownTokens > 0); }
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.deadline, deadline); assert.equal(requests.length, 2); assert.match(group.summary, /时限/);
|
||||
});
|
||||
|
||||
test('a response exceeding the cumulative token allocation stops before registering or executing its tools', async t => {
|
||||
const { f, manager, group, requests } = await ready(t, { respond: async () => ({ message: { role: 'assistant', tool_calls: [call(randomUUID(), 'propose_file', { path: 'src/a.mjs', content: 'over budget', reason: 'fixture' })] }, usage: { total_tokens: 10001 } }) }, { ...workerDefinition(), budget: { maxTokens: 20000 } });
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'paused', group.summary);
|
||||
for (const child of group.children) { const worker = f.store.core.worker.get(child.id); assert.equal(workerUsage(f.store, worker).accountedTokens, 10001); assert.equal(workerUsage(f.store, worker).toolCalls, 0); assert.equal(f.store.session(child.sessionId).changes.length, 0); }
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(requests.length, 2); assert.match(group.summary, /累计预算/);
|
||||
});
|
||||
|
||||
for (const [label, budget, count] of [['cumulative tool allocation', { maxToolCalls: 2 }, 2], ['single response 16 tool ceiling', {}, 17]]) {
|
||||
test(label + ' rejects the entire returned batch before any tool side effect', async t => {
|
||||
const { f, manager, group } = await ready(t, { respond: async () => ({ message: { role: 'assistant', tool_calls: Array.from({ length: count }, () => call(randomUUID(), 'inspect_project', {})) }, usage: { total_tokens: 100 } }) }, { ...workerDefinition(), budget });
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
for (const child of group.children) { const worker = f.store.core.worker.get(child.id); assert.equal(workerUsage(f.store, worker).toolCalls, 0); assert.equal(f.store.session(child.sessionId).changes.length, 0); assert.match(f.store.core.run.get(f.store.session(child.sessionId).runId).stopReason, /worker_tool_limit/); }
|
||||
});
|
||||
}
|
||||
|
||||
test('consumed request steps remain consumed across explicit worker resumes', async t => {
|
||||
const { f, manager, group, requests } = await ready(t, { respond: async () => ({ message: { role: 'assistant', content: 'No verified work' }, usage: { total_tokens: 10 } }) }, { ...workerDefinition(), budget: { maxSteps: 2 } });
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
await (await manager.start(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(requests.length, 2); assert.match(group.summary, /累计预算/);
|
||||
for (const child of group.children) assert.equal(workerUsage(f.store, f.store.core.worker.get(child.id)).steps, 1);
|
||||
});
|
||||
|
||||
test('a saved completed response with missing usage is conservatively accounted exactly once during recovery', async t => {
|
||||
const { f, group } = await ready(t), worker = f.store.core.worker.get(group.children[0].id), session = f.store.session(worker.sessionId), run = f.store.core.run.get(session.runId);
|
||||
const record = { id: randomUUID(), projectId: session.projectId, sessionId: session.id, taskId: session.taskId, runId: run.id,
|
||||
status: 'completed', workerDispatchedAt: new Date().toISOString(), estimatedInputTokens: 1234, workerUsageAccounted: false };
|
||||
f.store.putRecord('context_plan', session, record, 'fixture.response_saved_before_usage');
|
||||
const first = reopen(f, group.id), recovered = first.store.core.context_plan.get(record.id);
|
||||
assert.equal(recovered.status, 'completed'); assert.equal(recovered.workerUsageRecovered, true);
|
||||
const original = workerUsage(first.store, first.store.core.worker.get(worker.id)); assert.equal(original.unknownRequests, 1); assert.equal(original.requests, 1);
|
||||
first.store.close(); const second = new Store(f.data); f.onCleanup(() => second.close());
|
||||
assert.deepEqual(workerUsage(second, second.core.worker.get(worker.id)), original);
|
||||
});
|
||||
|
||||
test('an unexecuted second workspace plan resumes its original identity without recreating the first checkout', async t => {
|
||||
const f = fixture(t), { manager } = prepareWorkerFixture(f), group = await manager.plan(f.session, workerDefinition());
|
||||
let count = 0; manager.workspaces.faultInjector = phase => { if (phase === 'prepared' && ++count === 2) throw new Error('Fixture interrupted after saving the second unexecuted plan'); };
|
||||
await (await manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'unknown', group.summary); const first = f.store.core.worker.get(group.children[0].id), second = f.store.core.workspace.get(group.children[1].workspaceId);
|
||||
assert.equal(second.status, 'prepared'); assert.equal(second.creationAttempted, false);
|
||||
manager.workspaces.faultInjector = null; await evidence(manager, f.session, group);
|
||||
await manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256);
|
||||
assert.equal(group.status, 'partially_prepared');
|
||||
await (await manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'ready', group.summary); assert.equal(f.store.core.worker.get(first.id).runId, first.runId);
|
||||
assert.equal(f.store.core.workspace.get(second.id).id, second.id); assert.equal(f.store.core.workspace.size, 2);
|
||||
});
|
||||
|
||||
test('a verified interrupted parent proposal resumes sealing without duplicating or replacing its original change', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise;
|
||||
manager.faultInjector = phase => { if (phase === 'merge_proposal') throw new Error('Fixture interruption after the first persisted parent proposal'); };
|
||||
await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'unknown'); const originalId = group.merge.changeIds[0]; assert.equal(group.merge.changeIds.length, 1);
|
||||
manager.faultInjector = null; await evidence(manager, f.session, group);
|
||||
await manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256);
|
||||
assert.equal(group.status, 'collected', group.summary);
|
||||
await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'merge_prepared', group.summary); assert.equal(group.merge.changeIds[0], originalId);
|
||||
assert.equal(f.session.changes.filter(change => change.sourceBinding?.collaborationId === group.id).length, 2);
|
||||
});
|
||||
|
||||
test('recovery attaches a sealed parent batch saved before its group reference without creating another batch', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise; await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
const setId = group.merge.changeSetId; delete group.merge.changeSetId; delete group.merge.fingerprint; group.merge.status = 'proposing'; group.status = 'merge_preparing'; f.store.save(f.session);
|
||||
const restored = reopen(f, group.id); await evidence(restored.manager, restored.session, restored.group);
|
||||
await restored.manager.acknowledge(restored.session, group.id, group.fingerprint, restored.group.evidence.sha256);
|
||||
assert.equal(restored.group.status, 'merge_prepared', restored.group.summary); assert.equal(restored.group.merge.changeSetId, setId);
|
||||
assert.equal([...restored.store.core.change_set.values()].filter(set => set.collaborationBinding?.id === group.id).length, 1); assert.equal(restored.requests.length, 0);
|
||||
});
|
||||
|
||||
test('explicitly retaining an unexecuted parent merge cancels its batch and frees the next parent goal', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f), initial = ownerBytes(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise; await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
const set = f.store.core.change_set.get(group.merge.changeSetId); group.status = 'unknown'; group.requiresVerification = true; f.store.save(f.session);
|
||||
await evidence(manager, f.session, group); await manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256, true);
|
||||
assert.equal(group.status, 'resolved_external'); assert.equal(set.status, 'cancelled'); assert.equal(set.attemptedAt, undefined); assert.deepEqual(ownerBytes(f), initial);
|
||||
assert.equal(f.session.changes.some(change => ['pending', 'conflict'].includes(change.status)), false);
|
||||
const next = await manager.plan(f.session, { ...workerDefinition(), goal: 'The next explicitly planned goal' }); assert.notEqual(next.taskId, group.taskId);
|
||||
});
|
||||
|
||||
test('unknown collaboration blocks ordinary proposals but permits only original batch recovery and rollback', async t => {
|
||||
const f = fixture(t), { runtime, manager, group } = await completedWorkers(f), initial = ownerBytes(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise; await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
const set = f.store.core.change_set.get(group.merge.changeSetId);
|
||||
await (await runtime.changeSetManager().start(f.session, set.id, set.fingerprint)).promise;
|
||||
set.status = 'unknown'; set.requiresVerification = true; group.status = 'unknown'; group.requiresVerification = true; f.store.save(f.session);
|
||||
assert.throws(() => proposeFile(f.store, f.session, { path: 'src/new.mjs', content: 'blocked', reason: 'fixture' }), /待核对/);
|
||||
await runtime.changeSetManager().reconcile(f.session, set.id); assert.equal(set.status, 'completed');
|
||||
await runtime.changeSetManager().rollback(f.session, set.id, set.fingerprint); assert.equal(set.status, 'rolled_back');
|
||||
assert.deepEqual(ownerBytes(f), initial); assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/a.mjs')), false);
|
||||
await evidence(manager, f.session, group);
|
||||
await assert.rejects(manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256), /批次|保留现场/);
|
||||
await evidence(manager, f.session, group); await manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256, true);
|
||||
assert.equal(group.status, 'resolved_external');
|
||||
});
|
||||
|
||||
test('after a restart the batch application lazily reinstates the worker result guard before any parent write', async t => {
|
||||
const f = fixture(t), { manager, group } = await completedWorkers(f);
|
||||
await (await manager.collect(f.session, group.id, group.fingerprint)).promise; await (await manager.prepareMerge(f.session, group.id, group.fingerprint)).promise;
|
||||
const setId = group.merge.changeSetId; f.store.close(); const store = new Store(f.data), runtime = new Runtime(store, new Provider()); f.onCleanup(() => store.close()); f.onCleanup(() => runtime.stopAll());
|
||||
assert.equal(runtime.workers, undefined);
|
||||
fs.writeFileSync(path.join(store.project(group.children[0].projectId).root, 'src/a.mjs'), 'changed after original preview\n');
|
||||
const session = store.session(group.sessionId), set = store.core.change_set.get(setId); await assert.rejects(runtime.changeSetManager().start(session, set.id, set.fingerprint), /原成果|提案|不一致|变化/);
|
||||
assert.ok(runtime.workers); assert.equal(set.attemptedAt, undefined); assert.equal(fs.existsSync(path.join(f.projectRoot, 'src/a.mjs')), false);
|
||||
});
|
||||
|
||||
test('unknown original tool inputs must match before acknowledgement, and reviewed checkpoint IDs preserve the unknown fact', async t => {
|
||||
const { f, group } = await ready(t), child = group.children[0], worker = f.store.core.worker.get(child.id), session = f.store.session(child.sessionId);
|
||||
const run = f.store.beginRun(session, '', true, f.store.config); worker.currentRunId = run.id; worker.runIds.push(run.id); worker.status = 'running';
|
||||
const originalCall = call(randomUUID(), 'inspect_project', {}); session.providerMessages.push({ role: 'assistant', tool_calls: [originalCall] });
|
||||
const event = { id: randomUUID(), toolCallId: originalCall.id }; session.events.push(event); f.store.registerInvocation(session, originalCall, run, event); f.store.invocationState(session, event, 'running');
|
||||
const restored = reopen(f, group.id), restoredChild = restored.store.session(child.sessionId), tool = [...restored.store.core.tool.values()].find(value => value.callId === originalCall.id);
|
||||
assert.equal(restored.group.status, 'unknown'); await evidence(restored.manager, restored.session, restored.group);
|
||||
const savedCall = restoredChild.providerMessages.flatMap(message => message.tool_calls ?? []).find(value => value.id === originalCall.id), originalArgs = savedCall.function.arguments;
|
||||
savedCall.function.arguments = '{"changed":true}'; restored.store.save(restoredChild);
|
||||
await assert.rejects(restored.manager.acknowledge(restored.session, group.id, group.fingerprint, restored.group.evidence.sha256), /输入哈希/);
|
||||
savedCall.function.arguments = originalArgs; restored.store.save(restoredChild); await evidence(restored.manager, restored.session, restored.group);
|
||||
await restored.manager.acknowledge(restored.session, group.id, group.fingerprint, restored.group.evidence.sha256);
|
||||
assert.equal(tool.state, 'resolved_external'); assert.equal(tool.originalState, 'unknown'); assert.equal(tool.requiresVerification, false);
|
||||
assert.equal(restored.store.core.run.get(run.id).checkpoint.requiresVerification.includes(tool.id), false);
|
||||
assert.equal(restored.store.core.run.get(run.id).checkpoint.reviewedUnknownToolIds.includes(tool.id), true);
|
||||
assert.equal(restored.store.savedToolResult(child.sessionId, originalCall.id).status, 'unknown'); assert.equal(restored.requests.length, 0);
|
||||
});
|
||||
|
||||
test('a parent stop observes and waits for a manually approved child check and its real descendant process', async t => {
|
||||
const f = fixture(t), { manager, runtime } = prepareWorkerFixture(f); longCheckProject(f); const initial = ownerBytes(f), group = await manager.plan(f.session, workerDefinition());
|
||||
await (await manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
const child = group.children[0], session = f.store.session(child.sessionId), root = f.store.project(child.projectId).root;
|
||||
const plan = await runtime.checkRunner().plan(session, ['test']), started = await runtime.checkRunner().start(session, plan.id);
|
||||
await until(() => fs.existsSync(path.join(root, '.awb-heartbeat')) || started.job.finishedAt, 15000);
|
||||
assert.equal(fs.existsSync(path.join(root, '.awb-heartbeat')), true, JSON.stringify(started.job));
|
||||
const descendant = Number(fs.readFileSync(path.join(root, '.awb-child-pid'), 'utf8')); assert.equal(alive(descendant), true);
|
||||
assert.equal(manager.isActive(f.session.id), true); assert.equal(runtime.projectHasActivity(f.project.id), true);
|
||||
await assert.rejects(manager.plan(f.session, workerDefinition()), /执行|等待/);
|
||||
await runtime.stop(f.session.id); await started.promise;
|
||||
assert.equal(started.job.status, 'cancelled', started.job.summary); assert.equal(started.job.requiresVerification ?? false, false);
|
||||
assert.equal(started.job.results[0].process.rootExited, true); assert.equal(started.job.results[0].process.treeTermination, 'confirmed');
|
||||
assert.equal(alive(descendant), false); const bytes = fs.readFileSync(path.join(root, '.awb-heartbeat'));
|
||||
await new Promise(resolve => setTimeout(resolve, 150)); assert.deepEqual(fs.readFileSync(path.join(root, '.awb-heartbeat')), bytes); assert.deepEqual(ownerBytes(f), initial); assert.equal(runtime.hasActivity(), false);
|
||||
});
|
||||
|
||||
test('a real host crash preserves unknown checks, refuses a still living owned PID and never replays a model or tool', async t => {
|
||||
const f = fixture(t), { manager } = prepareWorkerFixture(f); longCheckProject(f); const group = await manager.plan(f.session, workerDefinition());
|
||||
await (await manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
for (const child of group.children) await manager.runtime.checkRunner().plan(f.store.session(child.sessionId), ['test']);
|
||||
f.store.close();
|
||||
const host = spawn(process.execPath, [path.join(workspace, 'tests/fixtures/workers-crash.mjs'), f.data, group.id], { cwd: workspace, env: { PATH: process.env.PATH, SystemRoot: process.env.SystemRoot, TEMP: process.env.TEMP }, windowsHide: true, stdio: ['ignore', 'pipe', 'pipe', 'ipc'] });
|
||||
let processStarted = false, treeObserved = false, output = ''; host.on('message', value => { if (value.kind === 'owned-check') { processStarted = true; if (value.descendants >= 3) treeObserved = true; } }); host.stderr.on('data', bytes => { output += bytes.toString('utf8'); });
|
||||
const ended = new Promise(resolve => host.once('close', resolve));
|
||||
t.after(async () => { if (host.exitCode === null && host.signalCode === null) { host.kill('SIGKILL'); await ended; } });
|
||||
await until(() => processStarted || host.exitCode !== null, 15000); assert.equal(processStarted, true, output);
|
||||
await until(() => group.children.some(child => fs.existsSync(path.join(manager.store.project(child.projectId).root, '.awb-heartbeat'))), 15000);
|
||||
await until(() => treeObserved || host.exitCode !== null, 20000); assert.equal(treeObserved, true, output);
|
||||
host.kill('SIGKILL'); await ended;
|
||||
const store = new Store(f.data), runtime = new Runtime(store, new Provider()), recovered = runtime.workerManager(), parent = store.session(group.sessionId), record = store.core.collaboration.get(group.id);
|
||||
f.onCleanup(() => store.close()); f.onCleanup(() => runtime.stopAll());
|
||||
const jobs = [...store.core.check_job.values()].filter(job => group.children.some(child => child.taskId === job.taskId));
|
||||
const pids = jobs.flatMap(job => job.currentCheck?.process ? [job.currentCheck.process, ...(job.currentCheck.process.descendants ?? []).map(value => ({ ...value, hostPid: host.pid, cwd: job.currentCheck.process.cwd }))] : []);
|
||||
t.after(() => { for (const info of pids) if (info.hostPid === host.pid && alive(info.pid)) { try { execFileSync('taskkill.exe', ['/PID', String(info.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' }); } catch {} } });
|
||||
assert.equal(record.status, 'unknown'); assert.ok(jobs.some(job => job.status === 'unknown')); assert.ok(pids.some(info => alive(info.pid)));
|
||||
await (await recovered.reconcile(parent, record.id, record.fingerprint)).promise; assert.equal(record.evidence, undefined); assert.match(record.summary, /PID|存活/);
|
||||
for (const info of pids) {
|
||||
assert.equal(info.hostPid, host.pid); assert.ok(path.resolve(info.cwd).startsWith(path.resolve(f.root) + path.sep));
|
||||
if (alive(info.pid)) { try { execFileSync('taskkill.exe', ['/PID', String(info.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' }); } catch { await until(() => !alive(info.pid), 3000); } }
|
||||
}
|
||||
await until(() => pids.every(info => !alive(info.pid)));
|
||||
const roots = jobs.flatMap(job => job.currentCheck?.process ? [job.currentCheck.process] : []);
|
||||
const cleanupDeadline = Date.now() + 20000;
|
||||
while (true) {
|
||||
const current = (await Promise.all(roots.map(info => readOwnedProcessTree(info)))).flatMap(tree => tree.processes);
|
||||
if (!current.length) break;
|
||||
assert.ok(Date.now() < cleanupDeadline, 'Owned late descendant did not exit after QA cleanup');
|
||||
for (const info of current) { try { execFileSync('taskkill.exe', ['/PID', String(info.pid), '/T', '/F'], { windowsHide: true, stdio: 'ignore' }); } catch {} }
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
await evidence(recovered, parent, record); await recovered.acknowledge(parent, record.id, record.fingerprint, record.evidence.sha256);
|
||||
assert.equal(record.requiresVerification, false); assert.equal(jobs.some(job => job.status === 'passed'), false); assert.equal([...store.core.tool.values()].some(tool => tool.originalState === 'unknown'), true);
|
||||
assert.equal(runtime.hasActivity(), false);
|
||||
});
|
||||
|
||||
test('a persisted child initialization resumes the original control run after a failure before its worker record', async t => {
|
||||
const f = fixture(t), { manager } = prepareWorkerFixture(f), group = await manager.plan(f.session, workerDefinition()), inventory = manager.inventory;
|
||||
let failed = false; manager.inventory = async function(project) { if (!failed) { failed = true; throw new Error('Owned failure after child task persistence'); } return inventory.call(this, project); };
|
||||
await (await manager.prepare(f.session, group.id, group.fingerprint)).promise; assert.equal(group.status, 'unknown', group.summary);
|
||||
const child = group.children[0], session = f.store.session(child.sessionId), originalRunId = session.runId; assert.equal(session.taskId, child.taskId); assert.equal(f.store.core.worker.has(child.id), false);
|
||||
manager.inventory = inventory; await evidence(manager, f.session, group); await manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256);
|
||||
assert.equal(group.status, 'partially_prepared'); await (await manager.prepare(f.session, group.id, group.fingerprint)).promise;
|
||||
assert.equal(group.status, 'ready', group.summary); assert.equal(f.store.core.worker.get(child.id).runId, originalRunId);
|
||||
assert.equal([...f.store.core.task.values()].filter(task => task.workerId === child.id).length, 1);
|
||||
});
|
||||
|
||||
test('failed request intent persistence never dispatches a worker request or changes source', async t => {
|
||||
const { f, manager, group, requests } = await ready(t, { respond: async () => ({ message: { role: 'assistant', content: 'unexpected' }, usage: { total_tokens: 5 } }) });
|
||||
const save = f.store.storage.save, rejected = new Set();
|
||||
f.store.storage.save = function(session, records, type, detail) { if (type === 'worker.request_intent' && !rejected.has(session.id)) { rejected.add(session.id); throw new Error('Owned SQLite request intent failure'); } return save.call(this, session, records, type, detail); };
|
||||
try { await (await manager.start(f.session, group.id, group.fingerprint)).promise; } finally { f.store.storage.save = save; }
|
||||
assert.equal(rejected.size, 2); assert.equal(requests.length, 0);
|
||||
for (const child of group.children) { assert.equal(workerUsage(f.store, f.store.core.worker.get(child.id)).requests, 0); assert.equal(f.store.session(child.sessionId).changes.length, 0); }
|
||||
});
|
||||
|
||||
test('failed usage persistence rolls back the uncommitted usage and conservatively reserves one unknown request without tools', async t => {
|
||||
const { f, manager, group, requests } = await ready(t, { respond: async () => ({ message: { role: 'assistant', tool_calls: [call(randomUUID(), 'propose_file', { path: 'src/a.mjs', content: 'must not execute', reason: 'fixture' })] }, usage: { total_tokens: 73 } }) });
|
||||
const save = f.store.storage.save, rejected = new Set();
|
||||
f.store.storage.save = function(session, records, type, detail) {
|
||||
if (type === 'session.updated' && records.some(record => record.kind === 'context_plan' && record.value.status === 'completed' && record.value.workerUsageAccounted) && !rejected.has(session.id)) { rejected.add(session.id); throw new Error('Owned SQLite usage persistence failure'); }
|
||||
return save.call(this, session, records, type, detail);
|
||||
};
|
||||
try { await (await manager.start(f.session, group.id, group.fingerprint)).promise; } finally { f.store.storage.save = save; }
|
||||
assert.equal(rejected.size, 2); assert.equal(requests.length, 2);
|
||||
for (const child of group.children) { const usage = workerUsage(f.store, f.store.core.worker.get(child.id)); assert.equal(usage.requests, 1); assert.equal(usage.unknownRequests, 1); assert.equal(usage.totalTokens, 0); assert.equal(usage.toolCalls, 0); assert.equal(f.store.session(child.sessionId).changes.length, 0); }
|
||||
});
|
||||
|
||||
test('a child file change after observation prevents acknowledgement even when the tool inputs did not change', async t => {
|
||||
const { f, manager, group } = await ready(t); group.status = 'unknown'; group.requiresVerification = true; f.store.save(f.session); await evidence(manager, f.session, group);
|
||||
fs.appendFileSync(path.join(f.store.project(group.children[0].projectId).root, 'README.md'), 'External owner edit after observation\n');
|
||||
await assert.rejects(manager.acknowledge(f.session, group.id, group.fingerprint, group.evidence.sha256), /现场.*变化/);
|
||||
assert.equal(group.status, 'unknown'); assert.equal(group.requiresVerification, true);
|
||||
});
|
||||
Reference in New Issue
Block a user