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>
132 lines
4.2 KiB
TypeScript
Executable File
132 lines
4.2 KiB
TypeScript
Executable File
import { describe, expect, it } from 'bun:test'
|
|
import { ProjectionStore } from '../../src/projection/ProjectionStore.js'
|
|
import type { RuntimeEvent } from '@aircoding/contracts'
|
|
|
|
function event(type: string, payload: Record<string, unknown>): RuntimeEvent<Record<string, unknown>> {
|
|
return {
|
|
id: `evt_${type}_${Math.random().toString(36).slice(2)}`,
|
|
type,
|
|
version: 1,
|
|
timestamp: new Date().toISOString(),
|
|
session_id: 'session_projection_apply' as any,
|
|
project_id: 'project_projection_apply' as any,
|
|
source: { kind: 'system' },
|
|
route: ['test', type],
|
|
payload,
|
|
}
|
|
}
|
|
|
|
describe('ProjectionStore.apply', () => {
|
|
it('applies task and agent lifecycle events into a live snapshot', () => {
|
|
const store = new ProjectionStore()
|
|
const updates: string[] = []
|
|
store.subscribe((projection) => {
|
|
updates.push(`${projection.tasks[0]?.status || 'none'}:${projection.agents[0]?.status || 'none'}`)
|
|
})
|
|
|
|
store.apply(event('task.created', {
|
|
task_id: 'task_1',
|
|
type: 'execute',
|
|
title: 'Create file',
|
|
task_spec_json: {},
|
|
dependencies: [],
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('task.started', {
|
|
task_id: 'task_1',
|
|
agent_id: 'agent_task_1',
|
|
attempt_id: 'task_1_1',
|
|
attempt_index: 0,
|
|
workspace_id: 'ws_task_1',
|
|
}))
|
|
store.apply(event('agent.started', {
|
|
agent_id: 'agent_task_1',
|
|
agent_type: 'executor',
|
|
task_id: 'task_1',
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('agent.completed', {
|
|
agent_id: 'agent_task_1',
|
|
task_id: 'task_1',
|
|
summary: 'done',
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('task.completed', {
|
|
task_id: 'task_1',
|
|
agent_id: 'agent_task_1',
|
|
attempt_id: 'task_1_1',
|
|
worker_result_json: { status: 'completed' },
|
|
summary: 'done',
|
|
changed_files: ['hello.txt'],
|
|
evidence_refs: [],
|
|
}))
|
|
|
|
const snapshot = store.get_snapshot('session_projection_apply')
|
|
expect(snapshot).toBeDefined()
|
|
expect(snapshot!.tasks).toHaveLength(1)
|
|
expect(snapshot!.tasks[0].status).toBe('completed')
|
|
expect(snapshot!.tasks[0].agent_id).toBe('agent_task_1')
|
|
expect(snapshot!.tasks[0].attempts).toBe(1)
|
|
expect(snapshot!.agents).toHaveLength(1)
|
|
expect(snapshot!.agents[0].status).toBe('completed')
|
|
expect(updates.some((u) => u.startsWith('completed:completed'))).toBe(true)
|
|
})
|
|
|
|
it('applies tool, permission, and blocker events', () => {
|
|
const store = new ProjectionStore()
|
|
|
|
store.apply(event('tool.started', {
|
|
tool_run_id: 'tool_1',
|
|
tool_name: 'fs.write',
|
|
input_json: {},
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('tool.completed', {
|
|
tool_run_id: 'tool_1',
|
|
output_json: { ok: true },
|
|
duration_ms: 12,
|
|
artifact_ids: [],
|
|
evidence_refs: [],
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('permission.prompt.requested', {
|
|
prompt_id: 'perm_1',
|
|
subject: 'shell.run',
|
|
risk_level: 'medium',
|
|
reason: 'risk score 70 requires user confirmation',
|
|
options: ['allow_once', 'deny'],
|
|
default_option: 'deny',
|
|
request_ref: {},
|
|
}))
|
|
store.apply(event('task.created', {
|
|
task_id: 'task_blocked',
|
|
type: 'execute',
|
|
title: 'Blocked task',
|
|
task_spec_json: {},
|
|
dependencies: [],
|
|
metadata: {},
|
|
}))
|
|
store.apply(event('task.blocked', {
|
|
task_id: 'task_blocked',
|
|
agent_id: 'agent_task_blocked',
|
|
reason: 'worker blocked',
|
|
blocker_kind: 'worker_blocked',
|
|
evidence_refs: [],
|
|
suggested_next_step: 'review blocker',
|
|
}))
|
|
store.apply(event('permission.prompt.resolved', {
|
|
prompt_id: 'perm_1',
|
|
selected_option: 'deny',
|
|
decision_id: 'decision_1',
|
|
resolved_by: 'test',
|
|
}))
|
|
|
|
const snapshot = store.get_snapshot('session_projection_apply')
|
|
expect(snapshot).toBeDefined()
|
|
expect(snapshot!.tool_runs).toEqual([{ tool_run_id: 'tool_1', tool_name: 'fs.write', status: 'ok', duration_ms: 12 }])
|
|
expect(snapshot!.permission_prompts).toHaveLength(0)
|
|
expect(snapshot!.tasks.find((task) => task.id === 'task_blocked')?.status).toBe('blocked')
|
|
expect(snapshot!.blockers).toEqual([{ task_id: 'task_blocked', reason: 'worker blocked', blocker_kind: 'worker_blocked' }])
|
|
})
|
|
})
|