feat(round2+round3): 完整实现 A/B/C/D 主线 + round3-F/H 修复

Round2 主线:
- A: 事件落库地基 (RuntimeApp EventStore 单例 + 14 repo wiring)
- B: 执行体对齐 (read-before-edit, verification-before-completion)
- C: 界面对齐 (@opentui/solid, 删除 runtime 依赖)
- D: 经验闭环 (ExperienceMiner, DebuggerRole, CompactorRole)

Round2 补充修复:
- fail-on-missing 反作弊门禁
- projection-store-apply.test.ts 补写
- 3个空壳测试转行为 (evidence-store, recovery-impl, knowledge-store)
- ask 项目根支持 AIRCODING_PROJECT_ROOT
- Worker 事件契约修复 (task.attempt.started → checkpoint)

Round3-F: cpp 工具切换
- 删除 BuiltInToolRegistrar cpp.* 闭包
- 接入 toolchain-cpp 真实 CppToolRegistrar
- canonical envelope {status/output/metadata}
- ExecutorRole system prompt 对齐新工具名

Round3-H: Doctor 5 类报告
- toolchain (cmake/ninja/cppcheck/clangd/g++)
- display (X11/Wayland + ImageMagick)
- network (internet connectivity)
- provider (api_key/base_url/model/connectivity)

Secret 脱敏:
- 状态交接.md: sk- → \${OPENAI_API_KEY}
- .gitignore: 添加 .air/ .claude/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
AirCoding
2026-06-09 16:13:16 +08:00
parent e383d5f6a7
commit 5e282a39b4
44 changed files with 2905 additions and 1343 deletions

View File

@@ -1,59 +1,55 @@
/**
* Regression test: EvidenceStore SQLite persistence
*
* Verifies that EvidenceStore uses SQLite (bun:sqlite) instead of
* in-memory Map for persistent storage.
*/
import { describe, test, expect } from 'bun:test'
import { readFileSync } from 'fs'
import { afterEach, describe, expect, test } from 'bun:test'
import { Database } from 'bun:sqlite'
import { mkdtempSync, rmSync } from 'fs'
import { tmpdir } from 'os'
import { join } from 'path'
const SOURCE_PATH = join(
import.meta.dir,
'..',
'..',
'src',
'artifacts',
'EvidenceStore.ts'
)
const source = readFileSync(SOURCE_PATH, 'utf-8')
import { createEvidenceStore } from '../../src/artifacts/EvidenceStore.js'
import { createNullEventIngestor } from '../../src/events/EventIngestor.js'
describe('EvidenceStore SQLite persistence', () => {
test('EvidenceStore does not use in-memory Map', () => {
// Should not have Map< for storage
expect(source).not.toMatch(/evidenceStore:\s*Map</)
// Should not use .set() on a map
expect(source).not.toContain('this.evidenceStore.set(')
const created: string[] = []
afterEach(() => {
for (const dir of created.splice(0)) rmSync(dir, { recursive: true, force: true })
})
test('EvidenceStore constructor accepts Database parameter', () => {
// Constructor should accept a Database parameter
expect(source).toContain('db: Database')
// Should import Database from bun:sqlite
expect(source).toContain("from 'bun:sqlite'")
})
test('persists evidence refs in SQLite and can list them by entity', async () => {
const dir = mkdtempSync(join(tmpdir(), 'air-evidence-store-'))
created.push(dir)
const dbPath = join(dir, 'evidence.db')
test('EvidenceStore has initSchema method', () => {
expect(source).toContain('initSchema()')
// Should be called in constructor
expect(source).toContain('this.initSchema()')
})
const db1 = new Database(dbPath)
const store1 = createEvidenceStore('session_evidence' as any, db1, createNullEventIngestor() as any)
const createdRef = await store1.create({
kind: 'command_output',
ref: 'artifact://stdout.txt',
claim: 'command produced expected output',
task_id: 'task_1' as any,
location_json: { line: 1 },
})
expect(createdRef.evidence_ref_id).toStartWith('evi_')
expect((await store1.list_for_entity('task', 'task_1'))[0]).toMatchObject({
evidence_ref_id: createdRef.evidence_ref_id,
kind: 'command_output',
ref: 'artifact://stdout.txt',
claim: 'command produced expected output',
location_json: { line: 1 },
})
db1.close()
test('EvidenceStore creates evidence_refs table', () => {
expect(source).toContain('CREATE TABLE IF NOT EXISTS evidence_refs')
// Should have key columns
expect(source).toContain('evidence_ref_id TEXT PRIMARY KEY')
expect(source).toContain('session_id TEXT NOT NULL')
expect(source).toContain('kind TEXT NOT NULL')
})
test('EvidenceStore uses INSERT INTO for create', () => {
expect(source).toContain('INSERT INTO evidence_refs')
})
test('EvidenceStore applies WAL PRAGMA', () => {
expect(source).toContain('PRAGMA journal_mode = WAL')
const db2 = new Database(dbPath)
const rows = db2.query('SELECT evidence_ref_id, session_id, kind, ref, claim, location_json, task_id FROM evidence_refs').all() as any[]
expect(rows).toHaveLength(1)
expect(rows[0]).toMatchObject({
evidence_ref_id: createdRef.evidence_ref_id,
session_id: 'session_evidence',
kind: 'command_output',
ref: 'artifact://stdout.txt',
claim: 'command produced expected output',
task_id: 'task_1',
})
expect(JSON.parse(rows[0].location_json)).toEqual({ line: 1 })
expect(db2.query("PRAGMA journal_mode").get()).toEqual({ journal_mode: 'wal' })
db2.close()
})
})