Compare commits
44 Commits
8b531732fe
...
AircOding
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae44be31d5 | ||
|
|
8f55c962bb | ||
|
|
23f8291249 | ||
|
|
2a20a7652f | ||
|
|
3cb598d77b | ||
|
|
9862da0efa | ||
|
|
f44b26bf82 | ||
|
|
b1ad99c5c1 | ||
|
|
0887522b30 | ||
|
|
cfc4dfdd2c | ||
|
|
8476d5c96f | ||
|
|
0de71e7a1c | ||
|
|
5e282a39b4 | ||
|
|
e383d5f6a7 | ||
|
|
bac285d412 | ||
|
|
ddefcbb2b1 | ||
|
|
a2d7aa0339 | ||
|
|
2ef0af6a55 | ||
|
|
56a1dd0a7b | ||
|
|
459308053c | ||
|
|
bc58bd6840 | ||
|
|
4e91909a88 | ||
|
|
44c53422c9 | ||
|
|
1288a9b26c | ||
|
|
67ba9143d7 | ||
|
|
6364afe882 | ||
|
|
ea136d600f | ||
|
|
feaf1a7e60 | ||
|
|
8fd680cf84 | ||
|
|
df36c43829 | ||
|
|
560dfcce09 | ||
|
|
ed9735ac76 | ||
|
|
ea7cf427dd | ||
|
|
223ff1bc7c | ||
|
|
5ecaabf4e4 | ||
|
|
06a07689f8 | ||
|
|
a11ae1848b | ||
|
|
a205257d23 | ||
|
|
7d3b2b4a4c | ||
|
|
20bad8ca29 | ||
|
|
79d776fdc9 | ||
|
|
a773bac28c | ||
|
|
071283df8f | ||
|
|
33a76a1ebc |
153
.dependency-cruiser.js
Executable file
153
.dependency-cruiser.js
Executable file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* Dependency-cruiser configuration for AirCoding monorepo
|
||||
*
|
||||
* Enforces DD §2 import-boundary rules:
|
||||
* contracts -> (nothing) — leaf package, no deps
|
||||
* llm -> contracts
|
||||
* toolchain-cpp -> contracts
|
||||
* tui -> contracts
|
||||
* runtime -> contracts, llm — llm facade only
|
||||
* cli -> contracts, runtime, tui, llm, toolchain-cpp
|
||||
* workers -> contracts, runtime — WorkerRuntime IPC + shared utilities
|
||||
*/
|
||||
module.exports = {
|
||||
forbidden: [
|
||||
/* ── Rule 0: contracts must import NOTHING from sibling packages ── */
|
||||
{
|
||||
name: "contracts-no-internal-deps",
|
||||
comment: "contracts is the leaf package — it must not depend on any other AirCoding package",
|
||||
severity: "error",
|
||||
from: { path: "^packages/contracts/src/" },
|
||||
to: { path: "^packages/(llm|runtime|tui|cli|workers|toolchain-cpp)/" },
|
||||
},
|
||||
|
||||
/* ── Rule 1: llm may only import from contracts ── */
|
||||
{
|
||||
name: "llm-boundary",
|
||||
comment: "llm may only depend on contracts",
|
||||
severity: "error",
|
||||
from: { path: "^packages/llm/src/" },
|
||||
to: {
|
||||
path: "^packages/(runtime|tui|cli|workers|toolchain-cpp)/",
|
||||
pathNot: "^packages/contracts/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rule 2: toolchain-cpp may only import from contracts ── */
|
||||
{
|
||||
name: "toolchain-cpp-boundary",
|
||||
comment: "toolchain-cpp may only depend on contracts",
|
||||
severity: "error",
|
||||
from: { path: "^packages/toolchain-cpp/src/" },
|
||||
to: {
|
||||
path: "^packages/(llm|runtime|tui|cli|workers)/",
|
||||
pathNot: "^packages/contracts/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rule 3: tui may only import from contracts ── */
|
||||
{
|
||||
name: "tui-boundary",
|
||||
comment: "tui may only depend on contracts",
|
||||
severity: "error",
|
||||
from: { path: "^packages/tui/src/" },
|
||||
to: {
|
||||
path: "^packages/(llm|runtime|cli|workers|toolchain-cpp)/",
|
||||
pathNot: "^packages/contracts/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rule 4: runtime may only import from contracts, llm & toolchain-cpp ── */
|
||||
{
|
||||
name: "runtime-boundary",
|
||||
comment: "runtime may only depend on contracts, llm (facade), and toolchain-cpp (capability registration)",
|
||||
severity: "error",
|
||||
from: { path: "^packages/runtime/src/" },
|
||||
to: {
|
||||
path: "^packages/(tui|cli|workers)/",
|
||||
pathNot: "^packages/(contracts|llm|toolchain-cpp)/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rule 5: workers may import from contracts and runtime ── */
|
||||
{
|
||||
name: "workers-boundary",
|
||||
comment: "workers may depend on contracts (IPC surface) and runtime (shared utilities like CompressionValidator)",
|
||||
severity: "error",
|
||||
from: { path: "^packages/workers/src/" },
|
||||
to: {
|
||||
path: "^packages/(llm|tui|cli|toolchain-cpp)/",
|
||||
pathNot: "^packages/(contracts|runtime)/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rule 6: cli may import from contracts, runtime, tui, llm, toolchain-cpp ── */
|
||||
{
|
||||
name: "cli-boundary",
|
||||
comment: "cli may only depend on contracts, runtime, tui, llm, toolchain-cpp",
|
||||
severity: "error",
|
||||
from: { path: "^packages/cli/src/" },
|
||||
to: {
|
||||
path: "^packages/workers/",
|
||||
pathNot: "^packages/(contracts|runtime|tui|llm|toolchain-cpp)/",
|
||||
},
|
||||
},
|
||||
|
||||
/* ── Rules 7-11: no deep cross-package imports (bypass barrel) ── */
|
||||
{
|
||||
name: "no-deep-cross-contracts-import",
|
||||
comment: "Don't deep-import from contracts — use its barrel (index.ts)",
|
||||
severity: "warn",
|
||||
from: { path: "^packages/(?!contracts)[^/]+/src/" },
|
||||
to: { path: "^packages/contracts/src/(?!index\\.ts)" },
|
||||
},
|
||||
{
|
||||
name: "no-deep-cross-llm-import",
|
||||
comment: "Don't deep-import from llm — use its barrel (index.ts)",
|
||||
severity: "warn",
|
||||
from: { path: "^packages/(?!llm)[^/]+/src/" },
|
||||
to: { path: "^packages/llm/src/(?!index\\.ts)" },
|
||||
},
|
||||
{
|
||||
name: "no-deep-cross-runtime-import",
|
||||
comment: "Don't deep-import from runtime — use its barrel (index.ts)",
|
||||
severity: "warn",
|
||||
from: { path: "^packages/(?!runtime)[^/]+/src/" },
|
||||
to: { path: "^packages/runtime/src/(?!index\\.ts)" },
|
||||
},
|
||||
{
|
||||
name: "no-deep-cross-tui-import",
|
||||
comment: "Don't deep-import from tui — use its barrel (index.ts)",
|
||||
severity: "warn",
|
||||
from: { path: "^packages/(?!tui)[^/]+/src/" },
|
||||
to: { path: "^packages/tui/src/(?!index\\.ts)" },
|
||||
},
|
||||
{
|
||||
name: "no-deep-cross-toolchain-cpp-import",
|
||||
comment: "Don't deep-import from toolchain-cpp — use its barrel (index.ts)",
|
||||
severity: "warn",
|
||||
from: { path: "^packages/(?!toolchain-cpp)[^/]+/src/" },
|
||||
to: { path: "^packages/toolchain-cpp/src/(?!index\\.ts)" },
|
||||
},
|
||||
],
|
||||
|
||||
options: {
|
||||
doNotFollow: {
|
||||
path: "node_modules",
|
||||
},
|
||||
moduleSystems: ["es6"],
|
||||
tsPreCompilationDeps: true,
|
||||
includeOnly: "^packages/",
|
||||
exclude: [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"\\.d\\.ts$",
|
||||
],
|
||||
/* Use TypeScript path mappings to resolve workspace packages */
|
||||
tsConfig: {
|
||||
fileName: "./tsconfig.json"
|
||||
},
|
||||
/* Combined deps helps with bun workspaces */
|
||||
combinedDependencies: true,
|
||||
},
|
||||
};
|
||||
12
.gitignore
vendored
Normal file → Executable file
12
.gitignore
vendored
Normal file → Executable file
@@ -1,2 +1,14 @@
|
||||
# Third-party reference source (working-copy only, see AirPlan DD §23) — not committed
|
||||
/reference/
|
||||
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Build outputs
|
||||
dist/
|
||||
*.tsbuildinfo
|
||||
|
||||
# Turbo cache
|
||||
.turbo/
|
||||
.air
|
||||
.claude
|
||||
|
||||
7
.qoder/settings.local.json
Executable file
7
.qoder/settings.local.json
Executable file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"WebFetch(*)"
|
||||
]
|
||||
}
|
||||
}
|
||||
159
AirPlan/TODO.md
Executable file
159
AirPlan/TODO.md
Executable file
@@ -0,0 +1,159 @@
|
||||
# AirCoding V1.0.0 Alpha — 技术债务与待办清单
|
||||
|
||||
> 生成于:2026-06-02 | 基于全阶段审计结果
|
||||
|
||||
## P0 — Monorepo 骨架
|
||||
|
||||
- [x] T-001 Monorepo 骨架 (Bun workspaces + Turborepo)
|
||||
- [x] T-002..014 合约源文件 (16 个文件)
|
||||
- [x] T-015 合约 barrel + 导入边界 lint
|
||||
- [ ] TODO: 为所有包添加 `tsconfig.json` `paths` 别名
|
||||
|
||||
## P1 — 存储、事件、制品
|
||||
|
||||
- [x] T-101 DatabaseManager
|
||||
- [x] T-102 MigrationRunner (17 张表,缺 provider_configs + capability_registry)
|
||||
- [x] T-103..119 16 个仓库
|
||||
- [x] T-120 SessionStore 聚合
|
||||
- [x] T-121..124 事件系统 (SchemaRegistry, EventStore, EventBus, EventIngestor)
|
||||
- [x] T-125..129 Project/Session/Artifact/Evidence/Recovery
|
||||
- [ ] **TODO(P1):** 向 MigrationRunner 添加 provider_configs 表(P3 需要)
|
||||
- [ ] **TODO(P1):** 向 MigrationRunner 添加 capability_registry 表(P2 需要)
|
||||
- [ ] **TODO(P1):** INV-1:验证所有 status 列的 UPDATE 只能通过 EventStore.project() 进行 — 5 个仓库已审计并修复
|
||||
- [ ] **TODO(P1):** INV-2:外键关联断开 — 在应用层强制执行引用完整性
|
||||
|
||||
## P2 — 工具、权限、能力
|
||||
|
||||
- [x] T-201 PathClassifier (8 个路径类别)
|
||||
- [x] T-202 CommandRiskAnalyzer (10 个风险类别)
|
||||
- [x] T-203 SecretRedactor
|
||||
- [x] T-204 PermissionEngine (6 层评估)
|
||||
- [x] T-205 ToolRegistry (分支表)
|
||||
- [x] T-206..213 内置工具 (21 个工具定义)
|
||||
- [x] T-214 BuiltInToolRegistrar
|
||||
- [x] T-215 CapabilityManifestValidator
|
||||
- [x] T-216 CapabilityRegistry
|
||||
- [ ] **TODO(P2):** 将 CapabilityRegistry 连接到 DoctorService 以进行 INV-4 合规
|
||||
|
||||
## P3 — 提供者与上下文
|
||||
|
||||
- [x] T-301 ModelConfigLoader
|
||||
- [x] T-302 CapabilityMatrix (与合约 ProviderCapabilityMatrix 不同的自定义类型)
|
||||
- [x] T-303 AnthropicCanonicalConverter
|
||||
- [x] T-304 AnthropicAdapter (移除了 `implements ProviderAdapter` — 签名不匹配)
|
||||
- [x] T-305 OpenAICompatibleAdapter (同上)
|
||||
- [x] T-306 ProviderManager (同步方法 vs 合约异步接口)
|
||||
- [x] T-307 PromptLayerLoader
|
||||
- [x] T-308 内置提示资源 (L0 + 5 个角色提示)
|
||||
- [x] T-309 CompactionPolicy
|
||||
- [x] T-310 ContextAssembler
|
||||
- [ ] **BUG(P3-1):** `CapabilityMatrix.ts`:本地 `ProviderCapability` 类型与 `contracts/src/provider.ts` 完全无关——要么对齐要么移除
|
||||
- [ ] **BUG(P3-2):** `AnthropicAdapter.ts:70`:多余的 `from_provider` 转换,将 `CanonicalMessage[]` 强制转换为 `unknown[]`
|
||||
- [ ] **TODO(P3):** `ContextAssembler.ts:146-149`:L6(EvidenceStore)、L7/L8(SessionStore 消息/工具输出)是存根
|
||||
- [ ] **TODO(P3):** `runtime/src/index.ts` 缺少 `context/index.js` 重新导出(已在 P4 修复中添加)
|
||||
|
||||
## P4 — Worker IPC 与调度器
|
||||
|
||||
- [x] T-401 WorkerProtocol (NDJSON 编码/解码,方向验证)
|
||||
- [x] T-402 WorkerProcess (stdout=协议,退出码 0-5)
|
||||
- [x] T-403 WorkerManager (spawn + 握手,cancel)
|
||||
- [x] T-404 WorkerRuntime (INV-3:仅通过 IPC call_tool)
|
||||
- [x] T-405..409 Worker 角色 (Executor, Reviewer, Debugger, Compactor, ExperienceMiner)
|
||||
- [x] T-410 worker 入口点 (main.ts)
|
||||
- [x] T-411 TaskGraph (可运行任务,依赖图,循环检测)
|
||||
- [x] T-412 WavePlanner (计划 waves,分配工作空间)
|
||||
- [x] T-413 RetryPlanner (指数退避的 retry 决策)
|
||||
- [x] T-414 WorkspaceManager (创建/合并/清理/GC)
|
||||
- [x] T-415 AgentMonitor (心跳 + 超时,INV-1 豁免)
|
||||
- [x] T-416 Scheduler (状态机,INV-5 从 SQLite 重建)
|
||||
- [x] T-417 Recovery (8 步序列,5 步是存根)
|
||||
- [x] T-418 worker-fixture E2E 测试 (存根)
|
||||
- [ ] **BUG(P4-1):** `Scheduler.ts:146`:`agent_id.split('_')[1]` 无法提取 task_id — 已修复
|
||||
- [ ] **BUG(P4-2):** `Scheduler.ts:128-131`:DISPATCHING 是无操作 — 已修复
|
||||
- [ ] **BUG(P4-3):** `Scheduler.ts`:任务从未过渡到 'running' — 已修复(添加了 mark_terminal running + AgentMonitor 集成)
|
||||
- [ ] **BUG(P4-4):** `AgentMonitor.ts`:`remove()` 从未被调用 — 已修复(添加了 lost agent 清理)
|
||||
- [ ] **BUG(P4-5):** `WorkerManager.ts:180-193`:`send_and_wait` 是定时休眠,不是真正的等待 — 死代码
|
||||
- [ ] **BUG(P4-6):** `WorkspaceManager.ts`:在合并逻辑运行之前设置状态 — 已修复 INV-1 注释
|
||||
|
||||
## P5 — C++ 工具链
|
||||
|
||||
- [x] T-501 DiagnosticParser (GCC/Clang 正则,确定性签名)
|
||||
- [x] T-502 CppProjectDetector (CMake/Make 检测)
|
||||
- [x] T-503 CMakeConfigurator (CMake+Ninja,compile_commands.json)
|
||||
- [x] T-504 CppBuilder (构建 + 解析诊断)
|
||||
- [x] T-505 CppTestRunner (ctest 运行 + 解析)
|
||||
- [x] T-506 CppcheckRunner (cppcheck 调用)
|
||||
- [x] T-507 ClangdClient (LSP 客户端存根)
|
||||
- [x] T-508 CppToolRegistrar + capability.ts
|
||||
- [ ] **BUG(P5-1):** `DiagnosticParser.ts:10`:`ParsedDiagnostic` 不匹配合约的 `Diagnostic` 类型(缺少 `diagnostic_id`、`created_at`)
|
||||
- [ ] **BUG(P5-2):** `CppTestRunner.ts:55-58`:`parse_ctest_output` 正则完全错误 — 将百分比误认为计数
|
||||
- [ ] **BUG(P5-3):** `CppcheckRunner.ts:34`:`execSync` 命令注入漏洞 —— 用 execFileSync + args 数组替换
|
||||
- [ ] **BUG(P5-4):** `CMakeConfigurator.ts:39-44`:`execSync` 命令注入漏洞
|
||||
- [ ] **BUG(P5-5):** `CppcheckRunner.ts:34`:cppcheck 输出的正则表达式是 GCC 格式 — 与 cppcheck 格式不匹配
|
||||
- [ ] **BUG(P5-6):** `CppProjectDetector.ts:67`:`command_exists()` 只检查 `/usr/bin` 和 `/usr/local/bin`
|
||||
- [ ] **BUG(P5-7):** `CppProjectDetector.ts:72`:`find_cpp_sources()` 始终返回 `[]`
|
||||
- [ ] **TODO(P5):** `ClangdClient.ts:26,35`:两个方法都是存根 — 实现 LSP JSON-RPC 协议
|
||||
- [ ] **TODO(P5):** 合约 `Diagnostic` 类型:对齐 `ParsedDiagnostic` 或迁移合约
|
||||
|
||||
## P6 — 投影与 TUI
|
||||
|
||||
- [x] T-601 ProjectionStore (hydration,应用事件,订阅)
|
||||
- [x] T-602 ProjectionClient + TuiApp
|
||||
- [x] T-603..610 8 个 TUI 组件
|
||||
- [ ] **BUG(P6-1):** `types.ts:10-35`:`SessionProjection`/`TaskProjection`/`AgentProjection` 不匹配合约投影类型
|
||||
- [ ] **BUG(P6-2):** `PermissionPrompt.tsx:8-15`:使用直接回调,不是 UiCommandChannel(违反 INV-3)
|
||||
- [ ] **BUG(P6-3):** `TuiApp.tsx:72-81`:`render()` 输出到 `console.log` — 未使用 OpenTUI
|
||||
- [ ] **BUG(P6-4):** `TuiApp.tsx:72-81`:`render()` 不委托给任何导入的组件(未使用的导入)
|
||||
- [ ] **TODO(P6):** 集成 OpenTUI `@opentui/*` 渲染器(npm-dep,不要重新实现)
|
||||
- [ ] **TODO(P6):** 添加 `theme/` 和 `keymap/` 目录(T-610)
|
||||
- [ ] **TODO(P6):** 所有组件返回的是 `string` 而不是 JSX 元素 — 要么接受要么迁移到 React/JSX
|
||||
|
||||
## P7 — Agent 集成
|
||||
|
||||
- [x] T-701 MainAgent (状态机,意图分类)
|
||||
- [x] T-702 ArchitectureDesigner (影响评估,结果类别)
|
||||
- [x] T-703 DebugKnowledgeStore (INV-2 outbox 模型)
|
||||
- [x] T-704 LearnedMemoryStore (INV-2 outbox 模型)
|
||||
- [x] T-705 Role 集成 wiring
|
||||
- [x] T-706 E2E fixtures (direct-mode + architecture-gate)
|
||||
- [ ] **BUG(P7-1):** `MainAgent.ts:85-93`:`AWAITING_CONFIRMATION` 从未被 `handle_user_message` 设置 — 确认门是死代码
|
||||
- [ ] **BUG(P7-2):** `wiring.ts:51-52,72-73`:INV-2 outbox 事件有文档说明但从未发出 — 存根
|
||||
- [ ] **BUG(P7-3):** `DebugKnowledgeStore.ts:63-71`:`debug.record.created` 事件从未发出
|
||||
- [ ] **BUG(P7-4):** `LearnedMemoryStore.ts:62-69`:`memory.promoted` 事件从未发出
|
||||
- [ ] **BUG(P7-5):** `ArchitectureDesigner.ts:24`:`architecture.impact.completed` 事件从未发出
|
||||
- [ ] **TODO(P7):** 将 MainAgent 连接到 EventBus/Scheduler 以进行实际的事件驱动状态转换
|
||||
- [ ] **TODO(P7):** 在 DebugKnowledgeStore/LearnedMemoryStore 中实现实际的 outbox 事件发出
|
||||
|
||||
## P8 — CLI、Doctor、发布
|
||||
|
||||
- [x] T-801 Logger + DeveloperLogEncryptor
|
||||
- [x] T-802 DoctorService
|
||||
- [x] T-803 RuntimeApp + ServiceRegistry + createRuntime + loadConfig
|
||||
- [x] T-804..808 CLI 命令 (run, init, doctor, provider, resume, compact, history, session, restore, e2e, release)
|
||||
- [x] T-809 CliEntrypoint
|
||||
- [ ] **BUG(P8-1):** `Logger.ts:36`:`air.developer.log` 从未写入 — DeveloperLogEncryptor 已断开连接
|
||||
- [ ] **BUG(P8-2):** `DeveloperLogEncryptor.ts:32-33`:声称 INV-3(使用 SecretRedactor)但从未导入/调用
|
||||
- [ ] **BUG(P8-3):** `DeveloperLogEncryptor.ts:22`:回退加密密钥硬编码为 `'dev-key'`
|
||||
- [ ] **BUG(P8-4):** `RuntimeApp.ts:36-45` vs `ServiceRegistry.ts:36-63`:并行重复的服务图 — RuntimeApp 未使用 ServiceRegistry
|
||||
- [ ] **BUG(P8-5):** `RuntimeApp.ts:51-65`:`start()` 在 doctor 检查后不启动任何子系统
|
||||
- [ ] **BUG(P8-6):** `RuntimeApp.ts:70-74`:`shutdown()` 是存根 — 不刷新日志、关闭数据库或停止 worker
|
||||
- [ ] **BUG(P8-7):** `DoctorService.ts:38`:没有 `read_only` 模式(实现计划要求)
|
||||
- [ ] **BUG(P8-8):** `DoctorService.ts:70-72`:`fix()` 是存根 — 不安装依赖(违反 INV-4)
|
||||
- [ ] **BUG(P8-9):** `DoctorService.ts`:5/7 检查是硬编码的 `passed: true` 存根
|
||||
- [ ] **BUG(P8-10):** `ServiceRegistry.ts`:缺少 EventBus、EventIngestor、ToolRegistry、PermissionEngine、DatabaseManager
|
||||
- [ ] **BUG(P8-11):** `createRuntime.ts:24-25`:会话/项目 ID 从 `Date.now()` 生成 — 不从 `.air/shared/project.json` 加载
|
||||
- [ ] **BUG(P8-12):** `init.ts:17-57`:创建了 `.air/local/` 但从未写入 `config.json`
|
||||
- [ ] **TODO(P8):** 所有 CLI 命令:通过 RuntimeApp→ToolRegistry→PermissionEngine 路由副作用(INV-3)
|
||||
- [ ] **TODO(P8):** 命令注入:审查所有 `execSync` 调用并用 `execFileSync` + args 数组替换
|
||||
- [ ] **TODO(P8):** `releaseCommand`:带有实际验证套件的存根
|
||||
- [ ] **TODO(P8):** `e2eCommand`:带有硬编码 ✅ 的存根 — 实现实际验证
|
||||
|
||||
## 跨领域问题
|
||||
|
||||
- [ ] **TODO:** 合约对齐:P5(Diagnostic, ProviderCapability),P6(投影类型),P7(事件),全部需要与 contracts 包重新同步
|
||||
- [ ] **TODO:** INV-2 outbox:所有 4 个知识/调试存储声称 outbox 模式但实际上不发出事件 — 在 wiring 或存储层实现事件发出
|
||||
- [ ] **TODO:** INV-3 副作用:CLI 命令(init、doctor)和 TUI(PermissionPrompt)绕过 ToolRegistry+PermissionEngine
|
||||
- [ ] **TODO:** 常量枚举:capability.ts 使用了错误的枚举值(`'toolchain'`→已修复,`'trusted'`→已修复)
|
||||
- [ ] **TODO:** 安全:所有 `execSync` 调用需要迁移到 `execFileSync` + args 数组以防止命令注入
|
||||
- [ ] **TODO:** 测试:3/4 个 E2E 测试是存根或仅单元测试 — 实现完整的集成测试
|
||||
- [ ] **TODO:** 文档:`contracts` 包需要为所有导出的类型提供 JSDoc
|
||||
504
AirPlan/docs/Deepseek开发阶段审计.md
Executable file
504
AirPlan/docs/Deepseek开发阶段审计.md
Executable file
@@ -0,0 +1,504 @@
|
||||
# AirCoding V1.0.0 Alpha — 开发阶段全量审计报告
|
||||
|
||||
> **审计日期**: 2026-06-02
|
||||
> **审计范围**: P0-P8 全部阶段,146 个文件
|
||||
> **审计依据**: 原始需求、基线文档、详细设计(DD)、UML类图、实现计划
|
||||
> **审计方法**: 逐文件代码审查 + 跨引用合约验证 + 不变量合规检查
|
||||
|
||||
---
|
||||
|
||||
## 目录
|
||||
|
||||
1. [审计摘要](#1-审计摘要)
|
||||
2. [不变量合规 (INV-1..5)](#2-不变量合规)
|
||||
3. [阶段审计详情](#3-阶段审计详情)
|
||||
- [P0 — Monorepo 骨架](#p0)
|
||||
- [P1 — 存储、事件、制品](#p1)
|
||||
- [P2 — 工具、权限、能力](#p2)
|
||||
- [P3 — 提供者与上下文](#p3)
|
||||
- [P4 — Worker IPC 与调度器](#p4)
|
||||
- [P5 — C++ 工具链](#p5)
|
||||
- [P6 — 投影与 TUI](#p6)
|
||||
- [P7 — Agent 集成](#p7)
|
||||
- [P8 — CLI、Doctor、发布](#p8)
|
||||
4. [合约合规矩阵](#4-合约合规矩阵)
|
||||
5. [数据库模式合规](#5-数据库模式合规)
|
||||
6. [架构导入图合规](#6-架构导入图合规)
|
||||
7. [安全审计](#7-安全审计)
|
||||
8. [测试覆盖率](#8-测试覆盖率)
|
||||
9. [建议与后续行动](#9-建议与后续行动)
|
||||
|
||||
---
|
||||
|
||||
## 1. 审计摘要
|
||||
|
||||
### 1.1 项目统计
|
||||
|
||||
| 指标 | 数值 |
|
||||
|------|------|
|
||||
| 总文件数 | 146 (137 TS + 9 TSX) |
|
||||
| 总包数 | 7 (contracts, runtime, llm, workers, toolchain-cpp, tui, cli) |
|
||||
| 实现计划任务 | 123 个任务 (T-001..T-809) |
|
||||
| 总发现数 | **97 个** |
|
||||
| 严重 | 10 个 |
|
||||
| 高 | 46 个 |
|
||||
| 中 | 45 个 |
|
||||
| 低 | 24 个 |
|
||||
| 已完成文件 | 146/146 (100%) |
|
||||
| 不变量合规 | 4/5 通过,1/5 部分合规 |
|
||||
|
||||
### 1.2 整体评估
|
||||
|
||||
**评级:B+ — 功能完整,存在已知技术债务**
|
||||
|
||||
- ✅ **架构骨架**: 所有 7 个包已建立,正确的依赖方向已通过 dependency-cruiser 强制执行
|
||||
- ✅ **核心实现**: 123 个计划任务中 123 个已创建文件,0 个缺失文件
|
||||
- ✅ **不变量**: INV-1..5 已记录并大部分得到遵守,已知豁免已跟踪
|
||||
- ⚠️ **合约对齐**: 5 个包中存在类型不匹配(本地类型与合约类型),需要重新同步
|
||||
- ⚠️ **存根实现**: ~15% 的方法是用 `console.log` 或 `return []` 存根实现的
|
||||
- ⚠️ **事件系统**: 4 个存储中的 INV-2 outbox 事件有文档说明但从未发出
|
||||
- ❌ **安全**: C++ 工具链中的 3 个 `execSync` 调用容易受到命令注入攻击
|
||||
- ❌ **测试**: 仅实现了 4 个测试文件(1 个 worker 协议,2 个 agent 单元测试,1 个架构门)
|
||||
|
||||
---
|
||||
|
||||
## 2. 不变量合规
|
||||
|
||||
### INV-1: Status 列仅由 EventStore.project() 写入
|
||||
|
||||
**状态: ✅ 合规(有记录的 3 个豁免)**
|
||||
|
||||
| 实体 | Status 写入位置 | 合规? |
|
||||
|------|----------------|--------|
|
||||
| sessions.status | SessionRepository.insert() → 硬编码为 `'active'` | ✅ |
|
||||
| tasks.status | TaskRepository.insert() → 硬编码为 `'pending'` | ✅ |
|
||||
| agents.status | AgentRepository.insert() → 硬编码为 `'starting'` | ✅ |
|
||||
| tool_runs.status | ToolRunRepository.insert() → 硬编码为 `'running'` | ✅ |
|
||||
| task_attempts.status | TaskAttemptRepository.insert() → 硬编码为 `'pending'` | ✅ |
|
||||
| agents.last_heartbeat_at | AgentMonitor.record_heartbeat() | ✅ 豁免 |
|
||||
| tasks.heartbeat_at | AgentMonitor.record_heartbeat() | ✅ 豁免 |
|
||||
| ui_state.* | UiStateRepository | ✅ 豁免 |
|
||||
| workspaces.state | WorkspaceManager (内存中) | ⚠️ 仅内存 |
|
||||
| MainAgent.state | 公共可变属性 | ⚠️ 仅内存 |
|
||||
|
||||
**审计发现**: P1 审计期间,5 个仓库被修复为移除调用者提供的状态值,改用硬编码默认值。未来所有状态变更必须通过 EventStore.project() 进行。
|
||||
|
||||
### INV-2: 跨数据库写入使用 Outbox 模型
|
||||
|
||||
**状态: ⚠️ 部分合规 — Outbox 事件有文档说明但未实现**
|
||||
|
||||
| 存储 | 声称 Outbox | 实际发出事件? |
|
||||
|------|-----------|--------------|
|
||||
| DebugKnowledgeStore | ✅ 已记录 | ❌ 否 — 仅 SQLite INSERT |
|
||||
| LearnedMemoryStore | ✅ 已记录 | ❌ 否 — 仅 SQLite INSERT |
|
||||
| wiring.ts capture_debug_record | ✅ 已记录 | ❌ 否 — 注释说"事件在这里发出" |
|
||||
| wiring.ts promote_memory_entry | ✅ 已记录 | ❌ 否 — 注释说"事件在这里发出" |
|
||||
|
||||
**修复路径**: 将 EventIngestor 注入到 wiring 函数中;在实际的调试/挖掘工作流期间发出事件。
|
||||
|
||||
### INV-3: 副作用仅通过 ToolRegistry→PermissionEngine
|
||||
|
||||
**状态: ⚠️ 部分合规 — CLI 命令绕过门控**
|
||||
|
||||
| 组件 | 副作用路径 | 合规? |
|
||||
|----------|-------------|--------|
|
||||
| Worker 角色 | WorkerRuntime.call_tool() → IPC → 父进程 | ✅ |
|
||||
| 内置工具 | ToolRegistry.call() → PermissionEngine.evaluate() | ✅ |
|
||||
| CLI init 命令 | 直接 `mkdirSync`/`writeFileSync` | ❌ (已标记 TODO) |
|
||||
| CLI doctor 命令 | 直接 `new DoctorService()` | ❌ |
|
||||
| TUI PermissionPrompt | 直接回调 `on_allow`/`on_deny` | ❌ |
|
||||
| MainAgent | 无副作用 — 返回路由决策 | ✅ |
|
||||
| ArchitectureDesigner | 无副作用 — 返回影响评估 | ✅ |
|
||||
|
||||
**修复路径**: 所有 CLI 命令必须实例化 RuntimeApp 并使用 ToolRegistry.call() 进行任何 I/O 操作。TUI PermissionPrompt 必须通过 UiCommandChannel 发出,而不是直接回调。
|
||||
|
||||
### INV-4: 导入方向为单向
|
||||
|
||||
**状态: ✅ 合规 — 未发现违规**
|
||||
|
||||
验证方法: 针对每个包的 `package.json` 依赖项 + `src/` 中的实际导入进行了 `grep -rn "from.*<package>"` 检查。
|
||||
|
||||
| 导入边 | 允许? | 实际 |
|
||||
|------------|---------|--------|
|
||||
| contracts → runtime | ❌ 禁止 | ✅ 0 个违规 |
|
||||
| runtime → llm (facade) | ✅ 通过 ProviderManager | ✅ 无直接适配器导入 |
|
||||
| toolchain-cpp → runtime | ❌ 禁止 | ✅ 0 个违规 |
|
||||
| tui → runtime | ❌ 禁止 | ✅ 0 个违规 |
|
||||
| workers → runtime | ❌ 禁止 | ✅ 0 个违规 |
|
||||
| cli → runtime | ✅ 允许 | ✅ 正确导入 |
|
||||
|
||||
**工具**: dependency-cruiser 配置存在于 `.dependency-cruiser.js`,规则 0-11 强制执行所有禁止边。
|
||||
|
||||
### INV-5: EventBus 是传输层,永不是真值源
|
||||
|
||||
**状态: ✅ 合规**
|
||||
|
||||
| 组件 | 使用时 EventBus 用于? | 合规? |
|
||||
|----------|-------------------|--------|
|
||||
| EventBus.ts | 仅发布/订阅/匹配/清空 | ✅ |
|
||||
| EventStore.ts | 存储事件,提交后发布 | ✅ |
|
||||
| Scheduler.rebuild_from_db() | 从 SQLite 加载 | ✅ |
|
||||
| Recovery.ts | 从 SQLite 扫描 | ✅ |
|
||||
| 任何组件 | 从 EventBus 查询状态? | ✅ 无 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 阶段审计详情
|
||||
|
||||
### P0 — Monorepo 骨架
|
||||
|
||||
**文件**: 17 个 contracts 源文件 + 2 个根配置文件
|
||||
**状态**: ✅ 完成
|
||||
**发现**: 0 个问题
|
||||
|
||||
| 检查项 | 结果 |
|
||||
|------|--------|
|
||||
| 所有 16 个合约文件 + index.ts | ✅ |
|
||||
| Bun workspaces 配置 | ✅ |
|
||||
| Turborepo 配置 | ✅ |
|
||||
| dependency-cruiser 规则 | ✅ |
|
||||
| 所有 contracts 类型均已导出 | ✅ |
|
||||
|
||||
---
|
||||
|
||||
### P1 — 存储、事件、制品
|
||||
|
||||
**文件**: 32 个源文件 (runtime/src/storage/, events/, project/, sessions/, artifacts/)
|
||||
**状态**: ✅ 完成(P1 审计后修复了 5 个 INV-1 违规)
|
||||
**发现**: 审计后已解决
|
||||
|
||||
| 检查项 | 结果 |
|
||||
|------|--------|
|
||||
| 16 个仓库,具有正确的 CRUD | ✅ |
|
||||
| 17/19 个表已创建 (provider_configs, capability_registry 推迟到 P2/P3) | ✅ |
|
||||
| EventSchemaRegistry 包含 55 个持久 + 7 个短暂事件类型 | ✅ |
|
||||
| EventStore.project() 处理所有持久事件 | ✅ |
|
||||
| EventBus 纯发布/订阅 | ✅ |
|
||||
| EventIngestor 路由持久→EventStore,短暂→EventBus | ✅ |
|
||||
| SessionManager, ProjectStore, ArtifactStore, EvidenceStore | ✅ |
|
||||
| Recovery 模块 | ⚠️ 8 步中的 5 步是存根 |
|
||||
|
||||
---
|
||||
|
||||
### P2 — 工具、权限、能力
|
||||
|
||||
**文件**: 18 个源文件 (security/, tools/, capabilities/)
|
||||
**状态**: ✅ 完成(P2 审计通过)
|
||||
**发现**: 0 个严重问题
|
||||
|
||||
| 工具类别 | 文件 | 工具 |
|
||||
|-------------|------|-------|
|
||||
| 文件系统 | tools/fs/index.ts | fs.read, fs.write, fs.edit, fs.patch, fs.list |
|
||||
| Shell | tools/shell/index.ts | shell.run |
|
||||
| Git | tools/git/index.ts | git.status, git.diff, git.commit, git.branch, git.merge |
|
||||
| 项目 | tools/project/index.ts | project.rules, project.context |
|
||||
| 制品 | tools/artifact/index.ts | artifact.create, artifact.read |
|
||||
| 上下文 | tools/context/index.ts | context.assemble, context.compact |
|
||||
| 权限 | tools/permission/index.ts | permission.check, permission.prompt |
|
||||
| Doctor | tools/doctor/index.ts | doctor.check, doctor.fix |
|
||||
|
||||
**总计**: 21 个工具定义,全部已注册通过 BuiltInToolRegistrar。
|
||||
|
||||
---
|
||||
|
||||
### P3 — 提供者与上下文
|
||||
|
||||
**文件**: 13 个 TS + 6 个 MD 提示文件
|
||||
**状态**: ✅ 完成(P3 审计后修复)
|
||||
**发现**: 6 个已修复
|
||||
|
||||
**已修复的关键问题**:
|
||||
1. `AnthropicCanonical.ts:10` — 移除了不存在的合约类型的死导入 (Message, TextBlock 等)
|
||||
2. `AnthropicAdapter.ts:9` — 移除了不存在的 `CompleteOptions`, `StreamEvent`, `ModelRequirement`
|
||||
3. `OpenAICompatibleAdapter.ts:9` — 同上
|
||||
4. `ProviderManager.ts:10` — 同上
|
||||
5. `PromptLayerLoader.ts:15` — ESM 兼容性 (`__dirname` → `import.meta.url`)
|
||||
6. `AnthropicAdapter` / `OpenAICompatibleAdapter` — 移除了 `implements ProviderAdapter`(签名不匹配合约)
|
||||
|
||||
**剩余技术债务**:
|
||||
- `CapabilityMatrix.ts` 本地类型与合约 `ProviderCapability` 不同
|
||||
- `ContextAssembler` L6/L7/L8/L9 是存根(未实现 EvidenceStore/SessionStore 读取)
|
||||
- `runtime/src/index.ts` 最初缺少 context 重新导出(已修复)
|
||||
|
||||
---
|
||||
|
||||
### P4 — Worker IPC 与调度器
|
||||
|
||||
**文件**: 17 个 TS + 1 个测试文件
|
||||
**状态**: ✅ 完成(P4 审计后修复)
|
||||
**发现**: 16 个问题(2 个严重,4 个高),关键问题已修复
|
||||
|
||||
**已修复的关键问题**:
|
||||
1. `Scheduler.ts:146` — 损坏的 `agent_id.split('_')[1]` task_id 提取 → 已修复为使用 AgentMonitor.get()
|
||||
2. `Scheduler.ts:128-131` — DISPATCHING 是无操作 → 已修复为过渡任务到 'running' 并注册心跳
|
||||
3. `Scheduler.ts` — 任务从未过渡到 'running' → 已修复(mark_terminal 现在接受 'running')
|
||||
4. `AgentMonitor.ts` — `remove()` 从未被调用 → 已修复为在 lost/timeout 处理时清理
|
||||
5. `WorkspaceManager.ts` — INV-1 违规(直接状态变更) → 已添加事件投影注释
|
||||
6. `workers/src/index.ts` — 空 barrel → 已填充所有 12 个导出
|
||||
|
||||
**剩余技术债务**:
|
||||
- `WorkerManager.send_and_wait()` 是 100ms 定时休眠,不是真正的响应等待
|
||||
- `WorkerProcess.is_alive()` 在进程退出窗口期间存在误报
|
||||
- `AgentMonitor.detect_lost_agents()` 如果不调用 remove() 会重新报告 — 已修复
|
||||
|
||||
---
|
||||
|
||||
### P5 — C++ 工具链
|
||||
|
||||
**文件**: 10 个 TS 文件
|
||||
**状态**: ✅ 完成(P5 审计后修复)
|
||||
**发现**: 28 个问题(5 个严重,16 个高)
|
||||
|
||||
**已修复的关键问题**:
|
||||
1. `capability.ts:9` — `CapabilityManifest` 类型不存在 → 修复为 `CapabilityManifestV1`
|
||||
2. `capability.ts:17-86` — 6 个工具使用了无效的 `category: 'toolchain'` → 修复为 `'debug'`/`'build'`/`'test'`/`'static_analysis'`
|
||||
3. `capability.ts:16` — `trust_level: 'trusted'` 不在合约枚举中 → 修复为 `'local'`
|
||||
4. `capability.ts:21-76` — 权限格式 `{read, write, network}` 不匹配 `ToolPermissionSpec` → 修复为 `{read_paths, write_paths, execute, network}`
|
||||
5. `index.ts:1-12` — 缺少 `CppToolRegistrar`, `ClangdClient`, `CPP_TOOLCHAIN_CAPABILITY` 导出 → 已添加
|
||||
6. 向 `CppcheckRunner` 和 `CMakeConfigurator` 添加了命令注入安全 TODO
|
||||
|
||||
**剩余技术债务**:
|
||||
- `DiagnosticParser`: `ParsedDiagnostic` 不匹配合约的 `Diagnostic`(缺少 `diagnostic_id`, `created_at`)
|
||||
- `CppTestRunner.parse_ctest_output`: 正则表达式完全损坏(将百分比误认为计数)
|
||||
- `ClangdClient`: 两个方法都是存根(需要 LSP JSON-RPC 实现)
|
||||
- `CppProjectDetector.find_cpp_sources()`: 始终返回 `[]`
|
||||
- `CppProjectDetector.command_exists()`: 仅检查 `/usr/bin`, `/usr/local/bin`
|
||||
- `CppcheckRunner`: cppcheck 输出格式与 GCC 正则表达式不匹配
|
||||
- 3 个文件中的 `execSync` 命令注入漏洞
|
||||
|
||||
---
|
||||
|
||||
### P6 — 投影与 TUI
|
||||
|
||||
**文件**: 12 个 TSX 文件
|
||||
**状态**: ✅ 完成
|
||||
**发现**: 17 个问题(5 个严重,9 个高)
|
||||
|
||||
**关键发现**:
|
||||
1. `types.ts`: `SessionProjection`/`TaskProjection`/`AgentProjection` 不匹配合约投影类型
|
||||
2. `ProjectionClient.ts`: 未实现合约的 `ProjectionClient` 接口
|
||||
3. `TuiApp.tsx:render()`: `console.log` 存根 — 未使用 OpenTUI 渲染器,不调用任何导入的组件
|
||||
4. `PermissionPrompt.tsx`: 使用直接回调而不是 UiCommandChannel(违反 INV-3)
|
||||
5. `ToolRunView`: 死代码 — 未集成到 TuiApp 中
|
||||
6. 缺少 `theme/` 和 `keymap/` 目录(实现计划 T-610)
|
||||
7. 所有组件返回 `string` 而不是 JSX 元素
|
||||
|
||||
**修复路径**: P6 需要与 OpenTUI 进行重大集成工作。当前组件在结构上是正确的,但无法渲染。
|
||||
|
||||
---
|
||||
|
||||
### P7 — Agent 集成
|
||||
|
||||
**文件**: 8 个 TS + 2 个测试文件
|
||||
**状态**: ✅ 完成(P7 审计后修复)
|
||||
**发现**: 25 个问题(9 个高,9 个中)
|
||||
|
||||
**已修复的关键问题**:
|
||||
1. `architecture-review-fixture.test.ts:24-26` — `toInclude` 不是有效的 Bun 匹配器 → 修复为 `toContain`
|
||||
|
||||
**关键发现**:
|
||||
1. `MainAgent.state`: 公共可变属性,`AWAITING_CONFIRMATION` 状态无法从正常流程到达
|
||||
2. `MainAgent`: 未发出 `requirement.changed` 事件(DoD T-701 要求)
|
||||
3. `ArchitectureDesigner`: 未发出 `architecture.impact.completed` / `architecture.plan.updated` 事件(DoD T-702 要求)
|
||||
4. `wiring.ts`: `capture_debug_record` 和 `promote_memory_entry` — INV-2 outbox 事件有文档说明但从未发出
|
||||
5. `DebugKnowledgeStore` / `LearnedMemoryStore`: outbox 事件有文档说明但从未发出
|
||||
6. E2E 测试是单元测试,标签为 E2E — 无集成、无 EventBus、无 Scheduler、无数据库
|
||||
7. `ArchitectureDesigner.identify_affected_components`: 使用 `.includes()` 进行子字符串匹配(误报)
|
||||
|
||||
---
|
||||
|
||||
### P8 — CLI、Doctor、发布
|
||||
|
||||
**文件**: 16 个 TS 文件
|
||||
**状态**: ✅ 完成(P8 审计后修复)
|
||||
**发现**: 27 个问题(12 个高,7 个中)
|
||||
|
||||
**已修复的关键问题**:
|
||||
1. `init.ts` — 为直接文件系统写入添加了 INV-3 TODO 注释
|
||||
|
||||
**关键发现**:
|
||||
1. `Logger`: `air.developer.log` 从未写入 — `DeveloperLogEncryptor` 已断开连接
|
||||
2. `DeveloperLogEncryptor`: 声称 INV-3(使用 SecretRedactor)但从未导入/调用
|
||||
3. `DeveloperLogEncryptor`: 回退加密密钥硬编码为 `'dev-key'`
|
||||
4. `RuntimeApp` 与 `ServiceRegistry`: 并行重复的服务图 — 需要去重
|
||||
5. `RuntimeApp.start()`: 在 doctor 检查后不启动任何子系统
|
||||
6. `RuntimeApp.shutdown()`: 纯存根 — 不刷新日志、关闭数据库或停止 worker
|
||||
7. `DoctorService`: 5/7 检查是硬编码的 `passed: true` 存根
|
||||
8. `DoctorService`: 无 `read_only` 模式,无 `bundle` 模式
|
||||
9. `ServiceRegistry`: 缺少 EventBus、EventIngestor、ToolRegistry、PermissionEngine、DatabaseManager
|
||||
10. `createRuntime`: 会话/项目 ID 从 `Date.now()` 生成,不加载现有项目元数据
|
||||
11. `init.ts`: 创建了 `.air/local/` 但从未写入 `config.json`
|
||||
12. `releaseCommand` 和 `e2eCommand`: 纯存根,带有硬编码输出
|
||||
13. 6 个 CLI 命令绕过 RuntimeApp(INV-3 违规)
|
||||
14. `loadConfig`: 从不读取环境变量 `AIRCODING_PROVIDER`/`AIRCODING_MODEL`
|
||||
15. `loadConfig`: 格式错误的 JSON 被静默忽略,无用户反馈
|
||||
|
||||
---
|
||||
|
||||
## 4. 合约合规矩阵
|
||||
|
||||
### 4.1 合约类型使用情况
|
||||
|
||||
| 合约文件 | 已导出 | 已使用于 |
|
||||
|--------------|---------|---------|
|
||||
| ids.ts | 18 个类型别名 | runtime, llm, tui, cli |
|
||||
| error.ts | AirError, is_air_error | runtime |
|
||||
| event.ts | RuntimeEvent, EventSource, EntityRef | runtime |
|
||||
| runtime.ts | AgentType, ContextPack, PromptLayer | runtime, context, tui |
|
||||
| ipc.ts | IpcEnvelope, IpcKind, ToolCallRequest | workers (未使用 — 自定义类型) |
|
||||
| task.ts | TaskRecord, TaskStatus, TaskType | runtime |
|
||||
| worker-result.ts | WorkerResult, ExecutorResult 等 | workers (未使用 — 自定义类型) |
|
||||
| tool.ts | ToolCategory, ToolDefinition, ToolPermissionSpec | runtime, toolchain-cpp |
|
||||
| artifact.ts | ArtifactType | runtime |
|
||||
| evidence.ts | EvidenceKind | runtime |
|
||||
| project.ts | ProjectContext, ProjectInitOptions | runtime |
|
||||
| provider.ts | ProviderAdapter, ProviderManager 接口 | llm (部分 — 签名不匹配) |
|
||||
| permission.ts | PathPolicy | runtime, toolchain-cpp |
|
||||
| ui.ts | UiCommandChannel | tui (未使用) |
|
||||
| capability.ts | CapabilityManifestV1, CapabilityRegistry 接口 | runtime |
|
||||
| platform.ts | PlatformInfo | runtime |
|
||||
|
||||
### 4.2 合约不匹配
|
||||
|
||||
| 包 | 本地类型 | 合约类型 | 严重性 |
|
||||
|---------|-----------|----------|--------|
|
||||
| llm | `ProviderCapability` (自定义) | `ProviderCapability` (不同形状) | 高 |
|
||||
| llm | `CompleteOptions` (本地) | `ProviderCompletionInput` | 高 |
|
||||
| llm | 同步 `select_model` | 异步 `ProviderManager.select_model` | 高 |
|
||||
| workers | `ToolCallRequest` (本地) | `IpcEnvelope<ToolCallRequest>` (ipc.ts) | 高 |
|
||||
| workers | 角色结果 (本地) | WorkerResult\<T\> (worker-result.ts) | 中 |
|
||||
| tui | `SessionProjection` (本地) | 合约 `SessionProjection` (不同字段) | 高 |
|
||||
| tui | `ToolRunProps` (本地) | 合约 `ToolRunProjection` | 高 |
|
||||
| toolchain-cpp | `ParsedDiagnostic` (本地) | 合约 `Diagnostic` | 高 |
|
||||
| toolchain-cpp | `BuildOutput` (本地) | 合约 (不存在) | 中 |
|
||||
|
||||
---
|
||||
|
||||
## 5. 数据库模式合规
|
||||
|
||||
### 5.1 MigrationRunner 表覆盖率
|
||||
|
||||
| 表 | 已创建? | 列数 | 状态 |
|
||||
|-------|---------|-------|--------|
|
||||
| sessions | ✅ | 11 | 已创建 |
|
||||
| messages | ✅ | 10 | 已创建 |
|
||||
| tasks | ✅ | 15 | 已创建 |
|
||||
| task_attempts | ✅ | 13 | 已创建 |
|
||||
| task_dependencies | ✅ | 3 | 已创建 |
|
||||
| agents | ✅ | 12 | 已创建 |
|
||||
| tool_runs | ✅ | 16 | 已创建 |
|
||||
| command_runs | ✅ | 13 | 已创建 |
|
||||
| artifacts | ✅ | 11 | 已创建 |
|
||||
| diagnostics | ✅ | 13 | 已创建 |
|
||||
| evidence_refs | ✅ | 8 | 已创建 |
|
||||
| summaries | ✅ | 7 | 已创建 |
|
||||
| ui_state | ✅ | 4 | 已创建 |
|
||||
| workspaces | ✅ | 10 | 已创建 |
|
||||
| message_drafts | ✅ | 5 | 已创建 |
|
||||
| event_log | ✅ | 10 | 已创建 |
|
||||
| event_outbox | ✅ | 8 | 已创建 |
|
||||
| provider_configs | ❌ | — | **缺失** |
|
||||
| capability_registry | ❌ | — | **缺失** |
|
||||
|
||||
**审计说明**: `provider_configs` 是 P3 需要的,`capability_registry` 是 P2 需要的。这两张表应在 P1 创建,但推迟了。
|
||||
|
||||
---
|
||||
|
||||
## 6. 架构导入图合规
|
||||
|
||||
**参考**: DD §2, c4/module.md, 合约 §23
|
||||
|
||||
```
|
||||
contracts → (无) ✅ 已验证
|
||||
llm → contracts ✅ 已验证
|
||||
toolchain-cpp → contracts ✅ 已验证
|
||||
tui → contracts ✅ 已验证
|
||||
runtime → contracts, llm (仅 facade) ✅ 已验证
|
||||
cli → contracts, runtime, tui, llm, toolchain-cpp ✅ 已验证
|
||||
workers → contracts + WorkerRuntime IPC ✅ 已验证
|
||||
```
|
||||
|
||||
**禁止边 — 所有已验证无违规**:
|
||||
- ❌ TUI 直接访问数据库: 0 个违规
|
||||
- ❌ Worker 直接写入 SQLite: 0 个违规
|
||||
- ❌ 能力直接安装依赖: 0 个违规
|
||||
- ❌ 提供者适配器静默更改提示语义: 0 个违规
|
||||
- ❌ 无 PermissionEngine 的工具执行: 1 个违规 (init.ts 直接 fs)
|
||||
- ❌ 包含调度策略的仓库: 0 个违规
|
||||
|
||||
---
|
||||
|
||||
## 7. 安全审计
|
||||
|
||||
| 漏洞 | 文件 | 严重性 | 状态 |
|
||||
|-------------|------|----------|--------|
|
||||
| execSync 命令注入 | `CppcheckRunner.ts:34` | **严重** | ⚠️ 已标记 TODO |
|
||||
| execSync 命令注入 | `CMakeConfigurator.ts:39-44` | **严重** | ⚠️ 已标记 TODO |
|
||||
| execSync 命令注入 | `CppBuilder.ts:30-31` | **严重** | ⚠️ 已标记 TODO |
|
||||
| 硬编码加密密钥 `'dev-key'` | `DeveloperLogEncryptor.ts:22` | 高 | ⚠️ 需要 env 变量 |
|
||||
| SecretRedactor 未使用 | `DeveloperLogEncryptor.ts:32-33` | 高 | ❌ 未修复 |
|
||||
| SecretRedactor 未调用 | `Logger.ts:45-46` (开发者日志路径) | 高 | ❌ 未修复 |
|
||||
| 格式错误的 JSON 静默忽略 | `loadConfig.ts:40-42, 52-54` | 中 | ⚠️ 需要用户反馈 |
|
||||
| 脆弱的 PID 检测 | `DoctorService.ts:76-82` | 低 | ⚠️ 应使用 `typeof Bun` |
|
||||
|
||||
---
|
||||
|
||||
## 8. 测试覆盖率
|
||||
|
||||
| 测试文件 | 类型 | 状态 |
|
||||
|-----------|------|--------|
|
||||
| `runtime/test/e2e/worker-fixture.test.ts` | 单元 (协议) | ✅ 7 个测试 |
|
||||
| `runtime/test/e2e/direct-mode-fixture.test.ts` | 单元 (agent) | ✅ 5 个测试 |
|
||||
| `runtime/test/e2e/architecture-review-fixture.test.ts` | 单元 (arch) | ✅ 4 个测试 |
|
||||
|
||||
**总计**: 16 个测试跨 3 个文件
|
||||
**覆盖率**: < 5%(146 个源文件,仅 3 个经过测试)
|
||||
**缺口**: 无仓库测试,无事件系统测试,无工具执行测试,无集成测试,无 E2E 测试
|
||||
|
||||
---
|
||||
|
||||
## 9. 建议与后续行动
|
||||
|
||||
### 立即(发布前)
|
||||
1. **[安全] 修复命令注入**: 将 `CppcheckRunner`、`CMakeConfigurator`、`CppBuilder` 中的 `execSync` 替换为 `execFileSync` + args 数组
|
||||
2. **[安全] 修复硬编码密钥**: 强制要求 `DeveloperLogEncryptor` 设置 `AIRCODING_PROJECT_KEY`
|
||||
3. **[合约] 重新同步类型**: 对齐 `ParsedDiagnostic`→`Diagnostic`,本地投影→合约投影,`CapabilityMatrix`→合约 `ProviderCapability`
|
||||
4. **[INV-2] 实现 Outbox 事件**: 从 `wiring.ts`、`DebugKnowledgeStore`、`LearnedMemoryStore` 发出 `debug.record.created`、`memory.promoted`、`memory.archived`
|
||||
|
||||
### 短期(Alpha 发布)
|
||||
5. **[测试] 添加仓库测试**: 每个仓库进行 CRUD 往返测试
|
||||
6. **[测试] 添加事件系统测试**: EventStore append/query/project, EventBus publish/subscribe
|
||||
7. **[集成] 连接 RuntimeApp↔ServiceRegistry**: 去重并行服务图
|
||||
8. **[集成] 完成 RuntimeApp.start()**: 启动 scheduler、workers、事件基础设施
|
||||
9. **[TUI] 集成 OpenTUI**: 将 TuiApp 连接到 `@opentui/*` 渲染器
|
||||
|
||||
### 中期(Beta 发布)
|
||||
10. **[测试] 完整的 E2E 套件**: worker-fixture、direct-mode、architecture-gate、完整调度器循环
|
||||
11. **[CLI] 通过 RuntimeApp 路由所有命令**: 遵守 INV-3
|
||||
12. **[文档] 为所有导出的类型添加 JSDoc**
|
||||
13. **[性能] 在长期运行的会话中对 AgentMonitor.heartbeats Map 进行 GC**
|
||||
|
||||
---
|
||||
|
||||
## 附录
|
||||
|
||||
### A. 审计方法
|
||||
|
||||
- **第 1 轮 (P0-P2)**: 子代理并行审计不变量 + 架构 + 基线
|
||||
- **第 2 轮 (P3-P8)**: 子代理并行审计每 2 个阶段
|
||||
- **第 3 轮 (本报告)**: 基于所有先前审计的交叉引用验证 + 合约合规矩阵 + 安全扫描
|
||||
|
||||
### B. 审查的文件
|
||||
|
||||
每个包中每个 `.ts`/`.tsx` 文件都至少被两个独立的子代理读取和审查。合约文件被约 5 个代理引用。总共审查了超过 146 个文件。
|
||||
|
||||
### C. 词汇表
|
||||
|
||||
| 术语 | 含义 |
|
||||
|------|-------|
|
||||
| DD | 详细设计文档 (system-detailed-design.md) |
|
||||
| INV | 域不变量 (DD §18.6) |
|
||||
| DoD | 完成定义 (实现计划中每个任务) |
|
||||
| Outbox | 事件溯源模式:先写入外部,然后发出完成事件 |
|
||||
| NDJSON | 换行符分隔的 JSON(Worker IPC 协议) |
|
||||
| FK-off | 外键关联断开 — 应用层引用完整性 |
|
||||
474
AirPlan/docs/MiniMaxM3开发阶段审计.md
Executable file
474
AirPlan/docs/MiniMaxM3开发阶段审计.md
Executable file
@@ -0,0 +1,474 @@
|
||||
# AirCoding V1.0.0 Alpha — MiniMax-M3 开发阶段审计报告
|
||||
|
||||
> **审计员**: MiniMax-M3
|
||||
> **审计日期**: 2026-06-02
|
||||
> **审计方法**: 2 个独立子代理(无前两份审计引用)
|
||||
> **审计依据**: baselineV1 / interface-contracts-v1 / system-overview-design / system-detailed-design §7-§22 / event-registry-v1 / db-schema-v1 / main-agent-state-machine / c4/code-view / error-taxonomy-v1 / tool-registry-v1 / capability-trust-v1
|
||||
> **审计范围**: 全部 146 个源文件 (137 TS + 9 TSX) vs 全部规范文档
|
||||
|
||||
---
|
||||
|
||||
## 0. 执行摘要
|
||||
|
||||
### 评级:**C+ — 架构轮廓合规,关键执行路径断的,V1.0.0 Alpha 不应在当前状态下发布**
|
||||
|
||||
### 三方审计对比
|
||||
|
||||
| 维度 | DeepSeek | Opus | **M3 (本文档)** |
|
||||
|------|----------|------|---------------|
|
||||
| 总体评级 | B+ | C+ | **C+** |
|
||||
| 阻断级 | 10 | 18 | **18 (P0)** |
|
||||
| 严重 | 46 | — | **20+ (P1)** |
|
||||
| 侧重 | 问题数量 | 逐字段对照 | **可执行性 + 治理** |
|
||||
| 独有发现 | — | 权限旁路 / 状态机终态缺失 | **Scheduler空壳 / TUI无OpenTUI / e2e假报绿 / 退出码错配 / Worker握手反转 / 3个RCE / DeveloperLog对称加密错配spec** |
|
||||
|
||||
**M3 的独特角度**:前两份审计侧重"代码与规范是否一致",M3 额外关注 **"代码即使符合规范,是否真能跑"** ——发现大量"接口定义清晰、实现是 stub、连接链路不存在"的可执行性阻断。
|
||||
|
||||
### 18 项 P0 阻断级缺陷速览
|
||||
|
||||
| # | 缺陷 | 文件:行 | 不变量/规范 |
|
||||
|---|------|---------|-----------|
|
||||
| 1 | 退出码 4 语义错配(spec 父取消 vs 实现任务阻塞) | WorkerProcess.ts:12-19 | baselineV1 §8 |
|
||||
| 2 | WorkerManager 握手顺序反转 + agent.start 缺三件套 | WorkerManager.ts:45-91, 75-80 | contracts §10 |
|
||||
| 3 | find_bun shell 命令注入 (test -x ${path}) | WorkerManager.ts:195-209 | baselineV1 §23 |
|
||||
| 4 | workers/main.ts 启动即发 ready + 信号走 exit(0) 而非 4 | workers/src/main.ts:33-57, 65-73 | baselineV1 §8 |
|
||||
| 5 | **Scheduler 多处 mark_terminal 直接写 tasks.status 绕过事件投影** | Scheduler.ts:128-175, TaskGraph.ts:99-105 | **INV-1 根本违反** |
|
||||
| 6 | **Scheduler 不调 WorkspaceManager/WorkerManager/ContextAssembler/EventIngestor** | Scheduler.ts:74-204 | DD §19.1 |
|
||||
| 7 | **CMakeConfigurator execSync 字符串拼接 → RCE** | CMakeConfigurator.ts:48 | baselineV1 §23 |
|
||||
| 8 | **CppBuilder execSync 字符串拼接 → RCE** | CppBuilder.ts:30 | baselineV1 §23 |
|
||||
| 9 | **CppcheckRunner execSync 字符串拼接 → RCE** | CppcheckRunner.ts:36 | baselineV1 §23 |
|
||||
| 10 | **ProjectionStore 8 投影只实现 3 个,不处理 ephemeral 事件** | ProjectionStore.ts:11-133 | contracts §17 |
|
||||
| 11 | **TUI 不依赖 OpenTUI,render 走 console.log** | TuiApp.tsx:24-82, tui/package.json:18-24 | DD §13.2 |
|
||||
| 12 | **MainAgent 状态机缺 7/11 态**(CLASSIFYING/SCHEDULING/...) | MainAgent.ts:13 | main-agent-state-machine.md |
|
||||
| 13 | ArchitectureDesigner 不 emit `architecture.plan.updated` | ArchitectureDesigner.ts:57-62 | DD §14.2 |
|
||||
| 14 | **INV-2 outbox:debug.record.created / memory.promoted 永不发出** | wiring.ts:35-73 | **INV-2 根本违反** |
|
||||
| 15 | DeveloperLogEncryptor 对称加密 + 默认 'dev-key'(spec 要团队公钥) | DeveloperLogEncryptor.ts:22 | baselineV1 §23 |
|
||||
| 16 | Doctor.fix 永远返回 ok:false | DoctorService.ts:70-73 | DD §16.1 |
|
||||
| 17 | CLI init 直接 fs 写入,绕过 ToolRegistry+PermissionEngine | cli/commands/init.ts:5-7 | **INV-3 根本违反** |
|
||||
| 18 | e2e 命令 hardcoded 全 ✅,不跑任何测试 | cli/commands/e2e.ts:6-16 | baselineV1 §24 release gate 形同欺骗 |
|
||||
|
||||
---
|
||||
|
||||
## 第一部分:P0 仓库骨架
|
||||
|
||||
### 评级:✅ 合规 + 仓库卫生存根
|
||||
|
||||
| 项 | 评级 | 文件 |
|
||||
|----|------|------|
|
||||
| workspaces 配置 | ✅ | package.json:1-22 |
|
||||
| turbo.json 任务依赖 | ✅ | turbo.json:1-19 |
|
||||
| bunfig.toml | ✅ | bunfig.toml:1-7 |
|
||||
| tsconfig 路径别名 | ✅ | tsconfig.base.json:1-32 |
|
||||
| 7 包依赖方向全部正确 | ✅ | 各 package.json |
|
||||
| dependency-cruiser 7 forbidden + 5 deep-import 规则 | ✅ | .dependency-cruiser.js |
|
||||
| **根 tsconfig.tsbuildinfo 1.4MB 留仓库** | 🔧 | 根目录 |
|
||||
| **packages/*/node_modules** | 🔧 | 应在 .gitignore |
|
||||
|
||||
**M3 强项**:7 个包的 `package.json` 依赖方向**完全符合 c4/module.md**:
|
||||
- contracts: 0 deps (leaf)
|
||||
- llm/tui/toolchain-cpp/workers: 仅 → contracts
|
||||
- runtime: → contracts + llm
|
||||
- cli: → contracts + runtime + tui + llm + toolchain-cpp(无 → workers,符合 c4 规则)
|
||||
|
||||
---
|
||||
|
||||
## 第二部分:P1 合约 / 存储 / 事件 / 项目 / 会话 / 制品
|
||||
|
||||
### 评级:🟢 整体合规,存储层有 4 项 P0
|
||||
|
||||
### 2.1 Contracts(packages/contracts/src/)
|
||||
|
||||
16 个文件**忠实编码**了 interface-contracts-v1 §2-§22 全部规范。**这是全项目最合规的部分**。
|
||||
|
||||
| 区块 | 状态 | 详情 |
|
||||
|------|------|------|
|
||||
| §2-§5 IDs/Errors/EntityRef/RuntimeEvent | ✅ | 完全一致 |
|
||||
| §8 Project/Session | ✅ | 一致 |
|
||||
| §9 Task/Scheduler | ✅ | 一致 |
|
||||
| §10 IPC | ✅ | IpcDirection/IpcEnvelope/IpcKind/WorkerRole/WorkerRuntime |
|
||||
| §11 WorkerResult | ✅ | 5 角色结果齐全 |
|
||||
| §12 Tool | ✅ | 16 类别 + PermissionSpec/PathPolicy |
|
||||
| §13 Permission | ✅ | Action/GrantScope/RiskLevel/Decision/Engine |
|
||||
| §14 Artifact/Evidence | ✅ | 一致 |
|
||||
| §15 Provider | ✅ | 17 字段 supports + 5 字段 conversion |
|
||||
| §17 Projection/UI | ✅ | 8 投影 + ProjectionStore/Client + UiCommandChannel |
|
||||
| §18 Capability | ✅ | 5 信任级别 + ManifestV1 |
|
||||
| §19 Doctor/Logger | ✅ | DoctorRunInput/Output + Logger + DeveloperLogEncryptor |
|
||||
| §20 DebugRecord/LearnedMemory | ✅ | 字段一致 |
|
||||
|
||||
### 2.2 存储层 4 项 P0 阻断
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `EventStore.ts:900,909` | workspace 投影写 `status:'created'/'merging'`,不在闭合枚举 → assertEnum 抛错 |
|
||||
| 2 | `DebugKnowledgeStore.ts:30,42-56` | 路径 `.air/shared` 应 `.air/local`;列集合偏离 db-schema §20 |
|
||||
| 3 | `LearnedMemoryStore.ts:31,40-55` | 表名 `learned_memory` 应 `learned_memories`;列偏离 |
|
||||
| 4 | `EventRepository.ts:185` | `route_prefix.join('.')` 拼接,但存储用 `/` 拼接(toRecord:462)→ 多段路由前缀过滤永久失效 |
|
||||
|
||||
### 2.3 事件系统
|
||||
|
||||
| 项 | 评级 | 详情 |
|
||||
|----|------|------|
|
||||
| 54 持久 + 7 短暂事件 | ✅ | EventSchemaRegistry.ts:37-129 程序化零差异 |
|
||||
| EventStore.project 30+ 投影 | ✅ | 覆盖 11 大类 |
|
||||
| eventBus.publish post-commit | ✅ | EventStore.ts:377,420 INV-5 通过 |
|
||||
| project() 唯一 status 写入点 | ✅ | EventStore.ts:492-933 INV-1 通过 |
|
||||
| context.compaction.* 投影 | ❌ | 4 事件落入 default |
|
||||
| 投影非法枚举 | ❌ | P0-#1 |
|
||||
| route_prefix 查询 bug | ❌ | P0-#4 |
|
||||
|
||||
### 2.4 不变量证据
|
||||
|
||||
| INV | 评级 | 证据 |
|
||||
|-----|------|------|
|
||||
| INV-1 | ⚠️ | Projector 内 status 写入唯一,但 P4 Scheduler 旁路(见 P0-#5) |
|
||||
| INV-2 | ⚠️ | EventStore.project 不开外部 DB ✓;但 P7 outbox 事件未发(见 P0-#14) |
|
||||
| INV-3 | ✅ | 静态层遵守,但 CLI init/RuntimeApp shutdown/CppBuilder 旁路(见 P0-#17, P5-#1, P5-#2) |
|
||||
| INV-4 | ✅ | dependency-cruiser 7 规则覆盖,零违规 |
|
||||
| INV-5 | ✅ | eventBus.publish 全部 post-commit |
|
||||
|
||||
---
|
||||
|
||||
## 第三部分:P2 安全 / 工具 / 能力
|
||||
|
||||
### 评级:🟠 4 项 P0(编译期阻塞)+ 7 项 P1(spec 错位)
|
||||
|
||||
### 3.1 4 项 P0 编译期阻塞
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `security/PermissionEngine.ts:481` | 访问不存在的 `decision.redacted` 字段,TS 编译失败 |
|
||||
| 2 | `security/PermissionEngine.ts:11`, `tools/ToolRegistry.ts:10` | `import { ToolCall }` 未在 contracts 导出(TS2305) |
|
||||
| 3 | `tools/ToolRegistry.ts:331-338` | create_error_result 返回字段 `{call_id, tool_name, type, content}`,应为 `ToolResultEnvelope` 的 `{status, output, error, artifact_ids, evidence_ref_ids}` |
|
||||
| 4 | `toolchain-cpp/src/capability.ts:11-67` | `name` 应为 `capability_id`;`trust_level: 'local'` 不在 spec 5 枚举 |
|
||||
|
||||
### 3.2 7 项 P1 spec 错位
|
||||
|
||||
| # | 文件:行 | spec vs 实现 |
|
||||
|---|---------|---------|
|
||||
| 5 | `PermissionEngine.ts:19-26`, `ToolRegistry.ts:36-98` | PermissionAction 6 值错位(spec `ask_user/block/refuse/announce_then_run` vs 实现 `prompt/read_only/sandbox/audit_log`) |
|
||||
| 6 | `PathClassifier.ts:13-22` | 8 类别命名分裂(spec 9 类别,缺 `project_air_shared / project_air_local / project_git_internal / credential_or_secret`) |
|
||||
| 7 | `CommandRiskAnalyzer.ts:12-22` | 10 类别命名分裂(spec `read_only/build/test/static_analysis/git_read/git_write/destructive/network/system_sensitive/credential_sensitive`) |
|
||||
| 8 | `llm/ProviderManager.ts:11-14` | `ModelRequirement/ModelAssignment/StreamEvent` 本地定义,与 contracts §15 不兼容 |
|
||||
| 9 | `llm/CapabilityMatrix.ts:10-28` | 4 bool + 2 int vs spec 17 字段 `ProviderSupports` + 5 字段 `ProviderConversion` |
|
||||
| 10 | `BuiltInToolRegistrar.ts:33-68` | 28 MVP 工具缺 8 个(fs.stat / process.kill / git.worktree.create / git.merge_workspace / project.scan / project.profile.write / permission.request / doctor.run) |
|
||||
| 11 | `toolchain-cpp/capability.ts:51-65` | `cpp.cppcheck/clangd` 应为 `cpp.static.cppcheck/cpp.clangd.query` |
|
||||
|
||||
### 3.3 工具执行流
|
||||
|
||||
- ToolRegistry 7 步流程(lookup → validate → permission ctx → evaluate → branch → execute → record)符合 contracts §13
|
||||
- 6 个 Action 分支定义但**缺 4 个 spec 值**(#5)
|
||||
- `read_before_edit` + `expected_existing_sha256` 在 fs.edit/fs.write 中已实现(对齐 Claude Code 行为基线)
|
||||
|
||||
---
|
||||
|
||||
## 第四部分:P3 LLM / Context / Provider
|
||||
|
||||
### 评级:🟠 CapabilityMatrix 字段严重偏离 spec
|
||||
|
||||
| 项 | 评级 | 详情 |
|
||||
|----|------|------|
|
||||
| ModelConfigLoader | ✅ | 配置加载正确 |
|
||||
| AnthropicCanonical | ✅ | 4 content blocks + ConversionReport.dropped_fields 满足 §23 无静默丢失 |
|
||||
| AnthropicAdapter | ✅ | 完整实现 |
|
||||
| OpenAICompatibleAdapter | ✅ | 完整实现 |
|
||||
| ProviderManager | ⚠️ | 本地 ModelRequirement/ModelAssignment 与 contracts §15 不兼容(#8) |
|
||||
| CapabilityMatrix | ❌ | 4+2 字段 vs spec 22 字段(#9) |
|
||||
| PromptLayerLoader | ✅ | 4 方法齐全 |
|
||||
| CompactionPolicy | ✅ | should_compact + compact |
|
||||
| ContextAssembler | ✅ | 5 层收集,发出 `context.compaction.requested` |
|
||||
|
||||
---
|
||||
|
||||
## 第五部分:P4 Worker IPC / Scheduler / Recovery
|
||||
|
||||
### 评级:🔴 7 项 P0 — 整套调度形同空壳
|
||||
|
||||
#### 5.1 Worker IPC(4 项 P0)
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `WorkerProcess.ts:12-19` | **退出码 4 语义错配**(spec 父取消 vs 实现任务阻塞) |
|
||||
| 2 | `WorkerManager.ts:45-91` | **握手顺序反转**(应 parent→agent.start→worker.ready,实现先等 ready) |
|
||||
| 3 | `WorkerManager.ts:75-80` | agent.start 载荷**缺 task_spec/context_pack/runtime 三件套** |
|
||||
| 4 | `WorkerManager.ts:195-209` | find_bun shell 注入(test -x ${path}) |
|
||||
| 5 | `workers/main.ts:33-57,65-73` | 启动即发 ready + SIGTERM 走 exit(0) 而非 4 |
|
||||
|
||||
#### 5.2 Scheduler(3 项 P0)
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 6 | `Scheduler.ts:128-175, TaskGraph.ts:99-105` | **mark_terminal 直接写 tasks.status 绕过事件投影**——INV-1 根本违反 |
|
||||
| 7 | `Scheduler.ts:74-204` | **不调 WorkspaceManager/WorkerManager/ContextAssembler/EventIngestor**——整套调度形同空壳 |
|
||||
| 8 | `Scheduler.ts:18-30` | 缺 BLOCKED/CANCELLED 终态,多了自创 TERMINATED |
|
||||
|
||||
#### 5.3 Recovery
|
||||
|
||||
8 步中实际只 3 个 stub 工作:FK-off 8 不变量和 PID liveness 都是 no-op。`readdirSync/statSync` 直接导入绕开 ToolRegistry(INV-3 争议点)。
|
||||
|
||||
#### 5.4 WorkerRole 角色实现
|
||||
|
||||
5 个角色全部是 stub,返回 shape 与 spec §11 `WorkerResult<TResult>` 不一致。
|
||||
- ExecutorRole: `shell.run('echo "stub"')` 凑出 passed:true
|
||||
- ReviewerRole: push 一条 info 假 finding
|
||||
- DebuggerRole: 永远 cannot_reproduce
|
||||
- CompactorRole: token 算法固定 0.4 倍
|
||||
- ExperienceMinerRole: 一条 stub entry
|
||||
|
||||
#### 5.5 WorkerRuntime INV-3
|
||||
|
||||
**正面**:grep 验证无 fs/child_process/net/sqlite/bun:sqlite/database 导入,workers 静态边界干净。
|
||||
|
||||
---
|
||||
|
||||
## 第六部分:P5 C++ 工具链
|
||||
|
||||
### 评级:🔴 3 项 P0 RCE + 1 项 P0 capability 字段错位
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `CMakeConfigurator.ts:48` | **execSync(\`cmake ${...} ${project_root}\`)** — shell 字符串拼接 RCE |
|
||||
| 2 | `CppBuilder.ts:30` | **execSync(\`cmake --build .${target_arg}\`)** — target 注入 RCE |
|
||||
| 3 | `CppcheckRunner.ts:36` | **execSync(\`cppcheck ${...} ${project_root}\`)** — RCE |
|
||||
| 4 | `CppToolRegistrar.ts:32-95` | tool permission 字段 `{read, write, network}` 不匹配 spec `ToolPermissionSpec`(`read_paths/write_paths/execute/network/system_sensitive/credentials`)→ **CommandRiskAnalyzer 10 分类被完全绕过** |
|
||||
| 5 | `capability.ts:11-67` | manifest 形状错(name→capability_id;trust_level:'local' 不在 spec 枚举) |
|
||||
| 6 | `ClangdClient.ts:26-37` | LSP 客户端完全 stub(2 方法都返回 not yet implemented) |
|
||||
| 7 | `CppProjectDetector.ts:67-72` | command_exists 仅查 /usr/bin;find_cpp_sources 永远 [] |
|
||||
| 8 | `DiagnosticParser.ts:62-67` | semantic_signature 32-bit 哈希冲突率高 |
|
||||
| 9 | `CMakeConfigurator.ts:42` | 缺 ninja 优先 make 回退逻辑 |
|
||||
| 10 | 整体 6 cpp.* 工具 | 经 CapabilityRegistry 注册(INV-4 通过),但 3 个 build 类有 RCE,权限字段错位使 PermissionEngine 失效 |
|
||||
|
||||
---
|
||||
|
||||
## 第七部分:P6 Projection / TUI
|
||||
|
||||
### 评级:🔴 3 项 P0 — TUI 形同空壳
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `ProjectionStore.ts:11-133` | **不实现 contracts.ProjectionStore**;8 投影只实现 3 个(task/agent/session),缺 tool_runs/command_runs/artifacts/permission_prompts/blockers |
|
||||
| 2 | `TuiApp.tsx:24-82` | render 走 console.log;start 不初始化 OpenTUI renderer |
|
||||
| 3 | `tui/package.json:18-24` | **完全缺 @opentui/solid @opentui/core @opentui/keymap** 依赖 |
|
||||
| 4 | `ProjectionClient.ts:10-38` | 不实现 contracts.ProjectionClient;receive_snapshot 无任何调用者 |
|
||||
| 5 | `ProjectionStore.ts:70-98` | apply 只 switch 5 个错误的事件名(task.status.changed 等不存在事件) |
|
||||
| 6 | `tui/types.ts:13-37` | 自创 SessionProjection/TaskProjection/AgentProjection,字段名 task_id→id 与 contracts 不一致 |
|
||||
| 7 | 8 组件 | 全部返回 string 的 stub,非 Solid/JSX |
|
||||
|
||||
**正面**:TUI 模块导入方向干净(仅 contracts + 本包),INV-4 通过。
|
||||
|
||||
---
|
||||
|
||||
## 第八部分:P7 Agents / Knowledge
|
||||
|
||||
### 评级:🔴 2 项 P0 (INV-2 + MainAgent)
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `wiring.ts:35-73` | **capture_debug_record / promote_memory_entry 注释说 emit 但完全没 emit** `debug.record.created` / `memory.promoted`——INV-2 根本违反 |
|
||||
| 2 | `MainAgent.ts:13` | **状态机只 6/11 态**:缺 CLASSIFYING / SCHEDULING / ARCHITECTURE_DESIGNING / CONFIRMING / EXECUTING / INTERRUPTING / ARCHITECTURE_REVISING |
|
||||
| 3 | `MainAgent.ts:64-80` | classify 用正则而非 LLM |
|
||||
| 4 | `MainAgent.ts:97-102` | summarize 压成 no-op,未触发 ExperienceMiner 子任务 |
|
||||
| 5 | `ArchitectureDesigner.ts:57-62` | `update_architecture_docs` 空函数,不 emit `architecture.plan.updated`,不调 ProviderManager |
|
||||
| 6 | `wiring.ts:36-46, 59` | DebugRecord/LearnedMemory 字段名与 contracts §20 不一致 |
|
||||
| 7 | `ArchitectureDesigner.ts:64-75` | identify_affected_components 粗粒度 string match |
|
||||
| 正面 | `ArchitectureDesigner` 4 结果类型 | silent_continue/requires_user_confirmation/requires_replan/reject_or_escalate ✓ |
|
||||
|
||||
---
|
||||
|
||||
## 第九部分:P8 Logging / Doctor / RuntimeApp / CLI
|
||||
|
||||
### 评级:🔴 5 项 P0(含 1 项设计错配 spec)
|
||||
|
||||
| # | 文件:行 | 问题 |
|
||||
|---|---------|------|
|
||||
| 1 | `DeveloperLogEncryptor.ts:22` | **对称 AES-256-GCM + 默认 'dev-key'**——spec baselineV1 §23 要求开发团队**公钥**非对称加密;当前设计性错配,团队无法解 developer log |
|
||||
| 2 | `DoctorService.ts:70-73` | `fix` 永远返回 ok:false——spec §11 "First startup always asks before doctor --fix" 完全没实现 |
|
||||
| 3 | `cli/commands/init.ts:5-7` | **直接 mkdirSync/writeFileSync 绕过 ToolRegistry+PermissionEngine**——INV-3 根本违反 |
|
||||
| 4 | `cli/commands/e2e.ts:6-16` | **hardcoded 全 ✅ 不跑任何测试**——release gate 形同欺骗 |
|
||||
| 5 | `cli/commands/init.ts:39-40` | project_id 用 `Date.now().toString(36)` 而非 spec 的 stable UUID(同一秒内重 init 撞 id) |
|
||||
| 6 | `RuntimeApp.ts:25-65` | 不通过 ServiceRegistry;start 仅 doctor self_bootstrap + logger,不 hydrate ProjectionStore / 不 rebuild Scheduler / 不 run Recovery |
|
||||
| 7 | `Logger.ts:25-37` | 只写 air.log,air.developer.log 一边空;两模块无联动 |
|
||||
| 8 | `DoctorService.ts:86,89,106,110,114` | 5 个 check 硬编码 passed:true |
|
||||
| 9 | `CLI 7 命令` | compact/restore/resume/history/session/release 全部 stub |
|
||||
| 10 | `loadConfig.ts:1-50` | 读 `~/.air/config.json` 而 spec 是 `~/.air/config.yaml` |
|
||||
| 正面 | `cli/src/index.ts:35-101` | 11 个命令入口路由齐备 ✓ |
|
||||
| 正面 | `provider.ts` | 只读 list/current ✓ |
|
||||
|
||||
---
|
||||
|
||||
## 第十部分:三方审计对比
|
||||
|
||||
### 10.1 评级对比
|
||||
|
||||
| 维度 | DeepSeek | Opus | **M3** |
|
||||
|------|----------|------|--------|
|
||||
| 总体评级 | B+ | C+ | **C+** |
|
||||
| 阻断级 | 10 | 18 | **18 (P0)** |
|
||||
| 侧重 | 问题数量 | 逐字段对照 | **可执行性 + 治理** |
|
||||
|
||||
### 10.2 独有发现交叉表
|
||||
|
||||
| 发现 | DeepSeek | Opus | M3 |
|
||||
|------|----------|------|---|
|
||||
| ToolRegistry 权限旁路 | ❌ | ✅ | ⚠️(部分) |
|
||||
| ACTION_BRANCHES this 崩溃 | ❌ | ✅ | ❌ |
|
||||
| Workspace 投影非法枚举 | ❌ | ✅ | ✅ |
|
||||
| 退出码 4 错配 | ❌ | ❌ | ✅ |
|
||||
| 3 个 RCE | ⚠️ | ✅ | ✅ |
|
||||
| Worker 握手反转 | ❌ | ❌ | ✅ |
|
||||
| agent.start 缺三件套 | ❌ | ❌ | ✅ |
|
||||
| **Scheduler 形同空壳** | ❌ | ❌ | ✅ |
|
||||
| **TUI 无 OpenTUI 依赖** | ⚠️ | ✅ | ✅ |
|
||||
| **MainAgent 缺 7 态** | ⚠️ | ✅ | ✅ |
|
||||
| **e2e 假报绿** | ❌ | ❌ | ✅ |
|
||||
| **DeveloperLog 对称错配 spec** | ❌ | ❌ | ✅ |
|
||||
| ProjectionClient↔Store 断开 | ❌ | ✅ | ✅ |
|
||||
| Route_prefix 查询 bug | ❌ | ✅ | ✅ |
|
||||
| Project_id Date.now 错 | ❌ | ❌ | ✅ |
|
||||
| Toolchain permission 字段错 | ❌ | ✅ | ✅ |
|
||||
|
||||
### 10.3 共识(三个审计都同意)
|
||||
|
||||
- **INV-2 outbox 事件不发出**(最关键的系统性问题)
|
||||
- **INV-3 多处旁路**(CLI init / CppBuilder / CppProjectDetector 等)
|
||||
- **3 个 RCE 漏洞**(CMakeConfigurator / CppBuilder / CppcheckRunner)
|
||||
- **合约漂移**:下游包自定类型不 import 契约
|
||||
- **存根率高**(~15% 方法是 stub)
|
||||
- **测试覆盖 <5%**
|
||||
|
||||
### 10.4 分歧点
|
||||
|
||||
- **DeepSeek B+ 偏乐观**:把"文件齐全、骨架完整"等同于"可发布"
|
||||
- **Opus C+ 聚焦规范对照**:把"逐字段不符"作为评级核心
|
||||
- **M3 C+ 聚焦可执行性**:额外关注"接口在但连接链路断"的执行性阻断
|
||||
|
||||
---
|
||||
|
||||
## 第十一部分:M3 独立总评
|
||||
|
||||
### 核心判断
|
||||
|
||||
> **V1.0.0 Alpha 不应在当前状态下发布**。
|
||||
> 模块边界、合约、依赖方向**架构轮廓合规**;
|
||||
> 但**关键路径执行逻辑**(调度 / TUI / Worker IPC / toolchain shell / CLI init / ArchitectureDesigner / outbox 事件 / Doctor fix / E2E)**全部是断的**。
|
||||
> 至少 18 项 P0 必须修复,10+ 项 P1 严重缺陷需配套真实 E2E 套件代替 hardcoded ✅。
|
||||
|
||||
### 实现完成度估算
|
||||
|
||||
| 维度 | 完成度 |
|
||||
|------|--------|
|
||||
| Contracts 字段覆盖 | ~98% |
|
||||
| Storage 19 表 + 22 索引 + 16 仓储 | ~100% |
|
||||
| 事件 schema 注册 54+7 | ~99% |
|
||||
| 事件投影 30+ 类型 | ~95% |
|
||||
| 6 层 PermissionEngine | ~95% |
|
||||
| PathClassifier 8 vs 9 类别 | ~60% |
|
||||
| CommandRiskAnalyzer 10 vs 10 类别 | ~70% |
|
||||
| 28 MVP 工具(20/28) | ~71% |
|
||||
| LLM provider + canonical | ~85% |
|
||||
| Toolchain C++ 6 工具 | ~85% |
|
||||
| TUI 边界(只 import contracts) | ~100% |
|
||||
| Worker 边界(只 import contracts) | ~100% |
|
||||
| CLI 边界 | ~100% |
|
||||
| Dependency cruiser 规则 | ~100% |
|
||||
| **关键路径执行(调度/TUI/Worker/toolchain/CLI init)** | **<30%** |
|
||||
| **E2E 测试(e2e 命令假报绿)** | **0%** |
|
||||
|
||||
### 整改优先级
|
||||
|
||||
#### P0 — 立即修(阻断 GA)
|
||||
|
||||
1. **Scheduler**(#5, #6):重写状态机,所有 status 变更走 EventStore.project;接入 WorkspaceManager/WorkerManager/ContextAssembler/EventIngestor
|
||||
2. **Worker IPC**(#1-#4):修退出码 4 语义、反转握手顺序、补 agent.start 三件套、消除 find_bun shell 注入
|
||||
3. **3 个 RCE**(#7-#9):CMakeConfigurator / CppBuilder / CppcheckRunner 改用 execFileSync + args 数组
|
||||
4. **TUI**(#11):添加 @opentui/* 依赖,render 接入 OpenTUI,ProjectionClient↔Store 建立推送链路
|
||||
5. **MainAgent**(#12):补 7 个状态 + LLM classify + Scheduler/ProviderManager/ContextAssembler 集成
|
||||
6. **INV-2 outbox**(#14):wiring/stores 注入 EventIngestor,真实发出 debug.record.created / memory.promoted
|
||||
7. **CLI init**(#17):改为 RuntimeApp→ToolRegistry→PermissionEngine 路径
|
||||
8. **e2e 假报绿**(#18):替换为真实测试套件
|
||||
9. **DeveloperLogEncryptor**(#15):改用团队公钥(asymmetric)+ 真实 KDF
|
||||
10. **Capability manifest / PathClassifier / CommandRiskAnalyzer**(#4, #6, #7):与契约对齐
|
||||
|
||||
#### P1 — 严重(阻塞 E2E 验证或稳定运行)
|
||||
|
||||
- 5 个 WorkerRole 真实实现
|
||||
- 8 个 TUI 组件改为 Solid/JSX
|
||||
- ArchitectureDesigner emit 事件 + LLM 调用
|
||||
- DoctorService fix / bundle 实现
|
||||
- ProjectionStore 8 投影齐全
|
||||
- Recovery 8 步实际工作
|
||||
- Logger + DeveloperLogEncryptor 联动
|
||||
- RuntimeApp 通过 ServiceRegistry
|
||||
- 8 个 MVP 工具补齐
|
||||
|
||||
#### P2 — 中等
|
||||
|
||||
- DiagnosticParser MSVC + 改进哈希
|
||||
- ClangdClient LSP 真实实现
|
||||
- CppProjectDetector PATH 检测 + find_cpp_sources
|
||||
- WavePlanner 按 TaskScope.write_area 提取
|
||||
|
||||
#### P3 — 治理
|
||||
|
||||
- 删除 hardcoded e2e ✅
|
||||
- 删除硬编码 'dev-key'
|
||||
- 删除 init 的 Date.now() project_id
|
||||
- 实跑 E2E 套件
|
||||
|
||||
### 治理建议
|
||||
|
||||
1. **立即冻结新特性开发**,转入"先修 P0"阶段
|
||||
2. **建立 CI 强制检查**:
|
||||
- `tsc --noEmit` 通过
|
||||
- `dependency-cruiser` 7 forbidden 规则零违规
|
||||
- 真实 E2E 套件(非 hardcoded)通过
|
||||
3. **核心路径连通性专项验证**:
|
||||
- 一次完整 dispatch → worker spawn → tool call → result → event projection → projection update → TUI render
|
||||
4. **安全问题红线**:
|
||||
- 任何 `execSync` 必须改 `execFileSync`
|
||||
- 任何 `--dev-key` 默认值必须改为强制环境变量
|
||||
- 任何 shell 字符串拼接必须改 args 数组
|
||||
|
||||
---
|
||||
|
||||
## 附录
|
||||
|
||||
### A. 审计方法论
|
||||
|
||||
派发 2 个独立 general-purpose 子代理(不引用前两份审计结论):
|
||||
- **代理 1** (P0-P3): 143K tokens, 88 工具调用
|
||||
- **代理 2** (P4-P8): 125K tokens, 108 工具调用
|
||||
|
||||
每个代理:
|
||||
1. 完整阅读对应规范文档(不依赖前审计)
|
||||
2. 逐文件对照实现
|
||||
3. 输出 ✅/⚠️/❌/🔧 评级 + 精确文件:行
|
||||
4. 独立汇总阻断级缺陷
|
||||
5. 独立给出 M3 评级
|
||||
|
||||
### B. 与前两份审计的关系
|
||||
|
||||
本审计**不参考** DeepSeek 和 Opus 审计的任何结论,但最终发现在很多关键点(INV-2 outbox / 3 个 RCE / capability 字段错位 / 投影事件名错位)上**与 Opus 审计完全独立地得出相同结论**——这增强了对这些缺陷的置信度。
|
||||
|
||||
同时 M3 的**独有发现**集中在:
|
||||
- **执行链路连通性**(Scheduler/TUI/Worker/ProjectionClient 之间的"接口在但连接断")
|
||||
- **设计错配 spec**(DeveloperLog 对称加密 vs spec 公钥)
|
||||
- **治理失败**(e2e 假报绿、CLI init 绕 INV-3、project_id Date.now 而非 UUID)
|
||||
- **可执行性阻断**(退出码 4 错配、握手反转、agent.start 缺三件套)
|
||||
|
||||
### C. 词汇表
|
||||
|
||||
| 术语 | 含义 |
|
||||
|------|-------|
|
||||
| P0 阻断 | 必须修复才能进入 GA 的硬性缺陷 |
|
||||
| P1 严重 | 阻塞 E2E 验证或稳定运行的严重缺陷 |
|
||||
| P2 中等 | 影响可维护性/可扩展性的中等缺陷 |
|
||||
| P3 轻微 | 命名/小 bug/卫生问题 |
|
||||
| RCE | 远程代码执行 (Remote Code Execution) |
|
||||
| outbox | "外部写入→发出完成事件" 模式保证跨存储一致性 |
|
||||
| 投影 (Projection) | 事件→领域状态的派生视图 |
|
||||
|
||||
---
|
||||
|
||||
**报告结束** — 共发现 18 项 P0 阻断级 + 20+ 项 P1 严重 + 中等/轻微若干。
|
||||
**M3 结论**:V1.0.0 Alpha 在当前状态下**不应发布**。先修 P0,再考虑 GA。
|
||||
373
AirPlan/docs/Opus开发阶段审计.md
Executable file
373
AirPlan/docs/Opus开发阶段审计.md
Executable file
@@ -0,0 +1,373 @@
|
||||
# AirCoding V1.0.0 Alpha — Opus 开发阶段审计报告
|
||||
|
||||
> **审计员**: Claude Opus 4.8 (1M context)
|
||||
> **审计日期**: 2026-06-02
|
||||
> **审计方法**: 4 个独立子代理对照规范文档逐文件交叉审查
|
||||
> **审计依据**: interface-contracts-v1, db-schema-v1, event-registry-v1, security-model-v1, tool-registry-v1, capability-trust-v1, prompt-layering-v1, provider-capability-matrix-v1, scheduler-state-machine-v1, runtime-semantics-v1, scope-escalation-v1, main-agent-state-machine, error-taxonomy-v1, c4/code-view, system-detailed-design (§7/8/13/14/15/16/17/22)
|
||||
> **审计范围**: 全部 146 个源文件 vs 全部规范文档
|
||||
|
||||
---
|
||||
|
||||
## 执行摘要
|
||||
|
||||
### 总体评级:**C+ — 骨架完整,规范符合度低,存在阻断级缺陷**
|
||||
|
||||
与 DeepSeek 审计(侧重发现问题数量)不同,本次 Opus 审计**逐字段对照规范文档**,得出更严峻的结论:
|
||||
|
||||
> **核心发现**:`packages/contracts/src/` 中的规范契约**忠实地**编码了全部规范文档,但下游实现(runtime/llm/workers/tui/toolchain-cpp)**系统性地重新定义了本地的、与契约冲突的类型**,几乎不 import 契约。这导致大量"实现存在但与规范不符"的偏差。
|
||||
|
||||
### 关键指标对比
|
||||
|
||||
| 维度 | DeepSeek 审计 | Opus 审计(本报告) |
|
||||
|------|--------------|---------------------|
|
||||
| 发现总数 | 97 | **140+** |
|
||||
| 审计深度 | 阶段级 | 字段级/逐行 |
|
||||
| 契约对照 | 部分 | 全部 16 合约文件 |
|
||||
| 状态机验证 | 否 | 是(Scheduler/MainAgent 逐状态) |
|
||||
| 阻断级缺陷 | 10 | **18** |
|
||||
|
||||
### 阻断级缺陷速览(18 项)
|
||||
|
||||
| # | 缺陷 | 文件 | 后果 |
|
||||
|---|------|------|------|
|
||||
| 1 | workspace 投影写入非法枚举 `'created'`/`'merging'` | EventStore.ts:900,909 | `workspace.created` 持久化必抛错 |
|
||||
| 2 | 项目级 DB 表名/路径/列全面偏离 db-schema §20 | DebugKnowledgeStore.ts, LearnedMemoryStore.ts | 与契约无法对接 |
|
||||
| 3 | route_prefix 查询用 `.` 拼接但存储用 `/` | EventRepository.ts:185 | 多段路由前缀过滤永久失效 |
|
||||
| 4 | TaskAttemptRepository 复制粘贴 bug | TaskAttemptRepository.ts:114 | failure_signature 列永不更新 |
|
||||
| 5 | ToolRegistry 权限上下文硬编码 undefined | ToolRegistry.ts:262-263 | **权限模型被完全旁路** |
|
||||
| 6 | ACTION_BRANCHES 内 `this.*` 调用崩溃 | ToolRegistry.ts:62,72 | read_only/sandbox 分支运行时崩溃 |
|
||||
| 7 | ModelConfig.api_key 明文内嵌 | ModelConfigLoader.ts:17 | 违反 auth_ref 规范,密钥泄露 |
|
||||
| 8 | Scheduler 状态机缺 BLOCKED/CANCELLED | Scheduler.ts:18-29 | 无法表达 5 处规范转换 |
|
||||
| 9 | WorkerProcess 退出码 4 错配为 blocked | WorkerProcess.ts:17,30 | parent-cancelled 语义丢失 |
|
||||
| 10 | 命令注入 — CMakeConfigurator | CMakeConfigurator.ts:40 | execSync 字符串拼接 |
|
||||
| 11 | 命令注入 — CppBuilder | CppBuilder.ts:27 | LLM 可控 target 注入 |
|
||||
| 12 | 命令注入 — CppcheckRunner | CppcheckRunner.ts:36 | project_root 注入 |
|
||||
| 13 | C++ 工具绕过 PermissionEngine | CppToolRegistrar.ts:23 | 违反 INV-3 |
|
||||
| 14 | INV-2 outbox 完全未发事件 | wiring.ts:35-73 | 跨 DB 一致性断裂 |
|
||||
| 15 | DeveloperLogEncryptor 硬编码弱密钥 'dev-key' | DeveloperLogEncryptor.ts:22 | 日志加密等同明文 |
|
||||
| 16 | CapabilityTrustLevel 用错误枚举值 | CapabilityManifestValidator.ts:19 | 信任模型失效 |
|
||||
| 17 | PermissionEngine 缺 block/refuse/announce_then_run | PermissionEngine.ts:19-26 | 无法执行高风险拒绝/备份 |
|
||||
| 18 | ProjectionClient↔ProjectionStore 从未连接 | (全仓) | 投影数据无法到达 TUI |
|
||||
|
||||
---
|
||||
|
||||
## 第一部分:契约层审计(packages/contracts)
|
||||
|
||||
### 评级:✅ 忠实编码规范(少量缺失)
|
||||
|
||||
合约层是整个项目**最符合规范**的部分。16 个文件忠实编码了 interface-contracts-v1 的 §2-§21。
|
||||
|
||||
| 合约区块 | 状态 | 说明 |
|
||||
|---------|------|------|
|
||||
| §2 ID 别名 (17) + Clock/IdGenerator | ✅ | 完全一致 (ids.ts) |
|
||||
| §3 ErrorKind(22)/Severity/Retryability/AirError | ✅ | 字段完全匹配 (error.ts) |
|
||||
| §4 EntityType(12)/EntityRef | ✅ | 一致 (event.ts) |
|
||||
| §5 RuntimeEvent/EventSource/EventFilter | ✅ | 一致 |
|
||||
| §6 SessionRecord/MessageRecord | ⚠️ | 定义在 runtime 而非 contracts(违反 §22.1) |
|
||||
| §6 PersistedEventRecord/PersistedEventInsert | ❌ | contracts 包完全缺失 |
|
||||
| §7 EventBus/EventStore/EventIngestor/SchemaRegistry 接口 | ❌ | 6 个核心接口在 contracts 中全部缺失(仅作 runtime class 存在) |
|
||||
| §8-§21 其余契约 | ✅ | 大部分一致 |
|
||||
| §16 ContextAssembler/CompactionPolicy 接口 | ❌ | contracts 中未找到 |
|
||||
|
||||
**关键发现**: 契约层缺失存储/事件层接口定义,导致下游实现"无契约可依",进而各自定义本地类型。
|
||||
|
||||
---
|
||||
|
||||
## 第二部分:P1 存储与事件审计
|
||||
|
||||
### 评级:⚠️ 表结构正确,投影与项目级 DB 有阻断缺陷
|
||||
|
||||
| 检查项 | 状态 | 详情 |
|
||||
|--------|------|------|
|
||||
| 17 张会话表全列匹配 | ✅ | MigrationRunner.ts 逐列核对 db-schema §2-§18 |
|
||||
| 55 持久 + 7 短暂事件注册 | ✅ | 程序化 diff 验证零差异 |
|
||||
| EventStore.project() 域投影 | ⚠️ | session/task/agent/tool/command 等已覆盖 |
|
||||
| **workspace 投影非法枚举** | ❌ | `status:'created'`/`'merging'` 不在闭合枚举 → assertEnum 抛错 |
|
||||
| **context.compaction.* 缺投影** | ❌ | 4 个事件落入 default,规范要求标记压缩任务 |
|
||||
| **debug-records.db schema** | ❌ | 路径 `.air/shared` (应 `.air/local`),列集合全面偏离 |
|
||||
| **learned-memory.db schema** | ❌ | 表名 `learned_memory` (应 `learned_memories`),列偏离 |
|
||||
| **route_prefix 查询 bug** | ❌ | EventRepository.ts:185 用 `.` 拼接但存储用 `/` |
|
||||
| **TaskAttempt update bug** | ❌ | failure_signature 分支错误 push failure_summary |
|
||||
| EventBus.subscribe 返回 Subscription | ⚠️ | 缺 `unsubscribe()` 方法 |
|
||||
| EventStore.append 缺 EventAppendOptions | ⚠️ | 无乐观并发校验、无外部事务复用 |
|
||||
| INV-1 status 写入 | ✅ | 5 仓库已修复为硬编码默认值 |
|
||||
|
||||
---
|
||||
|
||||
## 第三部分:P2 工具/权限/能力审计
|
||||
|
||||
### 评级:❌ 系统性偏离规范,存在权限旁路
|
||||
|
||||
这是**问题最严重的阶段**。实现几乎全部重新定义本地类型,忽略契约。
|
||||
|
||||
### 3.1 PathClassifier vs security-model §4(8 路径类别)
|
||||
|
||||
| 规范类别 | 实现 | 状态 |
|
||||
|---------|------|------|
|
||||
| project_air_shared / project_air_local | 笼统归入 project_internal | ❌ 缺失 |
|
||||
| project_git | 混入 project_internal | ❌ 缺失(.git 需独立保护) |
|
||||
| credential_store | 无(~/.ssh 归为 user_home) | ❌ 缺失(安全关键) |
|
||||
| unknown | 默认归类为 project_config | ❌ 方向错误(应保守) |
|
||||
|
||||
8 个规范类别仅对应 3 个,且全部命名不一致。
|
||||
|
||||
### 3.2 PermissionEngine vs security-model §13
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| 6 层评估顺序 | ✅ | capability→profile→task_scope→risk→credential→prompt |
|
||||
| **PermissionAction 枚举** | ❌ | 缺 `block`/`refuse`/`announce_then_run`;多 `read_only`/`sandbox`/`audit_log` |
|
||||
| **PermissionDecision 结构** | ❌ | 缺 grant_scope/risk_level/backup_required/evidence_refs |
|
||||
| **profile 概念** | ❌ | 被替换为 AgentType,缺 low/normal/high/developer 四档 |
|
||||
| capability/prompt 层 | ⚠️ | 桩实现,恒 allow |
|
||||
| record 发事件 | ❌ | 仅 push 内存数组 |
|
||||
| **decision.redacted 字段** | ❌ | ToolRegistry 引用不存在的字段 |
|
||||
|
||||
### 3.3 ToolRegistry vs tool-registry-v1
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| **权限上下文硬编码 undefined** | ❌ | build_permission_context 把 task_scope/profile 设为 undefined → Layer 2/3 恒放行,**权限旁路** |
|
||||
| **ACTION_BRANCHES this 崩溃** | ❌ | 模块级常量内 `this.downgrade_to_readonly` → 运行时 TypeError |
|
||||
| 6 分支 | ❌ | 仅 allow/deny 正确,缺 block/refuse/announce_then_run |
|
||||
| 生命周期事件 | ❌ | 无 tool.started/completed/failed 发射 |
|
||||
| schema 校验 | ❌ | validate_input 自承"simplified" |
|
||||
| 28 个 MVP 工具 | ❌ | 仅 ~7 个命中,cpp/debug/gui/network/process/fs.stat 全缺 |
|
||||
|
||||
### 3.4 CapabilityTrustLevel vs capability-trust-v1
|
||||
|
||||
| 规范值 | 实现 | 状态 |
|
||||
|--------|------|------|
|
||||
| built_in | core | ❌ 错误值 |
|
||||
| project_local | 无 | ❌ 缺失 |
|
||||
| user_installed | 无 | ❌ 缺失 |
|
||||
| verified_publisher | 无 | ❌ 缺失 |
|
||||
| untrusted | untrusted | ✅ |
|
||||
| — | trusted | ❌ 规范外 |
|
||||
|
||||
实现 `core/trusted/untrusted` 中仅 1 个命中。
|
||||
|
||||
---
|
||||
|
||||
## 第四部分:P3 提供者/上下文审计
|
||||
|
||||
### 评级:❌ 能力矩阵严重不全,上下文 L5-L9 未实现
|
||||
|
||||
### 4.1 ProviderCapabilityMatrix vs provider-capability-matrix-v1
|
||||
|
||||
| 规范 supports 字段 | 实现 | 状态 |
|
||||
|-------------------|------|------|
|
||||
| 16 个能力字段 | 仅 ~7 个(命名偏差) | ❌ 一半缺失 |
|
||||
| quality_tier | 无 | ❌ 缺失(模型选择核心) |
|
||||
| cost_tier | 无 | ❌ 缺失 |
|
||||
| default_use(按角色) | 无 | ❌ 缺失(Scheduler 分配依赖) |
|
||||
| max_tokens_output: 200000 | 数据错误 | ⚠️ 把上下文窗口误填为 output |
|
||||
|
||||
### 4.2 ContextAssembler vs prompt-layering-v1 (L0-L9)
|
||||
|
||||
| 层 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| L0 runtime_invariant | ✅ | 加载正确 |
|
||||
| L1 role | ⚠️ | 仅支持 worker 角色,main/architecture/scheduler 无法加载 |
|
||||
| L2 safety | ⚠️ | 硬编码字符串,非来自 permissions.yaml |
|
||||
| L3 project_rules | ⚠️ | 路径/来源不符,缺全局与 toolchain rules |
|
||||
| L4 architecture | ⚠️ | 无 AGENTS.md/plan.md/ADR 加载 |
|
||||
| **L5 task_spec** | ❌ | 硬编码假任务"Current Task" |
|
||||
| **L6 evidence** | ❌ | TODO 未实现 |
|
||||
| **L7 conversation** | ❌ | TODO 未实现 |
|
||||
| **L8 tool_output** | ❌ | TODO 未实现 |
|
||||
| **L9 user_override** | ❌ | TODO 未实现 |
|
||||
| Anthropic canonical 输出 | ❌ | 用 `{role,content:string}` 非 content blocks |
|
||||
|
||||
---
|
||||
|
||||
## 第五部分:P4 Worker IPC / 调度器审计
|
||||
|
||||
### 评级:❌ 状态机终态模型错误,核心状态为存根
|
||||
|
||||
### 5.1 Scheduler 状态机(11 状态)
|
||||
|
||||
| 规范状态 | 实现 | 评级 |
|
||||
|---------|------|------|
|
||||
| IDLE/LOADING_GRAPH/PLANNING_WAVE | 存在 | ⚠️ 转换简化 |
|
||||
| DISPATCHING | 🔧 存根 | 未创建 workspace/context/事件 |
|
||||
| MONITORING | ⚠️ | 缺 cancel/blocker 转换 |
|
||||
| COLLECTING_RESULTS/MERGING/REVIEWING_WAVE/REPAIRING | 🔧 存根 | 无条件跳转 |
|
||||
| COMPLETED | ✅ | 终态 |
|
||||
| **BLOCKED** | ❌ | SchedulerState 联合类型根本没有 |
|
||||
| **CANCELLED** | ❌ | 同上 |
|
||||
| TERMINATED | ⚠️ | 规范中不存在的多余状态 |
|
||||
|
||||
### 5.2 其他 P4 发现
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| RetryDecision 6 枚举 | ✅ | 齐全 |
|
||||
| **RetryPlanner.skip 分支** | ❌ | decide() 从不返回 skip |
|
||||
| **RetryPlanner 未接线** | ❌ | Scheduler 仅注释,不调用 decide() |
|
||||
| **退出码 4=parent cancelled** | ❌ | 错配为 blocked |
|
||||
| 工作空间三策略枚举 | ✅ | main/worktree/isolated_copy |
|
||||
| worktree git merge | 🔧 存根 | 仅改内存 state |
|
||||
| **Recovery 8 步** | 🔧 | 仅第 5 步实现,其余存根/缺失 |
|
||||
| ScopeImpactLevel | ❌ | 未定义(scope-escalation §13 必须) |
|
||||
| BlockerReport | ❌ | 角色仅返回裸 {error} |
|
||||
| WorkerProtocol 方向验证 | ✅ | 逻辑正确,但未知类型放行 |
|
||||
|
||||
---
|
||||
|
||||
## 第六部分:P5 C++ 工具链审计
|
||||
|
||||
### 评级:❌ 命令注入 + 绕过权限 + signature 格式错误
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| **命令注入 ×3** | ❌ | CMakeConfigurator/CppBuilder/CppcheckRunner execSync 拼接 |
|
||||
| **绕过 PermissionEngine** | ❌ | CppToolRegistrar executor 直接 execSync(违反 INV-3) |
|
||||
| **semantic_signature 格式** | ❌ | 输出 `diag_<hex>`,应为 `<kind>:<surface>:<class>:<loc>:<hash>` |
|
||||
| signature 丢弃 line/column | ⚠️ | 同消息不同位置会冲突 |
|
||||
| 无 LLM | ✅ | 纯正则+哈希 |
|
||||
| ClangdClient | 🔧 | 两方法纯存根 |
|
||||
| find_cpp_sources | 🔧 | 永远返回 [] |
|
||||
| 错误映射 AirError | ❌ | 仅返回 {ok:false},无 kind/retryability |
|
||||
| capability.ts 类型 | ✅ | 已修复对齐 CapabilityManifestV1 |
|
||||
|
||||
---
|
||||
|
||||
## 第七部分:P6 投影 / TUI 审计
|
||||
|
||||
### 评级:❌ 投影不符契约,数据链路断裂
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| **ProjectionStore 实现契约 §17** | ❌ | 方法签名全错 |
|
||||
| **8 类投影** | ❌ | 仅有 tasks/agents,缺 tool_runs/command_runs/artifacts/permission_prompts/blockers/updated_at |
|
||||
| **apply 处理事件名** | ❌ | 处理 `task.status.changed` 等不存在的事件名 |
|
||||
| 订阅 EventBus | ❌ | 无注入/订阅 |
|
||||
| **ProjectionClient↔Store 桥接** | ❌ | receive_snapshot 无调用者,投影到不了 TUI |
|
||||
| TUI 仅渲染(INV-4) | ✅ | 组件纯函数,仅 import contracts |
|
||||
| **TUI 实际渲染** | 🔧 | render() 仅 console.log,无 OpenTUI 依赖 |
|
||||
| **PermissionPrompt UiCommandChannel** | ❌ | 用回调,UiCommandChannel 全仓零引用 |
|
||||
| HUD 三预设 | ✅ | Full/Essential/Minimal |
|
||||
|
||||
---
|
||||
|
||||
## 第八部分:P7 Agent 集成审计
|
||||
|
||||
### 评级:❌ MainAgent 状态机缺 7 态,INV-2 未发事件
|
||||
|
||||
### 8.1 MainAgent 状态机(13 状态)
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| 实现状态数 | ❌ | 仅 6 态,缺 CLASSIFYING/SCHEDULING/ARCHITECTURE_DESIGNING/EXECUTING/INTERRUPTING 等 7 态 |
|
||||
| CLASSIFYING 经 LLM | ❌ | 用正则匹配首词,规范要求 LLM |
|
||||
| DELEGATING 分支 | ❌ | 硬编码 tasks:['task-1'],无 Scheduler 调用 |
|
||||
| /direct /done 触发 | ⚠️ | 用正则非命令 |
|
||||
| permission_template 映射 | ❌ | 无 main_direct 设置 |
|
||||
| requirement.changed | ❌ | 缺失 |
|
||||
|
||||
### 8.2 INV-2 Outbox
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| **debug.record.created 发射** | ❌ | wiring.ts 写库后仅注释,无 ingest |
|
||||
| **memory.promoted 发射** | ❌ | 同上,且 status='draft' 与 promote 语义矛盾 |
|
||||
| 单写者结构 | ✅ | 每 store 独立 db |
|
||||
| 外部失败补偿 | ❌ | 无 task.failed 路径 |
|
||||
| ArchitectureDesigner 经 LLM | ❌ | 关键字匹配,无 ProviderManager |
|
||||
| 四类结果枚举 | ✅ | 齐全 |
|
||||
|
||||
---
|
||||
|
||||
## 第九部分:P8 CLI / Doctor / RuntimeApp 审计
|
||||
|
||||
### 评级:❌ DI 容器虚设,Doctor 多为存根
|
||||
|
||||
| 项 | 状态 | 详情 |
|
||||
|----|------|------|
|
||||
| DoctorService 契约签名 | ❌ | run_diagnostics vs 契约 run(input) |
|
||||
| self_bootstrap 顺序 | ✅ | 先于 capability |
|
||||
| self_bootstrap 真实性 | ⚠️ | sqlite/shell 硬编码 passed:true |
|
||||
| capability 检查 | ❌ | 全硬编码 passed:true |
|
||||
| read_only/fix/bundle 三模式 | ❌ | fix/bundle 存根 |
|
||||
| doctor.* 事件 | ❌ | 无发射 |
|
||||
| **ServiceRegistry 使用** | ❌ | RuntimeApp/createRuntime 均绕过,自行 new |
|
||||
| RuntimeApp 服务完整 | ❌ | 缺 ProjectStore/SessionManager/Event* |
|
||||
| shutdown 清理 | 🔧 | 仅 log |
|
||||
| CLI 命令表(11) | ✅ | 全覆盖 |
|
||||
| **CLI 副作用经 RuntimeApp** | ❌ | doctor 直接 new DoctorService |
|
||||
| run 启动 TUI | 🔧 | console.log 占位 |
|
||||
| **Logger 双日志** | ⚠️ | 只写 air.log,不写 developer.log |
|
||||
| **DeveloperLogEncryptor 连接** | ❌ | 无调用者,且硬编码弱密钥 |
|
||||
|
||||
---
|
||||
|
||||
## 第十部分:不变量合规总评
|
||||
|
||||
| 不变量 | DeepSeek 评级 | Opus 评级 | 关键差异 |
|
||||
|--------|--------------|-----------|---------|
|
||||
| INV-1 Status 投影 | ✅ | ⚠️ | Opus 发现 workspace 投影写非法枚举 + Scheduler/WorkspaceManager 仅改内存 |
|
||||
| INV-2 Outbox | ⚠️ | ❌ | 完全未发事件,跨 DB 一致性断裂 |
|
||||
| INV-3 副作用门控 | ⚠️ | ❌ | ToolRegistry 权限旁路 + C++ 工具绕过 PermissionEngine |
|
||||
| INV-4 导入方向 | ✅ | ✅ | 一致通过 |
|
||||
| INV-5 EventBus 传输 | ✅ | ✅ | 一致通过(但 rebuild 是存根) |
|
||||
|
||||
---
|
||||
|
||||
## 第十一部分:与 DeepSeek 审计的对比结论
|
||||
|
||||
| 方面 | DeepSeek | Opus |
|
||||
|------|----------|------|
|
||||
| 总体评级 | B+ | C+ |
|
||||
| 侧重 | 问题计数 + 高层分类 | 逐字段对照规范 |
|
||||
| 独特发现 | — | 权限旁路、状态机终态缺失、能力矩阵不全、ProjectionClient 断裂、退出码错配、signature 格式错误 |
|
||||
| 共识 | 命令注入、INV-2 未实现、合约漂移、存根率高 | 同 |
|
||||
|
||||
**Opus 的更严峻判断**:DeepSeek 评 B+ 反映"文件齐全、骨架正确";Opus 评 C+ 反映"逐字段对照规范后,实现与规范的偏差是系统性的,且包含权限旁路这一安全致命缺陷"。
|
||||
|
||||
---
|
||||
|
||||
## 第十二部分:整改优先级
|
||||
|
||||
### P0 — 安全致命(发布前必修)
|
||||
1. **ToolRegistry 权限旁路**(ToolRegistry.ts:262-263)— 真实加载 task_scope/profile
|
||||
2. **ACTION_BRANCHES this 崩溃**(ToolRegistry.ts:62,72)— 改为实例方法或独立函数
|
||||
3. **3 处命令注入**(CMake/CppBuilder/Cppcheck)— execSync → execFileSync + args 数组
|
||||
4. **C++ 工具绕过 PermissionEngine** — 经 CapabilityRegistry.register_tools
|
||||
5. **明文 API key**(ModelConfigLoader.ts:17)— 改用 auth_ref
|
||||
6. **硬编码弱密钥 'dev-key'** — 强制 env 变量
|
||||
|
||||
### P1 — 阻断运行时
|
||||
7. **workspace 投影非法枚举** — 修正为合法 workspaces.status 值
|
||||
8. **route_prefix 查询 `.` vs `/`** — 统一分隔符
|
||||
9. **TaskAttempt update bug** — 修正 failure_signature 分支
|
||||
10. **Scheduler 缺 BLOCKED/CANCELLED** — 补回状态
|
||||
11. **退出码 4 错配** — 4=parent cancelled, 5=hard timeout
|
||||
|
||||
### P2 — 规范符合
|
||||
12. **INV-2 outbox 发事件** — wiring/stores 注入 EventIngestor
|
||||
13. **ProjectionClient↔Store 桥接** — 接通投影数据链路
|
||||
14. **下游 import 契约类型** — 删除本地重定义(PermissionAction/TrustLevel/Diagnostic/投影)
|
||||
15. **项目级 DB schema** — 对齐 db-schema §20
|
||||
16. **semantic_signature 格式** — 对齐 error-taxonomy §6
|
||||
|
||||
### P3 — 完整性
|
||||
17. ContextAssembler L5-L9、Recovery 8 步、ClangdClient、MainAgent 状态机、Doctor 检查、TUI OpenTUI 集成
|
||||
|
||||
---
|
||||
|
||||
## 附录:审计方法论
|
||||
|
||||
本次审计派发 4 个独立 general-purpose 子代理,每个负责 2-3 个阶段:
|
||||
- **代理 1**: contracts + P1(存储/事件)— 266K tokens, 44 工具调用
|
||||
- **代理 2**: P2(工具/权限/能力)+ P3(提供者/上下文)— 160K tokens, 24 工具调用
|
||||
- **代理 3**: P4(Worker/调度器状态机)— 134K tokens, 29 工具调用
|
||||
- **代理 4**: P5-P8(C++/TUI/Agent/CLI)— 154K tokens, 44 工具调用
|
||||
|
||||
每个代理先完整阅读对应规范文档,再逐文件对照实现,输出 ✅符合/⚠️偏差/❌缺失/🔧存根 四级评定,附精确 文件:行。
|
||||
|
||||
合约文件被全部 4 个代理交叉引用,确保契约层评估的一致性。
|
||||
|
||||
---
|
||||
|
||||
**报告结束** — 共发现 140+ 项,其中 18 项阻断级。建议按整改优先级 P0→P3 顺序处理。
|
||||
493
AirPlan/docs/analysis/full-requirements-audit.md
Executable file
493
AirPlan/docs/analysis/full-requirements-audit.md
Executable file
@@ -0,0 +1,493 @@
|
||||
# AirCoding V1.0.0 Alpha — 完整需求、设计决策、约束提取
|
||||
|
||||
**生成日期**: 2026-06-11
|
||||
**提取工具**: deepseek-v4-pro 全量提取
|
||||
**来源文档**: requirements.md + airplanV2-Qwen3.7-Max设计.md + baselineV1.md + solution-architecture.md + system-overview-design.md + system-detailed-design.md
|
||||
**参考原型**: air-suite-20260518 (V1 Python插件系统, 8个已验证插件)
|
||||
|
||||
> 共 383 条。每条的 source 字段标注了来源文档和章节。
|
||||
|
||||
---
|
||||
|
||||
## FR (Functional Requirements) — 21条 + 7条子要求
|
||||
|
||||
### 来源: requirements.md §3
|
||||
|
||||
1. **FR-001** (requirements.md §3): CLI Startup and Project Initialization — 从CLI入口启动,检测/打开项目,需要时初始化`.air/`,加载资源/配置,运行只读Doctor,打开session。
|
||||
|
||||
2. **FR-002** (requirements.md §3): Project-Local State — `.air/shared/`(可共享配置/规则/计划) + `.air/local/`(私有sessions/artifacts/workspaces/backups/local DBs)。
|
||||
|
||||
3. **FR-003** (requirements.md §3): Session Persistence — SQLite at `<project>/.air/local/sessions/<session-id>/session.db`, 支持messages/drafts/durable events/task graph state/agents/tool/command runs/artifacts/diagnostics/evidence refs/workspaces/summaries/UI state。
|
||||
|
||||
4. **FR-004** (requirements.md §3): Event-Driven Runtime — 发布RuntimeEvents用于实时行为,持久事件与域表更新事务一致。
|
||||
|
||||
5. **FR-005** (requirements.md §3): Main Agent Conversation — 面向用户的Agent: 接收请求,适当直接回答,分类工作,显示进度,呈现阻断/确认。
|
||||
|
||||
6. **FR-006** (requirements.md §3): Architecture Designer — 架构/接口/产品级决策路由到Architecture Designer: 更新架构制品,产生影响评估。
|
||||
|
||||
7. **FR-007** (requirements.md §3): Scheduler and TaskGraph — 调度TaskSpec: hard/soft依赖,写区冲突处理,重试预算,子Worker派发,心跳监控,合并协调,重启恢复。
|
||||
|
||||
8. **FR-007.5** (requirements.md §3): ADR级联失效与架构变更回滚 — 7条子要求:
|
||||
- (a) 通过TaskNode.adr_refs溯源所有依赖该ADR的任务(含已完成)
|
||||
- (b) 级联失效: completed→invalidated, running→终止, pending→cancelled
|
||||
- (c) 冻结调度(dispatch_frozen),阻止新任务派发
|
||||
- (d) 创建git回滚快照(rollback_ref),支持revert旧方案代码
|
||||
- (e) 接收ArchitectureDesigner产出的PlanDelta增量重规划
|
||||
- (f) apply_delta吸收新任务后解冻调度
|
||||
- (g) 终审时检查INVALIDATED任务的旧代码是否已清理
|
||||
|
||||
9. **FR-008** (requirements.md §3): Independent Worker Agents — Executor/Reviewer/Debugger/Compactor/ExperienceMiner作为独立Bun子进程,通过NDJSON IPC通信。
|
||||
|
||||
10. **FR-009** (requirements.md §3): Claude Code-Quality Execution Primitives — 强制: read-before-edit, exact conservative edits, small patches, no unrelated refactors, permission checks, verification-before-completion。
|
||||
|
||||
11. **FR-010** (requirements.md §3): ToolRegistry and Built-In Tools — Schema验证的工具: filesystem/shell/git/project scanning/完整C++ build/test/static-analysis/debug/GUI screenshot/network capture/artifacts/context assembly/permission requests/Doctor。
|
||||
|
||||
12. **FR-011** (requirements.md §3): Permission and Security Model — 分类paths/commands/network/credentials,强制权限配置,保护系统敏感和凭证操作,项目外写入备份,拒绝不安全请求。
|
||||
|
||||
13. **FR-012** (requirements.md §3): Plugin and Capability Foundation — manifest loading/validation/enable-disable config/dependency declaration/Doctor integration/namespaced tool registration/source-trust metadata/PermissionEngine enforcement。第三方registry/signing可延后,本地和内置capability打包必须可用。
|
||||
|
||||
14. **FR-013** (requirements.md §3): Provider Layer — 内部Anthropic canonical消息,通过适配器路由provider调用,能力矩阵验证和转换报告。
|
||||
|
||||
15. **FR-014** (requirements.md §3): Context Assembly and Compaction — 有序层组装prompt,适配token预算,记录遗漏,必要时copy-on-write压缩。
|
||||
|
||||
16. **FR-015** (requirements.md §3): Artifact and Evidence Management — temp-file→atomic rename,记录URI/path/hash/metadata,通过evidence refs链接声明。
|
||||
|
||||
17. **FR-016** (requirements.md §3): TUI and HUD — OpenTUI/Solid终端UI和HUD,仅消费ProjectionStore,不查询原始DB/EventBus。
|
||||
|
||||
18. **FR-017** (requirements.md §3): Complete C++ Development Workflow — 项目检测→构建系统评估→CMake configure→Ninja优先/Make回退→编译器/链接器诊断解析→clangd代码智能查询→cppcheck静态分析→CTest/GoogleTest执行→debug run/log解析→失败诊断→范围修复→审查→证据支持验证。
|
||||
|
||||
19. **FR-018** (requirements.md §3): Doctor — 启动时运行只读Doctor,报告环境/能力问题,在权限策略下支持修复模式。
|
||||
|
||||
20. **FR-019** (requirements.md §3): Logging and Diagnostics — 可读`air.log`,加密`air.developer.log`,默认7天保留。
|
||||
|
||||
21. **FR-020** (requirements.md §3): Release Gate — 定义tier-1 Linux发布门禁: unit tests/integration fixture replay/real LLM E2E/project init/C++ build-test flow/SQLite recovery/child IPC/TUI startup/artifact-event persistence。
|
||||
|
||||
---
|
||||
|
||||
## NFR (Non-Functional Requirements) — 8条
|
||||
|
||||
### 来源: requirements.md §4
|
||||
|
||||
22. **NFR-001** (requirements.md §4): Local-First Operation — 项目状态/制品/日志/调试知识保留在本地,除非用户显式导出/分享/上传。
|
||||
|
||||
23. **NFR-002** (requirements.md §4): Recoverability — 从进程/session重启恢复:读取SQLite状态,检测丢失agents,保留workspaces,重建Scheduler队列。
|
||||
|
||||
24. **NFR-003** (requirements.md §4): Extensibility — 通过`toolchain-*`包和能力清单添加语言/工具链支持。
|
||||
|
||||
25. **NFR-004** (requirements.md §4): Provider Flexibility — 内部契约在Anthropic/OpenAI/OpenRouter/ollama/兼容端点间保持稳定。
|
||||
|
||||
26. **NFR-005** (requirements.md §4): UI Responsiveness — Main Agent和TUI在后台Worker运行时保持响应。
|
||||
|
||||
27. **NFR-006** (requirements.md §4): Evidence-Based Completion — 任务未获得build/test/debug/review证据或显式skipped-gate报告前不得标记完成。
|
||||
|
||||
28. **NFR-007** (requirements.md §4): Linux-First Platform Support — Linux x86_64 tier1, arm64/WSL2 tier2, macOS实验, Windows native post-MVP/实验。
|
||||
|
||||
29. **NFR-008** (requirements.md §4): Security Boundary Preservation — LLM输出/工具结果/插件/外部内容在被运行时契约和策略验证前为不可信数据。
|
||||
|
||||
---
|
||||
|
||||
## AC (Acceptance Criteria) — 13条
|
||||
|
||||
### 来源: requirements.md §6
|
||||
|
||||
30. **AC-01**: CLI starts and initializes/opens a project `.air/` tree.
|
||||
31. **AC-02**: Session DB schema initializes and persists messages/events/tasks/tool runs/artifacts.
|
||||
32. **AC-03**: EventStore transactionally applies core durable events to domain tables.
|
||||
33. **AC-04**: ProjectionStore hydrates and updates a usable TUI/HUD view.
|
||||
34. **AC-05**: Scheduler dispatches worker child processes via NDJSON IPC, supports tool calls, receives WorkerResult.
|
||||
35. **AC-06**: ToolRegistry executes filesystem/shell/git/artifact/context/doctor/C++/debug/GUI/network tools through PermissionEngine.
|
||||
36. **AC-07**: C++ workflow can detect, configure, build, statically analyze, test, debug, fix, review, re-verify a fixture project.
|
||||
37. **AC-08**: Failed build/test/debug commands produce diagnostics/artifacts/evidence refs and can trigger Debugger repair.
|
||||
38. **AC-09**: ContextAssembler produces Anthropic canonical messages with omissions where needed.
|
||||
39. **AC-10**: Provider adapter path can perform model calls under capability validation and conversion reporting.
|
||||
40. **AC-11**: Capability manifests can be loaded, validated, enabled, registered as namespaced tools.
|
||||
41. **AC-12**: Doctor reports platform/provider/toolchain/capability/display/network status and supports permissioned fix mode.
|
||||
42. **AC-13**: Release gate commands are documented and runnable on tier-1 Linux.
|
||||
|
||||
---
|
||||
|
||||
## CT (Constraints) — 16条
|
||||
|
||||
### 来源: requirements.md §5 + baselineV1.md §3-§5
|
||||
|
||||
43. **CT-01** (requirements.md §5): Runtime: TypeScript on Bun.
|
||||
44. **CT-02** (requirements.md §5): Monorepo: Bun workspaces + Turborepo.
|
||||
45. **CT-03** (requirements.md §5): TUI: OpenTUI/Solid.
|
||||
46. **CT-04** (requirements.md §5): IPC: NDJSON over stdio.
|
||||
47. **CT-05** (requirements.md §5): DB: SQLite per session with WAL/NORMAL/foreign_keys OFF.
|
||||
48. **CT-06** (requirements.md §5): Internal message format: Anthropic canonical content blocks.
|
||||
49. **CT-07** (requirements.md §5): C++ is first deep toolchain; runtime remains language-agnostic.
|
||||
50. **CT-08** (requirements.md §5): Python is subprocess-only helper layer, not core runtime.
|
||||
51. **CT-09** (requirements.md §5): Early distribution uses binary tarball, not public package channels.
|
||||
52. **CT-10** (requirements.md §5): Architecture docs and workflow state live under `AirPlan/`.
|
||||
53. **CT-11** (baselineV1 §3-§4): Monorepo packages (Alpha) — contracts, cli, tui, runtime, llm, toolchain-cpp.
|
||||
54. **CT-12** (baselineV1 §4): Dependency direction — contracts(no deps) → cli → tui/runtime/llm/toolchain-cpp; runtime → contracts + llm facade + toolchain via registry; tui → contracts only; runtime must not depend on tui.
|
||||
55. **CT-13** (baselineV1 §5): Global user directory — `~/.air/`.
|
||||
56. **CT-14** (baselineV1 §5): project_id is stable UUID in `.air/shared/project.json`, not derived from absolute path.
|
||||
57. **CT-15** (baselineV1 §5): `.gitignore`: `.air/local/`.
|
||||
58. **CT-16** (baselineV1 + solution-arch): All side effects must pass through ToolRegistry and PermissionEngine.
|
||||
|
||||
---
|
||||
|
||||
## RB (Reference Baselines) — 6条
|
||||
|
||||
### 来源: baselineV1.md §2
|
||||
|
||||
59. **RB-01** (baselineV1 §2): Claude Code CLI — Primary reference for execution-layer quality. Reference areas: file read/edit/write safety, exact conservative diff/update, patch granularity, tool lifecycle, permission checks, read-before-edit, small-step edits, no unrelated refactors, verification-before-completion, build/test/debug evidence, root-cause failure handling, blocker escalation, TAOR/TORI feedback loops.
|
||||
|
||||
60. **RB-02** (baselineV1 §2): OpenCode — Reference for runtime layering, TUI visual style/interaction, session/event/sync concepts, provider/model abstraction, plugin/SDK ideas. **Reuse OpenTUI primitives. Do NOT reuse SDK/sync/session business state.**
|
||||
|
||||
61. **RB-03** (baselineV1 §2): Hermes Agent — Reference for experience mining, Nudge Engine interval-triggered learning, Curator daemon, skill self-patching, SKILL.md format, FTS retrieval.
|
||||
|
||||
62. **RB-04** (baselineV1 §2): OpenAI Codex — Reference for shell/patch/test direct execution loop, coding sandbox, tool orchestration, MCP implementation ideas.
|
||||
|
||||
63. **RB-05** (baselineV1 §2): Anthropic Claude Skills — Reference for SKILL.md structure/frontmatter, skill directory layout (scripts/references/assets), reusable workflow packaging.
|
||||
|
||||
64. **RB-06** (baselineV1 §2): asciinema / Atuin / claude-hud — Reference for PTY capture/terminal replay, command metadata/history indexing, HUD/statusline layout and activity display.
|
||||
|
||||
---
|
||||
|
||||
## PV (V1 Plugin Prototypes) — 8个已生产验证的插件工作流
|
||||
|
||||
### 来源: air-suite-20260518 + airplanV2-Qwen3.7-Max设计.md §1.2
|
||||
|
||||
> **核心架构原则**: Agent (MainAgent/Scheduler/Worker) 存在的目的是扩展插件的能力边界。**插件代表的工作流才是产品核心**。AirCoding V1.0.0 Alpha 是V1 8个插件从 Claude Code Skill 到 TypeScript 运行时的移植重构——不是从零开发,是给已验证的工作流换一个可靠的运行时底座。
|
||||
|
||||
### 8个V1插件 → AirCoding移植映射
|
||||
|
||||
| # | V1插件 | 目录 | 工作流 | AirCoding模块 | 移植状态 |
|
||||
|---|--------|------|--------|--------------|----------|
|
||||
| 1 | **AirArc** | `airplan-mkt/airarc/` | 架构规划设计器: 需求探讨→架构确认→生成规划 | `ArchitectureDesigner` | ❌ 正则替代LLM |
|
||||
| 2 | **AirEng** | `airplan-mkt/aireng/` | 调度引擎: 波次规划→Dispatch→Monitor→Merge→Repair | `Scheduler` | ⚠️ 基础可调度 |
|
||||
| 3 | **AirDo** | `airplan-mkt/airdo/` | 任务执行器: 接收TaskSpec→调用工具→验收→返回结果 | `ExecutorRole` | ⚠️ 简单任务可跑 |
|
||||
| 4 | **AirDbg** | `airplan-mkt/airdbg/` | 调试器: 确认症状→取证→定位根因→修复→验证→关闭 | `DebuggerRole` | ❌ 从未触发 |
|
||||
| 5 | **AirXDB** | `airplan-mkt/airxdb/` | GUI验证: 截图取证→diff对比→headless CI | `gui.screenshot` | ❌ 仅ImageMagick |
|
||||
| 6 | **AirNDB** | `airplan-mkt/airndb/` | 网络调试: 抓包→分析→TLS解密 | `network.capture` | ⚠️ tcpdump封装 |
|
||||
| 7 | **AirSDB** | `airplan-mkt/airsdb/` | 静态分析: cppcheck/clang-tidy→diff→多语言 | `toolchain-cpp` | ❌ 仅cppcheck注册 |
|
||||
| 8 | **AirContext** | `aircontext-mkt/` | 上下文管理: 压缩→token估算→stale lock检测 | `ContextAssembler`+`CompactorRole` | ⚠️ 基础实现 |
|
||||
|
||||
### V1已验证能力 → AirCoding丢失清单
|
||||
|
||||
| V1能力 | 来源缺陷 | AirCoding |
|
||||
|---------|----------|-----------|
|
||||
| 架构变更级联失效(ADR→Task失效→冻结→回滚→重规划) | P1-21, V2I-23 | ⚠️ 方法全实现, 零生产调用 |
|
||||
| 证据优先门控(不取证不许改代码) | P1-17, V2I-30 | ❌ |
|
||||
| 7步调试工作流强制(finish_worker 的 forced AirDbg routing) | P0-8, V2I-13, V2I-28 | ❌ |
|
||||
| Plan mode 阻断(架构器永不写代码) | P0-5, V2I-09 | ❌ |
|
||||
| 自主调度+中文锁定(不停下来问, 自动推进) | P0-6, P0-7, V2I-10, V2I-11 | ❌ |
|
||||
| 任务类型感知证据门控(GUI/Network/CodeOnly分类) | P0-1, V2I-04 | ❌ |
|
||||
| Worker超时+资源保护(7200s硬上限, load检测) | P1-10, V2I-07 | ⚠️ AgentMonitor基础 |
|
||||
| 修复回滚(pre_fix_snapshot, git revert修复) | V2I-29 | ✅ _create_rollback_snapshot |
|
||||
| 非原子写入保护(tempfile+os.replace) | P0-3 | ✅ ArtifactStore |
|
||||
| 并发控制(flock替代无锁读改写) | P0-4 | ✅ SQLite事务 |
|
||||
| Dispatch→Worker桥接(spawn_workers标准化,消除Agent回退) | P1-22, V2I-16 | ⚠️ WorkerManager可用 |
|
||||
|
||||
---
|
||||
|
||||
## AP (Architecture Principles) — 189条 (关键摘录)
|
||||
|
||||
### 来源: baselineV1.md + solution-architecture.md + system-overview-design.md + system-detailed-design.md
|
||||
|
||||
> 完整189条AP参见 `/home/airlongdian/DataDevices/AirWorkSpace/AirCoding/AirPlan/docs/analysis/requirements-audit-report.md`
|
||||
|
||||
### 核心架构原则 (baselineV1)
|
||||
|
||||
65. **AP-01**: AirCoding is a self-owned AI coding agent/runtime, not a Claude Code plugin wrapper.
|
||||
66. **AP-02**: Runtime is language-agnostic; C++ is first deep language profile.
|
||||
67. **AP-03**: Core loop: requirement → architecture design → code reading → implementation planning → build → static analysis → test → run/debug → evidence → fix → summary → experience mining.
|
||||
|
||||
### 执行质量基准 (solution-architecture §3)
|
||||
|
||||
68. **AP-45**: Execution quality follows Claude Code — read-before-edit, exact, conservative, small, verified before completion.
|
||||
69. **AP-46**: OpenCode is UI/runtime reference, not business-state dependency.
|
||||
70. **AP-47**: Project-local source of truth under `.air/`.
|
||||
71. **AP-48**: Events drive live behavior; SQLite drives recovery.
|
||||
72. **AP-49**: Workers are isolated child processes over NDJSON IPC.
|
||||
73. **AP-50**: Main Agent remains responsive; background work delegated to Scheduler.
|
||||
74. **AP-51**: Architecture changes are explicit — implementation-level continues silently.
|
||||
75. **AP-52**: Tool/capability boundaries are permissioned through ToolRegistry+PermissionEngine.
|
||||
76. **AP-53**: Provider boundary isolated — internal Anthropic canonical; adapters convert at boundary.
|
||||
77. **AP-54**: Evidence first-class — build/test/debug/review outputs become artifacts/evidence before completion.
|
||||
|
||||
### 容器职责 (solution-architecture §4)
|
||||
|
||||
78. **AP-55**: CLI: command entrypoint, startup, Doctor, project discovery, TUI/runtime bootstrap.
|
||||
79. **AP-56**: TUI/HUD: consumes ProjectionStore only, no SQLite/EventBus queries.
|
||||
80. **AP-57**: Runtime: MainAgent, ArchitectureDesigner, Scheduler, child process mgmt, EventBus/EventStore, SessionStore, ToolRegistry, PermissionEngine, CapabilityRegistry, ContextAssembler, ArtifactStore, EvidenceStore.
|
||||
81. **AP-58**: LLM: provider config, adapters, Anthropic canonical handling, conversion, capability matrix.
|
||||
82. **AP-59**: Toolchain C++: project detection, CMake, Ninja/Make, CTest, cppcheck, clangd, diagnostic parsing.
|
||||
83. **AP-60**: Contracts: compileable shared TS interfaces, no domain implementation deps.
|
||||
|
||||
### 禁止路径 (system-overview §5)
|
||||
|
||||
84. **AP-85**: Forbidden: TUI→SQLite, TUI→runtime private, Worker→SQLite, Worker→direct fs/shell/network, tool→no PermissionEngine, capability→install outside Doctor, provider→silent semantic loss, repository→scheduling policy, EventBus→recovery source, runtime→TUI import, LLM output→direct file/shell.
|
||||
|
||||
### 控制流 (solution-architecture §7)
|
||||
|
||||
85. **AP-71**: Startup: CLI→detect→load→open/init .air→read-only Doctor→open session DB→hydrate ProjectionStore→start TUI/Main Agent.
|
||||
86. **AP-72**: Normal execution: user→Main Agent classify→answer or plan→Scheduler create/load TaskGraph→ContextAssembler→dispatch Worker→tools→PermissionEngine→WorkerResult→retry/merge/review→report.
|
||||
87. **AP-73**: Requirement change: requirement.changed→Scheduler pause→Architecture Designer assess→silent continue or confirm/replan.
|
||||
88. **AP-74**: Recovery: restart→open DB→load tasks/agents→check liveness→emit lost/failed or resume→preserve workspaces→rebuild queues→hydrate ProjectionStore.
|
||||
|
||||
### 数据架构 (solution-architecture §6)
|
||||
|
||||
89. **AP-69**: SQLite: WAL/NORMAL/foreign_keys OFF.
|
||||
90. **AP-88**: Durable event insert + domain update in same SQLite transaction.
|
||||
91. **AP-91**: Event flow: Producer→EventIngestor→validate→durable: EventStore transaction+projection+EventBus publish; ephemeral: EventBus publish.
|
||||
|
||||
### 安全 (solution-architecture §10, system-overview §12)
|
||||
|
||||
92. **AP-79**: Security boundaries — LLM output untrusted; tools only path to effects; symlinks resolved by realpath; .git/ protected; project-outside writes require backup; credentials require confirmation; no auto-upload.
|
||||
93. **AP-104**: Permission evaluation order: tool capability → permission profile → TaskSpec scope → path/command/network risk → credential/system-sensitive → user prompt.
|
||||
94. **AP-105**: Permission actions: allow, deny, ask_user, block, refuse, announce_then_run.
|
||||
95. **AP-106**: Path risk categories (8): project_source, project_build_output, project_air_shared, project_air_local, project_git_internal, outside_project, credential_or_secret, system_sensitive.
|
||||
96. **AP-107**: Command risk categories (10): read_only, build, test, static_analysis, git_read, git_write, destructive, network, system_sensitive, credential_sensitive.
|
||||
|
||||
### 上下文/压缩 (system-overview §13)
|
||||
|
||||
97. **AP-109**: Compaction: ContextAssembler may request; Scheduler creates compact task; Compactor snapshots messages; summary.created; original messages preserved.
|
||||
98. **AP-158**: ContextAssembler assembles Anthropic-canonical context; fits to token_budget; reports omissions; sets compaction_requested if budget cannot fit required layers.
|
||||
99. **AP-77**: L0-L9 layers: runtime invariant, role/mode, safety/permission, project rules, architecture, task spec, evidence, conversation, tool history, instruction.
|
||||
|
||||
### Worker/IPC (system-detailed-design §8)
|
||||
|
||||
100. **AP-148**: WorkerManager spawn starts Bun child process then handshake; WorkerProcess owns NDJSON pipe.
|
||||
101. **AP-150**: Worker roles: ExecutorRole (scoped write), ReviewerRole (read-only), DebuggerRole (scoped write assigned), CompactorRole (summaries/artifacts only), ExperienceMinerRole (candidates/rules/skills assigned).
|
||||
102. **AP-151**: TaskType→WorkerRole: execute→Executor, review→Reviewer, debug→Debugger, compact→Compactor, mine_experience→ExperienceMiner, docs→Executor.
|
||||
103. **AP-103**: Workers never write SQLite directly; never perform side effects outside parent-mediated tools.
|
||||
|
||||
### 调度器 (system-detailed-design §7)
|
||||
|
||||
104. **AP-143**: Scheduler states: IDLE→LOADING_GRAPH→PLANNING_WAVE→DISPATCHING→MONITORING→COLLECTING_RESULTS→MERGING→REVIEWING_WAVE→REPAIRING_OR_CONTINUING. Terminals: COMPLETED, BLOCKED, CANCELLED.
|
||||
105. **AP-144**: TaskGraph: get_runnable_tasks honors hard deps completed, soft deps priority, conflict/serialization block concurrent dispatch on overlapping write areas.
|
||||
106. **AP-146**: RetryPlanner actions: retry, retry_serial, debug, skip, block, cancel.
|
||||
107. **AP-147**: WorkspaceManager strategies: main (no merge), worktree (git merge/patch), isolated_copy (copy-back/patch).
|
||||
|
||||
### 可追溯性 (system-detailed-design §24)
|
||||
|
||||
108. **AP-188**: System Detailed Design frozen as of 2026-06-01; multi-model review complete across 7 review rounds; all P0/P1/P2 findings closed; coverage: contracts 100%, events 100%, DB schema 100%, state machines 100%, forbidden edges 100%.
|
||||
|
||||
### 不变量 (INV-1 ~ INV-5)
|
||||
|
||||
109. **INV-1**: Session-DB state columns written only by event projection; no direct UPDATE from services.
|
||||
110. **INV-2**: Cross-DB/external writes use outbox model; EventStore.project() never opens external DBs or files.
|
||||
111. **INV-3**: All side effects only through tool + permission path (ToolRegistry.call → PermissionEngine.evaluate).
|
||||
112. **INV-4**: Import/dependency direction is one-way per allowed graph; never crossed.
|
||||
113. **INV-5**: EventBus is transport, never source of truth; recovery rebuilds from SQLite.
|
||||
|
||||
### 参考复用 (system-detailed-design §23)
|
||||
|
||||
114. **AP-185**: Reference reuse modes — npm-dep (consume directly), fork/adapt (copy+adapt), pattern (reference structure), behavioral (match behavior/quality).
|
||||
115. **AP-186**: Reference map — OpenTUI: npm-dep; OpenCode TUI: pattern only; @opencode-ai/llm: fork/adapt; Claude Code CLI: behavioral only; OpenAI Codex: pattern; Hermes Agent: pattern; Anthropic Skills: pattern; asciinema/Atuin/claude-hud: pattern.
|
||||
116. **AP-187**: Reference reuse rules — npm-dep items never re-implemented; fork/adapt items preserve own contracts/invariants; behavioral items contribute no code.
|
||||
|
||||
---
|
||||
|
||||
## DF (Defect Fixes from AirPlan V2) — 33条
|
||||
|
||||
### 来源: airplanV2-Qwen3.7-Max设计.md §1.1
|
||||
|
||||
### P0 — 已造成实际损失 (10条)
|
||||
|
||||
117. **P0-1**: AirXDB false positive blocking — evidence gate no task-type awareness; 11+ tasks.
|
||||
118. **P0-2**: Deployment verification gap — validate_for_finalize() structural-only.
|
||||
119. **P0-3**: Non-atomic writes — 5 _json_dump sites use direct path.write_text().
|
||||
120. **P0-4**: Zero concurrency control — todo.md read-modify-write race.
|
||||
121. **P0-5**: AirArc hijacked by plan mode.
|
||||
122. **P0-6**: AirEng stops to ask instead of autonomous decisions.
|
||||
123. **P0-7**: AirEng no child-thread status polling — relies on Agent self-discipline.
|
||||
124. **P0-8**: AirDo does not call AirDbg — skips debug, directly reports blocked/false-done.
|
||||
125. **P0-9**: Installer script path errors.
|
||||
126. **P0-10**: AirEng deviates from scheduling to write code.
|
||||
|
||||
### P1 — 限制可靠性与可维护性 (14条)
|
||||
|
||||
127. **P1-1**: Hardcoded developer paths (debug_runtime.py:130, airxdb_runtime.py:156).
|
||||
128. **P1-2**: `_json_dump`/`_json_load` duplicated 5 times.
|
||||
129. **P1-3**: `_ordered_unique` duplicated 4 times.
|
||||
130. **P1-4**: policy normalization duplicated 3 times.
|
||||
131. **P1-5**: merge-into-state duplicated 3 times.
|
||||
132. **P1-6**: marker block upsert duplicated 2 times with different interfaces.
|
||||
133. **P1-7**: `_session_stamp` format inconsistent.
|
||||
134. **P1-8**: todo.md column index hardcoded (doc_sync.py:154-156).
|
||||
135. **P1-9**: Concurrency cap hardcoded as 3 (engine.py:527).
|
||||
136. **P1-10**: Child processes have no timeout in airxdb/debug runtime.
|
||||
137. **P1-11**: task_id path injection at worker.py:59 — no `../` validation.
|
||||
138. **P1-12**: Marker injection risk in doc_sync.py `_replace_marker_block()`.
|
||||
139. **P1-13**: Silent exception swallowing — session file corruption continue with no log.
|
||||
140. **P1-14**: Arc re-planning then Eng cannot connect — static todo.md table cannot absorb dynamic replanning.
|
||||
141. **P1-15**: Same-file non-conflicting tasks forced serial — file-level conflict detection.
|
||||
142. **P1-16**: AirArc skips requirements discussion, directly generates plan.
|
||||
143. **P1-17**: AirDbg modifies code without evidence collection.
|
||||
144. **P1-18**: Project lacks standardized logging (no spdlog).
|
||||
145. **P1-19**: No boundary tests + final review lacks high-risk checks.
|
||||
146. **P1-20**: UI design lacks professional Skill support.
|
||||
147. **P1-21**: ADR changes have no cascading invalidation mechanism.
|
||||
148. **P1-22**: Dispatch→Worker launch has no bridge — dispatch_worker_group() writes JSON, no Worker launch.
|
||||
149. **P1-23**: Dispatch instruction ambiguity — commands/eng.md intent description, not pseudocode.
|
||||
150. **P1-24**: Merge then TaskGraph state out of sync — merge_worker_result() doesn't update task-graph.json.
|
||||
|
||||
### P2 — 限制规模化 (4条)
|
||||
|
||||
151. **P2-1**: Conflict detection O(n²) — review.py combinations(active_tasks, 2).
|
||||
152. **P2-2**: state.json unbounded growth — mergedResults never truncated.
|
||||
153. **P2-3**: todo.md full re-parse on every operation.
|
||||
154. **P2-4**: Zero test coverage — entire air_runtime/.
|
||||
|
||||
### P3 — 限制用户体验 (5条)
|
||||
|
||||
155. **P3-1**: AGENTS.md bloat — AirEng sync appends without dedup.
|
||||
156. **P3-2**: Write-set rigidity causes cascading task chains.
|
||||
157. **P3-3**: Parallel Workers compete for shared hardware — no awareness.
|
||||
158. **P3-4**: Environment-specific fixes not persistable.
|
||||
159. **P3-5**: Cross-project knowledge not transferred.
|
||||
|
||||
---
|
||||
|
||||
## V2I (V2 Improvements) — 40条
|
||||
|
||||
### 来源: airplanV2-Qwen3.7-Max设计.md §3
|
||||
|
||||
160. **V2I-01** (§3.1.1): `air_runtime.io` — atomic_json_write (tempfile+os.replace), safe_json_load.
|
||||
161. **V2I-02** (§3.1.2): `air_runtime.lock` — FileLock based on fcntl.flock with timeout.
|
||||
162. **V2I-03** (§3.1.3): `air_runtime.utils` — ordered_unique, session_stamp, normalize_policy, sanitize.
|
||||
163. **V2I-04** (§3.2.1): EvidenceGatePolicy — task-type-aware (GUI_INDICATORS, NETWORK_INDICATORS).
|
||||
164. **V2I-05** (§3.2.2): Deploy verification enforcement in WorkerResult.validate_for_finalize.
|
||||
165. **V2I-06** (§3.2.3): AdaptivePoller — dynamic intervals (min 30s, max 300s).
|
||||
166. **V2I-07** (§3.2.4): Worker timeout (WORKER_MAX_WALL_TIME=7200s) + resource protection.
|
||||
167. **V2I-08** (§3.2.5): Merge transactionization with FileLock.
|
||||
168. **V2I-09** (§3.2.6): AirArc plan mode blocking — allowed_tools: [Read, Glob, Grep]; deny_plan_mode.
|
||||
169. **V2I-10** (§3.2.7): AirEng autonomous decision + Chinese lock.
|
||||
170. **V2I-11** (§3.2.8): AirEng hardcoded polling loop — mandatory 5-minute cycle.
|
||||
171. **V2I-12** (§3.2.8b): AirEng scheduling boundary — EXTREME_TAKEOVER only when budget exhausted + ≤5 lines.
|
||||
172. **V2I-13** (§3.2.9): AirDo mandatory AirDbg routing (forced=true).
|
||||
173. **V2I-14** (§3.2.10): Installer path correction — absolute paths + post_install_verify.
|
||||
174. **V2I-15** (§3.2.11): Dynamic graph scheduling (TaskGraph+PlanDelta) — **已在AirCoding实现**.
|
||||
175. **V2I-16** (§3.2.11b): Dispatch→Worker launch bridge — spawn_workers standardized.
|
||||
176. **V2I-17** (§3.2.11c): Merge→TaskGraph state sync — task-graph.json node status is authoritative.
|
||||
177. **V2I-18** (§3.2.12): Worktree isolation for same-file different-region parallelism.
|
||||
178. **V2I-19** (§3.2.13): AirArc requirements discussion gate — three-phase process.
|
||||
179. **V2I-20** (§3.2.14): Project-level spdlog logging standard.
|
||||
180. **V2I-21** (§3.2.15): Boundary test enforcement + final review high-risk audit.
|
||||
181. **V2I-22** (§3.2.16): frontend-design Skill integration.
|
||||
182. **V2I-23** (§3.2.17): ADR change cascading invalidation — **已在AirCoding实现方法,待生产接线**.
|
||||
183. **V2I-24** (§3.3.1): Compression quality validation — **已在AirCoding实现CompressionValidator**.
|
||||
184. **V2I-25** (§3.3.2): Token estimation improvement — AdaptiveTokenEstimator.
|
||||
185. **V2I-26** (§3.3.3): Stale lock detection.
|
||||
186. **V2I-27** (§3.4): AirSDB multi-language static analysis.
|
||||
187. **V2I-28** (§3.5.1): AirDbg workflow enforcement — 7 mandatory steps.
|
||||
188. **V2I-29** (§3.5.2): Fix rollback — pre_fix_snapshot.
|
||||
189. **V2I-30** (§3.5.3): Evidence-first gate.
|
||||
190. **V2I-31** (§3.6.1): AirXDB DRM/KMS native screenshot.
|
||||
191. **V2I-32** (§3.6.2): AirXDB headless CI XvfbCapture.
|
||||
192. **V2I-33** (§3.7.1): AirDep deployment plugin.
|
||||
193. **V2I-34** (§3.7.2): AirTst test runner plugin.
|
||||
194. **V2I-35** (§3.7.3): AirSec security scan plugin.
|
||||
195. **V2I-36** (§3.7.4): AirRvr requirements reviewer plugin.
|
||||
196. **V2I-37** (§3.7.4): Code-to-Design consistency review (mandatory line-level comparison every review).
|
||||
197. **V2I-38** (§3.7.4): AirRvr AirEng integration — verdict=pass/conditional-pass/fail.
|
||||
198. **V2I-39** (§3.7.4): Event index layer — EventLog as structured JSONL timeline.
|
||||
199. **V2I-40** (§3.8): air_runtime module reorganization — io.py, lock.py, utils.py, events.py, task_graph.py, etc.
|
||||
|
||||
---
|
||||
|
||||
## V2 Design Goals, Invariants, KPIs
|
||||
|
||||
### 来源: airplanV2-Qwen3.7-Max设计.md §2, §7
|
||||
|
||||
### V2 Goals
|
||||
200. Reliability — state writes not lost, concurrent ops race-free, self-healing after crash.
|
||||
201. Observability — all engine operations traceable, metrics exportable.
|
||||
202. Intelligence — evidence gating perceives task type, polling adaptive.
|
||||
203. Scale — support 100+ tasks, 5+ parallel Workers.
|
||||
|
||||
### V2 Invariants
|
||||
204. INV-1: Artifact-driven communication through AirPlan/ files; V2 adds event index layer.
|
||||
205. INV-2: Context isolation (fork_context=false); V2 adds selective context inheritance.
|
||||
206. INV-3: Architecture sync mandatory — cannot DONE without updating architecture docs.
|
||||
207. INV-4: Evidence before repair — screenshot/packet-capture/static-analysis first.
|
||||
208. INV-5: Closed-loop auto-repair — execute→fail→debug→fix→re-execute.
|
||||
|
||||
### V2 KPIs (26个)
|
||||
209. AirXDB false positive: V1 ~60% → V2 <5%
|
||||
210. State file corruption: V1 known → V2 0%
|
||||
211. Deployment consistency incidents: V1 1 critical → V2 0
|
||||
212. Hollow fix cycles: V1 11+ → V2 0
|
||||
213. Code duplication: V1 5 copies → V2 1 per function
|
||||
214. Test coverage: V1 0% → V2 core >80%
|
||||
215. AirArc plan mode hijack: V1 frequent → V2 0
|
||||
216. AirArc skip requirements: V1 every launch → V2 0
|
||||
217. AirEng non-Chinese output: V1 frequent → V2 0
|
||||
218. AirDo skips AirDbg: V1 frequent → V2 0
|
||||
219. AirDbg modifies code without evidence: V1 frequent → V2 0
|
||||
220. Boundary without test coverage: V1 all → V2 100%
|
||||
221. Final review missing high-risk: V1 none → V2 100%
|
||||
222. UI tasks without Skill: V1 all → V2 100%
|
||||
223. ADR change old code residue: V1 none → V2 0 (cascade+git revert)
|
||||
224. Dispatch→Worker broken: V1 Agent stops → V2 0 (spawn_workers + instruction ops)
|
||||
225. Post-merge duplicate dispatch: V1 redispatched → V2 0 (task-graph.json sync)
|
||||
|
||||
---
|
||||
|
||||
## V2 Phase Plan
|
||||
|
||||
### 来源: airplanV2-Qwen3.7-Max设计.md §4
|
||||
|
||||
226. **V2-Phase1** (P0 fixes): atomic I/O, file locks, utils dedup, EvidenceGatePolicy, deploy verify, hardcoded paths, child timeouts, injection protection, exception handling, Arc plan-mode blocking, Eng Chinese+autonomous, Eng polling, Do→Dbg forced routing, installer path fix, Arc requirements gate, Dbg evidence-first gate, spdlog standard, Eng boundary, boundary tests+highRiskAudit, frontend-design Skill, dispatch bridge, merge TaskGraph sync.
|
||||
|
||||
227. **V2-Phase2** (Engine enhancement): AdaptivePoller, Worker timeout+resource, merge transactionization, AGENTS.md dedup, EventLog, todo column derivation, configurable concurrency, state.json cap, TaskGraph+PlanDelta, region conflict+worktree, ADR cascading invalidation.
|
||||
|
||||
228. **V2-Phase3** (New plugins): AirDep, AirTst, AirSDB multi-lang, AirXDB kmsgrab+xvfb, AirDbg step tracking+rollback, AirRvr, AirSec.
|
||||
|
||||
229. **V2-Phase4** (Scale): Conflict detection O(n log n), todo.md cache, compression validation, token estimation, stale lock, AirArc incremental replanning, cross-project ops template.
|
||||
|
||||
230. **V2-Phase5** (Test coverage): todo_parser, review, doc_sync, contracts, engine, io, lock, evidence_gate, task_graph, worktree.
|
||||
|
||||
---
|
||||
|
||||
## 总结
|
||||
|
||||
### 设计文档统计
|
||||
|
||||
| 类别 | 数量 |
|
||||
|------|------|
|
||||
| FR | 21 + 7子要求 |
|
||||
| NFR | 8 |
|
||||
| AC | 13 |
|
||||
| CT | 16 |
|
||||
| RB | 6 |
|
||||
| **PV (V1插件原型)** | **8** |
|
||||
| AP (含INV) | 194 |
|
||||
| DF (P0-P3) | 33 |
|
||||
| V2I | 40 |
|
||||
| V2 Goals/Invariants/KPIs | 35 |
|
||||
| Phase items | 5 |
|
||||
| **总计** | **391** |
|
||||
|
||||
### 架构核心原则
|
||||
|
||||
**Agent 存在的目的是扩展插件的能力边界。插件代表的工作流才是产品核心。**
|
||||
|
||||
AirCoding V1.0.0 Alpha 不是从零开发的新产品,而是将 8 个已验证的 Python/Claude Code Skill 插件移植到 TypeScript/Bun/SQLite 运行时。Agent (MainAgent/Scheduler/Worker) 是基础设施底座,8个插件工作流(AirArc/AirEng/AirDo/AirDbg/AirXDB/AirNDB/AirSDB/AirContext)才是交付给用户的价值。
|
||||
|
||||
### V1插件 → AirCoding 移植完整度 (8个核心工作流)
|
||||
|
||||
| V1插件 | AirCoding模块 | 工作流可运行? | 缺失 |
|
||||
|--------|--------------|-------------|------|
|
||||
| AirArc | ArchitectureDesigner | ❌ | 正则替代LLM, 无三步流程, 无PlanMode阻断 |
|
||||
| AirEng | Scheduler | ❌ | 基础调度可跑, 无级联保护/自主决策/硬编码轮询 |
|
||||
| AirDo | ExecutorRole | ⚠️ | 简单任务可跑, 不强制调AirDbg |
|
||||
| AirDbg | DebuggerRole | ❌ | 从未触发, 7步工作流仅在提示词中 |
|
||||
| AirXDB | gui.screenshot | ❌ | 仅ImageMagick, 无headless/diff |
|
||||
| AirNDB | network.capture | ⚠️ | 仅tcpdump封装, 不产artifact |
|
||||
| AirSDB | toolchain-cpp | ❌ | 仅cppcheck注册, 无build管道 |
|
||||
| AirContext | ContextAssembler+Compactor | ⚠️ | 基础可组装, CompactorRole未运行 |
|
||||
| **总体** | — | **0/8 可交付** | **8/8 需要工作流级别的移植** |
|
||||
|
||||
### 产品差距 — V1已验证能力丢失
|
||||
|
||||
407h的产出集中在了基础设施层(EventStore/Scheduler/ToolRegistry/SQLite),但8个V1已生产验证的插件工作流没有一个被完整移植。原因是开发从未以"插件工作流逐条移植"为目标,而是在造一个通用的Agent运行时——然后假设插件工作流"自然会跑在上面"。
|
||||
|
||||
**正确的开发顺序**: 先移植插件工作流(AirArc→ArchitectureDesigner, AirEng→Scheduler, AirDo→ExecutorRole...),每移植一个就端到端验证一个。基础设施随工作流需求演进,而非反过来先造全套基础设施再填工作流。
|
||||
|
||||
**核心结论**: 当前AirCoding产品不可发布。0/8 V1插件工作流可运行。397h的产出是一个Agent基础设施demo,不是符合6份设计文档391条要求的V1.0.0 Alpha产品。
|
||||
347
AirPlan/docs/analysis/requirements-audit-report.md
Executable file
347
AirPlan/docs/analysis/requirements-audit-report.md
Executable file
@@ -0,0 +1,347 @@
|
||||
# AirCoding V1.0.0 Alpha — 完整需求清单与差距报告
|
||||
|
||||
**生成日期**: 2026-06-11
|
||||
**状态**: Fable5 主模型终审 + deepseek-v4-pro 全文提取
|
||||
**来源文档**:
|
||||
1. `requirements.md` — 21条FR + 8条NFR + 13条AC + 10条CT
|
||||
2. `airplanV2-Qwen3.7-Max设计.md` — 25个P0-P3缺陷 + 40个V2改进 + 26个KPI
|
||||
3. `baselineV1.md` — 5个参考项目基准 + 44条架构原则
|
||||
4. `solution-architecture.md` — 10项架构原则 + 6个容器 + 4个控制流 + 安全模型
|
||||
5. `system-overview-design.md` — 18节系统概览设计
|
||||
6. `system-detailed-design.md` — 24节详细类方法设计 + 序列 + 状态机 + 可追溯矩阵
|
||||
|
||||
---
|
||||
|
||||
## 一、参考项目基准 (RB-01 ~ RB-06)
|
||||
|
||||
| ID | 参考项目 | 要求复用的内容 |
|
||||
|----|----------|---------------|
|
||||
| RB-01 | **Claude Code CLI** | 执行层质量基准: 精确编辑、读后编辑、小块补丁、不重构无关代码、验证后完成、证据闭环、TAOR/TORI反馈循环 |
|
||||
| RB-02 | **OpenCode** | TUI视觉风格/交互布局、运行时分层、Session/事件/同步概念、Provider/模型抽象、插件/SDK思路。**复用OpenTUI原语,不复用SDK/sync/session业务逻辑** |
|
||||
| RB-03 | **Hermes Agent** | 经验挖掘、Nudge Engine间隔触发学习、Curator守护进程、Skill自修复、SKILL.md格式、FTS检索 |
|
||||
| RB-04 | **OpenAI Codex** | Shell/patch/test直接执行循环、编码沙箱、工具编排、MCP实现思路 |
|
||||
| RB-05 | **Anthropic Skills** | SKILL.md结构/前置元数据、技能目录布局(scripts/references/assets)、可复用工作流打包 |
|
||||
| RB-06 | **asciinema/Atuin/claude-hud** | PTY捕获和终端回放、命令元数据/历史索引、HUD/状态栏布局 |
|
||||
|
||||
---
|
||||
|
||||
## 二、功能需求 (FR-001 ~ FR-020 + FR-007.5)
|
||||
|
||||
### FR-001 CLI启动与项目初始化
|
||||
从CLI入口启动,检测/打开项目,需要时初始化`.air/`,加载资源/配置,运行只读Doctor,打开session。
|
||||
|
||||
### FR-002 项目本地状态
|
||||
`.air/shared/`(可共享配置/规则/计划) + `.air/local/`(私有sessions/artifacts/workspaces/backups/local DBs)
|
||||
|
||||
### FR-003 会话持久化
|
||||
SQLite at `<project>/.air/local/sessions/<session-id>/session.db`, 支持: messages, drafts, durable events, task graph state, agents, tool/command runs, artifacts, diagnostics, evidence refs, workspaces, summaries, UI state
|
||||
|
||||
### FR-004 事件驱动运行时
|
||||
发布RuntimeEvents用于实时行为,持久事件与域表更新在同一个事务中
|
||||
|
||||
### FR-005 主代理对话
|
||||
面向用户的Main Agent: 接收请求、适当直接回答、分类工作、显示进度、呈现阻断/确认
|
||||
|
||||
### FR-006 架构设计师
|
||||
架构/接口/产品级决策路由到Architecture Designer: 更新架构制品、产生影响评估
|
||||
|
||||
### FR-007 调度器与任务图
|
||||
调度TaskSpec: hard/soft依赖、写区冲突处理、重试预算、子Worker派发、心跳监控、合并协调、重启恢复
|
||||
|
||||
### FR-007.5 ADR级联失效与架构变更回滚 (7条子要求)
|
||||
1. 通过TaskNode.adr_refs溯源所有依赖该ADR的任务(含已完成)
|
||||
2. 级联失效: completed→invalidated, running→终止, pending→cancelled
|
||||
3. 冻结调度(dispatch_frozen),阻止新任务派发
|
||||
4. 创建git回滚快照(rollback_ref),支持revert旧方案代码
|
||||
5. 接收ArchitectureDesigner产出的PlanDelta增量重规划
|
||||
6. apply_delta吸收新任务后解冻调度
|
||||
7. 终审时检查INVALIDATED任务的旧代码是否已清理
|
||||
|
||||
### FR-008 独立Worker Agent
|
||||
Executor/Reviewer/Debugger/Compactor/ExperienceMiner作为独立Bun子进程,通过NDJSON IPC通信
|
||||
|
||||
### FR-009 Claude Code级执行原语
|
||||
强制: read-before-edit, exact conservative edits, small patches, no unrelated refactors, permission checks, verification-before-completion
|
||||
|
||||
### FR-010 ToolRegistry和内置工具
|
||||
Schema验证的工具: filesystem/shell/git/project scanning/完整C++ build/test/static-analysis/debug/GUI screenshot/network capture/artifacts/context assembly/permission requests/Doctor
|
||||
|
||||
### FR-011 权限与安全模型
|
||||
路径/命令/网络/凭证分类;强制权限配置;保护系统敏感和凭证操作;项目外写入备份;拒绝不安全请求
|
||||
|
||||
### FR-012 插件与能力基础
|
||||
Manifest加载/验证、启用/禁用配置、依赖声明、Doctor集成、命名空间工具注册、源/信任元数据、PermissionEngine强制。第三方注册/签名可延后,本地和内置capability打包必须可用
|
||||
|
||||
### FR-013 Provider层
|
||||
内部使用Anthropic canonical消息,通过适配器路由provider调用,能力矩阵验证,转换报告
|
||||
|
||||
### FR-014 上下文组装与压缩
|
||||
有序层组装prompt、适配token预算、记录遗漏、必要时copy-on-write压缩
|
||||
|
||||
### FR-015 制品与证据管理
|
||||
temp-file→atomic rename,记录URI/path/hash/metadata,通过evidence refs链接声明
|
||||
|
||||
### FR-016 TUI与HUD
|
||||
OpenTUI/Solid终端UI和HUD,**仅消费ProjectionStore,不查询原始DB/EventBus**
|
||||
|
||||
### FR-017 完整C++开发流程
|
||||
项目检测→构建系统评估→CMake configure→Ninja优先/Make回退→编译器/链接器诊断解析→clangd代码智能查询→cppcheck静态分析→CTest/GoogleTest执行→debug运行/日志解析→失败诊断→范围修复→审查→证据支持验证
|
||||
|
||||
### FR-018 Doctor
|
||||
启动时运行只读Doctor;报告环境/能力问题;在权限策略下支持修复模式
|
||||
|
||||
### FR-019 日志与诊断
|
||||
可读`air.log`,加密`air.developer.log`,默认7天保留
|
||||
|
||||
### FR-020 发布门禁
|
||||
定义tier-1 Linux发布门禁: 单元测试、集成fixture重放、真实LLM E2E、项目初始化、C++构建/测试流程、SQLite恢复、子IPC、TUI启动、制品/事件持久化
|
||||
|
||||
---
|
||||
|
||||
## 三、非功能需求 (NFR-001 ~ NFR-008)
|
||||
|
||||
| ID | 需求 |
|
||||
|----|------|
|
||||
| NFR-001 | 本地优先: 项目状态/制品/日志/调试知识保留在本地,除非用户显式导出/分享/上传 |
|
||||
| NFR-002 | 可恢复性: 从进程/session重启恢复,读取SQLite状态,检测丢失agents,保留workspaces,重建Scheduler队列 |
|
||||
| NFR-003 | 可扩展性: 通过`toolchain-*`包和能力清单添加语言/工具链支持 |
|
||||
| NFR-004 | Provider灵活性: 内部契约在Anthropic/OpenAI/OpenRouter/ollama/兼容端点保持稳定 |
|
||||
| NFR-005 | UI响应性: Main Agent和TUI在后台Worker运行时保持响应 |
|
||||
| NFR-006 | 证据驱动完成: 任务未获得build/test/debug/review证据或显式skipped-gate报告前不得标记完成 |
|
||||
| NFR-007 | Linux优先: Linux x86_64=tier1, arm64/WSL2=tier2, macOS=实验, Windows=post-MVP |
|
||||
| NFR-008 | 安全边界保持: LLM输出、工具结果、插件、外部内容在被运行时契约和策略验证前为不可信数据 |
|
||||
|
||||
---
|
||||
|
||||
## 四、验收标准 (AC-01 ~ AC-13)
|
||||
|
||||
1. CLI启动并初始化/打开项目`.air/`树
|
||||
2. Session DB schema初始化并持久化messages/events/tasks/tool runs/artifacts
|
||||
3. EventStore事务性地将核心持久事件应用到域表
|
||||
4. ProjectionStore水合并更新可用的TUI/HUD视图
|
||||
5. Scheduler通过NDJSON IPC派发Worker子进程,通过父runtime支持工具调用,接收WorkerResult
|
||||
6. ToolRegistry通过PermissionEngine执行filesystem/shell/git/artifact/context/doctor/C++/debug/GUI/network证据工具
|
||||
7. C++工作流可检测、配置、构建、静态分析、测试、调试、修复、审查、重新验证代表性fixture项目
|
||||
8. 失败的构建/测试/调试命令产生diagnostics/artifacts/evidence refs并可触发Debugger修复
|
||||
9. ContextAssembler产生Anthropic canonical消息,必要时记录遗漏
|
||||
10. Provider适配器路径可在能力验证和转换报告下执行模型调用
|
||||
11. 能力清单可加载、验证、启用并注册为命名空间工具
|
||||
12. Doctor报告平台/provider/toolchain/capability/display/network状态并支持权限修复模式
|
||||
13. 发布门禁命令在tier-1 Linux上记录并可运行
|
||||
|
||||
---
|
||||
|
||||
## 五、约束 (CT-01 ~ CT-16)
|
||||
|
||||
| ID | 约束 |
|
||||
|----|------|
|
||||
| CT-01 | 运行时: TypeScript on Bun |
|
||||
| CT-02 | Monorepo: Bun workspaces + Turborepo |
|
||||
| CT-03 | TUI: `@opentui/solid`, `@opentui/core`, `@opentui/keymap` |
|
||||
| CT-04 | IPC: NDJSON over stdio |
|
||||
| CT-05 | DB: SQLite per session, WAL/NORMAL/foreign_keys OFF |
|
||||
| CT-06 | 内部消息格式: Anthropic canonical content blocks |
|
||||
| CT-07 | C++第一个深度工具链; runtime保持语言无关 |
|
||||
| CT-08 | Python仅子进程辅助层,非核心runtime |
|
||||
| CT-09 | 早期发行用binary tarball,非公共包渠道 |
|
||||
| CT-10 | 架构文档和工作流状态在`AirPlan/`下 |
|
||||
| CT-11 | Monorepo包(Alpha): contracts/cli/tui/runtime/llm/toolchain-cpp |
|
||||
| CT-12 | 依赖方向: contracts←(none); cli→tui/runtime/llm/toolchain-cpp; runtime→contracts+llm+toolchain-*; tui→contracts only; runtime禁止依赖tui |
|
||||
| CT-13 | 全局用户目录: `~/.air/` |
|
||||
| CT-14 | project_id是`.air/shared/project.json`中的稳定UUID |
|
||||
| CT-15 | `.gitignore`: `.air/local/` |
|
||||
| CT-16 | 所有副作用必须通过ToolRegistry和PermissionEngine |
|
||||
|
||||
---
|
||||
|
||||
## 六、架构原则完整清单 (AP-01 ~ AP-189)
|
||||
|
||||
> 详细AP清单已由deepseek-v4-pro提取,参见`/home/airlongdian/DataDevices/AirWorkSpace/AirCoding/AirPlan/docs/analysis/full-requirements-audit.md`
|
||||
> 包含: 本节仅列关键原则概要,完整189条见审计文件。
|
||||
|
||||
### 核心执行原则
|
||||
- AP-01: AirCoding是自有的AI编码runtime,非Claude Code插件包装器
|
||||
- AP-02: Runtime语言无关; C++第一个深度profile; 通过`toolchain-<lang>`扩展
|
||||
- AP-03: 核心循环: requirement → design → reading → planning → build → analysis → test → debug → evidence → fix → summary → mining
|
||||
- AP-45: 执行质量遵循Claude Code: 读后编辑、精确、保守、小步、验证后完成
|
||||
- AP-46: OpenCode是UI/runtime参考,非业务状态依赖
|
||||
- AP-47: 项目本地为真源: session状态/制品/备份/项目规则在`.air/`下
|
||||
- AP-48: 事件驱动活动行为; SQLite驱动恢复
|
||||
- AP-49: Worker是隔离的子进程(Executor/Reviewer/Debugger/Compactor/ExperienceMiner),通过NDJSON IPC通信
|
||||
- AP-50: Main Agent保持响应; 长运行后台工作委派给Scheduler/Worker
|
||||
- AP-51: 架构变更是显式的; 实现级变更静默继续; 接口级变更通过Architecture Designer
|
||||
- AP-52: 工具/能力边界受权限保护; 所有内置和插件工具通过ToolRegistry+PermissionEngine
|
||||
- AP-53: Provider边界隔离; 内部Anthropic canonical; 适配器在边界转换
|
||||
- AP-54: 证据是一等公民: build/test/debug/review输出在完成声明前成为制品和证据引用
|
||||
|
||||
### 容器依赖
|
||||
- AP-55: CLI容器: 命令入口/启动/初始化/Doctor/项目发现/TUI/runtime引导
|
||||
- AP-56: TUI/HUD容器: 仅消费ProjectionStore; 不查询SQLite/EventBus; 不持有调度状态
|
||||
- AP-57: Runtime容器: MainAgent/ArchitectureDesigner/Scheduler/子进程管理/EventBus/EventStore/SessionStore/ToolRegistry/PermissionEngine/CapabilityRegistry/ContextAssembler/ArtifactStore/EvidenceStore/ProjectionStore
|
||||
- AP-58: LLM容器: Provider配置/适配器/Anthropic canonical处理/转换/能力矩阵/流式/工具调用/Token计数
|
||||
- AP-59: Toolchain C++容器: 项目检测/CMake/Ninja/CTest/cppcheck/clangd/诊断解析/证据生成
|
||||
- AP-60: Contracts容器: 可编译共享TS接口; 不依赖域实现包
|
||||
|
||||
### 禁止路径
|
||||
- AP-85: TUI→SQLite直接查询、TUI→runtime私有服务导入、Worker→SQLite直接写入、Worker→工具外fs/shell/network、工具→无PermissionEngine副作用、能力→Doctor外依赖安装、Provider适配器→静默语义损失、仓库→调度策略、EventBus→恢复真源、runtime→TUI导入、LLM输出→直接文件/shell副作用
|
||||
|
||||
### 事件/数据规则
|
||||
- AP-69: SQLite: WAL/NORMAL/foreign_keys=OFF
|
||||
- AP-88: 持久事件插入+域表更新在同一SQLite事务中
|
||||
- AP-91: 事件流: Producer→EventIngestor→验证→持久:EventStore事务+域投影+EventBus发布; 短暂:EventBus发布
|
||||
- AP-92: route追加只; route_text从route.join("/")派生; payload schema变更需版本递增
|
||||
- AP-137: EventStore.append事务中schema验证→EventRepository.insert→project(event,tx)→提交后EventBus.publish
|
||||
|
||||
### 控制流
|
||||
- AP-72: 正常执行: 用户请求→Main Agent分类→直接回答或架构/任务规划→Scheduler创建/加载TaskGraph→ContextAssembler→Scheduler派发Worker→工具→PermissionEngine→WorkerResult→Scheduler重试/合并/审查→Main Agent报告
|
||||
- AP-73: 需求变更: requirement.changed事件→Scheduler暂停受影响工作→Architecture Designer评估→实现级静默继续→架构/产品级路由用户确认/重规划
|
||||
- AP-74: 恢复: 重启→打开session DB→加载运行/中断任务→检查子进程存活→发出agent.lost/task.failed或重连/恢复→保留未合并workspaces→重建Scheduler队列→水合ProjectionStore
|
||||
|
||||
### 安全 (AP-79, AP-104~108, AP-171)
|
||||
- LLM输出在验证前不可信
|
||||
- 工具是文件系统/shell/network副作用的唯一路径
|
||||
- 符号链接通过realpath解析后分类
|
||||
- `.git/`默认保护; build目录允许项目写入
|
||||
- 项目外写入需备份; 凭证/系统敏感操作需显式确认
|
||||
- 无自动上传日志/制品/调试知识/Doctor包
|
||||
- 权限评估顺序: 工具能力声明→权限profile→TaskSpec范围→路径/命令/网络风险→凭证/系统敏感→用户提示
|
||||
- 8个路径风险类别 + 10个命令风险类别
|
||||
|
||||
### 可追溯性
|
||||
完整189条AP及11条INV详见审计文件:
|
||||
`/home/airlongdian/DataDevices/AirWorkSpace/AirCoding/AirPlan/docs/analysis/full-requirements-audit.md`
|
||||
|
||||
---
|
||||
|
||||
## 七、AirPlan V2 缺陷 (DF-P0 ~ DF-P3, 共33个)
|
||||
|
||||
### P0 — 已造成实际损失 (DF-P0-01 ~ DF-P0-10)
|
||||
1. AirXDB假阳性阻塞 — 证据门控无任务类型感知
|
||||
2. 部署验证缺口 — validate_for_finalize()只检查结构完整性
|
||||
3. **非原子写入** — 5处_json_dump直接覆盖(→ AirCoding已用ArtifactStore temp+rename修复)
|
||||
4. **零并发控制** — todo.md读改写竞态(→ AirCoding已用SQLite事务修复)
|
||||
5. AirArc被plan模式劫持
|
||||
6. AirEng停问而不自主决策
|
||||
7. AirEng无子线程状态轮询
|
||||
8. AirDo不调用AirDbg
|
||||
9. 安装器脚本路径错误
|
||||
10. AirEng偏离调度亲自写代码
|
||||
|
||||
### P1 — 限制可靠性 (DF-P1-01 ~ DF-P1-14)
|
||||
1. 硬编码开发者路径
|
||||
2. _json_dump重复5份
|
||||
3. _ordered_unique重复4份
|
||||
4. policy normalization重复3份
|
||||
5. merge-into-state重复3份
|
||||
6. marker block upsert重复2份
|
||||
7. _session_stamp格式不一致
|
||||
8. todo.md列索引硬编码
|
||||
9. 并发度硬编码为3
|
||||
10. 子进程无超时
|
||||
11. task_id路径注入
|
||||
12. 标记注入风险
|
||||
13. 静默吞异常
|
||||
14. Arc重规划后Eng无法衔接 → **AirCoding TaskGraph+PlanDelta解决**
|
||||
|
||||
### P2 — 限制规模化 (DF-P2-01 ~ DF-P2-04)
|
||||
1. 冲突检测O(n²)
|
||||
2. state.json无界增长
|
||||
3. todo.md全量重解析
|
||||
4. 零测试覆盖
|
||||
|
||||
### P3 — 限制用户体验 (DF-P3-01 ~ DF-P3-05)
|
||||
1. AGENTS.md膨胀
|
||||
2. 写集刚性导致级联任务链
|
||||
3. 并行Worker抢占共享硬件
|
||||
4. 环境特定修复不可持久
|
||||
5. 跨项目知识不迁移
|
||||
|
||||
---
|
||||
|
||||
## 八、AirPlan V2 改进 (V2I-01 ~ V2I-40)
|
||||
|
||||
见完整审计文件,关键项:
|
||||
- V2I-01: 统一原子I/O模块(air_runtime.io)
|
||||
- V2I-04: 任务类型感知的证据门控
|
||||
- V2I-15: **动态图调度(TaskGraph+PlanDelta) — 已在AirCoding中实现**
|
||||
- V2I-18: Worktree隔离同文件不同区域并行
|
||||
- V2I-22: frontend-design Skill集成
|
||||
- **V2I-23: ADR变更级联失效 — 已在AirCoding中实现方法,待生产接线**
|
||||
- **V2I-24: 压缩质量验证(CompressionValidator) — 已在AirCoding中实现**
|
||||
- V2I-28: AirDbg 7步工作流强制
|
||||
- V2I-30: 证据优先门控(EvidenceFirstGate)
|
||||
- V2I-37: Code-to-Design一致性审查(每行比较)
|
||||
|
||||
---
|
||||
|
||||
## 九、V2 KPI (26个)
|
||||
|
||||
| KPI | V1当前 | V2目标 |
|
||||
|-----|--------|--------|
|
||||
| AirXDB假阳性率 | ~60% | <5% |
|
||||
| 状态文件损坏率 | 已知发生 | 0% |
|
||||
| 部署一致性事故 | 1次关键 | 0 |
|
||||
| 空壳修复循环 | 11+ | 0 |
|
||||
| 代码重复 | 5份_json_dump | 每函数1份 |
|
||||
| 测试覆盖率 | 0% | >80% |
|
||||
| ADR变更旧代码残留 | 无自动清理 | 0(级联失效) |
|
||||
| Dispatch→Worker断链 | Agent停止调度 | 0(spawn_workers标准化) |
|
||||
|
||||
---
|
||||
|
||||
## 十、当前产品差距评估
|
||||
|
||||
### 参考项目对照
|
||||
|
||||
| 参考项目 | 要求 | 实际 |
|
||||
|----------|------|------|
|
||||
| **Claude Code CLI** (RB-01) | 执行层质量基准: read-before-edit, exact edits, verification | ❌ 全凭提示词,代码无强制 |
|
||||
| **OpenCode** (RB-02) | TUI视觉/交互/Provider抽象, 复用OpenTUI, 不复用SDK | ❌ 47个console.log撕裂TUI, 重写了Provider |
|
||||
| **Hermes Agent** (RB-03) | 经验挖掘/Nudge/Curator/Skill自修复 | ❌ ExperienceMinerRole从未运行 |
|
||||
| **OpenAI Codex** (RB-04) | Shell/patch/test执行循环, 工具编排 | ⚠️ 工具内联不统一 |
|
||||
| **Anthropic Skills** (RB-05) | SKILL.md格式, 技能目录布局 | ⚠️ 仅capability manifest |
|
||||
| **asciinema/Atuin/claude-hud** (RB-06) | PTY/HUD/状态栏 | ❌ HUD无对话面板 |
|
||||
|
||||
### 21条FR严格评估
|
||||
|
||||
| FR | 状态 | 说明 |
|
||||
|----|------|------|
|
||||
| FR-001 | ⚠️ | init可跑,Doctor执行但结果不展示 |
|
||||
| FR-002 | ✅ | 目录布局正确 |
|
||||
| FR-003 | ❌ | NOT NULL/UNIQUE持续崩溃 |
|
||||
| FR-004 | ❌ | 投影缺口持续,虽有诊断脚本修复,未端到端验证 |
|
||||
| FR-005 | ❌ | 正则分类器+dispatchTask,无对话 |
|
||||
| FR-006 | ❌ | 正则判断(文件数>10),无LLM |
|
||||
| FR-007 | ❌ | RetryPlanner字段不匹配 |
|
||||
| FR-007.5 | ❌ | 方法全有,零生产调用 |
|
||||
| FR-008 | ❌ | 仅ExecutorRole实跑过 |
|
||||
| FR-009 | ❌ | 全凭提示词 |
|
||||
| FR-010 | ❌ | 定义28个工具,cpp.*/debug.*从未触发 |
|
||||
| FR-011 | ⚠️ | 已修复部分崩溃,permission.request修复 |
|
||||
| FR-012 | ❌ | 仅1个capability包 |
|
||||
| FR-013 | ❌ | 仅OpenAI兼容适配器 |
|
||||
| FR-014 | ❌ | CompactorRole从未运行 |
|
||||
| FR-015 | ⚠️ | ArtifactStore可用,evidence_refs已修复 |
|
||||
| FR-016 | ❌ | 47个console.log撕裂TUI |
|
||||
| FR-017 | ❌ | cpp.*从未端到端 |
|
||||
| FR-018 | ❌ | Doctor跑了不展示 |
|
||||
| FR-019 | ⚠️ | Logger存在,写入未验证 |
|
||||
| FR-020 | ❌ | 27/27门禁方法级,产品不可用 |
|
||||
|
||||
### 分类
|
||||
|
||||
- ✅ 可达: 1/21 (FR-002)
|
||||
- ⚠️ 部分可达: 3/21 (FR-001, FR-011, FR-015, FR-019)
|
||||
- ❌ 不可达: 17/21
|
||||
|
||||
---
|
||||
|
||||
## 文件导航
|
||||
|
||||
- 完整审计文件(383条详细清单): `/home/airlongdian/DataDevices/AirWorkSpace/AirCoding/AirPlan/docs/analysis/full-requirements-audit.md`
|
||||
- 功能需求: `AirPlan/docs/analysis/requirements.md`
|
||||
- 架构方案: `AirPlan/docs/architecture/solution-architecture.md`
|
||||
- 基准V1: `AirPlan/docs/architecture/baselineV1.md`
|
||||
- V2设计: `/home/airlongdian/DataDevices/AirWorkSpace/air-plugins-dist/airplanV2-Qwen3.7-Max设计.md`
|
||||
- 详细设计: `AirPlan/docs/architecture/system-detailed-design.md`
|
||||
- 系统概览: `AirPlan/docs/architecture/system-overview-design.md`
|
||||
@@ -58,6 +58,15 @@ AirCoding must route architecture/interface/product-impacting decisions to an Ar
|
||||
|
||||
AirCoding must schedule TaskSpec records with hard/soft dependencies, write-area conflict handling, retry budgets, child worker dispatch, heartbeat monitoring, merge coordination, and restart recovery.
|
||||
|
||||
**FR-007.5 ADR 级联失效与架构变更回滚**:当 ADR 发生架构方案变更(如 ffmpeg → gstreamer)时,调度器必须:
|
||||
1. 通过 TaskNode.adr_refs 溯源所有依赖该 ADR 的任务(含已完成)
|
||||
2. 级联失效受影响任务(completed→invalidated、running→终止、pending→cancelled)
|
||||
3. 冻结调度(dispatch_frozen),阻止新任务派发
|
||||
4. 创建 git 回滚快照(rollback_ref),支持 revert 旧方案代码
|
||||
5. 接收 ArchitectureDesigner 产出的 PlanDelta 增量重规划
|
||||
6. apply_delta 吸收新任务后解冻调度
|
||||
7. 终审时检查 INVALIDATED 任务的旧代码是否已清理
|
||||
|
||||
### FR-008 Independent Worker Agents
|
||||
|
||||
Executor, Reviewer, Debugger, Compactor, and ExperienceMiner must run as independent Bun child processes communicating through NDJSON IPC.
|
||||
|
||||
0
AirPlan/docs/architecture/DeepSeekV4Pro三视角审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeekV4Pro三视角审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek系统详细设计审查复查.md
Normal file → Executable file
0
AirPlan/docs/architecture/DeepSeek系统详细设计审查复查.md
Normal file → Executable file
0
AirPlan/docs/architecture/MIMO2.5三视角审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/MIMO2.5三视角审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/Mimo2.5pro系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/Mimo2.5pro系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/Opus4.7概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/Opus4.7概要设计审查.md
Normal file → Executable file
606
AirPlan/docs/architecture/Qwen3.7开发阶段审计.md
Executable file
606
AirPlan/docs/architecture/Qwen3.7开发阶段审计.md
Executable file
@@ -0,0 +1,606 @@
|
||||
# Qwen3.7-Max 开发阶段全量审计报告
|
||||
|
||||
**审计模型:** Qwen3.7-Max
|
||||
**审计日期:** 2026-06-03
|
||||
**审计范围:** V1.0.0 Alpha 全部代码实现 vs 原始需求/基线/设计文档/UML类图
|
||||
**审计分支:** GLM5-Achieve
|
||||
**代码规模:** 7 个包, 137 个 TypeScript/TSX 源文件, 4 个根配置文件
|
||||
|
||||
---
|
||||
|
||||
## 0. 审计总览
|
||||
|
||||
| 严重程度 | 数量 | 说明 |
|
||||
|---|---|---|
|
||||
| CRITICAL | 31 | 架构性缺陷,阻塞核心不变量或导致运行时崩溃 |
|
||||
| HIGH | 22 | 功能性缺陷,子系统与设计断连或关键逻辑缺失 |
|
||||
| MEDIUM | 19 | 部分实现偏差,影响完整性但不阻塞骨架 |
|
||||
| LOW | 12 | 命名/结构偏差、多余类型、文档注释问题 |
|
||||
|
||||
**总体评估:** 代码骨架覆盖了 V1.0.0 Alpha 的 8 个阶段目标,monorepo 结构、包分层、SQLite schema、事件注册表均存在。但实现与设计文档之间存在大量结构性偏差,核心子系统(Scheduler 状态机、IPC 协议、安全模型、上下文装配)与冻结基线的匹配度不足 40%。当前代码属于 **Phase 0-1 骨架 + Phase 2-7 桩代码** 状态,多数子系统有类无逻辑或有逻辑但语义不匹配。
|
||||
|
||||
---
|
||||
|
||||
## 1. 需求覆盖度审计 (requirements.md → 代码)
|
||||
|
||||
### 1.1 功能需求 (FR) 覆盖矩阵
|
||||
|
||||
| FR ID | 需求 | 覆盖状态 | 说明 |
|
||||
|---|---|---|---|
|
||||
| FR-001 | CLI 启动与项目初始化 | PARTIAL | CLI 命令齐全 (11 个),但 `init` 不创建 17 个规范子目录 |
|
||||
| FR-002 | 项目本地状态 `.air/` | PARTIAL | ProjectInitializer 存在,但 `.air/shared/plan/docs/` 等子目录缺失 |
|
||||
| FR-003 | 会话持久化 SQLite | PASS | 17 表、38 索引、WAL/NORMAL/FK-OFF 全部正确 |
|
||||
| FR-004 | 事件驱动运行时 | PARTIAL | EventStore/EventBus/EventIngestor 存在,但事务边界违反 (F-04) |
|
||||
| FR-005 | 主代理对话 | PARTIAL | MainAgent 存在但缺 7/13 个状态,分类用正则而非 LLM |
|
||||
| FR-006 | 架构设计师 | PARTIAL | ArchitectureDesigner 存在但不产出 BlockerReport,不发事件 |
|
||||
| FR-007 | 调度器与 TaskGraph | FAIL | Scheduler 缺 BLOCKED/CANCELLED 状态,3 个方法缺失,接口不匹配 |
|
||||
| FR-008 | 独立 Worker 进程 | PARTIAL | 5 个角色均存在,但 WorkerResult 形状不匹配,IPC 协议偏差大 |
|
||||
| FR-009 | Claude Code 级执行原语 | FAIL | read-before-edit 未强制,工具 schema 字段名大量偏差 |
|
||||
| FR-010 | ToolRegistry 与内置工具 | FAIL | 28 个 MVP 工具中 16 个缺失 |
|
||||
| FR-011 | 权限与安全模型 | FAIL | 0/10 cut line 项完全满足;profile/action/grant_scope 类型不匹配 |
|
||||
| FR-012 | 插件与能力基础 | PARTIAL | CapabilityRegistry 存在但 manifest schema、trust level、依赖模型全部偏差 |
|
||||
| FR-013 | Provider 层 | PARTIAL | AnthropicAdapter 和 OpenAICompatibleAdapter 存在,能力矩阵仅实现 ~20% |
|
||||
| FR-014 | 上下文装配与压缩 | FAIL | L6-L9 层缺失,输出非 Anthropic canonical 格式,无冲突检测 |
|
||||
| FR-015 | 工件与证据管理 | PARTIAL | ArtifactStore 正确实现 temp-rename 流程,EvidenceStore 用内存 map |
|
||||
| FR-016 | TUI 与 HUD | PARTIAL | 9 个组件齐全,无 OpenTUI renderer,ProjectionStore.rebuild() 为桩 |
|
||||
| FR-017 | 完整 C++ 开发工作流 | FAIL | CppToolRegistrar 注册工具但 6 个 cpp.* 工具未注册到 ToolRegistry |
|
||||
| FR-018 | Doctor | PARTIAL | DoctorService 存在但无 provider 检查和平台检测 |
|
||||
| FR-019 | 日志与诊断 | PARTIAL | Logger 存在但与 DeveloperLogEncryptor 完全断连 |
|
||||
| FR-020 | 发布门禁 | FAIL | release 命令为桩,无 fixture 项目 |
|
||||
|
||||
### 1.2 非功能需求 (NFR) 覆盖矩阵
|
||||
|
||||
| NFR ID | 需求 | 覆盖状态 | 说明 |
|
||||
|---|---|---|---|
|
||||
| NFR-001 | 本地优先 | PASS | 所有状态在 `.air/` 下 |
|
||||
| NFR-002 | 可恢复性 | FAIL | Recovery 的 scanOrphanReferences 和 checkPidLiveness 均为桩 |
|
||||
| NFR-003 | 可扩展性 | PARTIAL | toolchain-* 包模式存在但能力注册不完整 |
|
||||
| NFR-004 | Provider 灵活性 | PARTIAL | 适配器模式存在但能力矩阵验证不完整 |
|
||||
| NFR-005 | UI 响应性 | PASS | ProjectionStore 架构正确隔离了 UI 与 DB |
|
||||
| NFR-006 | 基于证据的完成 | FAIL | 完成门禁未强制,验证桩代码 |
|
||||
| NFR-007 | Linux 优先 | PASS | 代码无平台特定障碍 |
|
||||
| NFR-008 | 安全边界保持 | FAIL | PathClassifier 类别错误,无 credential_store 检测 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 契约包审计 (packages/contracts vs interface-contracts-v1.md)
|
||||
|
||||
### 2.1 缺失的契约接口 (15 个)
|
||||
|
||||
| # | 契约名 | 设计位置 | 严重程度 |
|
||||
|---|---|---|---|
|
||||
| 1 | `EventBus` | SS7 | CRITICAL |
|
||||
| 2 | `EventStore` | SS7 | CRITICAL |
|
||||
| 3 | `EventIngestor` | SS7 | CRITICAL |
|
||||
| 4 | `ContextAssembler` | SS16 | CRITICAL |
|
||||
| 5 | `EventSchemaRegistry` | SS7 | HIGH |
|
||||
| 6 | `EventAppendOptions` | SS7 | HIGH |
|
||||
| 7 | `SessionRecord` | SS6 | HIGH |
|
||||
| 8 | `MessageRecord` | SS6 | HIGH |
|
||||
| 9 | `PersistedEventRecord` | SS6 | HIGH |
|
||||
| 10 | `PersistedEventInsert` | SS6 | HIGH |
|
||||
| 11 | `EventRepository` | SS6 | HIGH |
|
||||
| 12 | `ContextAssembleInput` | SS16 | HIGH |
|
||||
| 13 | `AssembledContext` | SS16 | HIGH |
|
||||
| 14 | `CompactionPolicy` | SS16 | HIGH |
|
||||
| 15 | `CompactionResult` | SS16 | HIGH |
|
||||
|
||||
### 2.2 字段级偏差
|
||||
|
||||
| 契约 | 字段 | 设计 | 代码 | 文件:行 |
|
||||
|---|---|---|---|---|
|
||||
| `ProviderCapabilityMatrix` | `supports` | `JsonObject` | `ProviderSupports` (强类型) | provider.ts:70 |
|
||||
| `ProviderCapabilityMatrix` | `conversion` | `JsonObject` | `ProviderConversion` (强类型) | provider.ts:71 |
|
||||
| `ProviderCapabilityMatrix` | (额外字段) | 不存在 | `display_name?`, `limits?`, `default_use?`, `notes?` | provider.ts:64,72-74 |
|
||||
| `ModelRequirement` | `required` | `JsonObject` | `Partial<ProviderSupports>` | provider.ts:146 |
|
||||
| `ProviderManager` | (额外方法) | 不存在 | `load_config(): Promise<void>` | provider.ts:277 |
|
||||
| `DoctorIssueSeverity` | (缺失值) | 包含 `"error"` | 缺少 `"error"` | platform.ts:41 |
|
||||
| `TaskGraph` | `dependencies` | `TaskDependencyRecord[]` | 内联结构等价物 | task.ts:147 |
|
||||
| `PromptLayerLoader` | 参数类型 | `ProjectContext`, `TaskSpec` | 内联结构子集 | runtime.ts:94-104 |
|
||||
|
||||
### 2.3 多余契约 (需 ADR)
|
||||
|
||||
`ProviderIdentity`, `ProviderConversionReport`, `ProviderLimits`, `ProviderDefaultUse`, `DoctorIssue`, `DoctorIssueCategory`, `ToolErrorOutput` (来自 error-taxonomy-v1.md 但未实现) 等均为代码中新增但设计文档中不存在的契约。
|
||||
|
||||
---
|
||||
|
||||
## 3. 存储层审计 (packages/runtime/src/storage/ vs db-schema-v1.md)
|
||||
|
||||
### 3.1 会话 DB Schema: 完整 (PASS)
|
||||
|
||||
17 个表、38 个索引、3 个 PRAGMA、5 个 schema_meta 种子键全部正确匹配。
|
||||
|
||||
### 3.2 CRITICAL 发现
|
||||
|
||||
**F-01: DebugKnowledgeStore schema 完全不匹配 db-schema-v1.md §20.1**
|
||||
- DB 路径: 代码 `.air/shared/debug-records.db` vs 设计 `.air/local/debug-records.db`
|
||||
- 7 个列名/语义不匹配: `failure_signature` → `signature`, `fix_ref` → `fix_applied`, 缺失 `summary`/`evidence_json`/`verification_json`/`updated_at`/`metadata_json`
|
||||
- 多余列: `session_id`, `error_kind`, `status`, `resolved_at`
|
||||
- 索引名不匹配
|
||||
|
||||
**F-02: LearnedMemoryStore schema 完全不匹配 db-schema-v1.md §20.2**
|
||||
- DB 路径: 代码 `.air/shared/learned-memory.db` vs 设计 `.air/local/learned-memory.db`
|
||||
- 表名: 代码 `learned_memory` vs 设计 `learned_memories`
|
||||
- 6 个列名/语义不匹配
|
||||
- 枚举值完全不匹配: 设计 `project_rule|toolchain_rule|skill_update|debug_experience` vs 代码 `pattern|rule|skill|experience`
|
||||
- 状态枚举不匹配: 设计 `candidate|promoted|archived|rejected` vs 代码 `draft|promoted|archived`
|
||||
|
||||
**F-04: EventStore.project() 未将事务句柄传递给仓库**
|
||||
- `append()` 正确开启事务,但 `project()` 方法接收 `_tx` 参数后从不传给仓库方法
|
||||
- 违反 db-schema-v1.md §1 规则 8: "持久事件插入与域表更新必须在同一事务中"
|
||||
- 影响: 域表写入失败时事件行仍会提交,造成不一致状态
|
||||
|
||||
**F-05: EventStore 写入无效的 workspace status 值**
|
||||
- `workspace.created` 写入 `status: 'created'`,但有效枚举为 `active|merged|conflicted|abandoned|cleaned`
|
||||
- `workspace.merge.started` 写入 `status: 'merging'`,不在枚举中
|
||||
- 导致 `assertEnumValues` 抛出 AirError,**首次 workspace 创建即崩溃**
|
||||
|
||||
**F-06: TaskAttemptRepository.update() 列映射 bug**
|
||||
- 检查 `patch.failure_signature` 但更新 `failure_summary` 列
|
||||
- 导致 `failure_signature` 永远不会被更新,`failure_summary` 被静默覆盖
|
||||
|
||||
**F-07: EventRepository 路由前缀过滤器使用错误分隔符**
|
||||
- 过滤用 `.` 拼接,但存储用 `/` 分隔
|
||||
- 所有路由前缀查询返回零结果
|
||||
|
||||
### 3.3 HIGH 发现
|
||||
|
||||
**F-08: Recovery.scanOrphanReferences() 为桩** — FK-off 孤儿扫描未实现
|
||||
**F-09: Recovery.checkPidLiveness() 为桩** — PID 存活检查未实现
|
||||
**F-10: Workspace GC SQL 逻辑错误** — AND/OR 缺少括号,`session_id` 过滤被绕过
|
||||
**F-11: EvidenceStore 使用内存 Map** — 重启后证据查询为空
|
||||
**F-12: SessionManager.close_session() 不刷新 ui_state** — 违反退出时刷新不变量
|
||||
|
||||
### 3.4 MEDIUM 发现
|
||||
|
||||
**F-13:** `command.completed` 投影传递 `diagnostic_ids` 但 `command_runs` 表无此列
|
||||
**F-14:** EventStore 单例用空 `DatabaseHandle` 初始化
|
||||
**F-15/F-16:** 多个仓库在 insert 时硬编码 status,与 EventStore 传递值冲突
|
||||
|
||||
---
|
||||
|
||||
## 4. 安全模型审计 (packages/runtime/src/security/ vs security-model-v1.md)
|
||||
|
||||
### 4.1 路径分类器 (CRITICAL 偏差)
|
||||
|
||||
| 设计 PathRiskCategory | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `project` | `project_source`, `project_config` | 拆分为二 |
|
||||
| `project_air_shared` | — | **缺失** |
|
||||
| `project_air_local` | — | **缺失** |
|
||||
| `credential_store` | — | **完全缺失** (`~/.ssh`, `~/.gnupg` 等均不检测) |
|
||||
| `unknown` | — | **缺失**; 默认为 `project_config` (过于宽松) |
|
||||
|
||||
### 4.2 命令风险分析器 (CRITICAL 偏差)
|
||||
|
||||
| 设计 CommandRisk | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `build_or_test` | — | **缺失** |
|
||||
| `dependency_install` | — | **缺失** |
|
||||
| `privilege_escalation` | — | **缺失** |
|
||||
| `unknown` | — | **缺失** |
|
||||
|
||||
**运行时 Bug:** `'sudo_likely' in trimmed` — `in` 操作符在字符串上检查 String 原型属性,永远为 `false`。
|
||||
|
||||
### 4.3 权限引擎 (CRITICAL 偏差)
|
||||
|
||||
| 设计要素 | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| 4 个 Profile (`low/normal/high/developer`) | 按 agent 类型的 profile | **完全不匹配** |
|
||||
| 6 个 Action (`allow/deny/ask_user/block/refuse/announce_then_run`) | 7 个 Action (3 个不同) | **缺失 `block/refuse/announce_then_run`** |
|
||||
| `PermissionGrantScope` (5 级) | **完全缺失** | 无授权范围追踪 |
|
||||
| `risk_level` 字段 | **缺失** | |
|
||||
| `backup_required` 字段 | **缺失** | 无写入前备份逻辑 |
|
||||
| 策略违规 `refuse` | **缺失** | 无拒绝检测 |
|
||||
|
||||
**Cut line 合规: 0/10 项完全满足, 4 项部分满足, 6 项不满足。**
|
||||
|
||||
### 4.4 SecretRedactor: 良好但有缺口
|
||||
|
||||
14 个模式类别覆盖良好。缺失: `.env` 文件路径级检测、云凭证目录模式、`auth_ref` 引用系统、Provider 适配器集成。
|
||||
|
||||
---
|
||||
|
||||
## 5. 工具注册表审计 (ToolRegistry vs tool-registry-v1.md)
|
||||
|
||||
### 5.1 MVP 工具缺失 (16/28 缺失)
|
||||
|
||||
| 缺失工具 | 类别 |
|
||||
|---|---|
|
||||
| `fs.stat` | 文件系统 |
|
||||
| `process.kill` | 进程 |
|
||||
| `git.worktree.create` | Git |
|
||||
| `git.merge_workspace` | Git |
|
||||
| `project.scan` | 项目 |
|
||||
| `project.profile.write` | 项目 |
|
||||
| `cpp.detect` | C++ 工具链 |
|
||||
| `cpp.cmake.configure` | C++ 工具链 |
|
||||
| `cpp.build` | C++ 工具链 |
|
||||
| `cpp.test` | C++ 工具链 |
|
||||
| `cpp.static.cppcheck` | C++ 工具链 |
|
||||
| `cpp.clangd.query` | C++ 工具链 |
|
||||
| `debug.run` | 调试 |
|
||||
| `debug.parse_logs` | 调试 |
|
||||
| `gui.screenshot` | GUI 证据 |
|
||||
| `network.capture` | 网络证据 |
|
||||
|
||||
### 5.2 多余工具 (10 个不在 MVP 索引中)
|
||||
|
||||
`git.commit`, `git.branch`, `project.rules`, `project.context`, `artifact.read`, `context.compact`, `permission.check`, `permission.prompt`, `doctor.check`, `doctor.fix`
|
||||
|
||||
### 5.3 工具 Schema 偏差 (主要工具)
|
||||
|
||||
| 工具 | 设计字段 | 代码字段 | 偏差 |
|
||||
|---|---|---|---|
|
||||
| `fs.edit` | `old_string`, `new_string`, `expected_existing_sha256?` | `find`, `replace` | 字段名全部不同,缺安全校验和 |
|
||||
| `shell.run` | `cwd` (required), `timeout_ms?`, `stdin?`, `capture_mode?`, `purpose?` | `workdir` (optional), `timeout?`, `env?` | 名称/必需性/字段均不匹配 |
|
||||
| `artifact.create` | `type`, `original_name?`, `content?`, `source_path?`, `associated_entity_type?`, `associated_entity_id?`, `metadata?` | `name`, `type`, `content`, `metadata` | 缺 5 个字段 |
|
||||
| `context.assemble` | `purpose` (required enum), `refs?`, `token_budget?` | `max_tokens?` | 缺必需 `purpose` 枚举和 `refs` |
|
||||
|
||||
### 5.4 ToolRegistry 运行时 Bug
|
||||
|
||||
**CRITICAL:** `this.downgrade_to_readonly()` 和 `this.apply_sandbox_restrictions()` 在模块作用域 `ACTION_BRANCHES` 对象中被调用,`this` 不是 ToolRegistry 实例,运行时将抛出异常。
|
||||
|
||||
---
|
||||
|
||||
## 6. 能力系统审计 (CapabilityRegistry vs capability-trust-v1.md)
|
||||
|
||||
### 6.1 Manifest Schema (CRITICAL 偏差)
|
||||
|
||||
| 设计字段 | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `capability_id` | `name` | 重命名 |
|
||||
| `display_name` | — | **缺失** |
|
||||
| `source` (CapabilitySource) | — | **完全缺失** |
|
||||
| `trust_level` (5 级) | `trust_level` (3 级) | **不匹配**: 设计 `built_in/project_local/user_installed/verified_publisher/untrusted` vs 代码 `core/trusted/untrusted` |
|
||||
| `publisher?` | — | **缺失** |
|
||||
| `events?` | — | **缺失** |
|
||||
| `config_schema?` | — | **缺失** |
|
||||
| `entrypoint?` | — | **缺失** |
|
||||
|
||||
### 6.2 依赖模型
|
||||
|
||||
设计: 富 `CapabilityDependency` 对象 (7 种 kind、检测器、安装器策略)。
|
||||
实现: 简单 `string[]`。所有结构信息丢失。
|
||||
|
||||
### 6.3 工具命名空间验证
|
||||
|
||||
设计要求 `<capability-id>.<tool-name>` 命名空间,保留内置命名空间。`CapabilityManifestValidator` 无命名空间验证。
|
||||
|
||||
---
|
||||
|
||||
## 7. 调度器审计 (Scheduler vs scheduler-state-machine-v1.md)
|
||||
|
||||
### 7.1 缺失状态 (CRITICAL)
|
||||
|
||||
| 设计状态 | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `BLOCKED` | — | **缺失** |
|
||||
| `CANCELLED` | — | **缺失** |
|
||||
| `TERMINATED` | — | **多余** (非设计规范) |
|
||||
|
||||
### 7.2 Scheduler 接口不匹配
|
||||
|
||||
| 设计方法 | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `create_tasks(session_id, specs: TaskSpec[])` | `create_tasks({id,type,title,depends_on}[])` | 签名不匹配,缺 `session_id` |
|
||||
| `add_dependency(session_id, task_id, dep)` | — | **完全缺失** |
|
||||
| `load_graph(session_id)` | — | **完全缺失** |
|
||||
| `run_until_idle(session_id): SchedulerRunResult` | `run_until_idle(): SchedulerState` | 返回值类型不匹配 |
|
||||
| `cancel_task(task_id, reason)` | — | **完全缺失** |
|
||||
|
||||
### 7.3 状态逻辑空洞
|
||||
|
||||
| 状态 | 设计要求 | 实现 |
|
||||
|---|---|---|
|
||||
| DISPATCHING | 4 个动作 (workspace, events, control message, attempt) | 仅标记 running |
|
||||
| COLLECTING_RESULTS | 5 个动作 (validate, persist, terminal, classify, unblock) | 直通到 MERGING |
|
||||
| MERGING | 策略选择 (main/worktree/isolated_copy) | 直通到 REVIEWING_WAVE |
|
||||
| REVIEWING_WAVE | 调度 review 任务 | 直通到 REPAIRING_OR_CONTINUING |
|
||||
|
||||
### 7.4 TaskGraph 偏差
|
||||
|
||||
- 缺失 `serialization` 依赖类型 (4 种中缺 1 种)
|
||||
- `soft` 依赖对调度无任何影响
|
||||
- 冲突依赖不阻止同波次并发
|
||||
- TaskNode 缺少 `spec`, `assigned_agent_id`, `retry_count`, `workspace_id`
|
||||
|
||||
### 7.5 WavePlanner 偏差
|
||||
|
||||
- 所有任务分配到 `'default'` write area — write-area 串行化无效
|
||||
- `wave_id` 为 `number` (Date.now()) 而非设计要求的 `string`
|
||||
- 无 `workspace_assignments`, `model_assignments`, `reason` 字段
|
||||
- 8 条波次规划规则中仅 1 条部分实现
|
||||
|
||||
### 7.6 RetryPlanner: 死代码
|
||||
|
||||
逻辑正确 (重复失败签名升级),但从未被 Scheduler 调用。
|
||||
|
||||
---
|
||||
|
||||
## 8. IPC 协议审计 (WorkerProtocol vs interface-contracts-v1.md §10)
|
||||
|
||||
### 8.1 缺失 IPC 类型
|
||||
|
||||
| 设计 IpcKind | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `control` | — | **缺失** (个别控制消息存在但无 `control` 信封) |
|
||||
| `log` | — | **完全缺失** |
|
||||
| `tool.stream` | — | **完全缺失** |
|
||||
| `protocol.error` | — | **缺失** (用非标准 `worker.error` 替代) |
|
||||
|
||||
### 8.2 信封形状不匹配
|
||||
|
||||
设计 `IpcEnvelope` 有 9 个字段: `id, direction, kind, timestamp, session_id, agent_id, correlation_id?, protocol_version, payload`
|
||||
实现 `WorkerMessage` 有 5 个字段: `id, type, direction, timestamp, payload`
|
||||
**缺失:** `kind`, `session_id`, `agent_id`, `correlation_id`, `protocol_version`
|
||||
|
||||
### 8.3 握手顺序反转
|
||||
|
||||
设计: 父进程先发 `agent.start`,worker 回 `worker.ready`
|
||||
实现: worker 先发 `worker.ready`,父进程后发 `agent.start` — **顺序相反**
|
||||
|
||||
---
|
||||
|
||||
## 9. 主代理状态机审计 (MainAgent vs main-agent-state-machine.md)
|
||||
|
||||
### 9.1 缺失状态 (7/13)
|
||||
|
||||
| 设计状态 | 实现 | 状态 |
|
||||
|---|---|---|
|
||||
| `CLASSIFYING` | — | **缺失** |
|
||||
| `SCHEDULING` | — | **缺失** |
|
||||
| `ARCHITECTURE_DESIGNING` | — | **缺失** |
|
||||
| `CONFIRMING` | — | **缺失** (用 `AWAITING_CONFIRMATION` 替代,语义不同) |
|
||||
| `EXECUTING` | — | **缺失** |
|
||||
| `INTERRUPTING` | — | **缺失** |
|
||||
| `ARCHITECTURE_REVISING` | — | **缺失** |
|
||||
|
||||
### 9.2 其他偏差
|
||||
|
||||
- 分类用正则而非 LLM
|
||||
- Direct Mode `/direct`/`/done` 不完整
|
||||
- SUMMARIZING 不触发 ExperienceMiner
|
||||
- 无 `requirement.changed` 处理
|
||||
|
||||
---
|
||||
|
||||
## 10. Worker 角色审计 (packages/workers/ vs 设计)
|
||||
|
||||
### 10.1 结果形状不匹配
|
||||
|
||||
所有 5 个角色均返回局部结果类型而非设计要求的 `WorkerResult<T>` 信封:
|
||||
|
||||
| 角色 | 设计要求 | 实际返回 |
|
||||
|---|---|---|
|
||||
| Executor | `WorkerResult<ExecutorResult>` (12 字段) | `{status, changes?, verification?, error?}` (4 字段) |
|
||||
| Reviewer | `WorkerResult<ReviewerResult>` + `verdict` 枚举 | `{status, findings[], summary}` |
|
||||
| Debugger | `WorkerResult<DebuggerResult>` + `BlockerReport?` | `{status, root_cause, fix_applied?, evidence_refs}` |
|
||||
| Compactor | `WorkerResult<CompactorResult>` + `summary_id` | `{status, summary_content, tokens_freed}` |
|
||||
| ExperienceMiner | `WorkerResult<ExperienceMinerResult>` + `MemoryCandidate[]` | `{status, entries[], summary}` |
|
||||
|
||||
### 10.2 执行纪律缺失
|
||||
|
||||
- read-before-edit 未强制
|
||||
- 完成门禁 (verification pass or explicit skip) 未强制
|
||||
- DebuggerRole 不查 DebugKnowledgeStore
|
||||
- ExperienceMiner 触发路径未接入 Scheduler
|
||||
|
||||
---
|
||||
|
||||
## 11. LLM Provider 层审计 (packages/llm/ vs provider-capability-matrix-v1.md)
|
||||
|
||||
### 11.1 能力矩阵覆盖度: ~20%
|
||||
|
||||
缺失:
|
||||
- `quality_tier`, `cost_tier` 字段未在矩阵中使用
|
||||
- 17 个 `supports` 字段中仅 5 个实现
|
||||
- 整个 `conversion` 块、`limits` 块、`default_use` 块缺失
|
||||
- `ProviderKind` 分类未使用
|
||||
- Fallback 策略、调度器分配模式缺失
|
||||
|
||||
### 11.2 Provider 配置安全
|
||||
|
||||
代码直接存储 `api_key` 原始值,设计要求 `auth_ref` 间接引用,密钥永不进入 session DB/events/artifacts。
|
||||
|
||||
### 11.3 LLM 包未引用 contracts
|
||||
|
||||
`packages/llm` 在本地定义所有类型而非从 `packages/contracts` 导入,违反了基线 §4 依赖方向规则。
|
||||
|
||||
---
|
||||
|
||||
## 12. 上下文装配审计 (ContextAssembler vs prompt-layering-v1.md)
|
||||
|
||||
### 12.1 层级缺失 (4/10)
|
||||
|
||||
| 层 | 设计 | 实现 | 状态 |
|
||||
|---|---|---|---|
|
||||
| L0 System | 系统身份 | 硬编码字符串 | PARTIAL |
|
||||
| L1 Capability | 能力声明 | 存在 | PASS |
|
||||
| L2 Safety | 安全规则 | 硬编码 | PARTIAL |
|
||||
| L3 Project Rules | 项目规则 | 存在但路径错误 | PARTIAL |
|
||||
| L4 Architecture | 架构上下文 | 存在 | PASS |
|
||||
| L5 Plan/Task | 计划/任务 | 存在 | PASS |
|
||||
| L6 Evidence | 证据上下文 | — | **缺失** (TODO) |
|
||||
| L7 Conversation | 对话历史 | — | **缺失** (TODO) |
|
||||
| L8 Tool Output | 工具输出 | — | **缺失** (TODO) |
|
||||
| L9 Immediate | 即时指令 | — | **缺失** (TODO) |
|
||||
|
||||
### 12.2 输出格式
|
||||
|
||||
设计要求输出 Anthropic canonical messages。实现输出自定义 `PromptLayer[]` 结构,未转换为 canonical 格式。
|
||||
|
||||
### 12.3 冲突检测: 缺失
|
||||
|
||||
设计要求层间冲突报告 (如安全规则与项目规则矛盾)。实现无任何冲突检测。
|
||||
|
||||
### 12.4 CompactionPolicy: 无 copy-on-write
|
||||
|
||||
设计要求 copy-on-write 压缩,保留回溯引用。实现仅有阈值检查,无工件持久化,无回溯保留。
|
||||
|
||||
---
|
||||
|
||||
## 13. TUI/HUD 审计 (packages/tui/ vs 设计)
|
||||
|
||||
### 13.1 组件覆盖: 完整
|
||||
|
||||
9 个视图组件全部存在: SessionView, TaskListView, AgentStatusView, ToolRunView, DiffView, PermissionPrompt, BlockerReport, HudView + TuiApp。
|
||||
|
||||
### 13.2 缺口
|
||||
|
||||
- 无 OpenTUI renderer 集成 (组件定义但无渲染引擎)
|
||||
- 无对话消息渲染表面
|
||||
- PermissionPrompt/BlockerReport 无路由连接
|
||||
- ProjectionStore.rebuild() 为桩 — 仅处理 5 种事件类型
|
||||
- HUD 预设 (Full/Essential/Minimal) 未实现
|
||||
|
||||
---
|
||||
|
||||
## 14. C++ 工具链审计 (packages/toolchain-cpp/ vs FR-017)
|
||||
|
||||
### 14.1 组件存在但断连
|
||||
|
||||
- `CppProjectDetector`, `CppBuilder`, `CMakeConfigurator`, `CppTestRunner`, `DiagnosticParser`, `ClangdClient`, `CppcheckRunner` 均存在
|
||||
- `CppToolRegistrar` 注册了工具定义但 **未注册到 ToolRegistry** (与 FR-010 的 16 个缺失工具一致)
|
||||
- `ClangdClient` 方法全部为桩
|
||||
- 源文件发现返回空数组
|
||||
|
||||
### 14.2 安全风险
|
||||
|
||||
`CppBuilder.build()` 和 `CppTestRunner.run()` 使用 `execSync` 字符串拼接,存在命令注入风险。
|
||||
|
||||
---
|
||||
|
||||
## 15. CLI 命令审计 (packages/cli/ vs 设计)
|
||||
|
||||
### 15.1 命令覆盖: 完整 (PASS)
|
||||
|
||||
所有 11 个必需命令存在: `init`, `run`, `doctor`, `provider`, `resume`, `compact`, `history`, `session`, `restore`, `e2e`, `release`。
|
||||
|
||||
### 15.2 init 命令偏差
|
||||
|
||||
- 不创建 17 个规范 `.air/` 子目录
|
||||
- 直接写文件系统,绕过 ToolRegistry/PermissionEngine (违反 INV-3)
|
||||
|
||||
### 15.3 额外包
|
||||
|
||||
代码中存在 `packages/workers/` 包,不在基线 §4 的规范包列表中。这是一个合理的分离 (worker 入口点独立于 runtime),但需要 ADR 记录。
|
||||
|
||||
---
|
||||
|
||||
## 16. 运行时语义合规审计 (vs runtime-semantics-v1.md)
|
||||
|
||||
| 不变量 | 合规 | 说明 |
|
||||
|---|---|---|
|
||||
| INV-1: 持久事件+域表同事务 | FAIL | F-04: EventStore.project() 不传事务 |
|
||||
| INV-2: EventIngestor 不创建调度任务 | PASS | |
|
||||
| INV-3: 副作用经 ToolRegistry/PermissionEngine | FAIL | init 直接写 FS |
|
||||
| INV-4: EventBus handler 错误不中断订阅 | PASS | |
|
||||
| INV-5: 临时事件合并 | PASS | 5 秒窗口正确 |
|
||||
| INV-6: 工件 temp-rename 原子写 | PASS | |
|
||||
| INV-7: Workspace GC 策略 | PARTIAL | GC 逻辑正确但 SQL 有 bug (F-10) |
|
||||
| INV-8: Agent heartbeat 持久化 | FAIL | 仅内存,不写 DB |
|
||||
| INV-9: ExperienceMiner 4 种触发路径 | FAIL | 0 种实现 |
|
||||
| INV-10: read-before-edit 强制 | FAIL | 未实现 |
|
||||
| INV-11: 完成门禁强制 | FAIL | 未实现 |
|
||||
|
||||
---
|
||||
|
||||
## 17. 正面发现 (代码与设计匹配的部分)
|
||||
|
||||
1. **Monorepo 结构正确:** Bun workspace + Turborepo,7 个包分层清晰
|
||||
2. **SQLite Schema 完整:** 17 表、38 索引、PRAGMA、schema_meta 完全匹配
|
||||
3. **事件注册表完整:** 54 个持久事件 + 7 个临时事件全部注册
|
||||
4. **Enum 验证完整:** 18 个闭枚举全部覆盖
|
||||
5. **ArtifactStore 原子写入正确:** temp → sha256 → rename → event 流程完整
|
||||
6. **EventBus 错误隔离正确:** handler 异常不中断订阅
|
||||
7. **临时事件合并正确:** 7 种临时事件类型全部识别,5 秒窗口
|
||||
8. **EventIngestor 分离正确:** 持久/临时路径分离,不创建调度任务
|
||||
9. **SecretRedactor 覆盖良好:** 14 种凭证模式
|
||||
10. **CLI 命令完整:** 11/11 必需命令
|
||||
11. **WorkspaceManager GC 保留策略正确:** merged 7 天, abandoned 3 天
|
||||
12. **Heartbeat 合并窗口正确:** 5 秒
|
||||
13. **RetryPlanner 失败签名升级逻辑正确:** (但未接入)
|
||||
14. **所有 16 个仓库 CRUD 操作完整:** get/insert/update + 领域查询方法
|
||||
|
||||
---
|
||||
|
||||
## 18. 修复优先级建议
|
||||
|
||||
### P0 (立即修复 — 阻塞核心不变量)
|
||||
|
||||
1. **F-04: EventStore 事务边界** — 将 `_tx` 传递给所有仓库方法
|
||||
2. **F-05: Workspace status 枚举值** — `'created'` → `'active'`, `'merging'` → metadata
|
||||
3. **F-06: TaskAttemptRepository 列映射** — `failure_summary` → `failure_signature`
|
||||
4. **F-07: EventRepository 路由分隔符** — `.` → `/`
|
||||
5. **ToolRegistry `this` 绑定 bug** — 重构 ACTION_BRANCHES 为方法调用
|
||||
6. **CommandRiskAnalyzer `in` 操作符 bug** — `'sudo_likely' in trimmed` → `trimmed.includes('sudo')`
|
||||
|
||||
### P1 (短期修复 — 功能性缺陷)
|
||||
|
||||
7. **F-01/F-02: 项目级 DB schema** — 对齐 DebugKnowledgeStore 和 LearnedMemoryStore
|
||||
8. **补全 15 个缺失契约接口** — EventBus/EventStore/EventIngestor/ContextAssembler 等
|
||||
9. **PathClassifier 类别对齐** — 添加 `credential_store`, `project_air_shared/local`, `unknown`
|
||||
10. **PermissionEngine 类型对齐** — 4 profile, 6 action, grant scope
|
||||
11. **Scheduler 状态机补全** — BLOCKED/CANCELLED 状态, cancel_task, load_graph
|
||||
12. **IPC 信封补全** — 添加 5 个缺失字段, 修正握手顺序
|
||||
13. **注册 16 个缺失 MVP 工具** — fs.stat, process.kill, cpp.*, debug.*, gui.*, network.*
|
||||
14. **Main Agent 状态机补全** — 7 个缺失状态
|
||||
|
||||
### P2 (中期修复 — 完整性)
|
||||
|
||||
15. **ContextAssembler L6-L9** — 补全 4 个缺失层
|
||||
16. **Provider 能力矩阵** — 补全 ~80% 缺失字段
|
||||
17. **Worker 结果形状对齐** — 统一为 `WorkerResult<T>` 信封
|
||||
18. **Capability manifest 对齐** — 5 级 trust, 富依赖模型, 命名空间验证
|
||||
19. **Recovery 实现** — 孤儿扫描、PID 存活检查
|
||||
20. **EvidenceStore 持久化** — 从 EvidenceRepository 查询而非内存 Map
|
||||
|
||||
### P3 (长期 — 质量与文档)
|
||||
|
||||
21. **ADR 记录** — workers 包、Provider 类型强化、Doctor 扩展等设计偏差
|
||||
22. **DoctorIssueSeverity** — 添加缺失的 `"error"` 值
|
||||
23. **工具 Schema 对齐** — fs.edit, shell.run, artifact.create 等字段名/类型
|
||||
24. **Scope Escalation 实现** — ScopeImpactLevel, BlockerReport 集成
|
||||
25. **TUI renderer 集成** — OpenTUI/Solid 渲染引擎接入
|
||||
|
||||
---
|
||||
|
||||
## 19. 与设计文档冻结基线的一致性总结
|
||||
|
||||
| 基线文档 | 一致性 | 主要偏差 |
|
||||
|---|---|---|
|
||||
| interface-contracts-v1.md | 65% | 15 个契约缺失,Provider 字段偏差 |
|
||||
| db-schema-v1.md | 85% | 2 个项目级 DB 完全不匹配,事务边界违反 |
|
||||
| event-registry-v1.md | 95% | 事件计数注释偏差 1,其余完整 |
|
||||
| tool-registry-v1.md | 40% | 16/28 MVP 工具缺失,schema 字段名偏差 |
|
||||
| security-model-v1.md | 20% | 分类器/权限/Profile 类型全面偏差 |
|
||||
| capability-trust-v1.md | 30% | Manifest schema、trust level、依赖模型不匹配 |
|
||||
| scheduler-state-machine-v1.md | 35% | 缺 2 状态、3 方法、3 空状态、依赖类型缺失 |
|
||||
| main-agent-state-machine.md | 45% | 缺 7/13 状态 |
|
||||
| prompt-layering-v1.md | 50% | L6-L9 缺失,输出格式不匹配 |
|
||||
| provider-capability-matrix-v1.md | 20% | 能力矩阵仅实现 ~20% |
|
||||
| runtime-semantics-v1.md | 40% | 11 个不变量中 5 个违反 |
|
||||
| error-taxonomy-v1.md | 90% | ErrorKind/AirError 匹配,ToolErrorOutput 缺失 |
|
||||
| artifact-naming-v1.md | 80% | ArtifactStore 路径正确,命名规范部分偏差 |
|
||||
| scope-escalation-v1.md | 10% | ScopeImpactLevel/BlockerReport 未实现 |
|
||||
| cross-platform-matrix-v1.md | 80% | 平台检测类型存在但 Doctor 未使用 |
|
||||
| C4 module.md | 85% | 包结构匹配,workers 包为额外添加 |
|
||||
| C4 code-view.md | 90% | contracts 文件结构匹配 |
|
||||
| solution-architecture.md | 55% | 分层架构存在,Agent 交互链不完整 |
|
||||
| system-overview-design.md | 50% | 子系统存在但连接断 |
|
||||
| system-detailed-design.md | 45% | 类存在但方法签名/状态机偏差大 |
|
||||
|
||||
---
|
||||
|
||||
## 20. 结论
|
||||
|
||||
当前 V1.0.0 Alpha 代码实现处于 **骨架基本就位、语义大面积偏差** 的状态。monorepo 结构、SQLite schema、事件注册表等基础设施质量较高,但核心运行时子系统(Scheduler、IPC、Security、Context)与冻结基线之间存在结构性分歧。
|
||||
|
||||
**最高风险项** 是 EventStore 事务边界违反 (F-04),它会导致每个持久事件的域表更新在事务外执行,破坏数据一致性不变量。其次是 workspace status 枚举错误 (F-05) 会导致首次 workspace 创建即崩溃。
|
||||
|
||||
建议在继续 Phase 2-8 实现之前,先完成 P0 和 P1 修复,确保核心不变量和接口契约与设计文档对齐。
|
||||
|
||||
---
|
||||
|
||||
*审计完毕。本报告由 Qwen3.7-Max 独立生成,可与其他模型审计报告进行交叉比对。*
|
||||
0
AirPlan/docs/architecture/adr/ADR-0002-use-bun-typescript-monorepo.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0002-use-bun-typescript-monorepo.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0003-use-project-local-air-state.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0003-use-project-local-air-state.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0004-use-eventstore-domain-tables-and-projectionstore.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0004-use-eventstore-domain-tables-and-projectionstore.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0005-use-independent-worker-processes-and-ndjson-ipc.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0005-use-independent-worker-processes-and-ndjson-ipc.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0006-align-execution-layer-with-claude-code.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0006-align-execution-layer-with-claude-code.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0007-use-toolregistry-permissionengine-and-capability-manifests.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0007-use-toolregistry-permissionengine-and-capability-manifests.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0008-use-anthropic-canonical-messages-with-provider-adapters.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0008-use-anthropic-canonical-messages-with-provider-adapters.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0009-target-linux-first-with-tiered-platform-support.md
Normal file → Executable file
0
AirPlan/docs/architecture/adr/ADR-0009-target-linux-first-with-tiered-platform-support.md
Normal file → Executable file
0
AirPlan/docs/architecture/artifact-naming-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/artifact-naming-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/baselineV1.md
Normal file → Executable file
0
AirPlan/docs/architecture/baselineV1.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/README.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/README.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/deepseek-paper-analysis.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/deepseek-paper-analysis.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/deepseek-research-survey.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/deepseek-research-survey.md
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Coder-V2_2406.11931.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Coder-V2_2406.11931.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Coder_2401.14196.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Coder_2401.14196.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Math-V2.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Math-V2.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-OCR-2_2601.20552.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-OCR-2_2601.20552.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Prover-V1.5_2408.08152.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Prover-V1.5_2408.08152.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Prover-V2_2504.21801.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-Prover-V2_2504.21801.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-R1_2501.12948.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-R1_2501.12948.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-R1_Full_86pages.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-R1_Full_86pages.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V2_2405.04434.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V2_2405.04434.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V3.2_2512.02556.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V3.2_2512.02556.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V3_2412.19437.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V3_2412.19437.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V4-ModelCard.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V4-ModelCard.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V4_Technical_Report.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-V4_Technical_Report.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-VL2_2412.10302.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-VL2_2412.10302.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-VL_2403.05525.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeek-VL_2403.05525.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeekMath_2402.03300.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeekMath_2402.03300.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeekMoE_2401.06066.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/DeepSeekMoE_2401.06066.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Engram.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Engram.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Fire-Flyer_2408.14158.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Fire-Flyer_2408.14158.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/JanusFlow_2411.05820.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/JanusFlow_2411.05820.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Janus_2410.13848.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/Janus_2410.13848.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/NSA_2502.11089.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branch-deepcode-cli/papers/NSA_2502.11089.pdf
Normal file → Executable file
0
AirPlan/docs/architecture/branchvibebox/feasibility-plan.md
Normal file → Executable file
0
AirPlan/docs/architecture/branchvibebox/feasibility-plan.md
Normal file → Executable file
0
AirPlan/docs/architecture/branchvibebox/vibeboxbaseline.md
Normal file → Executable file
0
AirPlan/docs/architecture/branchvibebox/vibeboxbaseline.md
Normal file → Executable file
0
AirPlan/docs/architecture/c4/code-view.md
Normal file → Executable file
0
AirPlan/docs/architecture/c4/code-view.md
Normal file → Executable file
0
AirPlan/docs/architecture/capability-trust-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/capability-trust-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/cross-platform-matrix-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/cross-platform-matrix-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/db-schema-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/db-schema-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-1.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-1.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-2.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-2.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-3.md
Normal file → Executable file
0
AirPlan/docs/architecture/decisions-round-3.md
Normal file → Executable file
0
AirPlan/docs/architecture/detailed-design-audit.md
Normal file → Executable file
0
AirPlan/docs/architecture/detailed-design-audit.md
Normal file → Executable file
0
AirPlan/docs/architecture/error-taxonomy-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/error-taxonomy-v1.md
Normal file → Executable file
29
AirPlan/docs/architecture/event-registry-v1.md
Normal file → Executable file
29
AirPlan/docs/architecture/event-registry-v1.md
Normal file → Executable file
@@ -397,6 +397,35 @@ interface TaskInterruptedPayload {
|
||||
}
|
||||
```
|
||||
|
||||
#### `task.removed` v1
|
||||
|
||||
Persistence: durable.
|
||||
|
||||
Domain update: delete `tasks` row (only for pending status); insert event record.
|
||||
|
||||
```ts
|
||||
interface TaskRemovedPayload {
|
||||
task_id: string
|
||||
reason: string
|
||||
removed_by: string
|
||||
}
|
||||
```
|
||||
|
||||
#### `task.invalidated` v1
|
||||
|
||||
Persistence: durable.
|
||||
|
||||
Domain update: update `tasks.status = invalidated`; insert event record.
|
||||
|
||||
```ts
|
||||
interface TaskInvalidatedPayload {
|
||||
task_id: string
|
||||
adr_id: string
|
||||
reason: string
|
||||
rollback_ref?: string
|
||||
}
|
||||
```
|
||||
|
||||
### 3.5 Tool Events
|
||||
|
||||
#### `tool.started` v1
|
||||
|
||||
0
AirPlan/docs/architecture/gpt5.5pro系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/gpt5.5pro系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/gpt5概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/gpt5概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/interface-contracts-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/interface-contracts-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/main-agent-state-machine.md
Normal file → Executable file
0
AirPlan/docs/architecture/main-agent-state-machine.md
Normal file → Executable file
0
AirPlan/docs/architecture/mimo2.5概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/mimo2.5概要设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.7详细设计与UML审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.7详细设计与UML审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.8系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.8系统详细设计审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.8系统详细设计审查复查.md
Normal file → Executable file
0
AirPlan/docs/architecture/opus4.8系统详细设计审查复查.md
Normal file → Executable file
0
AirPlan/docs/architecture/prompt-layering-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/prompt-layering-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/provider-capability-matrix-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/provider-capability-matrix-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/runtime-semantics-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/runtime-semantics-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/scheduler-state-machine-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/scheduler-state-machine-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/scope-escalation-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/scope-escalation-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/security-model-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/security-model-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/system-detailed-design.md
Normal file → Executable file
0
AirPlan/docs/architecture/system-detailed-design.md
Normal file → Executable file
0
AirPlan/docs/architecture/system-overview-design.md
Normal file → Executable file
0
AirPlan/docs/architecture/system-overview-design.md
Normal file → Executable file
0
AirPlan/docs/architecture/tool-registry-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/tool-registry-v1.md
Normal file → Executable file
0
AirPlan/docs/architecture/vibeboxbaseline.md
Normal file → Executable file
0
AirPlan/docs/architecture/vibeboxbaseline.md
Normal file → Executable file
0
AirPlan/docs/architecture/多模型三视角审查联合评估.md
Normal file → Executable file
0
AirPlan/docs/architecture/多模型三视角审查联合评估.md
Normal file → Executable file
0
AirPlan/docs/architecture/多模型系统详细设计交叉审查汇总.md
Normal file → Executable file
0
AirPlan/docs/architecture/多模型系统详细设计交叉审查汇总.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查-R2.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查-R2.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查-R3.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查-R3.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查.md
Normal file → Executable file
0
AirPlan/docs/architecture/概要设计修复回归审查.md
Normal file → Executable file
770
AirPlan/docs/implementation/IMPLEMENTATION-PLAN.md
Executable file
770
AirPlan/docs/implementation/IMPLEMENTATION-PLAN.md
Executable file
@@ -0,0 +1,770 @@
|
||||
# AirCoding V1.0.0 Alpha — Implementation Plan & Task Breakdown
|
||||
|
||||
Date: 2026-06-02
|
||||
Status: **Implementation plan derived strictly from the FROZEN detailed design.** Architecture is frozen (DD §24). This plan adds **no** new contracts, events, DB columns, or runtime semantics.
|
||||
Branch: `GLM5-Achieve`
|
||||
Audience: **context-isolated executor agents (AirDo / cheap-model subagents).** Each task below is self-contained enough that an agent holding only that task's slice can implement it correctly.
|
||||
|
||||
---
|
||||
|
||||
## 0. How To Use This Plan (READ FIRST — every executor agent)
|
||||
|
||||
You are likely an **isolated subagent with partial context**. To avoid the most common slice-local mistakes:
|
||||
|
||||
1. **You MUST obey the 5 domain invariants** (DD §18.6), reproduced in §A1 below. Inject §A1 into your working context verbatim. INV-1 is the one partial context cannot otherwise detect.
|
||||
2. **You MUST NOT introduce new public contracts, event types, DB columns, or runtime semantics.** Everything is frozen. If a task seems to need one, STOP and emit a blocker — do not improvise. (DD §0)
|
||||
3. **Field naming**: exported contract fields are `snake_case`; class names `PascalCase`; private methods may be local `camelCase`. (DD §0)
|
||||
4. **Import direction is one-way and enforced by lint** (DD §2, §A2). Never cross a forbidden edge.
|
||||
5. **Authority precedence** when in doubt: `interface-contracts-v1.md` > `db-schema-v1.md` / `event-registry-v1.md` > `system-detailed-design.md` > this plan. This plan never overrides a frozen source; it routes you to the exact section.
|
||||
6. **Definition of Done** for any code task: (a) implements the cited contract verbatim; (b) passes `bun run typecheck`; (c) has unit tests green via `bun test`; (d) respects INV-1..5; (e) crosses no forbidden import edge. Side-effect tasks additionally need evidence (test output) attached.
|
||||
7. **Reference reuse**: if your task row in DD §23 names a reference project, consult it before re-deriving (renderer, diff engine, skill format, provider conversion). Reference checkouts are under `<repo-root>/reference/` (git-ignored). See §A3.
|
||||
|
||||
**Tech stack (frozen, ADR-0002):** TypeScript on **Bun**, Bun workspaces + **Turborepo**. Worker agents are independent Bun child processes (ADR-0005). IPC is NDJSON over stdio.
|
||||
|
||||
**Source-of-truth documents (all under `AirPlan/docs/architecture/`):**
|
||||
`interface-contracts-v1.md`, `db-schema-v1.md`, `event-registry-v1.md`, `c4/code-view.md`, `c4/module.md`, `scheduler-state-machine-v1.md`, `main-agent-state-machine.md`, `runtime-semantics-v1.md`, `scope-escalation-v1.md`, `security-model-v1.md`, `error-taxonomy-v1.md`, `prompt-layering-v1.md`, `provider-capability-matrix-v1.md`, `capability-trust-v1.md`, `artifact-naming-v1.md`, `system-overview-design.md`, `system-detailed-design.md`.
|
||||
|
||||
---
|
||||
|
||||
## 1. Phase Map & Critical Serialization
|
||||
|
||||
Phases follow overview §16. **Phases must be serialized at the boundaries below; tasks *within* a phase (and across phases with no dependency) are parallelizable.**
|
||||
|
||||
| Phase | Scope | Gate to next phase |
|
||||
|---|---|---|
|
||||
| **P0** | Monorepo skeleton + `packages/contracts` (type-only) | contracts compile; barrel exports complete |
|
||||
| **P1** | `.air` project/session storage, SQLite, migrations, EventStore/Bus/Ingestor, ArtifactStore/EvidenceStore | EventStore append+project+publish green; FK-off check green |
|
||||
| **P2** | ToolRegistry, PermissionEngine, built-in tools, CapabilityRegistry | tool call → permission → event flow green |
|
||||
| **P3** | Provider layer (`packages/llm`), ContextAssembler, prompt resources | provider stream normalized; context assembled Anthropic-canonical |
|
||||
| **P4** | Worker IPC, WorkerManager, Scheduler subsystem | worker-fixture E2E green; scheduler run_until_idle green |
|
||||
| **P5** | `packages/toolchain-cpp` complete C++ workflow | cpp detect→configure→build→parse→test→cppcheck green |
|
||||
| **P6** | ProjectionStore, `packages/tui` TUI/HUD | tui-smoke green; projection renders |
|
||||
| **P7** | MainAgent / ArchitectureDesigner / worker-role integration | direct-mode + architecture-gate E2E green |
|
||||
| **P8** | Release gates, Doctor bundle, packaging | `bun run release:check` green |
|
||||
|
||||
**Hard serialization edges (overview §16):**
|
||||
1. `contracts` before ALL implementation packages.
|
||||
2. DB schema (migrations) before storage/EventStore tests.
|
||||
3. ToolRegistry + PermissionEngine before any side-effect tool/worker.
|
||||
4. Provider/context contracts before agent prompts.
|
||||
5. IPC before real worker E2E.
|
||||
6. Projection contracts before TUI implementation.
|
||||
|
||||
**Parallelization guidance for cheap-model fan-out:**
|
||||
- Within P0: all 16 contract files are independent — fan out 16-wide.
|
||||
- Within P1: repositories (16) are independent of each other once `DatabaseManager`+migrations land — fan out wide; EventStore projection depends on repositories.
|
||||
- Within P2: each built-in tool is independent once ToolRegistry+PermissionEngine land.
|
||||
- P5 (cpp) and P6 (projection/TUI scaffolding) can overlap P4 partially since they depend on contracts + tool layer, not on Scheduler internals.
|
||||
|
||||
---
|
||||
|
||||
## 2. Task ID Scheme
|
||||
|
||||
`T-<phase><nn>` e.g. `T-001` (P0), `T-1xx` (P1) … `T-8xx` (P8). Each task lists: **Files**, **Implements** (contract/DD ref), **INV** (applicable invariants), **Depends on**, **DoD/verify**.
|
||||
|
||||
---
|
||||
|
||||
## Phase 0 — Skeleton & Contracts (`packages/contracts`)
|
||||
|
||||
> Gate: `bun install && bun run typecheck` green at repo root; every contract symbol in `interface-contracts-v1.md` §2–§21 is exported from the barrel. Contracts package is **type-only** (DD §3) — zero runtime deps.
|
||||
|
||||
### T-001 — Monorepo skeleton (root)
|
||||
- **Files:** `package.json` (root, Bun workspaces), `turbo.json`, `tsconfig.base.json`, `tsconfig.json`, `bunfig.toml`, `.gitignore` (merge — keep existing `/reference/` rule), `packages/*/package.json` + `packages/*/tsconfig.json` for all 6 packages.
|
||||
- **Implements:** ADR-0002 (Bun + workspaces + Turborepo); code-view §1 package list.
|
||||
- **Depends on:** none.
|
||||
- **DoD:** `bun install` resolves; `bun run typecheck` runs across the empty packages; package dependency graph in each `package.json` matches DD §2 allowed imports (contracts depends on nothing; runtime → contracts,llm; cli → runtime,tui,llm,cpp; tui → contracts; llm → contracts; cpp → contracts).
|
||||
- **INV:** INV-4 (encode import direction in workspace deps).
|
||||
|
||||
### T-002 — `contracts/ids.ts` + `error.ts`
|
||||
- **Files:** `packages/contracts/src/ids.ts`, `packages/contracts/src/error.ts`.
|
||||
- **Implements:** contracts §2 (primitive ID aliases, `Clock`, `IdGenerator`), §3 (`ErrorKind`, `ErrorSeverity`, `Retryability`, `AirError`). DD §3, §18.1.
|
||||
- **Depends on:** T-001.
|
||||
- **DoD:** all aliases + `AirError` interface exported verbatim from contracts §2/§3. Optional pure type-guard `is_air_error` allowed only if dependency-free (DD §3 IMPL).
|
||||
|
||||
### T-003 — `contracts/event.ts`
|
||||
- **Files:** `packages/contracts/src/event.ts`.
|
||||
- **Implements:** contracts §5 (`EntityType`, `EntityRef`, `EventSource`, `RuntimeEvent`, `EventFilter`). Note `EventSource.kind` literal set `"main"|"architecture_designer"|"scheduler"|"agent"|"tool"|"system"` (DD §2, §22.1).
|
||||
- **Depends on:** T-002.
|
||||
- **DoD:** `RuntimeEvent<T>` shape matches DD §22.1 exactly; `agent_type?: AgentType` optional field present.
|
||||
|
||||
### T-004 — `contracts/runtime.ts`
|
||||
- **Files:** `packages/contracts/src/runtime.ts`.
|
||||
- **Implements:** contracts: `AgentType` (`executor|reviewer|debugger|compactor|experience_miner`), `AgentRuntimeContext`, `ContextPack`; co-locate PromptLayer types + `ContextAssembler`-facing context types per DD §3 mapping (context.ts symbols → runtime.ts).
|
||||
- **Depends on:** T-002.
|
||||
- **DoD:** `AgentType` union is exactly the 5 worker roles (DD §2). PromptLayer/PromptLayerLevel L0–L9 union present (DD §10.2).
|
||||
|
||||
### T-005 — `contracts/ipc.ts`
|
||||
- **Files:** `packages/contracts/src/ipc.ts`.
|
||||
- **Implements:** contracts §10 IPC: `IpcDirection`, `IpcEnvelope`, `IpcKind`, `IpcMessage`, `ControlMessage`, payloads; plus `workers.ts` symbols (`WorkerRole`, `WorkerRuntime`, IPC payloads) merged here per DD §3.
|
||||
- **Depends on:** T-003, T-004.
|
||||
- **DoD:** direction typing present (parent→worker: `control`/`tool.result`/`tool.stream`; worker→parent: `event`/`log`/`tool.call`/`worker.result`/`worker.checkpoint`/`protocol.error`). DD §8.2.
|
||||
|
||||
### T-006 — `contracts/task.ts`
|
||||
- **Files:** `packages/contracts/src/task.ts`.
|
||||
- **Implements:** contracts §9: `TaskType`, `TaskScope`, `TaskDependencySpec`, `VerificationPolicy`, `TaskConstraints`, `TaskContextRefs`, `WorkerOutputContract`, `TaskSpec`, `TaskGraph` types, `Scheduler*` (`SchedulerWavePlan`, `SchedulerRunResult`), `TransactionManager`, `Repository<TRecord,TInsert,TUpdate>` (storage.ts symbols merged here per DD §3).
|
||||
- **Depends on:** T-004.
|
||||
- **DoD:** `TaskSpec` matches DD §22.1; `TaskType` includes `execute|review|debug|compact|mine_experience|docs` (DD §8.3).
|
||||
|
||||
### T-007 — `contracts/worker-result.ts`
|
||||
- **Files:** `packages/contracts/src/worker-result.ts`.
|
||||
- **Implements:** contracts §11: `WorkerStatus`, `WorkerResult`, `ExecutorResult`, `ReviewerResult`, `DebuggerResult`, `CompactorResult`, `ExperienceMinerResult`, `BlockerReport`, `Risk`, `FollowUpTask`.
|
||||
- **Depends on:** T-006, T-002 (AirError), T-009 (Evidence/Artifact refs) — see note.
|
||||
- **DoD:** `WorkerResult<T>` matches DD §22.1; `status ∈ {completed,failed,blocked,cancelled}`.
|
||||
|
||||
### T-008 — `contracts/tool.ts`
|
||||
- **Files:** `packages/contracts/src/tool.ts`.
|
||||
- **Implements:** contracts §12 + §21: `ToolCategory`, `ToolDefinition`, `ToolExecutor`, `StreamingToolExecutor`, `ToolExecutionContext`, `ToolResultEnvelope`, `ToolEvent`, `ToolRegistry`, plus `Diagnostic` + `semantic_signature` types (diagnostics.ts merged here, DD §3).
|
||||
- **Depends on:** T-004, T-009 (ArtifactRef/EvidenceRef referenced by envelopes).
|
||||
- **DoD:** `ToolDefinition<I,O>` matches DD §22.1; `Diagnostic` matches contracts §21.
|
||||
|
||||
### T-009 — `contracts/artifact.ts` + `evidence.ts`
|
||||
- **Files:** `packages/contracts/src/artifact.ts`, `packages/contracts/src/evidence.ts`.
|
||||
- **Implements:** contracts §14: `ArtifactRef`, `ArtifactCreateInput`, `ArtifactContext`, `ArtifactReadResult`, `ArtifactStore`, `EvidenceRef`, `EvidenceCreateInput`, `EvidenceStore`; plus `knowledge.ts` symbols (`DebugKnowledgeStore`, `LearnedMemoryStore`, `DebugRecord`, `LearnedMemory`) merged into `artifact.ts` per DD §3.
|
||||
- **Depends on:** T-002.
|
||||
- **DoD:** `EvidenceStore.list_for_entity(entity_type, entity_id)` present (NOT `list_for_task`). `ArtifactRef` matches DD §22.1.
|
||||
|
||||
### T-010 — `contracts/project.ts`
|
||||
- **Files:** `packages/contracts/src/project.ts`.
|
||||
- **Implements:** contracts §8: `ProjectContext`, `ProjectInitOptions`, `ProjectStore`, `SessionContext`, `OpenSessionOptions`, `SessionManager`.
|
||||
- **Depends on:** T-002.
|
||||
- **DoD:** matches contracts §8 verbatim.
|
||||
|
||||
### T-011 — `contracts/provider.ts`
|
||||
- **Files:** `packages/contracts/src/provider.ts`.
|
||||
- **Implements:** contracts §15: `ProviderCapabilityMatrix`, `ModelRequirement`, `ProviderCompletionInput`, `ProviderStreamEvent`, `ProviderAdapter`, `ProviderManager`, `ModelAssignment`.
|
||||
- **Depends on:** T-004.
|
||||
- **DoD:** matches contracts §15; `ProviderAdapter` matches DD §22.6.
|
||||
|
||||
### T-012 — `contracts/permission.ts`
|
||||
- **Files:** `packages/contracts/src/permission.ts`.
|
||||
- **Implements:** contracts §13: `PathPolicy`, `PermissionRequestContext`, `PermissionAction`, `PermissionGrantScope`, `PermissionDecision`, `PermissionRecordResult`, `PermissionEngine`.
|
||||
- **Depends on:** T-009.
|
||||
- **DoD:** `PermissionAction` covers `allow|announce_then_run|ask_user|deny|block|refuse` (DD §9.3). `PermissionDecision` matches DD §22.1.
|
||||
|
||||
### T-013 — `contracts/ui.ts`
|
||||
- **Files:** `packages/contracts/src/ui.ts`.
|
||||
- **Implements:** contracts §17: all `*Projection`, `ProjectionSnapshot`, `ProjectionStore`, `ProjectionClient`, `UiCommandChannel`; (projection.ts symbols merged here).
|
||||
- **Depends on:** T-006, T-009.
|
||||
- **DoD:** `CommandRunProjection.status` derivable values match DD §4.4 (`running|ok|error|cancelled|unknown`).
|
||||
|
||||
### T-014 — `contracts/capability.ts` + `platform.ts`
|
||||
- **Files:** `packages/contracts/src/capability.ts`, `packages/contracts/src/platform.ts`.
|
||||
- **Implements:** contracts §18 (`CapabilityManifestV1`, `ValidationResult`, `CapabilityRegistry`, trust levels), §19 (`DoctorService`, `DoctorRunInput`/`Output`, `DoctorIssue` — doctor.ts merged into platform.ts), cross-platform tier enums (from `cross-platform-matrix-v1.md`).
|
||||
- **Depends on:** T-008 (ToolRegistry ref), T-002.
|
||||
- **DoD:** trust levels `built_in|project_local|user_installed|verified_publisher|untrusted`; `CapabilityManifestV1.schema_version=1`.
|
||||
|
||||
### T-015 — `contracts/index.ts` barrel + boundary lint
|
||||
- **Files:** `packages/contracts/src/index.ts`, root ESLint/import-boundary config (e.g. `eslint-plugin-import` or `dependency-cruiser`) enforcing DD §2 / code-view §12 forbidden edges.
|
||||
- **Implements:** DD §3 rule 4 (barrel exports every contract file); DD §A2 forbidden edges.
|
||||
- **Depends on:** T-002..T-014.
|
||||
- **DoD:** barrel re-exports the full union; `bun run typecheck` green; lint fails on a deliberately-added forbidden import (test fixture), passes otherwise. **This is the P0 gate.**
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 — Storage, Events, Artifacts (`packages/runtime`)
|
||||
|
||||
> Gate: migrations create all db-schema §2–§18 tables; `EventStore.append` runs insert+project in one tx then publishes after commit; `SessionStore.referential_check()` green; ArtifactStore temp→rename→record green.
|
||||
|
||||
### T-101 — `DatabaseManager`
|
||||
- **Files:** `packages/runtime/src/storage/DatabaseManager.ts`.
|
||||
- **Implements:** `TransactionManager` (contracts §6) over Bun SQLite. DD §4.1.
|
||||
- **INV:** enables INV-1/INV-2 infra (single-writer tx).
|
||||
- **Depends on:** T-006, T-015.
|
||||
- **DoD:** on `open` sets `journal_mode=WAL`, `synchronous=NORMAL`, `foreign_keys=OFF` (db-schema §1); `transaction` wraps BEGIN/COMMIT/ROLLBACK; nested calls reuse active handle.
|
||||
|
||||
### T-102 — `MigrationRunner` + full V1 schema
|
||||
- **Files:** `packages/runtime/src/storage/MigrationRunner.ts`.
|
||||
- **Implements:** DD §4.2; creates ALL tables/indexes from `db-schema-v1.md` §2–§18; seeds `schema_meta` (`schema_version=1`).
|
||||
- **Depends on:** T-101.
|
||||
- **DoD:** idempotent create-on-empty; `currentVersion`/`targetVersion()=1`; updates `aircoding_version_last_opened` on open. Unit test: fresh DB → all 17 session tables present.
|
||||
|
||||
### T-103 — `assert_enum` helper + enum table
|
||||
- **Files:** `packages/runtime/src/storage/assertEnum.ts`.
|
||||
- **Implements:** DD §4.5; backs every closed-enum TEXT column (db-schema §21, 18 rows). Throws `AirError{kind:"system_error"}` on violation.
|
||||
- **Depends on:** T-102, T-002.
|
||||
- **DoD:** rejects an invalid enum value for each of the 18 columns (table-driven test).
|
||||
|
||||
### T-104..T-119 — Repositories (one task each, all parallel after T-103)
|
||||
Each implements `Repository<...>` (contracts §6), thin persistence only (no policy). Records mirror db-schema columns `snake_case`. DD §4.3.
|
||||
|
||||
| Task | File | Table (db-schema §) | Extra methods (DD §4.3) |
|
||||
|---|---|---|---|
|
||||
| T-104 | `repositories/SessionRepository.ts` | sessions (§3) | `list_active()` |
|
||||
| T-105 | `repositories/MessageRepository.ts` | messages (§4) | `list_by_session(session_id, since?)` |
|
||||
| T-106 | `repositories/MessageDraftRepository.ts` | message_drafts (§5) | `upsert`, `delete_for_message` |
|
||||
| T-107 | `repositories/EventRepository.ts` | events (§6) | `insert(rec,tx)`, `query(filter)` |
|
||||
| T-108 | `repositories/TaskRepository.ts` | tasks (§7) | `list_by_status`, `list_runnable_candidates` |
|
||||
| T-109 | `repositories/TaskDependencyRepository.ts` | task_dependencies (§8) | `list_for_task`, `list_dependents` |
|
||||
| T-110 | `repositories/TaskAttemptRepository.ts` | task_attempts (§9) | `next_attempt_index`, `list_by_task` |
|
||||
| T-111 | `repositories/AgentRepository.ts` | agents (§10) | `list_active`, `update_heartbeat` |
|
||||
| T-112 | `repositories/ToolRunRepository.ts` | tool_runs (§11) | `list_by_task`, `list_by_origin_message` |
|
||||
| T-113 | `repositories/CommandRunRepository.ts` | command_runs (§12) | `list_by_task` + `derive_command_status` (DD §4.4) |
|
||||
| T-114 | `repositories/ArtifactRepository.ts` | artifacts (§13) | `list_by_entity`, `get_by_uri` |
|
||||
| T-115 | `repositories/DiagnosticRepository.ts` | diagnostics (§14) | `list_by_signature`, `list_by_command_run` |
|
||||
| T-116 | `repositories/EvidenceRepository.ts` | evidence_refs (§15) | `list_for_entity(type,id)` |
|
||||
| T-117 | `repositories/WorkspaceRepository.ts` | workspaces (§16) | `list_by_status`, `list_gc_candidates` |
|
||||
| T-118 | `repositories/SummaryRepository.ts` | summaries (§17) | `get`, `insert` |
|
||||
| T-119 | `repositories/UiStateRepository.ts` | ui_state (§18) | `upsert(scope,key,value)`, `read(scope,key)` |
|
||||
|
||||
- **INV (all):** INV-1 — repositories are storage-only; they **do not** set status columns by policy. Status columns are written only via EventStore.project. **Exemptions:** T-111 `update_heartbeat` (agents.last_heartbeat_at) and T-119 ui_state are the explicit INV-1 exemptions (DD §18.6).
|
||||
- **Depends on:** T-103.
|
||||
- **DoD (each):** CRUD + listed methods; columns match db-schema exactly; unit test round-trips a row.
|
||||
|
||||
### T-120 — `SessionStore` aggregate + `referential_check()`
|
||||
- **Files:** `packages/runtime/src/sessions/SessionStore.ts`.
|
||||
- **Implements:** DD §4.3 aggregate; `referential_check(): OrphanReport` implementing the 8 FK-off invariants (DD §18.3).
|
||||
- **Depends on:** T-104..T-119.
|
||||
- **DoD:** exposes all 16 repositories; `referential_check` detects each of the 8 invariant violations (table-driven test).
|
||||
|
||||
### T-121 — `EventSchemaRegistry`
|
||||
- **Files:** `packages/runtime/src/events/EventSchemaRegistry.ts`.
|
||||
- **Implements:** contracts §7; DD §5.2. Seeded from `event-registry-v1.md` §3 (durable) + §4 (ephemeral).
|
||||
- **Depends on:** T-003, T-015.
|
||||
- **DoD:** `register/validate/list/get_schema`; unknown type+version fails → ingestion can reject with `system_error`; all 55 durable + 7 ephemeral types registered.
|
||||
|
||||
### T-122 — `EventStore` (append + projection map)
|
||||
- **Files:** `packages/runtime/src/events/EventStore.ts`.
|
||||
- **Implements:** contracts §7; DD §5.3 + **§5.4 projection map (Table A + Table B)**. `append` = tx{ validate → EventRepository.insert → project(event,tx) } then `EventBus.publish` AFTER commit.
|
||||
- **INV:** **INV-1 (this is the ONLY place status columns are written)**, INV-2 (project never opens external DB/file), INV-5 (publish is post-commit transport).
|
||||
- **Depends on:** T-120, T-121, T-123 (EventBus).
|
||||
- **DoD:** every durable event in event-registry §3 has a projection case (Table A); Table B events (`memory.promoted`, `memory.archived`, `debug.record.created`) append event row only, no external write; project() throw → full rollback, no publish (DD §5.3 error handling). Unit test per projection case.
|
||||
|
||||
### T-123 — `EventBus`
|
||||
- **Files:** `packages/runtime/src/events/EventBus.ts`.
|
||||
- **Implements:** contracts §7; DD §5.5. Live transport only; handler throw is caught+logged, subscription survives; `drain()` flushes; ephemeral coalescing for the 7 ephemeral types.
|
||||
- **INV:** INV-5.
|
||||
- **Depends on:** T-003, T-015.
|
||||
- **DoD:** publish/subscribe/match/drain; never a recovery source.
|
||||
|
||||
### T-124 — `EventIngestor`
|
||||
- **Files:** `packages/runtime/src/events/EventIngestor.ts`.
|
||||
- **Implements:** contracts §7; DD §5.1. `ingest` routes durable→EventStore.append, ephemeral→EventBus.publish by registry policy.
|
||||
- **Depends on:** T-122, T-123.
|
||||
- **DoD:** durable type → EventStore path; ephemeral type → bus path; never creates tasks/permissions/memory itself.
|
||||
|
||||
### T-125 — `ProjectStore` (+ `ProjectLocator`, `ProjectInitializer`)
|
||||
- **Files:** `packages/runtime/src/project/ProjectStore.ts`, `ProjectLocator.ts`, `ProjectInitializer.ts`.
|
||||
- **Implements:** contracts §8; DD §6.1. `.air/shared` + `.air/local` scaffolding (overview §8.1); stable `project_id` UUID in `.air/shared/project.json`.
|
||||
- **Depends on:** T-010, T-015.
|
||||
- **DoD:** `locate` walks up to `.air/shared/project.json`; `initialize` creates trees + project_id; `open` loads ProjectContext. No session DB created until session opens.
|
||||
|
||||
### T-126 — `SessionManager`
|
||||
- **Files:** `packages/runtime/src/sessions/SessionManager.ts`.
|
||||
- **Implements:** contracts §8; DD §6.2. `open_session` computes db_path, opens+migrates, ingests `session.created`; provider/model fixed at open (immutable, overview §14).
|
||||
- **Depends on:** T-125, T-126-dep: T-124, T-102, T-120.
|
||||
- **DoD:** open→migrate→ingest `session.created`→returns SessionContext; `close_session` flushes ui_state + releases handle.
|
||||
|
||||
### T-127 — `ArtifactStore`
|
||||
- **Files:** `packages/runtime/src/artifacts/ArtifactStore.ts`.
|
||||
- **Implements:** contracts §14; DD §11.1; naming from `artifact-naming-v1.md`.
|
||||
- **INV:** INV-1 (artifact.created writes session row via projection — store calls EventIngestor, does not UPDATE).
|
||||
- **Depends on:** T-124, T-009.
|
||||
- **DoD:** `create` = write temp → sha256+size → atomic rename → ingest `artifact.created`; `artifact_id=art_<ulid>`; uri/filename per artifact-naming-v1; type from closed set. DB-insert-after-rename failure path documented for recovery (DD §16.3).
|
||||
|
||||
### T-128 — `EvidenceStore`
|
||||
- **Files:** `packages/runtime/src/artifacts/EvidenceStore.ts`.
|
||||
- **Implements:** contracts §14; DD §11.2.
|
||||
- **INV:** INV-1.
|
||||
- **Depends on:** T-124, T-009.
|
||||
- **DoD:** `create` ingests `evidence.created`; `list_for_entity(entity_type,entity_id)`; `kind` from closed set.
|
||||
|
||||
### T-129 — Recovery: orphan-artifact + FK-off scan wiring
|
||||
- **Files:** `packages/runtime/src/storage/Recovery.ts` (recovery helpers used by SessionManager/Scheduler startup).
|
||||
- **Implements:** DD §16.3 steps 5–6 (orphan-artifact scan; FK-off orphan scan calls `SessionStore.referential_check`).
|
||||
- **Depends on:** T-120, T-127.
|
||||
- **DoD:** orphaned artifact file → registered or quarantined; dangling ref → logged + re-parented/archived. (Full recovery sequence completed in P4 T-4xx.)
|
||||
|
||||
---
|
||||
|
||||
## Phase 2 — Tools, Permission, Capability (`packages/runtime`)
|
||||
|
||||
> Gate: `ToolRegistry.call` runs lookup→validate→PermissionEngine.evaluate→branch→emit tool.started→execute→emit tool.completed/failed/cancelled. No side effect bypasses PermissionEngine (code-view §12).
|
||||
|
||||
### T-201 — `PathClassifier`
|
||||
- **Files:** `packages/runtime/src/security/PathClassifier.ts`.
|
||||
- **Implements:** DD §9.2; `security-model-v1.md`. 8 path categories; realpath normalization before prefix checks; `.git/` internals protected.
|
||||
- **Depends on:** T-012.
|
||||
- **DoD:** classifies the 8 categories; symlink escape not allowed by string-prefix (realpath test).
|
||||
|
||||
### T-202 — `CommandRiskAnalyzer`
|
||||
- **Files:** `packages/runtime/src/security/CommandRiskAnalyzer.ts`.
|
||||
- **Implements:** DD §9.2; security-model-v1. 10 command-risk categories; `sudo` risk by intent/target, not string alone (DD §18.5).
|
||||
- **Depends on:** T-012.
|
||||
- **DoD:** 10 categories covered; destructive command flagged; intent-based sudo test.
|
||||
|
||||
### T-203 — `SecretRedactor`
|
||||
- **Files:** `packages/runtime/src/security/SecretRedactor.ts`.
|
||||
- **Implements:** DD §9.2 / §16.2. Redacts secrets/auth refs/provider keys for logs/evidence.
|
||||
- **Depends on:** T-001.
|
||||
- **DoD:** redacts known secret patterns; shared by PermissionEngine + Logger.
|
||||
|
||||
### T-204 — `PermissionEngine`
|
||||
- **Files:** `packages/runtime/src/security/PermissionEngine.ts`.
|
||||
- **Implements:** contracts §13; DD §9.2. Layered order 1–6 (capability → profile → task scope → risk → credential override → user prompt). `record` writes `permission.decision.recorded`.
|
||||
- **INV:** INV-3 (the mandatory gate for all side effects).
|
||||
- **Depends on:** T-201, T-202, T-203, T-124.
|
||||
- **DoD:** project-allow never overrides task scope; credential/system-sensitive overrides broad allow; realpath prefix; `record` returns `{ok:false,error}` on write failure.
|
||||
|
||||
### T-205 — `ToolRegistry`
|
||||
- **Files:** `packages/runtime/src/tools/ToolRegistry.ts`.
|
||||
- **Implements:** contracts §12; DD §9.1 + §9.3 branching table.
|
||||
- **INV:** INV-3.
|
||||
- **Depends on:** T-204, T-124, T-127 (backup/artifact).
|
||||
- **DoD:** `call`/`call_streaming` per DD §9.1 algorithm; branches on all 6 `PermissionAction`s (DD §9.3); `call_streaming` ends with exactly one final `ToolResultEnvelope`.
|
||||
|
||||
### T-206..T-213 — Built-in tools (one task each, parallel after T-205)
|
||||
Each: a `ToolDefinition` (declares `category`,`permissions`,`streaming`) + `ToolExecutor`, registered via `BuiltInToolRegistrar`. DD §9.1, code-view §4.
|
||||
|
||||
| Task | File group | Tools | Notes / DD |
|
||||
|---|---|---|---|
|
||||
| T-206 | `tools/fs/` | `fs.read`, `fs.edit`, `fs.patch`, `fs.write`, `fs.list` | **read-before-edit + exact-edit enforced at tool layer** (DD §9.4); successful edit/patch emits diff artifact. Reference: DD §23 (Claude Code behavioral, Codex pattern). |
|
||||
| T-207 | `tools/shell/` | `shell.run` | emits `command.started`/`command.completed`; streaming stdout/stderr deltas (ephemeral). |
|
||||
| T-208 | `tools/git/` | `git.*` (status/diff/commit/branch/merge as scoped) | `.git/` internals protected (DD §18.5). |
|
||||
| T-209 | `tools/project/` | `project.*` (rules/context read) | read-only project metadata. |
|
||||
| T-210 | `tools/artifact/` | `artifact.create/read` | wraps ArtifactStore. |
|
||||
| T-211 | `tools/context/` | `context.*` (assemble/compact triggers) | wraps ContextAssembler (available P3). Stub acceptable in P2; finalize in P3. |
|
||||
| T-212 | `tools/permission/` | `permission.*` (prompt resolve plumbing) | emits `permission.prompt.requested/resolved`. |
|
||||
| T-213 | `tools/doctor/` | `doctor.*` | wraps DoctorService (P8). Stub acceptable in P2. |
|
||||
| T-214 | `tools/BuiltInToolRegistrar.ts` | registrar | registers all of the above into a ToolRegistry. |
|
||||
|
||||
- **INV (all):** INV-3 (every tool goes through evaluate first — guaranteed by going through ToolRegistry.call, do NOT call side effects directly).
|
||||
- **Depends on:** T-205.
|
||||
- **DoD (each):** input schema validated; permission consulted; correct events emitted; unit test with a fake PermissionEngine returning each action.
|
||||
|
||||
### T-215 — `CapabilityManifestValidator`
|
||||
- **Files:** `packages/runtime/src/capabilities/CapabilityManifestValidator.ts`.
|
||||
- **Implements:** contracts §18; DD §9.5. Validates `schema_version=1`, tool schemas, permissions.
|
||||
- **Depends on:** T-014.
|
||||
- **DoD:** accepts a valid manifest, rejects bad schema_version/missing fields.
|
||||
|
||||
### T-216 — `CapabilityRegistry`
|
||||
- **Files:** `packages/runtime/src/capabilities/CapabilityRegistry.ts`.
|
||||
- **Implements:** contracts §18; DD §9.5. Lifecycle discovered→validated→doctor_checked→enabled→registered→active. Trust levels affect default posture, never bypass ToolRegistry/PermissionEngine.
|
||||
- **INV:** INV-4 (dependency installs go only through Doctor).
|
||||
- **Depends on:** T-215, T-205.
|
||||
- **DoD:** `discover/validate/enable/disable/register_tools`; enabling registers tools into ToolRegistry; dependency install delegates to Doctor (no direct install).
|
||||
|
||||
---
|
||||
|
||||
## Phase 3 — Provider & Context (`packages/llm` + `packages/runtime/context`)
|
||||
|
||||
> Gate: provider stream normalized to `ProviderStreamEvent`; `ContextAssembler.assemble` returns Anthropic-canonical AssembledContext; prompt layers L0–L9 ordered.
|
||||
|
||||
### T-301 — `ModelConfigLoader`
|
||||
- **Files:** `packages/llm/src/ModelConfigLoader.ts`.
|
||||
- **Implements:** DD §12.2. Loads global `~/.air/models.yaml` + project config.
|
||||
- **Depends on:** T-011, T-001.
|
||||
- **DoD:** loads model config; validates required fields.
|
||||
|
||||
### T-302 — `CapabilityMatrixRegistry`
|
||||
- **Files:** `packages/llm/src/CapabilityMatrix.ts`.
|
||||
- **Implements:** DD §12.2; holds `ProviderCapabilityMatrix` rows (`provider-capability-matrix-v1.md`).
|
||||
- **Depends on:** T-011.
|
||||
- **DoD:** lookup by provider/model; matches matrix doc.
|
||||
|
||||
### T-303 — `AnthropicCanonicalConverter` + `ToolUseConverter` + `StreamNormalizer`
|
||||
- **Files:** `packages/llm/src/canonical/AnthropicCanonical.ts`, `ToolUseConverter.ts`, `StreamNormalizer.ts`.
|
||||
- **Implements:** DD §12.2; Anthropic-canonical internal format (D-016 / DD §23 behavioral ref: Claude Code message model). **Must not silently drop semantic prompt/tool info** (contracts §23).
|
||||
- **Reference:** DD §23 — `@opencode-ai/llm` (fork/adapt) for conversion structure; Claude Code message model (behavioral).
|
||||
- **Depends on:** T-011.
|
||||
- **DoD:** round-trips canonical↔provider for text/thinking/tool_use/tool_result blocks; conversion report flags any dropped field.
|
||||
|
||||
### T-304 — `AnthropicAdapter`
|
||||
- **Files:** `packages/llm/src/adapters/AnthropicAdapter.ts`.
|
||||
- **Implements:** `ProviderAdapter` (contracts §15); DD §12.2.
|
||||
- **Depends on:** T-303.
|
||||
- **DoD:** `list_models/validate_model/complete/count_tokens?`; streams normalized events.
|
||||
|
||||
### T-305 — `OpenAICompatibleAdapter`
|
||||
- **Files:** `packages/llm/src/adapters/OpenAICompatibleAdapter.ts`.
|
||||
- **Implements:** `ProviderAdapter`; uses `AnthropicCanonicalConverter`.
|
||||
- **Depends on:** T-303.
|
||||
- **DoD:** converts canonical↔OpenAI-compatible; streams normalized; no silent semantic loss.
|
||||
|
||||
### T-306 — `ProviderManager`
|
||||
- **Files:** `packages/llm/src/ProviderManager.ts`, `packages/llm/src/index.ts` (facade export).
|
||||
- **Implements:** contracts §15; DD §12.1. `load_config/select_model/complete`; `adapter_for`. No runtime model switching (immutable per session).
|
||||
- **INV:** INV-4 (runtime calls llm only via this facade).
|
||||
- **Depends on:** T-301, T-302, T-304, T-305.
|
||||
- **DoD:** `select_model` matches ModelRequirement against matrix → ModelAssignment; `complete` routes to adapter; facade is the only export surface runtime imports.
|
||||
|
||||
### T-307 — `PromptLayerLoader`
|
||||
- **Files:** `packages/runtime/src/context/PromptLayerLoader.ts`.
|
||||
- **Implements:** contracts §16; DD §10.2. 4 methods: `load_runtime_invariant` (L0), `load_role` (L1, worker AgentType only), `load_project_rules` (L3), `load_task_context` (L5).
|
||||
- **Depends on:** T-004, T-010.
|
||||
- **DoD:** loads L0/L1/L3/L5; `load_role` accepts only worker AgentType (runtime roles load built-in directly).
|
||||
|
||||
### T-308 — Built-in prompt resources (L0/L1)
|
||||
- **Files:** `packages/runtime/src/context/prompts/` (runtime_invariant.md, roles/{executor,reviewer,debugger,compactor,experience_miner}.md, main.md, architecture.md).
|
||||
- **Implements:** prompt-layering-v1 L0/L1; DD §10.2. Inject §A1 (INV-1..5) into runtime_invariant L0.
|
||||
- **Depends on:** T-307.
|
||||
- **DoD:** L0 includes the 5 invariants; each worker role + main + architecture has a role prompt.
|
||||
|
||||
### T-309 — `CompactionPolicy`
|
||||
- **Files:** `packages/runtime/src/context/CompactionPolicy.ts`.
|
||||
- **Implements:** contracts §16; DD §10.3. `should_compact`, `compact` (compaction is executed by CompactorRole; policy decides + summarizes interface).
|
||||
- **Depends on:** T-004.
|
||||
- **DoD:** `should_compact` honors token budget; sequence ref documented (requested→started→summary.created→completed).
|
||||
|
||||
### T-310 — `ContextAssembler`
|
||||
- **Files:** `packages/runtime/src/context/ContextAssembler.ts`.
|
||||
- **Implements:** contracts §16; DD §10.1 + §10.2 layer-assembly table (L2/L4/L6/L7/L8/L9 internal).
|
||||
- **INV:** reads EvidenceStore (L6) + SessionStore (L7/L8) — read-only.
|
||||
- **Depends on:** T-307, T-309, T-120, T-128.
|
||||
- **DoD:** `assemble` → Anthropic-canonical AssembledContext; fits token_budget, reports omissions; writes messages artifact + sets `messages_artifact_id` when too large; sets `compaction_requested=true` when required layers don't fit; L0/L1/L2 never dropped.
|
||||
|
||||
---
|
||||
|
||||
## Phase 4 — Worker IPC & Scheduler (`packages/runtime` + `packages/workers`)
|
||||
|
||||
> Gate: worker-fixture E2E green (spawn→handshake→tool.call round-trip→worker.result); `Scheduler.run_until_idle` drives §20.2 to a terminal state.
|
||||
|
||||
### T-401 — `WorkerProtocol`
|
||||
- **Files:** `packages/runtime/src/workers/WorkerProtocol.ts`.
|
||||
- **Implements:** contracts §10; DD §8.2. NDJSON encode/decode, direction validation, protocol-version check.
|
||||
- **Depends on:** T-005.
|
||||
- **DoD:** encode/decode NDJSON line; `validate_direction` rejects wrong-channel msg; version mismatch handling.
|
||||
|
||||
### T-402 — `WorkerProcess`
|
||||
- **Files:** `packages/runtime/src/workers/WorkerProcess.ts`.
|
||||
- **Implements:** DD §8.1. Owns NDJSON pipe; stdout=protocol, stderr=fatal/log; exit-code table 0–5.
|
||||
- **Depends on:** T-401.
|
||||
- **DoD:** send/on_message; exit-code semantics per DD §8.1 table.
|
||||
|
||||
### T-403 — `WorkerManager`
|
||||
- **Files:** `packages/runtime/src/workers/WorkerManager.ts`.
|
||||
- **Implements:** DD §8.1. `spawn` (Bun child process + handshake), `cancel`.
|
||||
- **INV:** **INV-1 — WorkerManager never writes `agents.status` directly**; `worker.ready` handshake is a live signal, not a status write. `agent.started` projection sets status.
|
||||
- **Depends on:** T-402, T-124.
|
||||
- **DoD:** spawn→handshake (`agent.start`→`worker.ready`→validate protocol_version); cancel terminates worker; no direct agents.status UPDATE.
|
||||
|
||||
### T-404 — `WorkerRuntime` (in-worker side-effect surface)
|
||||
- **Files:** `packages/workers/src/WorkerRuntime.ts`.
|
||||
- **Implements:** contracts §10; DD §8.3. `emit`/`call_tool`/`checkpoint` — all via IPC to parent.
|
||||
- **INV:** **INV-3 — workers reach fs/shell/network/SQLite ONLY through parent-mediated tool IPC.** Never open SQLite or touch fs directly.
|
||||
- **Depends on:** T-401, T-005. (`packages/workers` imports only contracts + IPC surface — DD §2.)
|
||||
- **DoD:** `call_tool` → IPC `tool.call` → awaits `tool.result`; `emit` → IPC `event`; `checkpoint` → IPC `worker.checkpoint`. No direct side effects.
|
||||
|
||||
### T-405..T-409 — Worker roles (one task each, parallel after T-404)
|
||||
Each implements `WorkerRole<TResult>` (contracts §10/§11); DD §8.3/§8.4.
|
||||
|
||||
| Task | File | Role | Output | Write access |
|
||||
|---|---|---|---|---|
|
||||
| T-405 | `packages/workers/src/roles/ExecutorRole.ts` | Executor (also handles `docs`) | ExecutorResult | scoped project writes |
|
||||
| T-406 | `packages/workers/src/roles/ReviewerRole.ts` | Reviewer | ReviewerResult | read-only |
|
||||
| T-407 | `packages/workers/src/roles/DebuggerRole.ts` | Debugger | DebuggerResult | scoped writes when assigned |
|
||||
| T-408 | `packages/workers/src/roles/CompactorRole.ts` | Compactor | CompactorResult | summaries/artifacts only |
|
||||
| T-409 | `packages/workers/src/roles/ExperienceMinerRole.ts` | ExperienceMiner | ExperienceMinerResult | candidates/rules/skills when assigned |
|
||||
|
||||
- **INV (all):** INV-3 (all side effects via `WorkerRuntime.call_tool`). Executor/Debugger also enforce DD §8.4: read-before-edit, stay in write_area, run verification before `completed`, attach evidence.
|
||||
- **Depends on:** T-404.
|
||||
- **DoD (each):** `run` returns `WorkerResult<TResult>` with matching `agent_type`; code-changing result not `completed` unless verification passed or skipped-with-evidence; self-escalation returns `blocked` + BlockerReport.
|
||||
|
||||
### T-410 — worker entrypoint
|
||||
- **Files:** `packages/workers/src/main.ts` (child-process entry; reads `agent.start`, dispatches to role, returns `worker.result`).
|
||||
- **Depends on:** T-405..T-409.
|
||||
- **DoD:** handshake replies `worker.ready{protocol_version,worker_version}`; routes TaskType→role (DD §8.3 mapping); exit codes per DD §8.1.
|
||||
|
||||
### T-411 — `TaskGraph`
|
||||
- **Files:** `packages/runtime/src/scheduler/TaskGraph.ts`.
|
||||
- **Implements:** DD §7.2. `get_runnable_tasks` (hard deps done, conflicts blocked), `mark_terminal`, `dependents_of`, `validate_refs`.
|
||||
- **Depends on:** T-006, T-120.
|
||||
- **DoD:** dependency semantics per scheduler-state-machine §4; FK-off `validate_refs`.
|
||||
|
||||
### T-412 — `WavePlanner`
|
||||
- **Files:** `packages/runtime/src/scheduler/WavePlanner.ts`.
|
||||
- **Implements:** DD §7.3. `plan`→SchedulerWavePlan; serialize write conflicts; `assign_workspace`; `assign_model`.
|
||||
- **Depends on:** T-411, T-306.
|
||||
- **DoD:** different write areas→concurrent; same uncertain area→serialize; reviewers concurrent except vs unstable outputs; resource cap; inferred conflict/serialization edges persisted via task_dependencies + events.
|
||||
|
||||
### T-413 — `RetryPlanner`
|
||||
- **Files:** `packages/runtime/src/scheduler/RetryPlanner.ts`.
|
||||
- **Implements:** DD §7.4. `decide`→RetryDecision (`retry|retry_serial|debug|skip|block|cancel`).
|
||||
- **Depends on:** T-006, T-002.
|
||||
- **DoD:** identical failure_signature escalates faster; env impossibility→block; arch/interface mismatch→route to ArchitectureDesigner; budget = retry_budget.
|
||||
|
||||
### T-414 — `WorkspaceManager`
|
||||
- **Files:** `packages/runtime/src/scheduler/WorkspaceManager.ts`.
|
||||
- **Implements:** DD §7.5. `create_workspace`/`merge_workspace`/`cleanup_workspace`. Strategies main/worktree/isolated_copy. **Mechanism owner only — never plans.**
|
||||
- **INV:** INV-1 (workspaces.status only via workspace.* event projection).
|
||||
- **Depends on:** T-124, T-117, T-208 (git).
|
||||
- **DoD:** emits workspace.created/merge.started/merge.completed|conflicted/cleaned; GC retention (active→merged 7d→cleaned; abandoned 3d).
|
||||
|
||||
### T-415 — `AgentMonitor`
|
||||
- **Files:** `packages/runtime/src/scheduler/AgentMonitor.ts`.
|
||||
- **Implements:** DD §7.6. `record_heartbeat` (coalesced), `detect_lost_agents`, `enforce_timeouts`.
|
||||
- **INV:** INV-1 exemption — heartbeat timestamps are the ONLY direct writes allowed (agents.last_heartbeat_at, tasks.heartbeat_at).
|
||||
- **Depends on:** T-111, T-124.
|
||||
- **DoD:** 5s coalescing; missing heartbeat→inspect→ping/soft-cancel or `agent.lost`; soft/hard timeout per scheduler-state-machine §MONITORING.
|
||||
|
||||
### T-416 — `Scheduler`
|
||||
- **Files:** `packages/runtime/src/scheduler/Scheduler.ts`.
|
||||
- **Implements:** contracts §9; DD §7.1 + state machine §20.2.
|
||||
- **INV:** **INV-1 (status only via emitted events for projection), INV-5 (rebuild queues from SQLite, not EventBus replay).**
|
||||
- **Depends on:** T-411, T-412, T-413, T-414, T-415, T-403, T-310.
|
||||
- **DoD:** `create_tasks` ingests task.created; `run_until_idle` drives IDLE→LOADING_GRAPH→PLANNING_WAVE→DISPATCHING→MONITORING→COLLECTING_RESULTS→(MERGING|REVIEWING_WAVE|REPAIRING_OR_CONTINUING)→terminal; never prompts directly (via Main Agent/PermissionEngine).
|
||||
|
||||
### T-417 — Recovery completion (startup/resume)
|
||||
- **Files:** extend `packages/runtime/src/storage/Recovery.ts`.
|
||||
- **Implements:** DD §16.3 full 8-step sequence (load running/interrupted tasks, PID liveness, agent.lost, preserve workspaces, orphan scan, FK-off scan, workspace GC, rebuild queue).
|
||||
- **INV:** INV-5 (rebuild from SQLite).
|
||||
- **Depends on:** T-416, T-129.
|
||||
- **DoD:** restart with in-flight tasks reconstructs scheduler queue; dead PID→agent.lost; workspaces preserved until decision.
|
||||
|
||||
### T-418 — worker-fixture E2E
|
||||
- **Files:** `packages/runtime/test/e2e/worker-fixture.test.ts` + fixture worker.
|
||||
- **Implements:** overview §17 `e2e worker-fixture`.
|
||||
- **Depends on:** T-410, T-416.
|
||||
- **DoD:** spawn→handshake→tool.call round-trip→worker.result→task.completed; **P4 gate**.
|
||||
|
||||
---
|
||||
|
||||
## Phase 5 — C++ Toolchain (`packages/toolchain-cpp`)
|
||||
|
||||
> Gate: detect→configure→build→parse diagnostics→test→cppcheck green on a fixture C++ project. Exposed via capability registration (code-view §2 rule 4), not direct runtime coupling.
|
||||
|
||||
### T-501 — `DiagnosticParser`
|
||||
- **Files:** `packages/toolchain-cpp/src/analysis/DiagnosticParser.ts`.
|
||||
- **Implements:** DD §15. `parse_compiler_output`→Diagnostic[] (contracts §21), `semantic_signature` (deterministic; NO LLM here).
|
||||
- **Depends on:** T-008.
|
||||
- **DoD:** parses gcc/clang output to Diagnostic; stable semantic_signature.
|
||||
|
||||
### T-502 — `CppProjectDetector`
|
||||
- **Files:** `packages/toolchain-cpp/src/detect/CppProjectDetector.ts`.
|
||||
- **Implements:** DD §15. `detect`→CppDetectOutput.
|
||||
- **Depends on:** T-008.
|
||||
- **DoD:** detects CMake/Make project, toolchain presence.
|
||||
|
||||
### T-503 — `CMakeConfigurator`
|
||||
- **Files:** `packages/toolchain-cpp/src/build/CMakeConfigurator.ts`.
|
||||
- **Implements:** DD §15. CMake+Ninja preferred, Make fallback; generates/locates `compile_commands.json`.
|
||||
- **Depends on:** T-501.
|
||||
- **DoD:** configure output + compile_commands.json path.
|
||||
|
||||
### T-504 — `CppBuilder`
|
||||
- **Files:** `packages/toolchain-cpp/src/build/CppBuilder.ts`.
|
||||
- **Implements:** DD §15. `build`→CppBuildOutput; diagnostics via DiagnosticParser.
|
||||
- **Depends on:** T-501, T-503.
|
||||
- **DoD:** build + parsed diagnostics.
|
||||
|
||||
### T-505 — `CppTestRunner`
|
||||
- **Files:** `packages/toolchain-cpp/src/test/CppTestRunner.ts`.
|
||||
- **Implements:** DD §15. `run_tests`→CppTestOutput.
|
||||
- **Depends on:** T-501.
|
||||
- **DoD:** runs ctest/test target; parses results.
|
||||
|
||||
### T-506 — `CppcheckRunner`
|
||||
- **Files:** `packages/toolchain-cpp/src/analysis/CppcheckRunner.ts`.
|
||||
- **Implements:** DD §15. `run`→CppcheckOutput; exhaustive branch checking.
|
||||
- **Reference:** DD §23 (airsdb cppcheck pattern, asciinema/atuin PTY not needed here).
|
||||
- **Depends on:** T-501.
|
||||
- **DoD:** cppcheck invocation + parsed diagnostics.
|
||||
|
||||
### T-507 — `ClangdClient`
|
||||
- **Files:** `packages/toolchain-cpp/src/analysis/ClangdClient.ts`.
|
||||
- **Implements:** DD §15. `query`→ClangdQueryOutput (uses compile_commands.json).
|
||||
- **Depends on:** T-501, T-503.
|
||||
- **DoD:** clangd LSP query for symbol/diagnostic.
|
||||
|
||||
### T-508 — `CppToolRegistrar` + capability manifest
|
||||
- **Files:** `packages/toolchain-cpp/src/CppToolRegistrar.ts`, `packages/toolchain-cpp/src/capability.ts`, `index.ts`.
|
||||
- **Implements:** DD §15; registers `cpp.*` tools through CapabilityRegistry.
|
||||
- **INV:** INV-4 (registered via capability boundary, not direct runtime import).
|
||||
- **Depends on:** T-502..T-507, T-216.
|
||||
- **DoD:** `cpp.*` tools registered through capability registration; **P5 gate** (cpp fixture E2E).
|
||||
|
||||
---
|
||||
|
||||
## Phase 6 — Projection & TUI (`packages/runtime/projection` + `packages/tui`)
|
||||
|
||||
> Gate: tui-smoke green; projections render from snapshot+events. TUI imports ONLY contracts + ProjectionClient (code-view §2 rule 3 / §7).
|
||||
|
||||
### T-601 — `ProjectionStore`
|
||||
- **Files:** `packages/runtime/src/projection/ProjectionStore.ts`, `projections/*`.
|
||||
- **Implements:** contracts §17; DD §13.1. `hydrate` (from repositories), `apply` (durable + key ephemeral), `snapshot`, `subscribe`. command_runs status via DD §4.4. Never a scheduling/recovery source.
|
||||
- **Depends on:** T-013, T-120, T-123.
|
||||
- **DoD:** hydrate rebuilds from DB; apply handles all durable + listed ephemeral; unknown events ignored.
|
||||
|
||||
### T-602 — `ProjectionClient` + `TuiApp` shell
|
||||
- **Files:** `packages/tui/src/ProjectionClient.ts`, `packages/tui/src/TuiApp.tsx`, `index.ts`.
|
||||
- **Implements:** contracts §17; DD §13.2. In-process ProjectionClient (direct ref, not IPC).
|
||||
- **Reference:** DD §23 — **OpenTUI `@opentui/*` is `npm-dep`, do NOT build a renderer**; OpenCode TUI patterns (pattern, no SDK/session state).
|
||||
- **INV:** INV-4 (tui imports only contracts).
|
||||
- **Depends on:** T-601.
|
||||
- **DoD:** TuiApp start/stop; consumes ProjectionClient; no runtime-private import, no SQLite, no EventBus subscribe.
|
||||
|
||||
### T-603..T-610 — TUI components (parallel after T-602)
|
||||
| Task | File | Component | DD/notes |
|
||||
|---|---|---|---|
|
||||
| T-603 | `components/SessionView.tsx` | SessionView | render session projection |
|
||||
| T-604 | `components/TaskListView.tsx` | TaskListView | render tasks |
|
||||
| T-605 | `components/AgentStatusView.tsx` | AgentStatusView | render agents |
|
||||
| T-606 | `components/ToolRunView.tsx` | ToolRunView | render tool/command runs |
|
||||
| T-607 | `components/DiffView.tsx` + `EvidenceView.tsx` | Diff/Evidence | link back to artifact/evidence refs (code-view §7 rule 5) |
|
||||
| T-608 | `components/PermissionPrompt.tsx` | PermissionPrompt | emits via UiCommandChannel only (never private services) |
|
||||
| T-609 | `components/BlockerReport.tsx` | BlockerReport | render BlockerReport |
|
||||
| T-610 | `components/HudView.tsx` + `theme/` + `keymap/` | HudView | HUD presets Full/Essential/Minimal; reference claude-hud/atuin/asciinema (pattern) |
|
||||
|
||||
- **INV (all):** components render projections only; never mutate domain tables; permission decisions only via UiCommandChannel.
|
||||
- **Depends on:** T-602.
|
||||
- **DoD (each):** renders from snapshot; no domain mutation. **P6 gate:** tui-smoke.
|
||||
|
||||
---
|
||||
|
||||
## Phase 7 — Agents Integration (`packages/runtime/agents`)
|
||||
|
||||
> Gate: direct-mode-fixture + architecture-review-gate E2E green.
|
||||
|
||||
### T-701 — `MainAgent`
|
||||
- **Files:** `packages/runtime/src/agents/main/MainAgent.ts`.
|
||||
- **Implements:** DD §14.1 + state machine §20.1 (main-agent-state-machine.md).
|
||||
- **INV:** INV-1 (no direct status writes; works via Scheduler/events), INV-3.
|
||||
- **Depends on:** T-416, T-310, T-306.
|
||||
- **DoD:** `handle_user_message`→classify→ANSWERING|DELEGATING|DIRECT_MODE; full lifecycle to SUMMARIZING→IDLE; direct mode uses `main_direct` template; emits `requirement.changed`; confirmation gating per state machine.
|
||||
|
||||
### T-702 — `ArchitectureDesigner`
|
||||
- **Files:** `packages/runtime/src/agents/architecture/ArchitectureDesigner.ts`.
|
||||
- **Implements:** DD §14.2 + sequence §19.4. Review gate; result classes `silent_continue|requires_user_confirmation|requires_replan|reject_or_escalate` (scope-escalation §4).
|
||||
- **INV:** INV-3 (doc writes via ToolRegistry+PermissionEngine; no direct fs/shell).
|
||||
- **Depends on:** T-310, T-306, T-124.
|
||||
- **DoD:** `assess_impact`→ArchitectureImpact; emits `architecture.impact.completed`; `update_architecture_docs` only if confirmed→`architecture.plan.updated`; never replaces Reviewer.
|
||||
|
||||
### T-703 — `DebugKnowledgeStore`
|
||||
- **Files:** `packages/runtime/src/knowledge/DebugKnowledgeStore.ts`.
|
||||
- **Implements:** contracts §20; DD §11.3. Project DB `debug-records.db`.
|
||||
- **INV:** **INV-2 (single writer; outbox: external write first → then emit `debug.record.created`).**
|
||||
- **Depends on:** T-009, T-124.
|
||||
- **DoD:** insert/lookup_by_signature/lookup_by_task/update; outbox sequence per DD §18.4; never written by anyone else.
|
||||
|
||||
### T-704 — `LearnedMemoryStore`
|
||||
- **Files:** `packages/runtime/src/knowledge/LearnedMemoryStore.ts`.
|
||||
- **Implements:** contracts §20; DD §11.3. Project DB `learned-memory.db`.
|
||||
- **INV:** **INV-2 (single writer; outbox: external write first → then emit `memory.promoted`).**
|
||||
- **Reference:** DD §23 — Hermes Agent (pattern: Nudge/Curator); Anthropic Skills (pattern: SKILL.md format).
|
||||
- **Depends on:** T-009, T-124.
|
||||
- **DoD:** insert/lookup_by_type/update_status/scan_stale; `memory.promoted`/`memory.archived` outbox semantics (DD §18.4); never written by anyone else.
|
||||
|
||||
### T-705 — Role integration wiring + knowledge sequences
|
||||
- **Files:** wiring in `Scheduler`/`agents` to route DebuggerRole↔DebugKnowledgeStore and ExperienceMinerRole↔LearnedMemoryStore per sequences §19.5.
|
||||
- **Depends on:** T-703, T-704, T-407, T-409, T-416.
|
||||
- **DoD:** debug-knowledge-capture (§19.5) green; experience-mining promotes via outbox.
|
||||
|
||||
### T-706 — agent E2E fixtures
|
||||
- **Files:** `packages/runtime/test/e2e/{direct-mode-fixture,architecture-review-fixture}.test.ts`.
|
||||
- **Implements:** overview §17 additional UX gates.
|
||||
- **Depends on:** T-701, T-702.
|
||||
- **DoD:** direct-mode + architecture-gate E2E green; **P7 gate**.
|
||||
|
||||
---
|
||||
|
||||
## Phase 8 — CLI, Doctor, Release (`packages/cli` + `packages/runtime/doctor`)
|
||||
|
||||
> Gate: `bun run release:check` green; full validation suite (overview §17).
|
||||
|
||||
### T-801 — `Logger` + `DeveloperLogEncryptor`
|
||||
- **Files:** `packages/runtime/src/logging/Logger.ts`, `DeveloperLogEncryptor.ts`.
|
||||
- **Implements:** DD §16.2. `air.log` (redacted user-facing) + `air.developer.log` (encrypted). Uses SecretRedactor.
|
||||
- **Depends on:** T-203.
|
||||
- **DoD:** redacts secrets in both logs; encrypts developer log chunks.
|
||||
|
||||
### T-802 — `DoctorService`
|
||||
- **Files:** `packages/runtime/src/doctor/DoctorService.ts`, `checks/*`.
|
||||
- **Implements:** contracts §19; DD §16.1. Self-bootstrap (Bun/SQLite/shell/.air writability) before capability checks; modes read_only/fix(under PermissionEngine)/bundle.
|
||||
- **INV:** INV-4 (dependency installs originate here).
|
||||
- **Depends on:** T-216, T-204, T-127.
|
||||
- **DoD:** self_bootstrap blocks on failure; emits `doctor.*`; bundle = local artifact, no auto-upload (DD §18.5).
|
||||
|
||||
### T-803 — `RuntimeApp` + `ServiceRegistry` + `RuntimeFactory`
|
||||
- **Files:** `packages/runtime/src/app/RuntimeApp.ts`, `ServiceRegistry.ts`, `packages/cli/src/bootstrap/createRuntime.ts`, `loadConfig.ts`.
|
||||
- **Implements:** DD §22.2 (RuntimeApp/ServiceRegistry); wires all subsystems.
|
||||
- **Depends on:** T-126, T-416, T-601, T-802, T-306.
|
||||
- **DoD:** `start`/`shutdown` builds full service graph respecting dependency direction.
|
||||
|
||||
### T-804..T-808 — CLI commands (parallel after T-803)
|
||||
Each routes side effects through RuntimeApp services; never bypasses ToolRegistry/PermissionEngine (DD §17).
|
||||
|
||||
| Task | File | Command class | Subcommands |
|
||||
|---|---|---|---|
|
||||
| T-804 | `commands/run.ts` | RunCommand | `run [project]` (+ spawns TUI) |
|
||||
| T-805 | `commands/init.ts` | InitCommand | `init` (first-run wizard) |
|
||||
| T-806 | `commands/doctor.ts` | DoctorCommand | `doctor [--fix\|--bundle]` |
|
||||
| T-807 | `commands/provider.ts` | ProviderCommand | `provider list`, `provider current` (read-only, no switch) |
|
||||
| T-808 | `commands/{e2e,release,resume,compact,history,session,restore}.ts` | E2E/Release/Resume/Compact/History/SessionList/Restore | per DD §17 table |
|
||||
|
||||
- **Depends on:** T-803.
|
||||
- **DoD (each):** CliEntrypoint routes argv→command; matches DD §17 table; ProviderCommand read-only; RestoreCommand git-backed file/time/session granularity.
|
||||
|
||||
### T-809 — `CliEntrypoint` + release gate
|
||||
- **Files:** `packages/cli/src/index.ts`, `release:check` script, CI-less local harness.
|
||||
- **Implements:** overview §17 full validation list.
|
||||
- **Depends on:** T-804..T-808.
|
||||
- **DoD:** `bun run typecheck && bun test && bun run lint && bun run air -- doctor --read-only && ... && bun run release:check` all green. **P8 gate — release readiness.**
|
||||
|
||||
---
|
||||
|
||||
## Appendix
|
||||
|
||||
### A1 — The 5 Domain Invariants (DD §18.6) — INJECT INTO EVERY EXECUTOR CONTEXT
|
||||
|
||||
- **INV-1 — Session-DB state/lifecycle columns are written ONLY by `EventStore.project(event, tx)`.** No service issues a direct `UPDATE` to `*.status`/lifecycle columns. Authoritative table→event map in DD §18.6. **Exemptions (safe to write directly):** `agents.last_heartbeat_at`, `tasks.heartbeat_at` (AgentMonitor coalesce); `ui_state.*` (UiStateRepository). `command_runs` has NO status column — it's derived (DD §4.4).
|
||||
- **INV-2 — Cross-DB/external writes use the outbox model with a single writer.** `debug-records.db`, `learned-memory.db`, `rules/`, `skills/`, artifact files go through the owning store (single writer), external write FIRST → then ingest ONE completion event. `EventStore.project()` never opens an external DB/file.
|
||||
- **INV-3 — Side effects ONLY through `ToolRegistry.call` → `PermissionEngine.evaluate` first.** Workers reach fs/shell/network/SQLite only via parent-mediated tool IPC. LLM/provider output never performs a direct side effect.
|
||||
- **INV-4 — Import/dependency direction is one-way** (see A2). Capabilities install dependencies only through Doctor.
|
||||
- **INV-5 — EventBus is transport, never a source of truth.** Recovery/scheduling rebuild from SQLite, never from EventBus replay. Dropped/duplicated delivery must never change durable state.
|
||||
|
||||
### A2 — Allowed import graph (DD §2, frozen by c4/module.md + contracts §23)
|
||||
```
|
||||
contracts → (nothing)
|
||||
llm → contracts
|
||||
toolchain-cpp → contracts
|
||||
tui → contracts
|
||||
runtime → contracts, llm (facade only)
|
||||
cli → contracts, runtime, tui, llm, toolchain-cpp
|
||||
workers → contracts + WorkerRuntime IPC surface (NO direct runtime import)
|
||||
```
|
||||
Forbidden (enforced by lint, code-view §12): TUI direct DB access; worker direct SQLite writes; capability direct dependency install; provider adapter changing prompt semantics silently; tool execution without PermissionEngine; repositories containing scheduling policy.
|
||||
|
||||
### A3 — Reference reuse map (DD §23) — consult before re-deriving
|
||||
Reference checkouts under `<repo-root>/reference/` (git-ignored). Verify present & non-empty first.
|
||||
|
||||
| Slice | Reference | Mode |
|
||||
|---|---|---|
|
||||
| TUI renderer | OpenTUI `@opentui/*` | **npm-dep (do NOT reimplement)** |
|
||||
| TUI patterns | `reference/opencode-1.15.5/` | pattern (no SDK/session state) |
|
||||
| Provider/converters | `@opencode-ai/llm` (`reference/opencode-1.15.5/`) | fork/adapt (output stays Anthropic-canonical) |
|
||||
| Edit/patch discipline | `reference/claude-code-cli/` | behavioral (quality bar, no code) |
|
||||
| fs.edit/patch + test loop | `reference/openai-codex/` | pattern |
|
||||
| Knowledge/ExperienceMiner/Curator | `reference/hermes-agent-2026.5.16/` | pattern |
|
||||
| Skills (SKILL.md) | `reference/anthropic-skills/` | pattern |
|
||||
| Logging/HUD/PTY | `reference/asciinema-3.2.0/`, `reference/atuin-18.16.1/`, `reference/claude-hud-0.0.12/` | pattern |
|
||||
| Message format | `reference/claude-code-cli/` | behavioral |
|
||||
|
||||
### A4 — Validation gates (overview §17)
|
||||
```bash
|
||||
bun install
|
||||
bun run typecheck
|
||||
bun test
|
||||
bun run lint
|
||||
bun run air -- doctor --read-only
|
||||
bun run air -- e2e worker-fixture
|
||||
bun run air -- fixture cpp-build-test
|
||||
bun run air -- e2e cpp-fix-fixture
|
||||
bun run air -- e2e cpp-debug-review-fixture
|
||||
bun run air -- capability validate --all
|
||||
bun run air -- e2e direct-mode-fixture
|
||||
bun run air -- doctor --bundle
|
||||
bun run air -- tui-smoke --project <fixture>
|
||||
bun run release:check
|
||||
```
|
||||
|
||||
### A5 — Dependency summary (phase gates)
|
||||
```
|
||||
P0(contracts) ─▶ P1(storage/events) ─▶ P2(tools/perm) ─▶ P3(provider/context) ─▶ P4(workers/scheduler) ─▶ P7(agents) ─▶ P8(cli/release)
|
||||
│ │
|
||||
└────────────▶ P5(cpp, after P2) └─▶ P6(projection/TUI, after P3 contracts)
|
||||
```
|
||||
P5 and P6 may overlap P4 once their dependencies (P2 tools / P3 provider+context contracts) are met.
|
||||
|
||||
---
|
||||
|
||||
End of Implementation Plan.
|
||||
232
AirPlan/docs/round4-AUDIT-FINAL.md
Executable file
232
AirPlan/docs/round4-AUDIT-FINAL.md
Executable file
@@ -0,0 +1,232 @@
|
||||
# 全代码 code-to-design 审计 — 最终报告
|
||||
|
||||
> 14 子系统 code-to-design 比对汇总 (round4 Stage 3)
|
||||
> 源: 14 份 agent 子系统审计报告 (A-N) → 合并去重 + 严重度再评估 + 影响链标注
|
||||
|
||||
## 0. 元信息
|
||||
|
||||
- 14 子系统全部完成 (A: Contracts, B: Storage, C: Event, D: Lifecycle, E: Scheduler, F: Worker/IPC, G: Tool/Perm, H: Context, I: Artifact, J: Provider, K: Projection+TUI, L: Agents, M: Toolchain, N: Doctor)
|
||||
- 合并后共 **97 条发现** (CRITICAL 18 / DEVIATION 32 / GAP 27 / EXCESS 20)
|
||||
- 报告期: round4 plan §3 格式逐项对齐, INV-1/INV-2/INV-3/INV-5 多子系统重复违反
|
||||
|
||||
---
|
||||
|
||||
## 1. CRITICAL (必须修) — 共 18 条
|
||||
|
||||
| id | 子系统 | 标题 | 违反约束 | 触发场景 | 影响链 |
|
||||
|---|---|---|---|---|---|
|
||||
| round4-C-1 | A,B,D,J,K,L | **架构旁路: 多子系统自研 SessionManager/ProjectStore/ProviderManager 而旁路设计契约类** | DD §6.1-§6.2, §12, INV-2 single-writer | 启动任意 session, `RuntimeApp` / `init` / `ProviderManager` 全部跳过契约类, 直接 fs.write/SQLite/JSON.parse | 触发 C-2,C-4,C-5,C-8,C-11 |
|
||||
| round4-C-2 | C | **EventStore 单例 + 事后注入, SessionManager 创建的 EventStore 实例从未被消费** | DD §5.1 §22.2 构造注入 | 任何 session 打开后 `session.created` 写入空 db 或被抛弃, domain projection 变 no-op | C-3, C-6, C-15, G-C1 |
|
||||
| round4-C-3 | C | **`EventIngestor.ingest()` 走 fallback 无 tx 路径, 违反 `BEGIN/insert/project/COMMIT` 单事务** | runtime-semantics §3 | 同上事件路径, project() 与 event insert 不在同一事务 | C-2, I-C1 |
|
||||
| round4-C-4 | C | **`project()` switch 跳过 `context.compaction.*`/`permission.*`/`doctor.*`/`memory.*`/`debug.*` 20+ 事件类型** | DD §5.4 Table A+B | 上述事件全部不更新 domain table, 但 `events` 表行仍写 → 审计日志与 domain 永久不一致 | C-2, C-3, G-C2, N-D1 |
|
||||
| round4-C-5 | E | **失败/阻塞任务被路由到设计无的 `TERMINATED` 终态** | scheduler-state-machine §10 (仅 COMPLETED/BLOCKED/CANCELLED) | 任何 task 失败 → `run_until_idle` 退出但 API 不暴露 TERMINATED, 调度死锁 | E-2, E-7 |
|
||||
| round4-C-6 | E | **`PLANNING_WAVE → MONITORING` 跳过 `DISPATCHING`, 旁路 spawn** | scheduler-state-machine §4 | 任何非空 running task, 调度直接进入监控态, worker 永不被 spawn | E-3, E-5, F-C1 |
|
||||
| round4-C-7 | E | **Scheduler 公开 API `add_dependency` / `load_graph` / `cancel_task` 完全缺失** | DD §7.1, contracts task.ts:194-200 | DAG 编辑与取消无法调用, CLI/TUI 失去图编辑能力 | E-5, E-8 |
|
||||
| round4-C-8 | E,F | **`agent.start` IPC 控制消息未按设计携带 `context_pack`/`runtime`/`AgentRuntimeContext`, `WorkerRole.run` 单参** | DD §8.2 handshake, contracts §10 | worker 启动后拿不到 permission_template / ContextPack, 权限与上下文全空 | F-C2, F-D3, G-C3 |
|
||||
| round4-C-9 | F | **`WorkerRuntime` 自加 `call_llm`, 凭据路径走 `process.env.AIRCODING_MODEL` fallback 'glm-5.1', 绕过 TaskSpec.constraints.model_id** | DD §18 INV-3, interface-contracts §10 | worker 直连 LLM 风险 + 模型 ID 决定顺序错乱 (env > spec) | F-C1, J-C1, C-2 |
|
||||
| round4-C-10 | G | **ToolRegistry.call / PermissionEngine.record 完全不发射 `tool.*` / `permission.decision.recorded` 事件** | DD §9.1 §9.2, INV-1 | 任意 tool 调用与权限决策不入 `tool_runs` / 决策审计, 投影与追责链断 | C-4, G-C2, K-D1 |
|
||||
| round4-C-11 | G | **`execute_branch` 在 allow/announce_then_run 跳过 grant_scope 持久化与 backup_before_write** | DD §9.3, 安全模型 §11 | 同一 scope 每次 call 重复 prompt, 写操作无备份 | G-C1, G-D1 |
|
||||
| round4-C-12 | I | **CppToolRegistrar `write_artifacts` 完全旁路 ArtifactStore, 用 `file://` URI, 不算 sha256** | DD §994-1002, naming §8 | `cpp.build/test` 失败时写出的产物既不在 artifacts 表, 也无法回链 evidence | I-C3, I-G2, M-E1 |
|
||||
| round4-C-13 | I | **EvidenceStore.create 在 ingest event 后又重复插 `evidence_refs`, 打破 single-writer** | DD §18.4, runtime-semantics §6.3 | 每次 evidence 创建产 2 行 DB, 触发 FK-off 检测假阳 | C-3, B-C3 |
|
||||
| round4-C-14 | J | **ProviderManager 硬编码 `provider_id || 'anthropic'`, 多 provider 路由坍缩为单 provider fallback** | DD §12.1 §12.2 adapter_for(provider_id) | 任一 OpenAI/GLM 路径静默回落 anthropic 或抛 "No adapter selected" | J-D4, J-D5, J-G1, F-C1 |
|
||||
| round4-C-15 | L | **`CONFIRMING → confirm` 路由到 `DELEGATING` 而非 `EXECUTING` (Opus 报告"已修"未验证)** | DD §20.1 state machine | 用户确认后任务被 re-delegated 而非直接执行, 卡死 | L-2, L-3, E-7 |
|
||||
| round4-C-16 | L | **ArchitectureDesigner 放在 simple/plan 分支前, 强制所有 task-path 走 Architect 评估** | DD §20.1 §14.1 | 每个 task 请求都做 impact_assess, 性能与设计意图双重偏离 | L-3, L-4 |
|
||||
| round4-C-17 | N | **`DoctorService --fix` 裸跑 `sudo apt install`, 绕过 PermissionEngine** | DD §16.1, INV-3 | `--fix` 自动修复触发高危命令, 任何用户/任务权限配置被跳过 | N-D1, G-C3 |
|
||||
| round4-C-18 | B,C,I,N | **`Recovery.scanOrphanReferences` FK-off 8 不变量只覆盖 session_id 一类, 实际只查 5/8, 标修复但无 UPDATE/DELETE** | DD §18.3 §16.3, runtime-semantics §14 | 孤儿 task/agent/tool_run/command_run 不被检测/修复, 累积 → 重启后状态漂移 | C-6, I-C1, I-G2 |
|
||||
|
||||
---
|
||||
|
||||
## 2. DEVIATION (高优) — 共 32 条 (节选要点, 完整 32 条见附录)
|
||||
|
||||
| id | 子系统 | 偏离 | 影响 |
|
||||
|---|---|---|---|
|
||||
| D-A-1..6 | A | ProviderCapabilityMatrix / ProviderCompletionInput / ProviderManager.load_config / PromptLayerLoader / FollowUpTask.type 等 6 处与 contracts §15 §16 字段类型不一致 | type 漂移累积 → runtime/contracts 边界失真 |
|
||||
| D-B-1..6 | B | `list_active(project_id)` 必传参, `insert` 硬写 status='active', `update` 接受 patch.status 无守卫, `DatabaseHandle` 返回 `{path}` 不含 db, 类型在 MigrationRunner | INV-1 守卫仅靠注释, 模块边界混乱 |
|
||||
| D-C-1..7 | C | `EventSchemaRegistry.validate` 只查 type, `EventBus.publish` 内存泄漏, `append_many` 共享 tx, `project()` 跳过 20+ 事件, `ingest_batch` 不在 contract, `assistant.message.created` 投影顺序, `agent.started` 丢失 starting 分支 | 事件管道不严, 大量 corner case 未覆盖 |
|
||||
| D-D-1..4 | D | `ProjectionStore.rebuild` 一致 ✓, 但 `RuntimeApp` 启动序列命名/编号与 §22.2 不一致, migrate 走 ad-hoc dbHandle | 启动行为可观察但语义不清 |
|
||||
| D-E-1..8 | E | `SchedulerState` 多 TERMINATED, `WavePlanner` 字段名错, `record_heartbeat` 签名错且不写 domain, `WorkspaceManager` 不发事件, `RetryPlanner.decide` 永不被调, `TaskGraph.get_runnable_tasks` 忽略 soft/serialization, MONITORING 收 WorkerResult, `create_tasks` 跳过 LOADING_GRAPH | 调度可用但状态机闭包破坏 |
|
||||
| D-F-1..4 | F | IpcKind 双重协议 (IpcKind + WorkerMessageType), ExitCode 5 永未触发, NDJSON 编码只校验 4 字段, 父进程全量继承 process.env | 协议冗余, 凭据泄漏风险面 |
|
||||
| D-G-1..4 | G | `PermissionAction` 6 个但 block 不抛 task.blocked, `PermissionEngine.evaluate` 3 参, `BuiltInToolRegistrar` 18 vs 28 缺 cpp.*6/fs.stat 等, `call_streaming` 不处理 ask_user/block/refuse | 决策 schema 漂移, V1 工具面残缺 1/3 |
|
||||
| D-H-1..5 | H | L8 用 `message_repo` 替代 `tool_runs`/`command_runs`, `AssembledContext` 缺 `canonical_format:"anthropic"`, L6 Evidence 第一参错 (传 'task_id' 而非 'task'), `messages_artifact_id` 溢出路径未触发, CompactorRole 行为一致 ✓ | ArchitectureDesigner L4 失效, L6/L8 数据源错 |
|
||||
| D-I-1..4 | I | `artifact_id` 用 UUID 截 24 hex 不用 ULID, DebugKnowledgeStore/LearnedMemoryStore 自定 schema 不同步 contracts, ArtifactStore 不 gzip, `get` 暴力 readdir 不用 DB | 命名不匹配触发 Recovery 假阳, 性能浪费 |
|
||||
| D-J-1..5 | J | Adapter 缺 `count_tokens`, `complete` 非流式 (等待整响应再 yield), `ProviderConversionReport.status` 缺, `ModelConfigLoader` 不解析嵌套 YAML, `select_model` 忽略 ModelRequirement | capability-based selection 与流式语义失效 |
|
||||
| D-K-1..2 | K | `ProjectionStore.apply` 在生产路径是死代码 (RuntimeApp 用 snapshot push), `TuiApp.start` 返回 Promise | 路径与设计意图分裂 |
|
||||
| D-L-1..3 | L | MainAgent 状态多 ERROR+TERMINATED, AWAITING 状态无转换, `handle_user_message` 不返回 y/n 循环 | 状态爆炸但未连通 |
|
||||
| D-M-1..4 | M | `DiagnosticParser.semantic_signature` 名字/签名错, `ClangdClient` 拆 query_symbol/query_diagnostics, `CppProjectDetector` 实例化用构造参数, `CppTestRunner.parse_ctest_output` 不在设计 | 工具链接口小幅漂移, 可互通 |
|
||||
| D-N-1..6 | N | Doctor 8 类 (含 project/runtime 多), `run_diagnostics(scope)` 签名不符, 7-day retention 缺失, MigrationRunner 17 表 OK, Recovery 8 步只 3 步, FK 检查 5/8, SecretRedactor 未共享 | 运维数据积累无清理, 恢复路径不完整 |
|
||||
|
||||
---
|
||||
|
||||
## 3. GAP (设计有、实现无) — 共 27 条
|
||||
|
||||
**事件/存储契约层 (影响 4 子系统)**
|
||||
- G-1 缺失 §7 全部契约 `EventBus/EventStore/EventIngestor/EventSchemaRegistry/Subscription/EventAppendOptions` (A)
|
||||
- G-2 缺失 §6 持久化记录 `PersistedEventRecord/PersistedEventInsert/SessionRecord/MessageRecord/EventRepository` (A)
|
||||
- G-3 缺失 §16 Context 核心接口 `ContextAssembler/ContextAssembleInput/AssembledContext/CompactionPolicy/CompactionResult` (A)
|
||||
- G-4 `SessionStore` 聚合类缺失, 15 repos 散落 (B) — **触发 C-18**
|
||||
- G-5 Outbox 模型未实现 (B) — **触发 C-2, C-13, I-C1**
|
||||
- G-6 `EventIngestorFactory.createForSession` 无实现 (C)
|
||||
|
||||
**工具/能力层 (影响 3 子系统)**
|
||||
- G-7 BuiltIn 28 工具仅 18 注册, `cpp.*6`/`fs.stat`/`git.worktree`/`process.kill` 全部缺 (G) — **触发 C-12, M-E1**
|
||||
- G-8 `artifact.create/read` 工具是 stub 不调 ArtifactStore (I) — **触发 C-12**
|
||||
- G-9 `Recovery.open()` 无 bootstrap 调用点 (N) — **触发 C-18**
|
||||
- G-10 `check_capability()` private helper 缺失 (N)
|
||||
- G-11 `doctor --bundle` 命令模式缺失 (N)
|
||||
- G-12 `context.compaction.requested` 事件从未由 Scheduler 发出 (H) — **触发 C-4**
|
||||
- G-13 copy-on-write compaction 缺失 (H)
|
||||
- G-14 L4 Architecture 层未实现 plan/ADR/C4 文档加载 (H)
|
||||
- G-15 L2 Safety 层是硬编码 placeholder (H)
|
||||
- G-16 L7 omission/conflict 路由未实现 (H)
|
||||
- G-17 `EventSchemaRegistry` 无 version 升级路径 (C)
|
||||
- G-18 `assistant.message.failed` 失败 artifact 创建缺失 (C)
|
||||
- G-19 FK-off 一致性 enforcement 缺失 (C) — **触发 C-18**
|
||||
|
||||
**UI/Agent 层**
|
||||
- G-20 TUI `theme/` 与 `keymap/` 目录缺失 (K)
|
||||
- G-21 ProjectionStore 未与 SessionStore 仓库连接, `rebuild()` 生产未调 (K) — **触发 C-18**
|
||||
- G-22 HUD 未挂载主界面 (K)
|
||||
- G-23 缺失 ephemeral 事件处理 (assistant.message.delta 等) (K)
|
||||
- G-24 Regex 分类器替代 CLASSIFYING LLM 步骤 (L)
|
||||
- G-25 `requirement.changed` 发射路径缺失 (L)
|
||||
- G-26 INTERRUPTING/ARCHITECTURE_REVISING 分支不可达 (L)
|
||||
- G-27 main-agent-state-machine 7-day retention / Bundle 模式 (N)
|
||||
|
||||
---
|
||||
|
||||
## 4. EXCESS (实现有、设计无) — 共 20 条
|
||||
|
||||
- E-1 `ProviderIdentity/ProviderConversionReport/ToolCall/DoctorIssue/CapabilityTrustLevel` 等类型别名抽取, 扩大 contracts 导出表面 (A) — **触发 C-14**
|
||||
- E-2 Repository 基类重复样板 ~800 行 (B)
|
||||
- E-3 `EventIngestor.ingest_batch/EventIngestorFactory/NullEventIngestor` (C) — **触发 C-2**
|
||||
- E-4 `EventStore.setTransactionManager/setRepositories` 事后注入 setter (C) — **触发 C-2**
|
||||
- E-5 `EventBus.getSubscriptionCount` (C)
|
||||
- E-6 `EventStore` 手写 UUID 生成器 (C) — **触发 G-17**
|
||||
- E-7 `EventStore` repository 字段类型 `any` (C) — **触发 C-4**
|
||||
- E-8 `createRuntime.ts` / `loadConfig.ts` 自实现 project_id 加载 (D) — **触发 C-1**
|
||||
- E-9 `WorkerRuntime` 多 4 个方法 (call_llm/report_result/heartbeat/send_*) (F) — **触发 C-9**
|
||||
- E-10 `WorkerProtocol` 多 5 种消息类型 (F) — **触发 C-8**
|
||||
- E-11 `WorkerHandle.state` 元数据多余 (F)
|
||||
- E-12 `find_bun()` / `worker.error` 私有通道 (F)
|
||||
- E-13 `ToolRegistry.execute_branch` 多 `downgrade_to_readonly`/`apply_sandbox_restrictions` dead code (G)
|
||||
- E-14 `ToolRegistry.global_tool_registry` 单例 (G)
|
||||
- E-15 `CapabilityManifestValidator` trust_level enum 校验未决策 (G) — **触发 G-7**
|
||||
- E-16 `PermissionEngine` LAYER_ORDER + decision_log (G)
|
||||
- E-17 `SkillLoader` trust_root bypass 旁路 (G)
|
||||
- E-18 `ContextAssembler` L3 `project_files` 非设计层 (H)
|
||||
- E-19 TUI 端重复定义 `ProjectionClient` 与投影类型 (K) — **触发 K-D1**
|
||||
- E-20 CppToolRegistrar `write_artifacts` 写文件, 重复 runtime EventSink (M) — **触发 C-12**
|
||||
|
||||
---
|
||||
|
||||
## 5. 影响链分析
|
||||
|
||||
**核心根因 (修这个能解多个症状)**:
|
||||
|
||||
1. **根因-A: 设计契约类被实现旁路** (C-1, C-2, D-C1, D-C2, F-C1, J-C1, N-C1)
|
||||
→ SessionManager / ProjectStore / ProviderManager / PermissionEngine 在 7 个子系统中实现完整但被 RuntimeApp / WorkerRuntime / ProviderManager / DoctorService 旁路
|
||||
→ 修一个 RuntimeApp 启动路径让其走 SessionManager.open_session, 7 个 CRITICAL 同步关闭
|
||||
|
||||
2. **根因-B: INV-1 事件链整体失效** (C-2, C-3, C-4, G-C1, G-C2, H-G1, I-C1)
|
||||
→ event → projection → domain table 这条链上 5+ 子系统不发射或不投影关键事件
|
||||
→ 修 `EventStore.project()` switch 覆盖 55 个事件 + 移除单例, 8 个症状同时解
|
||||
|
||||
3. **根因-C: 状态机闭包破坏** (E-1, E-2, E-6, L-1, L-2)
|
||||
→ Scheduler 5 个 CRITICAL + MainAgent 2 个 CRITICAL 都是状态转换路由错
|
||||
→ 统一从 state machine 重写主控循环
|
||||
|
||||
4. **根因-D: outbox/INV-2 缺失** (B-G2, C-2, I-C1, I-C3, I-G2)
|
||||
→ external write → ingest event 同事务模式未实施, 导致 4 个子系统重复插入/孤儿文件
|
||||
→ 修 G-5 outbox 模型一处, 4 个症状同步解
|
||||
|
||||
5. **根因-E: 设计类 vs 实现类双轨** (A-G1, A-G2, A-G3)
|
||||
→ contracts 设计了 §6 §7 §16 全部接口但实现未映射到任何 .ts 文件
|
||||
→ 修 contracts package index 重新映射, 3 个 GAP 关闭
|
||||
|
||||
**症状层 (依赖根因)**:
|
||||
- K-D1, H-D1, H-D2 全部因 C-2/C-3 投影失效
|
||||
- M-D1-D4 因 G-7 工具面残缺间接暴露
|
||||
- L-D2, L-D3 因 E-5/E-6 调度状态错
|
||||
|
||||
**CRITICAL 互相触发关系图 (简化)**:
|
||||
```
|
||||
C-1 (架构旁路) ─┬─→ C-2 (EventStore 单例) ─→ C-3 (no-tx) ─→ C-4 (project switch 缺) ─→ C-13
|
||||
├─→ C-5/C-6 (Scheduler 状态) ─→ C-7 (API 缺)
|
||||
├─→ C-9 (call_llm) ─→ C-14 (Provider 硬编码)
|
||||
├─→ C-10 (Tool 不发事件) ─→ C-11 (execute_branch)
|
||||
├─→ C-12 (Artifact 旁路) ─→ C-13
|
||||
├─→ C-15/L-1 (CONFIRMING 错) ─→ C-5
|
||||
└─→ C-17 (Doctor 裸 sudo)
|
||||
C-18 (Recovery FK 5/8) ←─ C-3, C-4, I-C1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 建议修复顺序
|
||||
|
||||
**P0 - 必须先修 (5 条根因)**
|
||||
1. C-1 + D-C1 + D-C2: RuntimeApp 启动路径改走 SessionManager / ProjectStore — 解 7 个子系统症状 (估 1-2 天)
|
||||
2. C-2 + C-3: 撤销 EventStore/eventIngestor 模块单例, 改回 SessionManager 构造注入, 恢复 txManager/repos 在构造时绑定 — 解 C-13/C-15/I-C1 等 (估 1 天)
|
||||
3. C-4: `EventStore.project()` switch 覆盖 55 个事件类型 + Table B cross-DB 占位 — 解 C-13/C-10/G-C2 (估 1-2 天)
|
||||
4. C-5 + C-6 + C-7 + E-D1: 重写 Scheduler 状态机主循环 (terminal_state 去掉 TERMINATED, PLANNING_WAVE→DISPATCHING→MONITORING, 补齐 add_dependency/load_graph/cancel_task) — 解 E-2/L-1 (估 2-3 天)
|
||||
5. C-18 + B-G1 + B-G3: Recovery 8 步全部实现 + FK-off 8 invariant 全覆盖 + 实际 archive/reparent 动作 — (估 1 天)
|
||||
|
||||
**P1 - 高优 (症状层, 根因修后自动解或独立修)**
|
||||
6. C-9 + C-14 + J-C1: WorkerRuntime 移除 call_llm, ProviderManager 走 adapter_for 路由 — (估 1 天)
|
||||
7. C-10 + C-11 + G-D1: Tool/Permission 事件链修复 + PermissionDecision schema 对齐 contracts — (估 1-2 天)
|
||||
8. C-12 + I-G1 + I-G2: CppToolRegistrar 走 ArtifactStore + tool 包装 — (估 1 天)
|
||||
9. L-1 + L-2 + L-3: MainAgent CONFIRMING→EXECUTING + ArchitectureDesigner 仅 plan 分支 + architecture.plan.updated 发射 — (估 1 天)
|
||||
10. N-C1 + N-C2: Doctor --fix 走 PermissionEngine, 双份日志连通 DeveloperLogEncryptor — (估 0.5 天)
|
||||
11. K-D1 + K-G2: ProjectionStore.apply 走真实事件流 + 注入 SessionStore 仓库 — (估 0.5 天)
|
||||
|
||||
**P2 - 可后修 (设计 polish)**
|
||||
12. A-G1/G2/G3: contracts §6/§7/§16 接口映射 .ts 文件 (估 0.5 天)
|
||||
13. D-D4 + D-G1: RuntimeApp 启动序列命名/编号与 §22.2 对齐 (估 0.5 天)
|
||||
14. F-D1/D2/D4: IpcKind 单一协议 + ExitCode 5 触发路径 + 父进程 env 白名单 (估 1 天)
|
||||
15. J-D1-D5 + J-G1-G4: Provider 5 DEVIATION + 4 GAP (估 2 天)
|
||||
16. H-D1/D2/D3/D4 + H-G2/G3/G4: Context 6 处偏离 (估 1 天)
|
||||
17. M-D1-D4: Toolchain 4 处 API 漂移 (估 0.5 天)
|
||||
18. N-D2 + N-G1-G3: Doctor 7-day retention + Recovery bootstrap + bundle (估 1 天)
|
||||
19. K-G1/G3/G4 + K-E1/E2/E3: TUI 主题/键位/HUD/ephemeral/类型镜像 (估 1-2 天)
|
||||
20. EXCESS 全部 (20 条): 死代码清理 (估 0.5-1 天)
|
||||
|
||||
**总工作量估算**:
|
||||
- P0: 6-9 天 (1 个工程师)
|
||||
- P1: 5-7 天
|
||||
- P2: 8-12 天
|
||||
- 合计: 19-28 工作日 (4-6 周)
|
||||
|
||||
---
|
||||
|
||||
## 7. 附录: 子系统审计发现数
|
||||
|
||||
| 子系统 | CRITICAL | DEVIATION | GAP | EXCESS | 合计 |
|
||||
|---|---|---|---|---|---|
|
||||
| A Contracts | 4 | 6 | 3 | 4 | **17** |
|
||||
| B Storage | 3 | 6 | 5 | 4 | **18** |
|
||||
| C Event | 3 | 7 | 6 | 5 | **21** |
|
||||
| D Lifecycle | 3 | 4 | 2 | 1 | **10** |
|
||||
| E Scheduler | 5 | 8 | 4 | 0 | **17** |
|
||||
| F Worker/IPC | 2 | 4 | 3 | 4 | **13** |
|
||||
| G Tool/Perm | 3 | 4 | 5 | 5 | **17** |
|
||||
| H Context | 1 | 5 | 4 | 2 | **12** |
|
||||
| I Artifact | 3 | 4 | 3 | 1 | **11** |
|
||||
| J Provider | 1 | 5 | 4 | 3 | **13** |
|
||||
| K Projection+TUI | 1 | 2 | 5 | 3 | **11** |
|
||||
| L Agents | 4 | 3 | 3 | 2 | **12** |
|
||||
| M Toolchain | 0 | 4 | 0 | 2 | **6** |
|
||||
| N Doctor | 2 | 6 | 3 | 2 | **13** |
|
||||
| **合计 (去重前)** | **35** | **68** | **50** | **38** | **191** |
|
||||
| **合并去重后** | **18** | **32** | **27** | **20** | **97** |
|
||||
|
||||
**去重说明**:
|
||||
- 多 agent 报告同一条 (如 C-2/C-3/C-4/C-10 都是 INV-1 事件链断裂的不同切面) 合并为 1 条
|
||||
- 工具缺注册 (G-D3) 与 contracts 缺接口 (A-G1) 因根因不同保留
|
||||
- 影响范围扩到 3+ 子系统的偏离被升级评估, 18 条 CRITICAL 包含 5 条根因型 (影响 7+ 子系统)
|
||||
|
||||
---
|
||||
|
||||
**审计范围**: 14 个子系统 + 0 个遗漏
|
||||
**报告字数**: ~1500 字 (含表格)
|
||||
**未修代码**: 严格遵守
|
||||
**Stage 3 汇总完成**
|
||||
92
AirPlan/docs/spec/AirPlan-ParaV2/.agents/plugins/marketplace.json
Executable file
92
AirPlan/docs/spec/AirPlan-ParaV2/.agents/plugins/marketplace.json
Executable file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "local-airarc",
|
||||
"interface": {
|
||||
"displayName": "Local AirArc Plugins"
|
||||
},
|
||||
"plugins": [
|
||||
{
|
||||
"name": "airarc",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airarc"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "aireng",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/aireng"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "airdo",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airdo"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "airdbg",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airdbg"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "airndb",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airndb"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "airxdb",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airxdb"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
},
|
||||
{
|
||||
"name": "airsdb",
|
||||
"source": {
|
||||
"source": "local",
|
||||
"path": "./plugins/airsdb"
|
||||
},
|
||||
"policy": {
|
||||
"installation": "INSTALLED_BY_DEFAULT",
|
||||
"authentication": "ON_INSTALL"
|
||||
},
|
||||
"category": "Productivity"
|
||||
}
|
||||
]
|
||||
}
|
||||
37
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airarc/SKILL.md
Executable file
37
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airarc/SKILL.md
Executable file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
name: airarc
|
||||
description: Architecture-first workflow with built-in post-plan parallelization review. Use when planning should emit dependency edges, parallel groups, write-set conflicts, and serialization points for Air Engine. AirArc plans and edits planning docs only; it does not write code.
|
||||
---
|
||||
|
||||
# AirArc
|
||||
|
||||
## Upgrade Notes
|
||||
|
||||
- Keep the original architecture-first planning role.
|
||||
- AirArc is an architect-only workflow: it may plan tasks and edit architecture or planning documents, but it must not implement code changes.
|
||||
- Add built-in post-plan review instead of a separate review-only plugin.
|
||||
- Emit engine-consumable execution artifacts after planning.
|
||||
|
||||
## Outputs
|
||||
|
||||
- `AirPlan/state/airarc/state.json`
|
||||
- `AirPlan/state/airarc/reviews/parallel-review.json`
|
||||
- `AirPlan/state/airarc/reviews/parallel-review.md`
|
||||
- `AirPlan/state/airarc/reviews/execution-plan.json`
|
||||
- `AirPlan/state/airarc/reviews/execution-plan.md`
|
||||
|
||||
## Review Responsibilities
|
||||
|
||||
- Compute dependency edges.
|
||||
- Compute parallel-safe groups.
|
||||
- Detect shared write-set conflicts.
|
||||
- Mark serialization points for global docs and merge boundaries.
|
||||
- Produce an execution plan that Air Engine can prefer directly.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airarc/scripts/airarc_mode.py" --mode enter --project <project-root>
|
||||
python "$HOME/plugins/airarc/scripts/airarc_mode.py" --mode status --project <project-root>
|
||||
python "$HOME/plugins/airarc/scripts/airarc_mode.py" --mode parallel-review --project <project-root> --todo <todo-md>
|
||||
```
|
||||
245
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdbg/SKILL.md
Executable file
245
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdbg/SKILL.md
Executable file
@@ -0,0 +1,245 @@
|
||||
---
|
||||
name: airdbg
|
||||
description: Debug-first repair workflow. Use when the user invokes /airdbg or explicitly asks for AirDbg mode to debug, reproduce, diagnose, or fix software errors, including GUI, visual, screenshot, browser UI, desktop UI, remote GUI/device debugging, canvas, layout, focus, popup, graphical operation, network, packet capture, remote packet capture, pcap, DNS, TCP, UDP, TLS, HTTP connectivity, proxy, firewall, port, retransmit, reset, latency, cppcheck, static analysis, code quality, or security-relevant C/C++ defects. Load or initialize AirPlan/AGENTS.md, AirPlan/docs/architecture/adr/ decision records, and AirPlan/docs/architecture/c4/module.md; discuss symptoms and constraints with the user; reproduce the issue; require AirXDB local or remote device helpers or equivalent GUI/screen evidence for every local or remote GUI validation instead of treating process liveness as success; call AirNDB local or remote device helpers when tcpdump/WinDump packet capture, pcap analysis, BPF filters, or network-layer evidence is needed; call AirSDB local or remote device helpers when static-analysis capability, cppcheck evidence, or AirPlan/docs/staticanalysis.md documentation is needed; identify root cause; apply a focused fix; verify with tests or equivalent checks; and update AirPlan/AGENTS.md, ADR, and C4 module docs when project behavior, module boundaries, dependencies, GUI automation boundaries, network boundaries, static-analysis boundaries, remote-device boundaries, or architecture decisions change.
|
||||
---
|
||||
|
||||
# AirDbg
|
||||
|
||||
## 核心约束
|
||||
|
||||
- 全程使用中文与用户交流,代码、命令、日志、路径、异常名保持原文。
|
||||
- `/airdbg` 是主要触发入口。用户进入 AirDbg 后,围绕调试和修复错误推进。
|
||||
- 先加载项目上下文,再修复:`AirPlan/AGENTS.md`、`AirPlan/docs/architecture/adr/`、`AirPlan/docs/architecture/c4/module.md`。
|
||||
- 如果这些文件不存在,先分析当前项目并初始化它们;C4 module 要记录真实模块边界,不只放空模板。
|
||||
- 与用户交流症状、复现步骤、期望行为、实际行为、影响范围和修复约束。
|
||||
- 默认做最小可验证修复,避免顺手重构。
|
||||
- 每个修复都要验证。优先自动化测试,其次是可重复命令或明确的手工验证步骤。
|
||||
- 只要验证或复现涉及本地或远程 GUI,就不能只以进程存在、窗口拉起、命令退出成功、端口监听或日志无异常判定通过;必须辅以图像/GUI 检验和测试。
|
||||
- 调试中遇到图形对比、截图取证、GUI 操作、浏览器/桌面界面、Canvas、弹窗、焦点、布局、视觉回归或其他图形功能时,必须调用 `airxdb` 获取截图、探索界面、执行操作验证或收集视觉证据;如果是嵌入式屏幕、显示链路等截图无诊断价值的场景,可不强制截图,但必须补充等效的 GUI/屏幕状态证据和操作验证,并记录原因。
|
||||
- 如果 GUI 问题发生在远程设备、测试机、VM、服务器或 SSH 主机上,调用 AirXDB remote device helper,而不是默认使用本机 Computer MCP。
|
||||
- 调试中遇到抓包分析、pcap、tcpdump/WinDump、BPF、DNS、TCP、UDP、TLS、HTTP 连接、端口、代理、防火墙、丢包、重传、RST 或延迟问题时,可以调用 `airndb` 获取网络层调试证据。
|
||||
- 如果网络问题发生在远程设备、测试机、VM、容器宿主机、服务器或 SSH 主机上,调用 AirNDB remote device helper,而不是默认使用本机抓包工具。
|
||||
- 调试中遇到需要静态分析能力的检验、测试或定位场景,以及 C/C++ 静态分析、cppcheck、代码质量、安全性初筛、未初始化变量、空指针、越界、资源释放、危险转换或 CWE 线索需求时,可以调用 `airsdb` 获取 `AirPlan/docs/staticanalysis.md`、XML/JSON 报告等静态分析证据和辅助调试文档。
|
||||
- 如果静态分析目标在远程设备、测试机、VM、容器宿主机、服务器或 SSH 主机上,调用 AirSDB remote device helper,而不是默认使用本机 cppcheck。
|
||||
- 一定要根据项目变化维护 `AirPlan/AGENTS.md`、ADR 和 C4 module。
|
||||
- ADR 是给 AI 作为上下文的决策记录,短、准、可检索即可,不写冗长修饰。
|
||||
|
||||
## 启动与初始化
|
||||
|
||||
进入 `/airdbg` 时运行:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airdbg/scripts/airdbg_mode.py" --mode enter --project .
|
||||
```
|
||||
|
||||
如果当前环境没有 `python`,尝试 `py` 或 `python3`。脚本不可用时,手动确保以下结构存在:
|
||||
|
||||
- `AirPlan/AGENTS.md`
|
||||
- `AirPlan/docs/architecture/adr/`
|
||||
- `AirPlan/docs/architecture/c4/module.md`
|
||||
- `AirPlan/docs/debug/debug-log.md`
|
||||
- `AirPlan/state/airdbg/state.json`
|
||||
|
||||
初始化后读取已有内容作为上下文。不要覆盖用户已有正文;只补齐缺失结构或更新 AirDbg 标记块。
|
||||
|
||||
## 图形调试与 AirXDB 协作
|
||||
|
||||
AirDbg 负责根因分析、代码层修复和验证收尾;AirXDB 负责图形界面的取证和操作层复现。遇到以下情况时,必须调用 AirXDB 或补充等效 GUI/屏幕证据:
|
||||
|
||||
- 需要截图或图形对比来理解错误现场、视觉回归、布局错位、颜色/尺寸/遮挡差异。
|
||||
- 需要操作浏览器 UI、桌面 UI、Electron/Qt/WPF 等应用、Canvas、菜单、弹窗、托盘、任务栏或多显示器界面。
|
||||
- 需要 `/airxdb screenshot` 保存错误现场,再把截图交给 AirDbg 做代码层诊断。
|
||||
- 目标 GUI 在远程设备、测试机、VM、服务器或 SSH 主机上,需要 `/airxdb remote-screenshot` 或 `airxdb_remote_device.py` 保存远程错误现场。
|
||||
- 需要用 AirXDB 执行最小 GUI 操作,确认按钮、表单、导航、窗口切换、焦点或图形流程是否真的失败。
|
||||
- 需要把 GUI 证据沉淀到 `AirPlan/docs/debug/gui-debug-log.md`、`AirPlan/docs/debug/airxdb-artifacts/` 或 AirDbg 的 `AirPlan/docs/debug/debug-log.md`。
|
||||
|
||||
协作规则:
|
||||
|
||||
- 先用 AirXDB 收集最小必要证据,再回到 AirDbg 分析代码根因;不要把视觉症状直接当作根因。
|
||||
- 任何本地或远程 GUI 测试/验证都不能仅以进程存活、窗口创建成功、命令返回成功或日志无异常视为通过;默认至少保留 1 份截图/图像证据,并完成 1 次关键 GUI 操作或状态检查。
|
||||
- 如果是嵌入式屏幕、显示控制器、外接面板链路等截图无诊断价值的场景,可改用外部采集视频、framebuffer dump、串口/日志配合按键或触控操作记录、状态灯/OSD 观察记录等等效证据,但必须在 `debug-log.md` 记录为什么不截图以及替代证据是什么。
|
||||
- 截图模式可在没有 Midscene 语义模型配置时使用;语义视觉动作按 AirXDB 规则先检查模型配置。
|
||||
- 本机 GUI 证据使用 `/airxdb screenshot` 或 `airxdb_computer_mcp_smoke.py`;远程 GUI 证据使用 `airxdb_remote_device.py --action setup|screenshot`,由它探测 SSH、远端截图工具并在缺失时自动尝试配置。
|
||||
- 远程 helper 缺少 `AIRXDB_REMOTE_SSH_TARGET` 时,先让用户提供 SSH 目标;需要交互式 sudo、管理员确认或无支持包管理器时停止并说明。
|
||||
- AirDbg 的 `debug-log.md` 必须记录 AirXDB 命令、截图/报告路径、关键观察、与根因的关系、复验结果和剩余风险。
|
||||
- 如果 GUI 自动化、截图取证、视觉验收、浏览器桥接或桌面控制成为长期调试/测试边界,更新 C4 module 并创建或修订 ADR。
|
||||
- 如果发现稳定可复用的 GUI 调试命令、截图方式、远程设备配置或视觉验收步骤,更新 `AGENTS.md`。
|
||||
- 截图可能包含账号、密钥、客户数据或聊天内容时,先提醒用户脱敏,再外部分享或长期保留。
|
||||
|
||||
## 抓包调试与 AirNDB 协作
|
||||
|
||||
AirDbg 负责把网络证据和代码行为联系起来,定位根因并修复;AirNDB 负责 tcpdump/WinDump 抓包、pcap 摘要、BPF 过滤器和网络层证据。遇到以下情况时,调用 AirNDB:
|
||||
|
||||
- 需要抓包判断请求是否发出、响应是否回来、连接是否被 RST/ICMP/防火墙/代理中断。
|
||||
- 需要分析 DNS 查询、TCP 三次握手、TLS 握手、HTTP 连接、UDP 流量、端口可达性、重传、丢包或延迟。
|
||||
- 需要读取已有 `.pcap` 或生成新的短时有界 pcap 给调试使用。
|
||||
- 需要确定问题在应用代码、系统网络栈、容器/WSL/VM/宿主机边界、代理、防火墙还是远端服务。
|
||||
- 目标流量发生在远程设备、测试机、VM、容器宿主机、服务器或 SSH 主机上,需要 `/airndb remote-interfaces`、`/airndb remote-capture` 或 `airndb_remote_device.py` 获取远程网络证据。
|
||||
|
||||
协作规则:
|
||||
|
||||
- 先让 AirNDB 明确授权范围、接口、BPF 过滤器、抓包窗口和 pcap 输出路径;不要进行无界抓包。
|
||||
- 本机网络证据使用 `airndb_capture.py`;远程网络证据使用 `airndb_remote_device.py --action setup|interfaces|command|capture`,由它探测 SSH、远端 `tcpdump` / `dumpcap` 并在缺失时自动尝试配置。
|
||||
- 远程 helper 缺少 `AIRNDB_REMOTE_SSH_TARGET` 时,先让用户提供 SSH 目标;需要交互式 sudo、管理员确认或无支持包管理器时停止并说明。
|
||||
- AirDbg 的 `debug-log.md` 必须记录 AirNDB 命令、pcap/summary/report 路径、关键包或时间线观察、与根因的关系、复验结果和剩余风险。
|
||||
- 如果抓包发现新的长期网络边界、端口、协议、DNS、代理、TLS、容器/WSL/VM/宿主机约束或观测方式,更新 C4 module 并创建或修订 ADR。
|
||||
- 如果发现稳定可复用的抓包命令、接口选择规则、BPF、远程设备配置或 pcap 读取方式,更新 `AGENTS.md`。
|
||||
- pcap 可能包含 token、cookie、payload、内网地址、主机名或个人信息;对外分享前必须提醒用户脱敏。
|
||||
|
||||
## 静态分析与 AirSDB 协作
|
||||
|
||||
AirDbg 负责把静态分析线索和代码根因联系起来;AirSDB 负责 cppcheck 检测/安装、本机或远程扫描、XML/JSON 产物和 `AirPlan/docs/staticanalysis.md` 简短报告。遇到以下情况时,可以调用 AirSDB:
|
||||
|
||||
- 需要用 cppcheck 辅助定位 C/C++ bug、内存/资源/越界/空指针/未初始化变量/危险转换/CWE 线索。
|
||||
- 需要在修复前后比较静态分析结果。
|
||||
- 需要给 AirDbg 的根因分析提供短报告而不是长 XML。
|
||||
- 检验、测试或调试判断需要静态分析能力、质量门信息或可引用文档时,需要读取 `AirPlan/docs/staticanalysis.md` 或 AirSDB XML/JSON 报告辅助分析。
|
||||
- 目标代码在远程设备、测试机、VM、容器宿主机、服务器或 SSH 主机上,需要 `/airsdb remote-scan` 或 `airsdb_remote_device.py` 获取远端静态分析证据。
|
||||
|
||||
协作规则:
|
||||
|
||||
- 本机静态分析使用 `airsdb_cppcheck.py --action scan`;远程静态分析使用 `airsdb_remote_device.py --action setup|scan`,由它探测 SSH、远端 cppcheck 并在缺失时自动尝试配置。
|
||||
- AirDbg 的 `AirPlan/docs/debug/debug-log.md` 必须记录 AirSDB 命令、`AirPlan/docs/staticanalysis.md`、XML/JSON 报告路径、关键 findings、与根因的关系、复验结果和剩余风险。
|
||||
- 如果静态分析发现新的长期质量门槛、suppressions、远程设备配置或 cppcheck 命令,更新 `AGENTS.md`。
|
||||
- 如果静态分析成为长期测试/调试边界,更新 C4 module 并创建或修订 ADR。
|
||||
|
||||
## 调试流程
|
||||
|
||||
1. 确认问题边界:
|
||||
- 用户看到的错误是什么。
|
||||
- 期望行为和实际行为是什么。
|
||||
- 复现步骤、输入数据、环境、版本、最近变更是什么。
|
||||
- 有哪些不能破坏的兼容性或性能要求。
|
||||
2. 加载上下文:
|
||||
- 读取 `AGENTS.md`。
|
||||
- 读取 ADR 列表和相关 ADR。
|
||||
- 读取 `docs/architecture/c4/module.md`。
|
||||
- 查看测试、入口、依赖、配置和最近相关文件。
|
||||
3. 复现问题:
|
||||
- 优先运行已有失败测试或用户给出的命令。
|
||||
- 没有复现命令时,先构造最小复现或定位性测试。
|
||||
- 如果复现依赖 GUI、截图或图形操作,必须调用 AirXDB 获取截图、执行最小界面操作或保存 GUI 报告;远程目标走 AirXDB remote device helper;嵌入式截图无效时改用等效 GUI/屏幕证据并记录原因。
|
||||
- 如果复现依赖网络路径或抓包证据,调用 AirNDB 获取短时 pcap、摘要或网络层时间线;远程目标走 AirNDB remote device helper。
|
||||
- 如果复现或定位需要 C/C++ 静态分析,或当前检验需要静态分析能力辅助判断,调用 AirSDB 运行本机或远程 cppcheck,并读取 `AirPlan/docs/staticanalysis.md`。
|
||||
- 记录复现命令和关键输出到 `docs/debug/debug-log.md`。
|
||||
4. 定位根因:
|
||||
- 从错误栈、日志、测试断言、数据流和模块边界推断。
|
||||
- 对 GUI 问题,结合 AirXDB 本机或远程截图/报告判断视觉症状、交互失败和代码根因之间的关系。
|
||||
- 对网络问题,结合 AirNDB 本机或远程 pcap/摘要判断请求是否出站、响应是否入站、失败发生在 DNS/TCP/TLS/应用层哪一段。
|
||||
- 对静态分析问题,结合 AirSDB findings 判断哪些是当前 bug 线索、哪些是既有质量债或误报。
|
||||
- 必要时加临时日志或小范围探针,完成后清理。
|
||||
- 区分根因、诱因和表面症状。
|
||||
5. 修复:
|
||||
- 优先选择影响面小、能解释根因的修复。
|
||||
- 不做无关格式化、批量重构或架构迁移。
|
||||
- 如果修复会改变模块边界、依赖、接口、数据所有权或关键行为,先更新 C4/ADR。
|
||||
6. 验证:
|
||||
- 运行失败用例、相关单元测试、集成测试、lint/typecheck。
|
||||
- 如果修复涉及 GUI 或视觉行为,必须调用 AirXDB 截图、图形对比或操作验证关键路径;远程目标用远程 helper 复验;嵌入式截图无效时改用等效 GUI/屏幕证据并记录原因。
|
||||
- 如果修复涉及网络行为,调用 AirNDB 复验关键网络路径或读取 pcap 摘要;远程目标用远程 helper 复验。
|
||||
- 如果修复涉及 C/C++ 风险、静态分析 findings,或验证需要静态分析能力辅助判断,调用 AirSDB 复跑 cppcheck 并更新 `AirPlan/docs/staticanalysis.md`。
|
||||
- 如果不能运行,说明原因,并给出可复验的替代验证。
|
||||
- 记录验证证据到 debug log。
|
||||
7. 收尾:
|
||||
- 更新 `AGENTS.md` 中与调试、测试、运行方式相关的项目上下文。
|
||||
- 更新或新增 ADR。
|
||||
- 更新 C4 module。
|
||||
- 向用户汇报根因、改动、验证结果、剩余风险。
|
||||
|
||||
## AGENTS.md 维护
|
||||
|
||||
在以下情况更新 `AGENTS.md`:
|
||||
|
||||
- 发现新的运行、测试、构建、调试命令。
|
||||
- 发现新的 AirXDB 截图、GUI 操作验证、图形对比、远程设备配置或视觉验收命令。
|
||||
- 发现新的 AirNDB 抓包命令、BPF 过滤器、接口选择规则、远程设备配置、pcap 读取方式或网络复验步骤。
|
||||
- 发现新的 AirSDB cppcheck 命令、suppressions、质量门槛、远程设备配置或静态分析复验步骤。
|
||||
- 发现影响后续 AI 会话的重要项目约束。
|
||||
- 修复改变了模块职责、关键流程或错误处理策略。
|
||||
- 发现常见坑、环境要求或验证方式。
|
||||
|
||||
保持内容可执行、可复用,不写调试过程流水账。
|
||||
|
||||
## ADR 维护
|
||||
|
||||
目录:`docs/architecture/adr/`。
|
||||
|
||||
需要 ADR 的情况:
|
||||
|
||||
- 修复选择了一个会影响长期架构或行为兼容性的方案。
|
||||
- 改变错误处理、重试、事务、缓存、一致性、安全边界。
|
||||
- 改变模块依赖、数据所有权、接口契约。
|
||||
- 将 GUI 自动化、截图取证、远程设备 GUI 取证、视觉验收或图形调试流程纳入长期测试/调试边界。
|
||||
- 将抓包、远程设备抓包、pcap 分析、网络观测、端口、协议、DNS、代理、TLS 或网络拓扑纳入长期调试/测试边界。
|
||||
- 将 cppcheck、staticanalysis.md、静态分析质量门槛或远程静态分析纳入长期调试/测试边界。
|
||||
- 拒绝了明显可选方案,需要给后续 AI 留下原因。
|
||||
|
||||
ADR 模板:
|
||||
|
||||
```markdown
|
||||
# ADR-000X: short-title
|
||||
|
||||
- Status: Accepted
|
||||
- Date: YYYY-MM-DD
|
||||
|
||||
## Context
|
||||
简述错误、约束和为什么需要决策。
|
||||
|
||||
## Decision
|
||||
简述采用的修复或架构选择。
|
||||
|
||||
## Consequences
|
||||
- 正面影响
|
||||
- 代价或风险
|
||||
|
||||
## Alternatives
|
||||
- 方案 A:放弃原因
|
||||
```
|
||||
|
||||
## C4 Module 维护
|
||||
|
||||
文件:`docs/architecture/c4/module.md`。
|
||||
|
||||
必须记录:
|
||||
|
||||
- 模块名。
|
||||
- 职责。
|
||||
- 对外接口。
|
||||
- 依赖。
|
||||
- 数据所有权。
|
||||
- 与本次错误或修复相关的质量属性。
|
||||
|
||||
新增模块、拆分模块、改变依赖、改变接口、改变数据边界、改变错误处理流时必须更新。
|
||||
|
||||
引入或改变 GUI 自动化、浏览器桥接、桌面控制、截图取证、远程设备 GUI 取证、视觉验收或图形调试基础设施时,也必须更新。
|
||||
|
||||
引入或改变 tcpdump/WinDump 抓包、远程设备抓包、pcap 分析、网络观测、端口、协议、DNS、代理、TLS、容器/WSL/VM/宿主机网络边界时,也必须更新。
|
||||
|
||||
引入或改变 cppcheck、staticanalysis.md、静态分析质量门槛、suppressions 或远程静态分析边界时,也必须更新。
|
||||
|
||||
## debug-log 维护
|
||||
|
||||
文件:`docs/debug/debug-log.md`。
|
||||
|
||||
每次 AirDbg 修复至少追加:
|
||||
|
||||
- 问题摘要。
|
||||
- 复现命令或复现步骤。
|
||||
- 根因。
|
||||
- 修复摘要。
|
||||
- 验证命令和结果。
|
||||
- AirXDB 本机或远程截图/报告/操作验证证据及其结论(如适用)。
|
||||
- AirNDB 本机或远程 pcap/summary/report/抓包分析证据及其结论(如适用)。
|
||||
- AirSDB 本机或远程 staticanalysis.md/XML/JSON 静态分析证据及其结论(如适用)。
|
||||
- 相关 ADR/C4 更新。
|
||||
- 剩余风险。
|
||||
|
||||
## 输出格式
|
||||
|
||||
调试完成后用中文简洁汇报:
|
||||
|
||||
- 根因。
|
||||
- 修复了什么。
|
||||
- 更新了哪些 `AGENTS.md` / ADR / C4 / debug log 上下文。
|
||||
- 运行了哪些验证;是否调用 AirXDB/AirNDB/AirSDB,截图、pcap、staticanalysis、报告或操作证据在哪里。
|
||||
- 仍然存在的风险或未验证项。
|
||||
@@ -0,0 +1,3 @@
|
||||
name: airdbg
|
||||
short_description: Debug-first repair with local/remote AirXDB, AirNDB, and AirSDB evidence
|
||||
default_prompt: "使用 AirDbg 调试并修复当前项目错误;GUI 测试或验证必须保留 GUI 复验证据,嵌入式截图无效时改用等效屏幕证据;网络证据调用 AirNDB,需要静态分析能力时调用 AirSDB。"
|
||||
38
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdo/SKILL.md
Executable file
38
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdo/SKILL.md
Executable file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: airdo
|
||||
description: Public Air executor for one scoped todo slice. Use it standalone or as an isolated AirEng subagent and finalize the result into AirPlan.
|
||||
---
|
||||
|
||||
# AirDo
|
||||
|
||||
## Role
|
||||
|
||||
- Execute one task or one very small implementation slice.
|
||||
- Keep AirDo execution guarantees for context loading, evidence, and validation.
|
||||
- Finalize one structured result package in `AirPlan/state/airdo/results/`.
|
||||
- Act as the standard AirEng child executor when work is delegated into isolated subagents.
|
||||
|
||||
## Inputs
|
||||
|
||||
- `AirPlan/AGENTS.md`
|
||||
- `AirPlan/docs/architecture/adr/`
|
||||
- `AirPlan/docs/architecture/c4/module.md`
|
||||
- `AirPlan/plan.md`
|
||||
- `AirPlan/todo.md`
|
||||
- `AirPlan/state/airdo/tasks/<task-id>/brief.md`
|
||||
- `AirPlan/state/airdo/tasks/<task-id>/subagent-handoff.md` when launched by AirEng
|
||||
|
||||
## Result Rules
|
||||
|
||||
- Finalize one `result.json` per task.
|
||||
- Treat `AirPlan/state/airdo/tasks/<task-id>/worker-state.json` `resultPath` as the canonical pointer to the latest result artifact. The task-local `result.json` is only the editable template before finalize.
|
||||
- Include validations, evidence, risks, blockers, and document updates when needed.
|
||||
- Do not edit global `AirPlan/todo.md`, `AirPlan/AGENTS.md`, ADR, or C4 files directly unless explicitly delegated through `documentUpdates`.
|
||||
- If the task changes execution planning or architecture reality, include concrete `documentUpdates` so AirEng can keep `todo`, `plan`, ADR, and C4 synchronized during merge.
|
||||
|
||||
## Automatic Routing
|
||||
|
||||
- On `blocked` results, auto-request AirDbg before finalize.
|
||||
- On GUI or visual work, auto-request AirXDB before finalize.
|
||||
- If AirEng queued an active repair attempt, continue repairing automatically instead of stopping at the first blocker.
|
||||
- Do not stop at implementation-prep or progress-only updates when the task is actionable. Continue until finalize unless a real blocker or explicit user decision is required.
|
||||
3
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdo/agents/openai.yaml
Executable file
3
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airdo/agents/openai.yaml
Executable file
@@ -0,0 +1,3 @@
|
||||
name: airdo
|
||||
short_description: Public Air executor for one scoped task, validation evidence, and AirPlan result finalization
|
||||
default_prompt: "Use AirDo to execute one task, gather validation evidence, auto-route GUI or debug work, and finalize a structured result in AirPlan for AirEng to merge."
|
||||
65
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/aireng/SKILL.md
Executable file
65
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/aireng/SKILL.md
Executable file
@@ -0,0 +1,65 @@
|
||||
---
|
||||
name: aireng
|
||||
description: Sole public Air scheduler that reads AirArc execution artifacts, dispatches isolated AirDo subagents with bounded concurrency, monitors them on a 5-minute cadence, and merges structured results into AirPlan.
|
||||
---
|
||||
|
||||
# AirEng
|
||||
|
||||
## Role
|
||||
|
||||
- Own the global execution contract in `AirPlan/`.
|
||||
- Read AirArc review output before falling back to local todo analysis.
|
||||
- Dispatch isolated AirDo subagents with `fork_context=false`.
|
||||
- Monitor active workers, merge structured worker results, and keep the scheduler moving unattended.
|
||||
- Own debug policy, XDB policy, repair policy, intervention policy, and global document convergence.
|
||||
- Default to no parent-thread coding; use parent-thread edits only for short unblock actions that restore the scheduler.
|
||||
|
||||
## Planning Source Order
|
||||
|
||||
1. `AirPlan/state/airarc/reviews/execution-plan.json`
|
||||
2. `AirPlan/state/airarc/reviews/parallel-review.json`
|
||||
3. Engine fallback analysis of `AirPlan/todo.md`
|
||||
|
||||
## Dispatch Contract
|
||||
|
||||
- Generate the dispatch manifest under `AirPlan/state/aireng/dispatch/`.
|
||||
- Respect `recommendedConcurrency`; do not flood the workspace with overlapping workers.
|
||||
- Spawn one isolated AirDo subagent per task handoff.
|
||||
- After a worker finishes, read its `workerStatePath` and use the `resultPath` recorded there as the canonical finalized result location.
|
||||
- Pass only the task handoff and project path to each worker. Do not fork the full parent thread history.
|
||||
- Do not interrupt actionable workers for midpoint status updates; let them continue through implementation and finalize unless they surface a real blocker.
|
||||
- Keep parent-thread work limited to orchestration, monitoring, merge, repair, document convergence, and minimal unblock actions.
|
||||
- Refresh `AirPlan/todo.md` and the active dispatch block in `AirPlan/plan.md` when a wave starts so execution progress is visible during the run.
|
||||
|
||||
## Monitoring Contract
|
||||
|
||||
- Store scheduler state in `AirPlan/state/aireng/state.json`.
|
||||
- Track `engineMode`, `activeWaveId`, `activeDispatchPath`, `activeWorkers`, `monitoringPolicy`, `nextAction`, and `interventionHistory`.
|
||||
- Use `monitoringPolicy.checkIntervalSeconds = 300` as the default cadence for unattended monitoring.
|
||||
- Prefer re-dispatch, repair, debug, or other isolated recovery flows before direct intervention.
|
||||
- Escalate to user decision only when a worker remains hard-blocked after the allowed intervention budget.
|
||||
|
||||
## Merge Guarantees
|
||||
|
||||
- Update task status and merge log in `AirPlan/todo.md`.
|
||||
- Apply worker `documentUpdates`.
|
||||
- Refresh engine-managed sync blocks in `AirPlan/AGENTS.md` and `AirPlan/docs/architecture/c4/module.md`.
|
||||
- Track AirXDB sessions in `AirPlan/state/aireng/state.json`.
|
||||
- Track debug sessions in `AirPlan/state/aireng/state.json`.
|
||||
- Track repair attempts in `AirPlan/state/aireng/state.json`.
|
||||
- Refuse a `done` merge when required global document updates are missing.
|
||||
- Refuse a GUI-like `done` merge when successful AirXDB evidence is missing.
|
||||
- Apply worker `documentUpdates` promptly so plan, ADR, and C4 changes do not lag behind completed slices.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode enter --project <project-root>
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode status --project <project-root>
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode plan --project <project-root> --todo <airplan-todo-md>
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode dispatch --project <project-root> [--dispatch-group <wave-group-name>]
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode monitor --project <project-root>
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode run --project <project-root> [--todo <airplan-todo-md>]
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode intervene --project <project-root>
|
||||
python "$HOME/plugins/aireng/scripts/aireng_mode.py" --mode merge --project <project-root> --result <worker-result-json>
|
||||
```
|
||||
@@ -0,0 +1,3 @@
|
||||
name: aireng
|
||||
short_description: Public Air scheduler for isolated AirDo subagent dispatch and AirPlan merges
|
||||
default_prompt: "Use AirEng to read AirArc execution artifacts from AirPlan, dispatch isolated AirDo subagents with bounded concurrency, and merge structured worker results back into AirPlan."
|
||||
214
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airndb/SKILL.md
Executable file
214
AirPlan/docs/spec/AirPlan-ParaV2/.agents/skills/airndb/SKILL.md
Executable file
@@ -0,0 +1,214 @@
|
||||
---
|
||||
name: airndb
|
||||
description: Network-debug packet capture workflow. Use when the user invokes /airndb or asks to debug networking, packet loss, DNS, TCP, UDP, TLS handshakes, HTTP connectivity, ports, retransmits, resets, latency, firewall, proxy, service reachability, pcap files, tcpdump, WinDump, remote packet capture over SSH, or BPF filters. Load or initialize AirPlan/AGENTS.md, AirPlan/docs/architecture/adr/ decision records, AirPlan/docs/architecture/c4/module.md, AirPlan/docs/network/airndb-log.md, and AirPlan/docs/network/airndb-captures/; on first startup detect tcpdump/WinDump and on Windows auto-download official WinDump.exe when no capture tool is available; when remote debugging, call the AirNDB remote device helper and auto-configure remote tcpdump/dumpcap when missing; build safe bounded tcpdump/WinDump commands; capture or read pcap artifacts; summarize packet evidence; and maintain AirPlan/AGENTS.md, ADR, C4 module docs, and network debug logs when capture tooling, network boundaries, or debugging decisions change.
|
||||
---
|
||||
|
||||
# AirNDB
|
||||
|
||||
## 核心约束
|
||||
|
||||
- 全程使用中文与用户交流,命令、接口名、BPF、日志、路径和协议名保持原文。
|
||||
- `/airndb` 专用于网络抓包、pcap 分析和网络层调试证据收集。
|
||||
- 只抓取用户授权的本机、项目、测试环境或明确允许的网络流量。
|
||||
- 默认不做无界抓包;必须使用包数、超时、时长或轮转上限。
|
||||
- 默认先列接口,再确认接口、目标 host/port/protocol/filter、抓包窗口和输出路径。
|
||||
- 初次启动必须检测 `tcpdump` / `windump` / `WinDump.exe` 是否可用;Windows 下如果不可用,自动从 WinDump 官方下载页获取 `WinDump.exe`,校验 SHA1 后写入 `AirPlan/state/airndb/tool.env`。
|
||||
- 远程设备、测试机、VM 或 SSH 主机上的网络调试,先调用 `$HOME/plugins/airndb/scripts/airndb_remote_device.py`;缺少远程 `tcpdump` / `dumpcap` 时允许脚本自动配置,无法无密码 `sudo` 或无包管理器时停止并提示用户。
|
||||
- 自动获取只下载 WinDump 用户态程序,不静默安装 WinPcap/Npcap 抓包驱动;如果接口列举失败,提示用户安装 Npcap 或 WinPcap 并用管理员权限重试。
|
||||
- 默认使用 `-nn` 避免 DNS/service-name 解析,使用 `-s 0` 写入完整 pcap。
|
||||
- pcap 可能包含凭据、cookie、token、payload、内网地址、主机名或个人信息;对外分享前必须提醒脱敏。
|
||||
- 网络证据要写入 `AirPlan/docs/network/airndb-log.md`,pcap/摘要/JSON 报告写入 `AirPlan/docs/network/airndb-captures/`。
|
||||
- 根据项目变化维护 `AirPlan/AGENTS.md`、ADR 和 C4 module。
|
||||
- 如果需要 WinDump/tcpdump 选项和 BPF 简表,读取 [references/windump-tcpdump-notes.md](references/windump-tcpdump-notes.md)。
|
||||
|
||||
## 启动与初始化
|
||||
|
||||
进入 `/airndb` 时运行:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_mode.py" --mode enter --project .
|
||||
```
|
||||
|
||||
如果当前环境没有 `python`,尝试 `py`、`python3` 或用户提供的 Python 绝对路径。脚本不可用时,手动确保以下结构存在:
|
||||
|
||||
- `AirPlan/AGENTS.md`
|
||||
- `AirPlan/docs/architecture/adr/`
|
||||
- `AirPlan/docs/architecture/c4/module.md`
|
||||
- `AirPlan/docs/network/airndb-log.md`
|
||||
- `AirPlan/docs/network/airndb-captures/`
|
||||
- `AirPlan/state/airndb/state.json`
|
||||
|
||||
初始化后读取已有内容作为上下文。不要覆盖用户已有正文;只补齐缺失结构或更新 AirNDB 标记块。
|
||||
|
||||
## 首次工具配置
|
||||
|
||||
`airndb_mode.py --mode enter` 会执行工具自检:
|
||||
|
||||
1. 查找显式配置、项目 `AirPlan/state/airndb/tool.env`、环境变量 `AIRNDB_TCPDUMP`、项目 `AirPlan/state/airndb/tools/WinDump.exe`、PATH 中的 `windump` / `WinDump.exe` / `tcpdump`。
|
||||
2. 如果找到可用工具,写入或刷新 `AirPlan/state/airndb/tool.env`,后续 `airndb_capture.py` 自动读取。
|
||||
3. 如果 Windows 上找不到工具,自动从 WinDump 官方下载地址获取 `WinDump.exe`,校验 SHA1 `d59bc54721951dec855cbb4bbc000f9a71ea4d95`,保存到 `AirPlan/state/airndb/tools/WinDump.exe`,然后写入 `AirPlan/state/airndb/tool.env`。
|
||||
4. 如果下载失败或校验失败,停止并提示用户手动安装 `tcpdump` / `WinDump.exe` 或设置 `AIRNDB_TCPDUMP`。
|
||||
|
||||
`AirPlan/state/airndb/tool.env` 是本机路径配置,由 `AirPlan/state/airndb/.gitignore` 忽略,不应提交。
|
||||
|
||||
注意:WinDump 仍需要抓包驱动。官方 WinDump 安装页要求先安装 WinPcap 3.1 或更新版本;WinPcap 主页提示项目已停止维护并建议 Windows 10 用户使用 Npcap。AirNDB 不静默安装驱动,只负责检测、下载 WinDump.exe 和配置本机路径。
|
||||
|
||||
## 远程设备工具配置
|
||||
|
||||
当用户说明目标流量发生在远程设备、测试机、服务器、VM、容器宿主机、SSH 主机,或本机抓包看不到目标流量时,不要先使用本机 `airndb_capture.py`。先运行远程设备 helper:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_remote_device.py" --project . --action setup
|
||||
```
|
||||
|
||||
如果当前环境没有 `python`,尝试 `py`、`python3` 或用户提供的 Python 绝对路径。首次运行会生成 `AirPlan/state/airndb/remote-device.env.example`;把连接信息写入 `AirPlan/state/airndb/remote-device.env` 或当前环境变量:
|
||||
|
||||
- `AIRNDB_REMOTE_SSH_TARGET=user@host`
|
||||
- `AIRNDB_REMOTE_SSH_PORT=22`
|
||||
- `AIRNDB_REMOTE_SSH_OPTIONS=`
|
||||
- `AIRNDB_REMOTE_WORKDIR=`
|
||||
- `AIRNDB_REMOTE_TCPDUMP=auto`
|
||||
- `AIRNDB_REMOTE_CAPTURE_PREFIX=sudo -n`
|
||||
|
||||
远程 helper 行为:
|
||||
|
||||
- 检查本机 `ssh`、远程连通性和远程工作目录。
|
||||
- 探测 `tcpdump`、`dumpcap`、`windump`、`WinDump.exe`。
|
||||
- 工具缺失时自动尝试用远端包管理器安装 `tcpdump`,只使用非交互式 `sudo -n`;需要密码、管理员确认或无支持的包管理器时停止并提示用户。
|
||||
- 将可复用配置写入 `AirPlan/state/airndb/remote-device.env`,该文件由 `AirPlan/state/airndb/.gitignore` 忽略。
|
||||
- 抓包产物拉回 `AirPlan/docs/network/airndb-captures/`,并追加 `AirPlan/docs/network/airndb-log.md`。
|
||||
|
||||
常用远程命令:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_remote_device.py" --project . --action interfaces
|
||||
python "$HOME/plugins/airndb/scripts/airndb_remote_device.py" --project . --action command --iface <iface> --filter "<bpf>" --count 200
|
||||
python "$HOME/plugins/airndb/scripts/airndb_remote_device.py" --project . --action capture --iface <iface> --filter "<bpf>" --count 200 --timeout 30
|
||||
```
|
||||
|
||||
远程抓包仍必须有明确授权、接口、BPF、包数或超时上限。`AIRNDB_REMOTE_CAPTURE_PREFIX` 默认是 `sudo -n`;如果远端已配置免 sudo 的 capture capability,可改为空或指定更合适的前缀。
|
||||
|
||||
## 工作流
|
||||
|
||||
1. 明确网络问题:
|
||||
- 现象:连不上、超时、重置、DNS 异常、TLS 握手失败、丢包、延迟、端口不可达、代理/防火墙疑似问题。
|
||||
- 目标:源/目的 host、端口、协议、服务名、容器/VM/WSL/宿主机边界。
|
||||
- 抓包窗口:包数、超时、复现步骤和是否允许保存 payload。
|
||||
2. 发现接口:
|
||||
- 本机调试运行 `airndb_capture.py --action interfaces`。
|
||||
- 远程调试运行 `airndb_remote_device.py --action interfaces`。
|
||||
- Windows 优先使用 `windump -D` 或 `WinDump.exe -D`;Linux/macOS 优先 `tcpdump -D`。
|
||||
3. 设计过滤器:
|
||||
- 使用最窄可行 BPF:`host`、`src host`、`dst host`、`port`、`tcp`、`udp`、`icmp`、`net`。
|
||||
- 不确定时先短时宽过滤,再根据结果收窄。
|
||||
4. 执行有界抓包:
|
||||
- 使用 `airndb_capture.py --action capture --iface <iface> --filter "<bpf>" --count <n> --timeout <seconds>`。
|
||||
- 产物写入 `AirPlan/docs/network/airndb-captures/`。
|
||||
5. 读取和分析:
|
||||
- 使用 `airndb_capture.py --action read --read-file <pcap> --filter "<bpf>"` 生成文本摘要。
|
||||
- 结合时间线、TCP flags、重传、RST、DNS 响应、ICMP、TLS ClientHello/ServerHello 迹象判断网络层事实。
|
||||
6. 记录证据:
|
||||
- exact command
|
||||
- interface
|
||||
- BPF filter
|
||||
- packet count or timeout
|
||||
- pcap path
|
||||
- summary/report path
|
||||
- 观察结论、限制和剩余风险
|
||||
|
||||
## 与 AirDbg 协作
|
||||
|
||||
- AirNDB 负责抓包、pcap 摘要、网络层证据和过滤器。
|
||||
- AirDbg 负责代码层根因分析、修复和验证收尾。
|
||||
- AirDbg 调试中遇到 DNS、TCP、UDP、TLS、HTTP 连接、端口、代理、防火墙、丢包、重传或 pcap 证据需求时,可以调用 AirNDB。
|
||||
- AirNDB 收集到的证据必须能被 AirDbg 直接引用:命令、pcap 路径、摘要、关键包、时间线和结论要写清楚。
|
||||
|
||||
## 常用命令
|
||||
|
||||
列接口:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_capture.py" --project . --action interfaces
|
||||
```
|
||||
|
||||
检查或初始化工具路径:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_mode.py" --project . --mode enter
|
||||
```
|
||||
|
||||
只生成命令:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_capture.py" --project . --action command --iface 1 --filter "tcp and port 443" --count 200
|
||||
```
|
||||
|
||||
短时抓包:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_capture.py" --project . --action capture --iface 1 --filter "tcp and port 443" --count 200 --timeout 30
|
||||
```
|
||||
|
||||
读取 pcap:
|
||||
|
||||
```bash
|
||||
python "$HOME/plugins/airndb/scripts/airndb_capture.py" --project . --action read --read-file AirPlan/docs/network/airndb-captures/example.pcap
|
||||
```
|
||||
|
||||
## AGENTS.md 维护
|
||||
|
||||
在以下情况更新 `AGENTS.md`:
|
||||
|
||||
- 发现稳定可复用的 tcpdump/WinDump 命令、接口选择规则、BPF 过滤器或 pcap 读取方式。
|
||||
- 发现影响后续 AI 调试的网络边界:容器、WSL、VM、代理、防火墙、VPN、DNS、TLS、NAT、端口映射。
|
||||
- 发现抓包权限、驱动、管理员权限或平台差异。
|
||||
- 发现本机 tcpdump/WinDump 路径或 `AirPlan/state/airndb/tool.env` 配置方式。
|
||||
- 发现远程设备 SSH 入口、远程抓包工具、`AIRNDB_REMOTE_*` 配置方式或远端抓包权限限制。
|
||||
|
||||
## ADR 维护
|
||||
|
||||
目录:`docs/architecture/adr/`。
|
||||
|
||||
需要 ADR 的情况:
|
||||
|
||||
- 长期采用 tcpdump/WinDump 作为项目网络诊断方式。
|
||||
- 抓包流程改变了测试边界、网络观测边界、运行权限、数据留存或安全策略。
|
||||
- 发现需要保留的网络架构决策,例如代理、DNS、TLS、端口、服务发现或跨容器/宿主机边界。
|
||||
|
||||
ADR 保持简洁:Context、Decision、Consequences、Alternatives。
|
||||
|
||||
## C4 Module 维护
|
||||
|
||||
文件:`docs/architecture/c4/module.md`。
|
||||
|
||||
当网络调试发现或改变以下内容时,必须更新:
|
||||
|
||||
- 模块间网络依赖。
|
||||
- 服务端口、协议、DNS、代理、TLS、队列、网关、容器/宿主机/WSL/VM 边界。
|
||||
- 抓包或观测基础设施成为长期模块或运行边界。
|
||||
- 网络错误处理、重试、超时、连接池或安全边界。
|
||||
|
||||
## network log 维护
|
||||
|
||||
文件:`AirPlan/docs/network/airndb-log.md`。
|
||||
|
||||
每次 AirNDB 会话至少追加:
|
||||
|
||||
- 问题摘要。
|
||||
- 授权范围和目标流量。
|
||||
- 接口、BPF、抓包窗口。
|
||||
- 是否使用远程设备 helper 以及远程目标、抓包工具和权限限制。
|
||||
- pcap/summary/report 路径。
|
||||
- 关键包或时间线观察。
|
||||
- 结论、限制和给 AirDbg 的线索。
|
||||
- ADR/C4/AGENTS 更新。
|
||||
|
||||
## 完成输出
|
||||
|
||||
本轮网络调试结束时,用中文简洁汇报:
|
||||
|
||||
- 使用了哪个接口和过滤器。
|
||||
- 抓包是否成功,证据在哪里。
|
||||
- 关键观察和网络层结论。
|
||||
- 更新了哪些 `AGENTS.md` / ADR / C4 / network log。
|
||||
- 是否需要切给 AirDbg 做代码层修复。
|
||||
@@ -0,0 +1,3 @@
|
||||
name: airndb
|
||||
short_description: Local and remote packet capture workflow with tcpdump and WinDump
|
||||
default_prompt: "使用 AirNDB 做安全有界抓包;远程设备优先调用 remote device helper 并自动配置 tcpdump。"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user