From d6bbe25a9e3ac9b104560617cbc8942c128f299b Mon Sep 17 00:00:00 2001 From: Agent Workbench Dev Date: Fri, 30 Oct 2026 05:39:00 +0800 Subject: [PATCH] fix: bound REA exports for deep Windows data directories --- CHANGELOG.md | 1 + THIRD_PARTY_NOTICES.txt | 30 ++++ docs/QA-1.8.md | 4 + docs/REA-INTEGRATION.md | 2 + docs/rea-engine-archives-validation.json | 24 +++ docs/rea-engine-deep-export-validation.json | 185 ++++++++++++++++++++ docs/rea-engine-portable-validation.json | 67 +++++++ docs/rea-engine-source-initial-failure.json | 7 + licenses/REA-6.8.0-LICENSE.txt | 21 +++ progress.md | 10 ++ src/core/research-manager.mjs | 7 +- src/core/tools/research-output.mjs | 26 +++ tests/research.test.mjs | 28 ++- 13 files changed, 406 insertions(+), 6 deletions(-) create mode 100644 docs/rea-engine-archives-validation.json create mode 100644 docs/rea-engine-deep-export-validation.json create mode 100644 docs/rea-engine-portable-validation.json create mode 100644 docs/rea-engine-source-initial-failure.json create mode 100644 licenses/REA-6.8.0-LICENSE.txt create mode 100644 src/core/tools/research-output.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index ae8d688a..ecaf598b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - 原分析绑定工件SHA256、Task/Run、固定REA版本和实际工具契约;同版本核验后复用,停止或失败记录保留,重启不会自动重跑。 - 便携与源码包保留REA 6.8.0的锁定生产依赖、原许可证和文件清单。研究界面适配390px,嵌套原证据窗口支持独立键盘关闭。 - 修复同Task新Run读取旧页时的进展误判,反馈替换预算按当前结果计算,避免旧页记录阻止有效续接。 +- Windows数据目录较深时,为REA分配有独立归属的较短输出目录,完整Evidence仍封存到原Task,避免导出误报目录不存在。 ## 1.7.0 · 2026-10-30 diff --git a/THIRD_PARTY_NOTICES.txt b/THIRD_PARTY_NOTICES.txt index 4fdc4724..0e0bfbc3 100644 --- a/THIRD_PARTY_NOTICES.txt +++ b/THIRD_PARTY_NOTICES.txt @@ -5922,6 +5922,36 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +======================================================================== +REA (rea-agents) 6.8.0 +License: MIT +Source: https://github.com/morluto/rea + +MIT License + +Copyright (c) 2026 morluto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +The fixed production dependency declarations, integrity metadata and file hashes are recorded in runtime/REA-RUNTIME.json. +Original package and dependency license texts remain under runtime/node_modules/. REA additional notices are retained at runtime/node_modules/rea-agents/THIRD_PARTY_NOTICES.md. + ======================================================================== Node.js v24.22.1 diff --git a/docs/QA-1.8.md b/docs/QA-1.8.md index 1313669e..26c9121a 100644 --- a/docs/QA-1.8.md +++ b/docs/QA-1.8.md @@ -14,4 +14,8 @@ MCP/研究16项专项通过,覆盖分片UTF-8、最终响应、反向请求拒 发行脚本已准备REA生产依赖、固定安装锁、原许可证及runtime/REA-RUNTIME.json完整文件快照;便携和源码均需在自己的runtime中完成三项真实静态分析,不能借用父目录安装。不可变包、独立离线源码构建/回归、归档与原PID/Provider升级完成后补充实际证据。 +首个不可变发行20261029212137336的便携10769份/源码8973份归档、CRC与SHA256核对通过,便携三项真实REA、原Bundle/复用、自带Node/npm四项检查和启动/停止通过。独立源码离线安装与6份构建对照通过,但完整回归尚未开始,REA导出在超过300字符的Windows路径报目录不存在,原失败见[源码初验](rea-engine-source-initial-failure.json)。 + +新增深数据目录回归先失败,再为所属job分配较短输出目录;17项MCP/研究专项、构建及原深解压目录内三项真实REA复验通过,见[深路径实际分析](rea-engine-deep-export-validation.json)。专项第二轮中的测试变量拼写错误已校正;不把原失败或未运行的243项记为通过。修复后的不可变包与最终244项独立源码需另行验收。 + 正式4318当前仍保留1.7.0/PID23080及原Provider。原真实任务在1.7.0的5次响应后no_progress、无提案的失败保留;本轮源码、接口夹具或静态分析通过均不代表真实模型已经交付工程,也不代表Purge、其他引擎、Electron安装端或手机配对完成。 diff --git a/docs/REA-INTEGRATION.md b/docs/REA-INTEGRATION.md index 33fe5e3d..3a51e189 100644 --- a/docs/REA-INTEGRATION.md +++ b/docs/REA-INTEGRATION.md @@ -17,3 +17,5 @@ 验收分开登记:确定性契约/中断/来源测试、真实REA惰性工件分析、实际API持久与重启、桌面/390px交互,以及不可变发行内自带REA运行。机制研究完成不表示已经复制远端模型服务或交付所有外部引擎。 便携与源码发行均保留固定REA6.8.0的已安装生产依赖;runtime/REA-PACKAGE-LOCK.json保存原安装锁,runtime/REA-RUNTIME.json记录每个包的版本/许可/完整性元数据、缺失可选包和实际文件SHA256。原包与依赖许可证保留在runtime/node_modules及主许可目录。构建不运行REA setup、不写客户端配置、不隐式安装缺少的可选分析器;实际保证范围以发行内三项分析验收为准。 + +Windows导出路径按UTF-8预留240字节:普通Task输出留在会话数据目录,深数据目录改用宿主TEMP下AgentWorkbench-REA/原jobId。实际目录及归属随job持久保存;原输出保留,完整Evidence与Bundle仍封存至同一Task工件库,恢复不依赖重新运行生产者。不能满足路径范围时在启动REA前失败。 diff --git a/docs/rea-engine-archives-validation.json b/docs/rea-engine-archives-validation.json new file mode 100644 index 00000000..50dda3f9 --- /dev/null +++ b/docs/rea-engine-archives-validation.json @@ -0,0 +1,24 @@ +{ + "success": true, + "version": "1.8.0", + "testedAt": "2026-10-29T21:29:09.593363+00:00", + "archives": [ + { + "kind": "portable", + "path": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\releases\\Agent-Workbench-1.8.0-win-x64-20261029212137336.zip", + "files": 10769, + "crcPassed": true, + "manifestAndDirectoryMatch": true, + "sha256": "1f4dbfda2c6ba692056dc5dc0693b1204e7f175bf8e5698200fb599809a9fb0c" + }, + { + "kind": "source", + "path": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\releases\\Agent-Workbench-1.8.0-source-20261029212137336.zip", + "files": 8973, + "crcPassed": true, + "manifestAndDirectoryMatch": true, + "sha256": "83fafa1780df28b9b3e14e8ed52ccc334929c0826c8a923a972ae20e1bd39ffb" + } + ], + "extractionRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336" +} \ No newline at end of file diff --git a/docs/rea-engine-deep-export-validation.json b/docs/rea-engine-deep-export-validation.json new file mode 100644 index 00000000..e2065aa2 --- /dev/null +++ b/docs/rea-engine-deep-export-validation.json @@ -0,0 +1,185 @@ +{ + "success": true, + "version": "1.8.0", + "testedAt": "2026-10-29T21:37:00.779Z", + "directory": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336\\.qa\\rea-integration-04825f8e-3a9e-4dae-8836-6e1bd4b3bfcb", + "appDirectory": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336", + "installation": { + "status": "available", + "version": "6.8.0", + "packageRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336\\runtime\\node_modules\\rea-agents", + "entry": { + "path": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336\\runtime\\node_modules\\rea-agents\\scripts\\rea.mjs", + "sha256": "67ca7682986ff2b90678e1797e625caca6026a1732d9cad1a1088253c7bb45e5" + }, + "metadata": { + "path": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336\\runtime\\node_modules\\rea-agents\\package.json", + "sha256": "b0fc212f6bea9b4ee6e2b3ab0b52dd95402c229da3b8652127e5f131c3445b39" + }, + "protocolVersion": "2025-03-26", + "mcpEntry": { + "path": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336\\runtime\\node_modules\\rea-agents\\dist\\mcp\\main.js", + "sha256": "2af98f5f6190a3374218c283eba99c60822dbf7c093d2b1ba7dd31c5f54c56c9" + }, + "node": { + "path": "C:\\Program Files\\nodejs\\node.exe", + "version": "24.22.1" + }, + "inputSchemaProfile": "compact", + "outputSchemaProfile": "off", + "operations": [ + { + "id": "javascript", + "name": "analyze_javascript_application", + "extensions": [ + ".asar" + ], + "label": "JavaScript / Electron静态分析" + }, + { + "id": "pe-imports", + "name": "inspect_pe_imports", + "extensions": [ + ".exe", + ".dll" + ], + "label": "PE导入表" + }, + { + "id": "pe-resources", + "name": "inspect_pe_resources", + "extensions": [ + ".exe", + ".dll" + ], + "label": "PE静态资源" + } + ], + "identityScope": "package declaration, entry files and actual MCP handshake; not a full installation equivalence claim" + }, + "taskId": "e3f5b4ed-d745-49bf-860a-6e133601feb5", + "sessionId": "831baaa3-30f6-4773-8e23-00cdd89de32a", + "modelRequests": 0, + "targetExecution": false, + "results": [ + { + "operation": "javascript", + "targetSha256": "7ed8b630eb4ad0c0231f6fcd302bc4e3ecfda808dfca647f45c93d8526eb500c", + "bytes": 649, + "evidenceId": "ev_643ccc11f0c69602835dc48817ffeb040c0a80102489e37572f0bde01d532664", + "originalOperation": "analyze_javascript_application", + "normalizedFields": [ + "format", + "graph", + "input_path", + "integrity_contradictions", + "inventory_graph_sha256", + "inventory_manifest_id", + "limitations", + "root_artifact_sha256", + "route_inventory", + "semantic_graph", + "statistics", + "summary" + ], + "bundleSha256": "ca8f0b282adf80f32b0283c0c8602a8346b74dbbb1ae12189338032977b2dc67", + "evidenceSha256": "de4d6337c6509e0f7afd9ae1bbc25865d706f7e36f5343312c2328d194592c61", + "rawSha256": "ce5975fc6a0f34ffb65c842a0b519d0073aa0790d8dcc2680c55dae0e2b742ec", + "advertisedTools": 229, + "cleanup": { + "connectionId": "680b301a-80ee-4be5-a9c5-123e10dda9aa", + "pid": 12788, + "rootExited": true, + "forced": false, + "killError": null, + "exit": { + "code": 0, + "signal": null + }, + "scope": "owned-stdio-process", + "finishedAt": "2026-10-29T21:36:56.520Z" + }, + "reusedFromJobId": "8bc1fa5f-f422-4434-83c0-17b20de1d1d0", + "verification": "actual-REA-6.8.0; owned inert artifacts" + }, + { + "operation": "pe-imports", + "targetSha256": "7102754492d544b471ff84afdb3bbec983824049e4c2118bd0e240f8e7cbe973", + "bytes": 1024, + "evidenceId": "ev_6711d1f944c88c33dad385a05669dea55bc37f26b9392f15fa7d5b616319f5b6", + "originalOperation": "inspect_pe_imports", + "normalizedFields": [ + "architecture", + "artifact", + "bits", + "coverage", + "delay_import_directory", + "delay_imports", + "format", + "imphash", + "import_directory", + "imports", + "issues", + "limitations", + "machine" + ], + "bundleSha256": "007132f8d6808dc8eb92140739f7420b79efe634bb2f0257f5ee022ee35a1505", + "evidenceSha256": "09ad2c434eb507e7e156fbee3d828685f42c8393a5114e16627c1c7cc632bfd1", + "rawSha256": "eca2fec23827979325392a2a36f439085621428495b3dd120ca2dcd3fc5895b6", + "advertisedTools": 229, + "cleanup": { + "connectionId": "c8360774-410b-4322-a66a-6655877d0b95", + "pid": 43072, + "rootExited": true, + "forced": false, + "killError": null, + "exit": { + "code": 0, + "signal": null + }, + "scope": "owned-stdio-process", + "finishedAt": "2026-10-29T21:36:58.602Z" + }, + "reusedFromJobId": "9fbab0ef-72fb-41ac-9ec9-98114768fd95", + "verification": "actual-REA-6.8.0; owned inert artifacts" + }, + { + "operation": "pe-resources", + "targetSha256": "7102754492d544b471ff84afdb3bbec983824049e4c2118bd0e240f8e7cbe973", + "bytes": 1024, + "evidenceId": "ev_3d997abd00a78dd8edc96535aefe5c7930ee8dbbb3d65c7820aa3748bbaaa1ea", + "originalOperation": "inspect_pe_resources", + "normalizedFields": [ + "artifact", + "coverage", + "directories", + "directory", + "format", + "icon_groups", + "limitations", + "machine", + "resources" + ], + "bundleSha256": "3f7045c5e97224a6f840c92c628cd24c77f9e3eb44a0970596bbf408035334cc", + "evidenceSha256": "fa82c30f48a7699219f86a8edb4958f05d9f95ea480d6efbd9f455e9c4666207", + "rawSha256": "44ebb849720de819e237a8c61365fde0f4c6a5afe543d887d3585884aaf906a2", + "advertisedTools": 229, + "cleanup": { + "connectionId": "7fdf69ec-860a-4ec6-aac3-855e18742f5c", + "pid": 9756, + "rootExited": true, + "forced": false, + "killError": null, + "exit": { + "code": 0, + "signal": null + }, + "scope": "owned-stdio-process", + "finishedAt": "2026-10-29T21:37:00.602Z" + }, + "reusedFromJobId": "34a7c46e-c05d-4b17-a2d7-a5b2bf7d9cf7", + "verification": "actual-REA-6.8.0; owned inert artifacts" + } + ], + "credentialsHandling": "No model connection, login state, key lookup or client MCP configuration changes." +} diff --git a/docs/rea-engine-portable-validation.json b/docs/rea-engine-portable-validation.json new file mode 100644 index 00000000..74abd398 --- /dev/null +++ b/docs/rea-engine-portable-validation.json @@ -0,0 +1,67 @@ +{ + "success": true, + "date": "2026-10-29T21:29:37.471Z", + "appRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\releases\\Agent-Workbench-1.8.0-win-x64-20261029212137336", + "version": "1.8.0", + "nodeVersion": "v24.22.1", + "verifiedFiles": 10769, + "url": "http://127.0.0.1:61712", + "reusedPid": 49988, + "checks": { + "jobId": "fd035b6f-c9cd-407b-96c5-f34e811ff939", + "status": "passed", + "tests": { + "total": 4, + "passed": 4, + "failed": 0, + "cancelled": 0, + "skipped": 0 + } + }, + "actualRea": [ + { + "operation": "javascript", + "jobId": "71ceee79-0e6a-4139-8c2c-a2624a9bd288", + "evidenceId": "ev_3dbd75d5467c648f2eb5b1cd4b12536fd6648496c8c7103e7e703f870bd826f6", + "targetSha256": "66f90ee16dcb9b17f6f6ab6664fe02d7c0c829aa9f6c38ae43248c7b666471b0", + "bundleSha256": "c0b4458045c3571d1d8397e1d3fe0eb69d7c7e027d6f612ee3d0d1c93012ea1b", + "rootExited": true, + "reusedJobId": "a7c3017b-0092-4c83-833f-61594ff2d87c" + }, + { + "operation": "pe-imports", + "jobId": "ac0011bd-e3b5-41b6-b443-4a62de483fce", + "evidenceId": "ev_cdef70e1495319c0e300d4bd15938c96f9806fde51a2414ec5431b0bd1eb896f", + "targetSha256": "7102754492d544b471ff84afdb3bbec983824049e4c2118bd0e240f8e7cbe973", + "bundleSha256": "baf080145207c5a3ba71cdef5db45e3e679096175dff86e8916bc117144ecacf", + "rootExited": true, + "reusedJobId": "697e5290-fdc3-46de-b531-ff1f6891bef8" + }, + { + "operation": "pe-resources", + "jobId": "46a76eb0-7977-488d-90ef-5a5524451c9b", + "evidenceId": "ev_5bdaa9a0cc5a645aaa210630be6df9dcb5b40c7a0eac281bba2bb950282b71db", + "targetSha256": "7102754492d544b471ff84afdb3bbec983824049e4c2118bd0e240f8e7cbe973", + "bundleSha256": "bb120dc28840e45c9eba8fe488665428a33a544b3474318e24232734352cf033", + "rootExited": true, + "reusedJobId": "97a9558b-b993-4f75-9265-acd73fe8f38b" + } + ], + "steps": [ + "manifest hashes", + "bundled Node launch", + "same-service reuse", + "packaged example and static page", + "explicit command consent", + "actual bundled Node version", + "actual bundled npm check without system Node/npm", + "check log artifact", + "contained REA installation and Node identity", + "actual ASAR/imports/resources", + "original Bundle and target hash binding", + "verified reuse without producer replay", + "report availability", + "graceful stop" + ], + "realModel": false +} \ No newline at end of file diff --git a/docs/rea-engine-source-initial-failure.json b/docs/rea-engine-source-initial-failure.json new file mode 100644 index 00000000..eb97f033 --- /dev/null +++ b/docs/rea-engine-source-initial-failure.json @@ -0,0 +1,7 @@ +{ + "success": false, + "version": "1.8.0", + "stage": "contained REA", + "error": "contained REA failed (1): {\"success\":false,\"version\":\"1.8.0\",\"directory\":\"D:\\\\Ai-project\\\\REA逆向\\\\Agent-Workbench\\\\.qa\\\\source-check-66bd9e1748c0461e9915f2e137b15108\\\\Agent-Workbench-1.8.0-source-20261029212137336\\\\.qa\\\\rea-integration-f0fafe45-5261-448a-9b33-0bb58aae976c\",\"results\":[],\"error\":\"AssertionError [ERR_ASSERTION]: REA没有返回原完整Evidence;原响应已保留。\\n+ actual - expected\\n\\n+ 'unverified'\\n- 'completed'\\n\\n at file:///D:/Ai-project/REA%E9%80%86%E5%90%91/Agent-Workbench/.qa/source-check-66bd9e1748c0461e9915f2e137b15108/Agent-Workbench-1.8.0-source-20261029212137336/scripts/verify-rea.mjs:27:12\\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\"}\n", + "sourceRoot": "D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\source-check-66bd9e1748c0461e9915f2e137b15108\\Agent-Workbench-1.8.0-source-20261029212137336" +} \ No newline at end of file diff --git a/licenses/REA-6.8.0-LICENSE.txt b/licenses/REA-6.8.0-LICENSE.txt new file mode 100644 index 00000000..2d476d24 --- /dev/null +++ b/licenses/REA-6.8.0-LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 morluto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/progress.md b/progress.md index 24140e99..e9b2e76a 100644 --- a/progress.md +++ b/progress.md @@ -242,3 +242,13 @@ - 首轮完整源码243项242通过/1失败,原完整TAP与输入散列保留于.qa/tests-1.8.0-68f4eb98-fd4e-4e46-b227-12917f7448ef。唯一失败为upgrade-running未把升级后的1.8.0列入再次升级支持范围;先修正版本契约并针对复验,最终独立源码另行全量验证。界面首六类54组已通过,context额外8组后因resize异步收起项目栏超时;原报告保留docs/rea-engine-all-ui-initial-failure.json,验证器显式等待窄屏栏位收起再选择,保留已通过结果并接续未完成五类。 - 重复升级/原内存连接/工程检查专项1/1通过,十一类98组界面最终通过且0页面/请求异常。首六类原结果/日志保留,只接续失败和未跑五类;runtime/UI/test输入仍与冻结回归一致,升级和UI验证脚本改动分别记录。三份桌面/390px截图已目视核对并保存;准备不可变1.8包和最终独立源码243项回归。 + +## 2026-10-30 全量开发再次接续 + +- 恢复到6a1ef12:1.8.0不可变发行20261029212137336已生成,正式4318实测仍为1.7.0/PID23080。只接续未完成的源码、归档、便携与升级验收,不重跑已封存的98组界面。 +- 保留未提交的REA许可证与第三方告知;发行脚本已经在便携及源码中保留相同原许可证。先核对完整归档并解压独立源码,使用独立QA Python运行最终243项回归。 +- 沿用planning-with-files开发记录;session-catchup无额外输出。后续核心切片优先将已研究的外部Harness契约变成真实可验证的内置适配,具体范围在1.8发行验收后核对。 + +- 首轮独立源码离线安装及6份构建对照通过,但实际REA导出失败,完整243项尚未运行。原export返回“Evidence output directory does not exist”,该目录实测存在、长度251字符,完整导出路径超过300字符;原响应、传输、根进程正常退出及失败源码保留。先补Windows深数据目录回归,再限定所属REA临时输出路径,不修改原REA包或忽略证据校验。 + +- 深目录回归修复前失败;修复后首轮16/17,新增测试最后用量断言引用session而非f.session,校正后17/17与构建通过。原深解压目录使用包内REA的三项实际分析、原Evidence、复用和根进程退出全部通过;最终244项源码验收将使用新不可变包,原失败和旧包保留。 diff --git a/src/core/research-manager.mjs b/src/core/research-manager.mjs index 176f7112..a5f7be08 100644 --- a/src/core/research-manager.mjs +++ b/src/core/research-manager.mjs @@ -1,10 +1,10 @@ -import fs from 'node:fs'; import path from 'node:path'; import { createHash, randomUUID } from 'node:crypto'; import { ReaAdapter, REA_OPERATIONS, resolveReaInstallation } from './tools/rea-adapter.mjs'; import { RESEARCH_ACTIVE, researchError, researchFileIdentity, researchTargetContract, bindReaEvidence, researchPointer, sealResearchDocument, readResearchDocument } from '../shared/contracts/research.mjs'; import { artifactPage } from './context/read-budget.mjs'; +import { createResearchOutputDirectory } from './tools/research-output.mjs'; const at = () => new Date().toISOString(); const sha = text => createHash('sha256').update(text, 'utf8').digest('hex'); @@ -101,9 +101,8 @@ export class ResearchManager { for (const key of ['evidence', 'bundle', 'raw', 'contractArtifactId', 'contractSha256', 'evidenceId', 'evidenceBinding', 'installation']) job[key] = structuredClone(reusable[key]); job.reusedFromJobId = reusable.id; job.after = job.before; job.summary = '已复用原完整Evidence,登记工件SHA256仍一致;没有再次调用REA。'; } else { - const scratchRoot = path.join(this.store.directory, 'research-operations'); fs.mkdirSync(scratchRoot, { recursive: true }); - if (fs.lstatSync(scratchRoot).isSymbolicLink()) throw researchError('研究执行目录不能是链接。'); - const scratch = path.join(scratchRoot, job.id); fs.mkdirSync(scratch); job.outputDirectory = scratch; + const output = createResearchOutputDirectory(this.store.directory, job.id); + const scratch = output.path; job.outputDirectory = scratch; job.outputScope = output.scope; adapter = this.adapterFactory(job.installation, { cwd: scratch, timeoutMs: this.timeoutMs, onClient: client => { active.client = client; job.connection = { id: client.id, pid: client.pid ?? null, startedAt: client.startedAt }; this.store.save(session, { type: 'research.connection_owned', detail: { jobId: job.id } }); } }); phase('connecting', '正在核对REA握手和实际工具契约。'); diff --git a/src/core/tools/research-output.mjs b/src/core/tools/research-output.mjs new file mode 100644 index 00000000..89ae2ed3 --- /dev/null +++ b/src/core/tools/research-output.mjs @@ -0,0 +1,26 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import os from 'node:os'; +import { researchError } from '../../shared/contracts/research.mjs'; + +// REA's export guard also runs at its external filesystem boundary. Keep a +// bounded ordinary Windows path even when the session's durable data is deep. +// The original output stays in this owned directory; durable Evidence is sealed +// into the session's artifact store and never depends on replaying the producer. +export function createResearchOutputDirectory(directory, jobId) { + if (!/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(jobId)) throw researchError('研究执行目录身份无效。'); + const fits = root => process.platform !== 'win32' + || Buffer.byteLength(path.join(root, jobId, 'evidence-' + 'a'.repeat(36) + '.json'), 'utf8') <= 240; + let root = path.join(fs.realpathSync.native(directory), 'research-operations'), location = 'session-data'; + if (!fits(root)) { + root = path.join(fs.realpathSync.native(os.tmpdir()), 'AgentWorkbench-REA'); location = 'host-temporary'; + } + if (!fits(root)) throw researchError('当前Windows临时路径仍超过REA导出范围,尚未启动分析。请选择较短的TEMP目录后重新准备。'); + fs.mkdirSync(root, { recursive: true, mode: 0o700 }); + if (fs.lstatSync(root).isSymbolicLink()) throw researchError('研究执行目录不能是链接。'); + root = fs.realpathSync.native(root); + if (!fits(root)) throw researchError('研究执行目录的实际路径超过REA导出范围,尚未启动分析。'); + const output = path.join(root, jobId); + fs.mkdirSync(output, { mode: 0o700 }); + return { path: output, scope: { location, root, ownership: 'one-research-job', retained: true } }; +} diff --git a/tests/research.test.mjs b/tests/research.test.mjs index d4b1d317..cc8ad270 100644 --- a/tests/research.test.mjs +++ b/tests/research.test.mjs @@ -12,8 +12,14 @@ import { Provider } from '../src/server/provider.mjs'; import { fixture, until, compatibleFixture, completion, call, assertToolPairs } from './helpers.mjs'; const digest = text => createHash('sha256').update(text).digest('hex'); -function researchFixture(t, behavior = null) { - const f = fixture(t), file = path.join(f.root, '用户登记工件.asar'); fs.writeFileSync(file, 'Owned research fixture bytes.'); +function researchFixture(t, behavior = null, { deepStore = false } = {}) { + let f = fixture(t); + if (deepStore) { + const data = path.join(f.root, ...Array.from({ length: 4 }, (_, index) => '用户深层数据目录-' + index + '-'.repeat(28)), 'data'); + const store = new Store(data), project = store.addProject(f.projectRoot), session = store.createSession(project.id); + f.onCleanup(() => store.close()); f = { ...f, data, store, project, session }; + } + const file = path.join(f.root, '用户登记工件.asar'); fs.writeFileSync(file, 'Owned research fixture bytes.'); const calls = { connect: 0, analyze: 0, close: 0 }, installation = { status: 'available', version: '6.8.0', protocolVersion: '2025-03-26', fixture: true }; const makeEvidence = (target, operation) => ({ evidence_id: 'ev_' + digest(target.sha256 + operation), operation: REA_OPERATIONS[operation].name, subject: { digest: { sha256: target.sha256 } }, authority: 'static-observation', confidence: 1, limitations: ['Fixture static candidates; execution is not observed.'], @@ -35,6 +41,24 @@ function researchFixture(t, behavior = null) { return { ...f, file, manager, calls, installation }; } +test('deep Windows data directories keep REA output within the external path allowance and retain owned evidence', async t => { + const f = researchFixture(t, null, { deepStore: true }), before = fs.readFileSync(path.join(f.projectRoot, 'README.md')); + const target = await f.manager.register(f.session, { path: f.file }); + const { job, promise } = f.manager.start(f.session, target.id, 'javascript'); await promise; + assert.equal(job.status, 'completed', job.summary); assert.equal(f.calls.analyze, 1); + if (process.platform === 'win32') { + assert.ok(Buffer.byteLength(path.join(job.outputDirectory, 'evidence-' + 'a'.repeat(36) + '.json'), 'utf8') <= 240, + 'Existing deep data directories must not become an overlong REA export path.'); + assert.equal(job.outputScope.location, 'host-temporary'); + const output = fs.realpathSync.native(job.outputDirectory), root = fs.realpathSync.native(job.outputScope.root); + assert.equal(path.dirname(output), root); assert.equal(path.basename(output), job.id); + f.onCleanup(() => { assert.equal(path.dirname(fs.realpathSync.native(output)), root); assert.equal(path.basename(output), job.id); fs.rmSync(output, { recursive: true, force: true }); }); + } + assert.deepEqual(fs.readFileSync(path.join(f.projectRoot, 'README.md')), before); + const evidence = f.manager.verifiedEvidence(f.session, job); assert.equal(evidence.subject.digest.sha256, target.sha256); + assert.equal(f.store.core.task.get(f.session.taskId).usage.requests, 0); +}); + test('user research registration creates an owned Task without model requests and seals the exact artifact identity', async t => { const f = researchFixture(t), owner = fs.readFileSync(path.join(f.projectRoot, 'README.md')); await assert.rejects(f.manager.register(f.session, { path: 'relative.asar' }), /绝对路径/);