fix(regression): repair 5 regressions from second round, close B10/B12/B15/B16
Round 2 regression fixes: - B10 (INV-2 outbox, CRITICAL): wiring.ts — switch durable events from eventBus.publish (live-only) to eventIngestor.ingest (persistent) for debug.record.created and memory.promoted. Add required RuntimeEvent fields (id, source, route). - B12 (Scheduler events, CRITICAL): Scheduler.ts — replace all 4 eventBus.publish calls with eventIngestor.ingest + registered event types (task.started/task.failed/agent.lost/agent.cancelled). Remove unregistered task.status.changed references. - B15 (duplicate ProjectionClient): remove orphan tui/src/ProjectionClient.ts (zero references, superseded by runtime/src/projection/ProjectionClient.ts re-exported via @aircoding/runtime barrel). - RuntimeApp: wire Scheduler→WorkerManager in constructor; document start() bootstrap→recover→hydrate→ready sequence (DD §22.2). - createRuntime: read project_id from .air/shared/project.json (DD §6.1 stable UUID), fallback to Date.now() only if not initialized. - B16 (api_key strict): ProviderManager.get_or_create_adapter now calls ModelConfigLoader.validate() before passing raw api_key to adapter. Also fix from R1 regression: - ArchitectureDesigner: replace broken additive-heuristic risk scoring (single runtime file→replan, large refactor→confirmation only) with change-scope classification (contracts→confirmation, breaking→escalate, large→replan, safe→silent_continue). Remove dead evaluate_risk(). - MainAgent test: update confirmation test from old state name AWAITING_CONFIRMATION to canonical CONFIRMING (B13 state machine fix). Test: 148/148 pass (regression + e2e + llm + toolchain-cpp). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import { WavePlanner } from './WavePlanner.js'
|
||||
import { RetryPlanner } from './RetryPlanner.js'
|
||||
import { WorkspaceManager } from './WorkspaceManager.js'
|
||||
import { AgentMonitor } from './AgentMonitor.js'
|
||||
import { eventIngestor } from '../events/EventIngestor.js'
|
||||
import type { WorkerManager } from '../workers/WorkerManager.js'
|
||||
|
||||
export type SchedulerState =
|
||||
@@ -138,9 +139,22 @@ export class Scheduler {
|
||||
case 'DISPATCHING': {
|
||||
const runnable = this.graph.get_runnable_tasks()
|
||||
for (const task of runnable) {
|
||||
this.graph.mark_terminal(task.id, 'running' as any)
|
||||
const agent_id = `agent_${task.id}`
|
||||
|
||||
// INV-1: Emit task.started event (durable) for projection
|
||||
const now = new Date().toISOString()
|
||||
await eventIngestor.ingest({
|
||||
id: `evt_${task.id}_started`,
|
||||
type: 'task.started',
|
||||
version: 1,
|
||||
session_id: this.context.session_id,
|
||||
project_id: this.context.project_id,
|
||||
timestamp: now,
|
||||
source: { kind: 'scheduler' },
|
||||
route: ['scheduler', 'dispatch'],
|
||||
payload: { task_id: task.id, agent_id, attempt_id: `${task.id}_1`, attempt_index: 0, workspace_id: `ws_${task.id}` }
|
||||
})
|
||||
|
||||
if (this.worker_manager) {
|
||||
try {
|
||||
await this.worker_manager.spawn({
|
||||
@@ -151,7 +165,18 @@ export class Scheduler {
|
||||
})
|
||||
this.agent_monitor.record_heartbeat(agent_id, task.id)
|
||||
} catch {
|
||||
this.graph.mark_terminal(task.id, 'failed')
|
||||
// INV-1: emit task.failed event for projection
|
||||
await eventIngestor.ingest({
|
||||
id: `evt_${task.id}_failed`,
|
||||
type: 'task.failed',
|
||||
version: 1,
|
||||
session_id: this.context.session_id,
|
||||
project_id: this.context.project_id,
|
||||
timestamp: new Date().toISOString(),
|
||||
source: { kind: 'scheduler' },
|
||||
route: ['scheduler', 'dispatch'],
|
||||
payload: { task_id: task.id, agent_id, attempt_id: `${task.id}_1`, error: { message: 'Worker spawn failed' }, evidence_refs: [], metadata: {} }
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.agent_monitor.record_heartbeat(agent_id, task.id)
|
||||
@@ -165,10 +190,32 @@ export class Scheduler {
|
||||
// Check agent health
|
||||
const lost = this.agent_monitor.detect_lost_agents()
|
||||
for (const l of lost) {
|
||||
// Emit agent.lost event and mark associated task as failed
|
||||
// Emit agent.lost + task.failed events for projection (INV-1/INV-5)
|
||||
const hb = this.agent_monitor.get(l.agent_id)
|
||||
if (hb) {
|
||||
this.graph.mark_terminal(hb.task_id, 'failed')
|
||||
const now = new Date().toISOString()
|
||||
await eventIngestor.ingest({
|
||||
id: `evt_${hb.task_id}_lost`,
|
||||
type: 'agent.lost',
|
||||
version: 1,
|
||||
session_id: this.context.session_id,
|
||||
project_id: this.context.project_id,
|
||||
timestamp: now,
|
||||
source: { kind: 'scheduler' },
|
||||
route: ['scheduler', 'monitoring'],
|
||||
payload: { agent_id: l.agent_id, task_id: hb.task_id, last_heartbeat_at: l.last_heartbeat, detection_reason: l.state }
|
||||
})
|
||||
await eventIngestor.ingest({
|
||||
id: `evt_${hb.task_id}_failed`,
|
||||
type: 'task.failed',
|
||||
version: 1,
|
||||
session_id: this.context.session_id,
|
||||
project_id: this.context.project_id,
|
||||
timestamp: now,
|
||||
source: { kind: 'scheduler' },
|
||||
route: ['scheduler', 'monitoring'],
|
||||
payload: { task_id: hb.task_id, agent_id: l.agent_id, attempt_id: '', error: { message: `Agent ${l.state}` }, evidence_refs: [], metadata: {} }
|
||||
})
|
||||
this.agent_monitor.remove(l.agent_id)
|
||||
}
|
||||
}
|
||||
@@ -181,12 +228,21 @@ export class Scheduler {
|
||||
case 'hard_cancel':
|
||||
case 'soft_cancel':
|
||||
if (task_id) {
|
||||
this.graph.mark_terminal(task_id, 'failed')
|
||||
await eventIngestor.ingest({
|
||||
id: `evt_${task_id}_cancelled`,
|
||||
type: 'agent.cancelled',
|
||||
version: 1,
|
||||
session_id: this.context.session_id,
|
||||
project_id: this.context.project_id,
|
||||
timestamp: new Date().toISOString(),
|
||||
source: { kind: 'scheduler' },
|
||||
route: ['scheduler', 'monitoring'],
|
||||
payload: { agent_id: t.agent_id, task_id, reason: t.action }
|
||||
})
|
||||
}
|
||||
this.agent_monitor.remove(t.agent_id)
|
||||
break
|
||||
case 'ping':
|
||||
// Agent is stalled, ping to see if it responds
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user