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:
@@ -1,111 +1,88 @@
|
||||
/**
|
||||
* C1 regression: Knowledge Store schema alignment.
|
||||
* Bug: DebugKnowledgeStore and LearnedMemoryStore used .air/shared/ paths,
|
||||
* had non-canonical column names, and were missing PRAGMAs.
|
||||
* Fix: moved to .air/local/, renamed columns, added WAL/synchronous/foreign_keys PRAGMAs.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'bun:test'
|
||||
import { readFileSync } from 'fs'
|
||||
import { afterEach, describe, expect, it } from 'bun:test'
|
||||
import { existsSync, mkdtempSync, rmSync } from 'fs'
|
||||
import { tmpdir } from 'os'
|
||||
import { join } from 'path'
|
||||
import { DebugKnowledgeStore } from '../../src/knowledge/DebugKnowledgeStore.js'
|
||||
import { LearnedMemoryStore } from '../../src/knowledge/LearnedMemoryStore.js'
|
||||
|
||||
describe('C1: Knowledge Store schema alignment', () => {
|
||||
const debug_src = readFileSync(
|
||||
join(import.meta.dir, '..', '..', 'src', 'knowledge', 'DebugKnowledgeStore.ts'),
|
||||
'utf-8'
|
||||
)
|
||||
const memory_src = readFileSync(
|
||||
join(import.meta.dir, '..', '..', 'src', 'knowledge', 'LearnedMemoryStore.ts'),
|
||||
'utf-8'
|
||||
)
|
||||
const created: string[] = []
|
||||
|
||||
it('DebugKnowledgeStore DB path uses .air/local/ not .air/shared/', () => {
|
||||
expect(debug_src).toContain("'.air', 'local', 'debug-records.db'")
|
||||
expect(debug_src).not.toContain("'.air', 'shared', 'debug-records.db'")
|
||||
afterEach(() => {
|
||||
for (const dir of created.splice(0)) rmSync(dir, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it('LearnedMemoryStore DB path uses .air/local/ not .air/shared/', () => {
|
||||
expect(memory_src).toContain("'.air', 'local', 'learned-memory.db'")
|
||||
expect(memory_src).not.toContain("'.air', 'shared', 'learned-memory.db'")
|
||||
it('DebugKnowledgeStore stores and queries records from .air/local', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'air-debug-store-'))
|
||||
created.push(root)
|
||||
const store = new DebugKnowledgeStore(root)
|
||||
store.open()
|
||||
const now = new Date().toISOString()
|
||||
|
||||
store.insert({
|
||||
id: 'debug_1',
|
||||
failure_signature: 'compiler:error:missing-header',
|
||||
task_id: 'task_1',
|
||||
root_cause: 'missing include path',
|
||||
fix_ref: 'fix://1',
|
||||
summary: 'Add include path before rebuilding',
|
||||
evidence_json: JSON.stringify(['evi_1']),
|
||||
verification_json: JSON.stringify(['build passed']),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
metadata_json: JSON.stringify({ source: 'test' }),
|
||||
})
|
||||
|
||||
expect(existsSync(join(root, '.air', 'local', 'debug-records.db'))).toBe(true)
|
||||
expect(existsSync(join(root, '.air', 'shared', 'debug-records.db'))).toBe(false)
|
||||
expect(store.lookup_by_signature('compiler:error:missing-header')).toHaveLength(1)
|
||||
expect(store.lookup_by_task('task_1')[0]).toMatchObject({
|
||||
id: 'debug_1',
|
||||
failure_signature: 'compiler:error:missing-header',
|
||||
task_id: 'task_1',
|
||||
root_cause: 'missing include path',
|
||||
fix_ref: 'fix://1',
|
||||
summary: 'Add include path before rebuilding',
|
||||
})
|
||||
|
||||
store.update('debug_1', { summary: 'Updated summary', updated_at: now })
|
||||
expect(store.lookup_by_signature('compiler:error:missing-header')[0].summary).toBe('Updated summary')
|
||||
})
|
||||
|
||||
it('DebugRecord has failure_signature not signature', () => {
|
||||
const iface_match = debug_src.match(/export interface DebugRecord\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
it('LearnedMemoryStore stores candidates/promoted memories from .air/local', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'air-memory-store-'))
|
||||
created.push(root)
|
||||
const store = new LearnedMemoryStore(root)
|
||||
store.open()
|
||||
const now = new Date().toISOString()
|
||||
|
||||
expect(iface_body).toContain('failure_signature')
|
||||
// Should not have bare 'signature' field (failure_signature contains 'signature' as substring, so check for the exact field pattern)
|
||||
expect(iface_body).not.toMatch(/^\s*signature\s*:/m)
|
||||
})
|
||||
store.insert({
|
||||
id: 'mem_1',
|
||||
memory_type: 'project_rule',
|
||||
summary: 'Use Bun for package scripts',
|
||||
content: 'Project commands should use Bun unless explicitly overridden.',
|
||||
source_entity_type: 'task',
|
||||
source_entity_id: 'task_1',
|
||||
status: 'candidate',
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
metadata_json: JSON.stringify({ confidence: 0.8 }),
|
||||
})
|
||||
|
||||
it('DebugRecord has summary and fix_ref fields', () => {
|
||||
const iface_match = debug_src.match(/export interface DebugRecord\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
expect(existsSync(join(root, '.air', 'local', 'learned-memory.db'))).toBe(true)
|
||||
expect(existsSync(join(root, '.air', 'shared', 'learned-memory.db'))).toBe(false)
|
||||
expect(store.lookup_by_type('project_rule')).toHaveLength(1)
|
||||
expect(store.lookup_by_type('project_rule')[0]).toMatchObject({
|
||||
id: 'mem_1',
|
||||
memory_type: 'project_rule',
|
||||
status: 'candidate',
|
||||
source_entity_type: 'task',
|
||||
source_entity_id: 'task_1',
|
||||
})
|
||||
|
||||
expect(iface_body).toContain('summary')
|
||||
expect(iface_body).toContain('fix_ref')
|
||||
})
|
||||
|
||||
it('DebugRecord does not have error_kind or session_id', () => {
|
||||
const iface_match = debug_src.match(/export interface DebugRecord\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
|
||||
expect(iface_body).not.toContain('error_kind')
|
||||
expect(iface_body).not.toContain('session_id')
|
||||
})
|
||||
|
||||
it('DebugKnowledgeStore applies WAL PRAGMA', () => {
|
||||
expect(debug_src).toContain('PRAGMA journal_mode = WAL')
|
||||
})
|
||||
|
||||
it('LearnedMemoryStore table is learned_memories (plural)', () => {
|
||||
expect(memory_src).toContain('learned_memories')
|
||||
// Ensure we don't have the singular form used as table name
|
||||
expect(memory_src).not.toMatch(/FROM learned_memory\b/)
|
||||
expect(memory_src).not.toMatch(/INTO learned_memory\b/)
|
||||
expect(memory_src).not.toMatch(/UPDATE learned_memory\b/)
|
||||
expect(memory_src).not.toMatch(/TABLE.*learned_memory\b/)
|
||||
})
|
||||
|
||||
it('MemoryEntry.memory_type has 4 spec values', () => {
|
||||
const iface_match = memory_src.match(/export interface MemoryEntry\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
|
||||
expect(iface_body).toContain("'project_rule'")
|
||||
expect(iface_body).toContain("'toolchain_rule'")
|
||||
expect(iface_body).toContain("'skill_update'")
|
||||
expect(iface_body).toContain("'debug_experience'")
|
||||
expect(iface_body).toContain('memory_type')
|
||||
})
|
||||
|
||||
it('MemoryEntry.status has 4 spec values: candidate, promoted, archived, rejected', () => {
|
||||
const iface_match = memory_src.match(/export interface MemoryEntry\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
|
||||
expect(iface_body).toContain("'candidate'")
|
||||
expect(iface_body).toContain("'promoted'")
|
||||
expect(iface_body).toContain("'archived'")
|
||||
expect(iface_body).toContain("'rejected'")
|
||||
})
|
||||
|
||||
it('MemoryEntry.status default is candidate not draft', () => {
|
||||
// Check that the CREATE TABLE DDL uses 'candidate' as default
|
||||
expect(memory_src).toContain("DEFAULT 'candidate'")
|
||||
expect(memory_src).not.toContain("DEFAULT 'draft'")
|
||||
})
|
||||
|
||||
it('MemoryEntry uses source_entity_type + source_entity_id', () => {
|
||||
const iface_match = memory_src.match(/export interface MemoryEntry\s*\{([\s\S]*?)\}/)
|
||||
expect(iface_match).not.toBeNull()
|
||||
const iface_body = iface_match![1]
|
||||
|
||||
expect(iface_body).toContain('source_entity_type')
|
||||
expect(iface_body).toContain('source_entity_id')
|
||||
expect(iface_body).not.toContain('source_task_ids')
|
||||
store.update_status('mem_1', 'promoted')
|
||||
expect(store.lookup_by_type('project_rule')[0].status).toBe('promoted')
|
||||
store.update_status('mem_1', 'archived')
|
||||
expect(store.lookup_by_type('project_rule')).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user