Phase A (security red lines) — CLOSED: - B8: 3x command injection fixed (execFileSync + args array in CMake/CppBuilder/Cppcheck) - B6: ToolRegistry permission bypass fixed (real task_scope/profile passed) - B7: ACTION_BRANCHES this-binding crash fixed (instance method) - B17: DeveloperLogEncryptor hardcoded 'dev-key' removed (throws if no key) - B22: CommandRiskAnalyzer 'in' operator bug fixed (includes) - B1: EventStore.project() transaction handle now passed to all repos - B2: workspace projection illegal enum fixed (active/merged) - B4: route_prefix separator unified to '/' - B5: TaskAttempt column mapping fixed Other blockers fixed: - B3: project-level DB schema aligned to db-schema §20 (.air/local, learned_memories) - B9: cpp.* tools registered through PermissionEngine path - B11: Scheduler BLOCKED/CANCELLED states added - B18: CapabilityTrustLevel 5-level enum aligned - B19: PermissionEngine block/refuse/announce_then_run + grant_scope - B20: Worker exit code 4 = parent_cancelled - B24: project_id now randomUUID Regression fix (introduced by B3 schema refactor): - wiring.ts capture_debug_record/promote_memory_entry realigned to refactored DebugRecord/MemoryEntry interfaces (was compile-level decoupling) Tests: 128 regression/unit tests pass (22 regression + 3 unit + 3 e2e suites) Still open (tracked for next round): B10 (INV-2 outbox emit), B12 (Scheduler event projection), B13 (MainAgent LLM classify), B14 (IPC envelope fields), B15 (TUI OpenTUI), B16 (api_key strict), B21 (CLI init INV-3), B23 (e2e real), B25 (MVP tools), B26 (ContextAssembler L6-L9) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
2.9 KiB
TypeScript
Executable File
80 lines
2.9 KiB
TypeScript
Executable File
/**
|
|
* C2 regression: MainAgent missing 7 states
|
|
* Validates that MainAgentState includes all spec states,
|
|
* AWAITING_CONFIRMATION is removed, and new methods exist.
|
|
*
|
|
* 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/agents/main/MainAgent.ts')
|
|
const source = readFileSync(source_path, 'utf-8')
|
|
|
|
describe('C2: MainAgent states audit', () => {
|
|
const required_states = [
|
|
'CLASSIFYING',
|
|
'SCHEDULING',
|
|
'ARCHITECTURE_DESIGNING',
|
|
'CONFIRMING',
|
|
'EXECUTING',
|
|
'INTERRUPTING',
|
|
'ARCHITECTURE_REVISING',
|
|
]
|
|
|
|
for (const state of required_states) {
|
|
it(`MainAgentState includes ${state}`, () => {
|
|
// Check that the state appears in the type definition
|
|
expect(source).toContain(`'${state}'`)
|
|
})
|
|
}
|
|
|
|
it('MainAgentState does not include legacy AWAITING_CONFIRMATION', () => {
|
|
// The type definition should not contain AWAITING_CONFIRMATION
|
|
// Extract the type definition block
|
|
const type_match = source.match(/export type MainAgentState\s*=\s*([\s\S]*?)(?:\n\n|\nexport)/)
|
|
expect(type_match).not.toBeNull()
|
|
expect(type_match![1]).not.toContain('AWAITING_CONFIRMATION')
|
|
})
|
|
|
|
it('handle_interruption method exists', () => {
|
|
expect(source).toContain('handle_interruption(')
|
|
// Verify it accepts the three change levels
|
|
expect(source).toContain("'execution'")
|
|
expect(source).toContain("'design'")
|
|
expect(source).toContain("'full'")
|
|
})
|
|
|
|
it('handle_user_message transitions through CLASSIFYING', () => {
|
|
// The handle_user_message method should set state to CLASSIFYING
|
|
// before calling classify
|
|
expect(source).toContain("this.state = 'CLASSIFYING'")
|
|
// Verify it appears before the classify call
|
|
const classifying_idx = source.indexOf("this.state = 'CLASSIFYING'")
|
|
const classify_call_idx = source.indexOf('this.classify(message)')
|
|
expect(classifying_idx).toBeGreaterThan(-1)
|
|
expect(classify_call_idx).toBeGreaterThan(-1)
|
|
expect(classifying_idx).toBeLessThan(classify_call_idx)
|
|
})
|
|
|
|
it('classify still uses regex (Alpha scope)', () => {
|
|
// Verify the classify method uses regex patterns
|
|
expect(source).toContain('/^(what|how|why|when|where|who')
|
|
expect(source).toContain('/^(implement|create|build|write|add|fix')
|
|
expect(source).toContain('/^(run|execute|test|debug|check|inspect')
|
|
})
|
|
|
|
it('transition methods exist', () => {
|
|
expect(source).toContain('transition_to_confirming()')
|
|
expect(source).toContain('transition_to_executing()')
|
|
expect(source).toContain('transition_to_interrupting()')
|
|
})
|
|
|
|
it('handle_confirmation references CONFIRMING not AWAITING_CONFIRMATION', () => {
|
|
expect(source).toContain("this.state !== 'CONFIRMING'")
|
|
expect(source).not.toContain('AWAITING_CONFIRMATION')
|
|
})
|
|
})
|