fix(P0): close 15 blockers + add 26 regression tests; fix wiring schema regression
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>
This commit is contained in:
@@ -10,7 +10,19 @@
|
||||
|
||||
import type { SessionID, ProjectID } from '@aircoding/contracts'
|
||||
|
||||
export type MainAgentState = 'IDLE' | 'ANSWERING' | 'DELEGATING' | 'DIRECT_MODE' | 'AWAITING_CONFIRMATION' | 'SUMMARIZING'
|
||||
export type MainAgentState =
|
||||
| 'IDLE'
|
||||
| 'CLASSIFYING'
|
||||
| 'ANSWERING'
|
||||
| 'DELEGATING'
|
||||
| 'DIRECT_MODE'
|
||||
| 'SCHEDULING'
|
||||
| 'ARCHITECTURE_DESIGNING'
|
||||
| 'CONFIRMING'
|
||||
| 'EXECUTING'
|
||||
| 'INTERRUPTING'
|
||||
| 'ARCHITECTURE_REVISING'
|
||||
| 'SUMMARIZING'
|
||||
|
||||
export interface MainAgentConfig {
|
||||
session_id: SessionID
|
||||
@@ -35,6 +47,7 @@ export class MainAgent {
|
||||
response?: string
|
||||
}> {
|
||||
// Classify intent
|
||||
this.state = 'CLASSIFYING'
|
||||
const classification = this.classify(message)
|
||||
|
||||
switch (classification) {
|
||||
@@ -83,7 +96,7 @@ export class MainAgent {
|
||||
* Handle confirmation from user.
|
||||
*/
|
||||
async handle_confirmation(confirmed: boolean): Promise<void> {
|
||||
if (this.state !== 'AWAITING_CONFIRMATION') return
|
||||
if (this.state !== 'CONFIRMING') return
|
||||
|
||||
if (confirmed) {
|
||||
this.state = 'DELEGATING'
|
||||
@@ -100,4 +113,47 @@ export class MainAgent {
|
||||
// After summarization completes
|
||||
this.state = 'IDLE'
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an interruption at the specified change level.
|
||||
* 'execution' → state EXECUTING
|
||||
* 'design' → state ARCHITECTURE_REVISING
|
||||
* 'full' → state ARCHITECTURE_DESIGNING
|
||||
*/
|
||||
handle_interruption(change_level: 'execution' | 'design' | 'full'): void {
|
||||
this.state = 'INTERRUPTING'
|
||||
|
||||
switch (change_level) {
|
||||
case 'execution':
|
||||
this.state = 'EXECUTING'
|
||||
break
|
||||
case 'design':
|
||||
this.state = 'ARCHITECTURE_REVISING'
|
||||
break
|
||||
case 'full':
|
||||
this.state = 'ARCHITECTURE_DESIGNING'
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transition to CONFIRMING state (awaiting user confirmation).
|
||||
*/
|
||||
transition_to_confirming(): void {
|
||||
this.state = 'CONFIRMING'
|
||||
}
|
||||
|
||||
/**
|
||||
* Transition to EXECUTING state.
|
||||
*/
|
||||
transition_to_executing(): void {
|
||||
this.state = 'EXECUTING'
|
||||
}
|
||||
|
||||
/**
|
||||
* Transition to INTERRUPTING state.
|
||||
*/
|
||||
transition_to_interrupting(): void {
|
||||
this.state = 'INTERRUPTING'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,22 +31,35 @@ export function createKnowledgeWiring(project_root: string): KnowledgeWiring {
|
||||
/**
|
||||
* Handle a debug capture from DebuggerRole.
|
||||
* INV-2: External write first → then emit debug.record.created via outbox.
|
||||
* Fields aligned with DebugRecord (db-schema-v1 §20.1) after the §20 schema refactor.
|
||||
*/
|
||||
export async function capture_debug_record(
|
||||
store: DebugKnowledgeStore,
|
||||
record: { id: string; signature: string; task_id: string; session_id: string; error_kind: string; root_cause?: string; fix_applied?: string }
|
||||
record: {
|
||||
id: string
|
||||
failure_signature: string
|
||||
task_id: string
|
||||
summary: string
|
||||
root_cause?: string
|
||||
fix_ref?: string
|
||||
evidence_json?: string
|
||||
verification_json?: string
|
||||
metadata_json?: string
|
||||
}
|
||||
): Promise<void> {
|
||||
const now = new Date().toISOString()
|
||||
store.insert({
|
||||
id: record.id,
|
||||
signature: record.signature,
|
||||
failure_signature: record.failure_signature,
|
||||
task_id: record.task_id,
|
||||
session_id: record.session_id,
|
||||
error_kind: record.error_kind,
|
||||
summary: record.summary,
|
||||
root_cause: record.root_cause,
|
||||
fix_applied: record.fix_applied,
|
||||
status: 'open',
|
||||
created_at: new Date().toISOString(),
|
||||
resolved_at: undefined
|
||||
fix_ref: record.fix_ref,
|
||||
evidence_json: record.evidence_json,
|
||||
verification_json: record.verification_json,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
metadata_json: record.metadata_json,
|
||||
})
|
||||
// INV-2: emit debug.record.created event AFTER external write
|
||||
}
|
||||
@@ -54,20 +67,32 @@ export async function capture_debug_record(
|
||||
/**
|
||||
* Handle experience mining promotion.
|
||||
* INV-2: External write first → then emit memory.promoted via outbox.
|
||||
* Fields aligned with MemoryEntry (db-schema-v1 §20.2) after the §20 schema refactor.
|
||||
*/
|
||||
export async function promote_memory_entry(
|
||||
store: LearnedMemoryStore,
|
||||
entry: { id: string; type: 'pattern' | 'rule' | 'skill' | 'experience'; title: string; content: string; source_task_ids: string[]; project_id: string }
|
||||
entry: {
|
||||
id: string
|
||||
memory_type: 'project_rule' | 'toolchain_rule' | 'skill_update' | 'debug_experience'
|
||||
summary: string
|
||||
content: string
|
||||
source_entity_type?: string
|
||||
source_entity_id?: string
|
||||
metadata_json?: string
|
||||
}
|
||||
): Promise<void> {
|
||||
const now = new Date().toISOString()
|
||||
store.insert({
|
||||
id: entry.id,
|
||||
type: entry.type,
|
||||
title: entry.title,
|
||||
memory_type: entry.memory_type,
|
||||
summary: entry.summary,
|
||||
content: entry.content,
|
||||
source_task_ids: entry.source_task_ids.join(','),
|
||||
project_id: entry.project_id,
|
||||
status: 'draft',
|
||||
created_at: new Date().toISOString()
|
||||
source_entity_type: entry.source_entity_type,
|
||||
source_entity_id: entry.source_entity_id,
|
||||
status: 'candidate',
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
metadata_json: entry.metadata_json,
|
||||
})
|
||||
// INV-2: emit memory.promoted event AFTER external write
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user