Files
AirCoding/packages/runtime/test/regression/worker-result-envelope.test.ts
AirCoding 5e282a39b4 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>
2026-06-09 16:13:16 +08:00

65 lines
2.5 KiB
TypeScript
Executable File

/**
* D3 regression: Worker result WorkerResult<T> envelope
* Validates that WorkerManager has the result field on WorkerHandle,
* wrap_worker_result and get_result methods, and imports WorkerResult
* from contracts.
*
* Uses source inspection (reading the source file as text).
*/
import { describe, it, expect } from 'bun:test'
import { readFileSync } from 'fs'
import { join } from 'path'
const source_path = join(import.meta.dir, '../../src/workers/WorkerManager.ts')
const source = readFileSync(source_path, 'utf-8')
describe('D3: Worker result envelope', () => {
it('WorkerHandle has result field', () => {
expect(source).toContain('result?: WorkerResult<unknown>')
})
it('wrap_worker_result method exists', () => {
expect(source).toContain('wrap_worker_result(')
// Should be a private method
expect(source).toContain('private wrap_worker_result')
})
it('get_result method exists', () => {
expect(source).toContain('get_result(agent_id: string)')
// Should return WorkerResult<unknown> | undefined
expect(source).toContain('WorkerResult<unknown> | undefined')
})
it('imports WorkerResult from contracts', () => {
expect(source).toContain("import type { WorkerResult")
expect(source).toContain("from '@aircoding/contracts'")
})
it('imports WorkerStatus from contracts', () => {
expect(source).toContain('WorkerStatus')
})
it('imports AgentType from contracts', () => {
expect(source).toContain('AgentType')
})
it('wrap_worker_result maps role results into WorkerResult with safe defaults', () => {
expect(source).toContain('agent_type: (payload.agent_type as AgentType) || this.worker_agent_type(handle.config.agent_id)')
expect(source).toContain("const raw_status = (payload.status as string) || 'completed'")
expect(source).toContain("raw_status === 'fixed'")
expect(source).toContain("raw_status === 'pass'")
expect(source).toContain("raw_status === 'cannot_reproduce'")
expect(source).toContain("raw_status === 'compacted'")
expect(source).toContain("raw_status === 'no_patterns'")
expect(source).toContain('changes.map((c: any) => String(c.file))')
expect(source).toContain("verification_payload ? [{ command: 'worker verification'")
expect(source).toContain('result: (payload.result as unknown) || payload')
})
it('get_result returns undefined for unknown agent', () => {
// The method should check if handle exists and return undefined
expect(source).toContain('if (!handle) return undefined')
})
})