feat: pin controlled Harness profile and verify owned tool and model bridge

This commit is contained in:
Agent Workbench Dev
2026-10-31 04:25:44 +08:00
parent 60b63bc70f
commit a01c41811b
14 changed files with 1928 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# 1.14 受控外部引擎验收
2026-10-31,接续60b63bc/正式1.13.0。本阶段按PLAN-1.14开发,当前尚未完成完整发行或正式升级;本地模型夹具、实际工具链、真实模型推理分别判定。
## A:固定版本与协议
受控适配器锁定已有Harness 0.2.1-rc.2、sdk-minimal、原SDK/CLI/Node及七份工具/代理/LLM/Include关键运行器。每个Run生成独立home、agents、叠加插件和JSON patch;禁用原生文件、工作目录工具、持久终端、原生模型与重试插件,实际appReady后再次核对完整工具schema、唯一代理provider、所属PID/nonce/SDK session/Run和工作目录。
原SDK不提供单会话取消或反向审批。受控桥通过独立本地HTTP返回工具/模型请求,原SDK仍使用initialize、session/prompt、session/wait与shutdown;收据必须在所属agent/inbox/spliced原事件中出现,输出来自同一活动的assistant/message,不能用idle或回复文字判工程交付。停止/恢复与真实工程的完整接入仍由后续切片验收。
首轮7/7专项通过:关键运行器变化、Include patch、完整目录与重复schema、进程/Run/SDK身份及Origin/认证、重复/越界/格式错误/来源变化、模型目录/输出预算和停止/超长正文守卫。原TAP为controlled-engine-core-first.tap。
实际Harness加本地固定模型夹具通过:完整启动目录核对、两次代理模型请求、一次原工具调用、prompt入队收据、所属原活动输出与正常退出;0真实模型请求、0stderr。原输入/协议/通知/桥数据与退出保存在controlled-engine-native-first.json及对应-log.txt。本轮只读取独立夹具README,没有开放用户工程或现有真实连接。
## 尚待验收
B:受限桥与自有Task/Run审批/账本接入;C:独立工程、累计预算、进程树和父审查;D:恢复/桌面/390px;E:Purge来源/兼容/同题对照;F:完整回归、独立发行及保留状态升级。正式4318继续使用不可变1.13.0。
+15
View File
@@ -0,0 +1,15 @@
# 1.14 阶段回顾
2026-10-31。每个切片按计划、实现、原证据、限制和本地Git回顾;此文随实际结果更新,阶段尚未完整交付。
| 切片 | 当前实现/验证 | 遗留与下一步 |
| --- | --- | --- |
| A:版本/协议 | 新受控安装身份、七份关键运行器、独立profile叠加/桥;7/7边界专项和实际Harness固定模型2请求/1工具/收据/wait/正常退出通过 | 原SDK没有单会话取消或反向审批;桥不能单凭启动成功宣称工程交付 |
| B:工具桥 | 原生项目/终端/模型/重试插件禁用,appReady核对完整工具schema;原进程/Run/SDK/来源、输入上限和重复ID守卫 | 接入自有执行账本、文件审查及固定检查,保持原工具身份和未知状态 |
| C–F | 尚未完成 | 独立工程/停止恢复/父审查、真实界面、Purge同题对照、完整发行与状态保持升级 |
前置研究确认sdk-minimal仍含danger-full-access策略和本机工具,不能把profile名字当权限边界;采用宿主受限桥和实际目录检查。Harness现有DeepSeek provider使用Messages API,本工作台现有连接是兼容Chat层;自有代理provider保持两层分离,使引擎不取得模型Key,也不把一种协议冒充另一种协议。
查询期间过宽文件枚举、几处推测的不存在路径、一次PowerShell foreach直连管道解析失败已保存计划/发现并修正为已确认文件、明确变量结果;这些查询不当作功能失败或验收结果。首轮实际协议与本地专项成功原记录保留,后续实现变化采用新的结果目录。
正式服务/原模型连接保持,真实模型推理和Purge收益仍按用户既有决定暂缓。每个已完成切片检查diff后本地提交,不把计划或夹具成功登记为整个产品完成。
+52
View File
@@ -0,0 +1,52 @@
TAP version 13
# Subtest: controlled installation pins the native kernel and bridge independently of the existing connection-probe identity
ok 1 - controlled installation pins the native kernel and bridge independently of the existing connection-probe identity
---
duration_ms: 881.612
type: 'test'
...
# Subtest: controlled profiles disable every native project/terminal provider and native model/retry route using the actual include patch contract
ok 2 - controlled profiles disable every native project/terminal provider and native model/retry route using the actual include patch contract
---
duration_ms: 0.5845
type: 'test'
...
# Subtest: owned tool catalogues seal full schemas canonically and reject duplicate or malformed declarations
ok 3 - owned tool catalogues seal full schemas canonically and reject duplicate or malformed declarations
---
duration_ms: 5.3258
type: 'test'
...
# Subtest: bridge authentication, current Run, process, SDK session and browser-origin checks reject before dispatch
ok 4 - bridge authentication, current Run, process, SDK session and browser-origin checks reject before dispatch
---
duration_ms: 756.6592
type: 'test'
...
# Subtest: bridge duplicates, unknown tools, malformed arguments and source changes are refused before a second side effect
ok 5 - bridge duplicates, unknown tools, malformed arguments and source changes are refused before a second side effect
---
duration_ms: 685.1501
type: 'test'
...
# Subtest: bridge model requests bind the exact catalogue, route and output bound and preserve raw request/result identity
ok 6 - bridge model requests bind the exact catalogue, route and output bound and preserve raw request/result identity
---
duration_ms: 655.7846
type: 'test'
...
# Subtest: stopped and oversized bridge requests never reach a local model or tool callback
ok 7 - stopped and oversized bridge requests never reach a local model or tool callback
---
duration_ms: 649.3997
type: 'test'
...
1..7
# tests 7
# suites 0
# pass 7
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 3727.1463
@@ -0,0 +1,4 @@
STATE starting
STATE initializing
STATE ready
{"success":true,"root":"D:\\Ai-project\\REA逆向\\Agent-Workbench\\.qa\\controlled-native-01e1d8d0-f51a-4799-9d81-3e591267ea11","modelCalls":2,"toolCalls":1,"realModelRequests":0,"status":"closed","error":null,"stderr":""}
@@ -0,0 +1,39 @@
import fs from 'node:fs';
import path from 'node:path';
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
import { resolveControlledInstallation } from '../src/core/engines/controlled-installation.mjs';
import { ControlledDeepSeekSession } from '../src/core/engines/controlled-session.mjs';
const root = path.resolve('.qa/controlled-native-' + randomUUID()), cwd = path.join(root, 'project');
fs.mkdirSync(cwd, { recursive: true }); fs.writeFileSync(path.join(cwd, 'README.md'), '# Owned controlled SDK fixture\n');
const owner = Object.fromEntries(['sessionId', 'projectId', 'taskId', 'runId', 'jobId'].map(key => [key, randomUUID()]));
const installation = resolveControlledInstallation(process.cwd(), process.env.AGENT_WORKBENCH_DEEPSEEK_ROOT);
assert.equal(installation.controlledStatus, 'available', installation.message);
const controller = new AbortController(), timeout = setTimeout(() => controller.abort(new Error('Owned fixture deadline.')), 30000);
const driver = new ControlledDeepSeekSession(installation, { timeoutMs: 10000 }); let success = false, failure = null, modelCalls = 0, toolCalls = 0;
try {
await driver.open({ directory: path.join(root, 'runtime'), cwd, owner, sdkSessionId: randomUUID(), signal: controller.signal,
tools: [{ name: 'read_file', description: 'Read one owned fixture file.', parameters: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] } }],
config: { model: 'fixture-controlled', maxOutputTokens: 512, contextLimit: 32000, maxRunDurationMs: 30000 },
onModel: async input => {
modelCalls++;
assert.equal(input.model, 'fixture-controlled');
return { message: { role: 'assistant', content: modelCalls === 1 ? '' : 'Owned fixture inspected.', ...(modelCalls === 1 ? {
tool_calls: [{ id: 'controlled-read-1', type: 'function', function: { name: 'read_file', arguments: JSON.stringify({ path: 'README.md' }) } }],
} : {}) }, usage: { prompt_tokens: 30, completion_tokens: 8, total_tokens: 38 } };
},
onTool: async input => { toolCalls++; assert.equal(input.name, 'read_file'); assert.equal(input.arguments.path, 'README.md'); return { text: fs.readFileSync(path.join(cwd, input.arguments.path), 'utf8') }; },
onState: state => console.log('STATE ' + state),
});
await driver.prompt('Read README.md with the owned tool and report completion.');
assert.equal(await driver.wait(), 'Owned fixture inspected.'); assert.equal(modelCalls, 2); assert.equal(toolCalls, 1);
success = true;
} catch (error) { failure = { name: error.name, message: error.message, stack: error.stack }; }
finally {
const report = await driver.close({ force: !success }); clearTimeout(timeout);
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify({ success, scope: 'actual-harness-scripted-model-controlled-bridge', installation,
owner, modelCalls, toolCalls, realModelRequests: 0, failure, report }, null, 2));
fs.writeFileSync('.qa/controlled-native-first-location.json', JSON.stringify({ root, result: path.join(root, 'result.json') }));
console.log(JSON.stringify({ success, root, modelCalls, toolCalls, realModelRequests: 0, status: report.status, error: failure?.message ?? null, stderr: report.stderr?.slice(-3000) }));
assert.equal(success, true, failure?.message); assert.equal(report.status, 'closed'); assert.equal(report.cleanup.rootExited, true);
}
File diff suppressed because it is too large Load Diff