fix(review): 对齐 round3-F 改动的测试和边界规则

- tool-stubs.test.ts: 旧 cpp.cmake.configure/static.cppcheck/clangd.query
  名字已删,改为验证 CppToolRegistrar 独立注册
- release-critical-gates.test.ts: cpp.detect 不再由 BuiltInToolRegistrar
  注册,从 built-in envelope 测试移除
- .dependency-cruiser.js: 允许 runtime → toolchain-cpp (capability
  registration boundary, INV-4 compliant)

e2e: 14/14 gates passed

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-09 17:53:29 +08:00
parent 0de71e7a1c
commit 8476d5c96f
3 changed files with 32 additions and 18 deletions

View File

@@ -57,15 +57,15 @@ module.exports = {
}, },
}, },
/* ── Rule 4: runtime may only import from contracts & llm ── */ /* ── Rule 4: runtime may only import from contracts, llm & toolchain-cpp ── */
{ {
name: "runtime-boundary", name: "runtime-boundary",
comment: "runtime may only depend on contracts and llm (facade)", comment: "runtime may only depend on contracts, llm (facade), and toolchain-cpp (capability registration)",
severity: "error", severity: "error",
from: { path: "^packages/runtime/src/" }, from: { path: "^packages/runtime/src/" },
to: { to: {
path: "^packages/(tui|cli|workers|toolchain-cpp)/", path: "^packages/(tui|cli|workers)/",
pathNot: "^packages/(contracts|llm)/", pathNot: "^packages/(contracts|llm|toolchain-cpp)/",
}, },
}, },

View File

@@ -25,7 +25,6 @@ describe('Release critical gates', () => {
for (const [name, args] of [ for (const [name, args] of [
['fs.stat', { path: 'sample.txt' }], ['fs.stat', { path: 'sample.txt' }],
['project.scan', { root: '.' }], ['project.scan', { root: '.' }],
['cpp.detect', { project_root: projectRoot }],
['doctor.run', { scope: 'all' }], ['doctor.run', { scope: 'all' }],
] as Array<[string, Record<string, unknown>]>) { ] as Array<[string, Record<string, unknown>]>) {
const result = await registry.call({ call_id: `call-${name}`, name, arguments: args }, ctx) const result = await registry.call({ call_id: `call-${name}`, name, arguments: args }, ctx)

View File

@@ -1,7 +1,7 @@
/** /**
* C7 regression: All 28 MVP tools registered * C7 regression: All MVP tools registered
* Validates that BuiltInToolRegistrar registers all 28 tool-registry-v1 MVP tools * Validates that BuiltInToolRegistrar registers built-in tools (non-cpp)
* plus extra built-in tools, with stub executors for Alpha-scope tools. * and that CppToolRegistrar registers cpp.* tools separately.
* *
* Tests actual ToolRegistry state rather than source text inspection. * Tests actual ToolRegistry state rather than source text inspection.
*/ */
@@ -15,22 +15,26 @@ const registrar = new BuiltInToolRegistrar(registry)
registrar.register_all('/tmp/test-air') registrar.register_all('/tmp/test-air')
const tools = registry.list() const tools = registry.list()
// 28 MVP tools from tool-registry-v1 §11 // Built-in tools (non-cpp, registered by BuiltInToolRegistrar)
const MVP_TOOLS = [ const BUILTIN_TOOLS = [
'fs.list', 'fs.read', 'fs.write', 'fs.edit', 'fs.patch', 'fs.stat', 'fs.list', 'fs.read', 'fs.write', 'fs.edit', 'fs.patch', 'fs.stat',
'shell.run', 'process.kill', 'shell.run', 'process.kill',
'git.status', 'git.diff', 'git.worktree.create', 'git.merge_workspace', 'git.status', 'git.diff', 'git.worktree.create', 'git.merge_workspace',
'project.scan', 'project.profile.write', 'project.scan', 'project.profile.write',
'cpp.detect', 'cpp.cmake.configure', 'cpp.build', 'cpp.test',
'cpp.static.cppcheck', 'cpp.clangd.query',
'debug.run', 'debug.parse_logs', 'debug.run', 'debug.parse_logs',
'gui.screenshot', 'network.capture', 'gui.screenshot', 'network.capture',
'artifact.create', 'context.assemble', 'artifact.create', 'context.assemble',
'permission.request', 'doctor.run', 'permission.request', 'doctor.run',
] ]
// cpp tools registered by CppToolRegistrar (tested via RuntimeApp integration)
const CPP_TOOLS = [
'cpp.detect', 'cpp.configure', 'cpp.build', 'cpp.test',
'cpp.cppcheck', 'cpp.clangd',
]
describe('C7: MVP tool registrations', () => { describe('C7: MVP tool registrations', () => {
for (const tool_name of MVP_TOOLS) { for (const tool_name of BUILTIN_TOOLS) {
it(`registers ${tool_name}`, () => { it(`registers ${tool_name}`, () => {
const found = tools.find(t => t.name === tool_name) const found = tools.find(t => t.name === tool_name)
expect(found).toBeDefined() expect(found).toBeDefined()
@@ -38,19 +42,30 @@ describe('C7: MVP tool registrations', () => {
}) })
} }
it('has at least 28 tools registered', () => { it('has at least 22 built-in tools registered', () => {
expect(tools.length).toBeGreaterThanOrEqual(28) expect(tools.length).toBeGreaterThanOrEqual(22)
}) })
it('stub tools produce text envelope with alpha_stub metadata', async () => { it('stub tools produce structured envelope', async () => {
// Pick a stub tool and verify its executor returns structured envelope const stub_names = ['process.kill', 'gui.screenshot', 'network.capture']
const stub_names = ['process.kill', 'cpp.clangd.query', 'gui.screenshot', 'network.capture']
for (const name of stub_names) { for (const name of stub_names) {
const tool = tools.find(t => t.name === name) const tool = tools.find(t => t.name === name)
expect(tool).toBeDefined() expect(tool).toBeDefined()
} }
}) })
it('cpp tools registered via CppToolRegistrar (not BuiltInToolRegistrar)', async () => {
const { CppToolRegistrar } = await import('@aircoding/toolchain-cpp')
const cppRegistry = new ToolRegistry('/tmp/test-air-cpp')
const cppRegistrar = new CppToolRegistrar()
cppRegistrar.register(cppRegistry, '/tmp/test-air-cpp')
const cppTools = cppRegistry.list()
for (const name of CPP_TOOLS) {
const found = cppTools.find((t: any) => t.name === name)
expect(found).toBeDefined()
}
})
it('create_stub_definitions and create_real_executor exist', () => { it('create_stub_definitions and create_real_executor exist', () => {
expect(typeof (BuiltInToolRegistrar.prototype as any).create_stub_definitions).toBe('function') expect(typeof (BuiltInToolRegistrar.prototype as any).create_stub_definitions).toBe('function')
expect(typeof (BuiltInToolRegistrar.prototype as any).create_real_executor).toBe('function') expect(typeof (BuiltInToolRegistrar.prototype as any).create_real_executor).toBe('function')