/** * FR-D05: PDCA Cycle Auto-Driver. * * Listens for gap events (FR-D03 post-release-gap-found, FR-D04 okr-check-completed * with unachieved KRs) and automatically drives PDCA cycles until convergence * or escalation. * * Design: * - Reuses PdcaCycleRecord from FR-18 types. * - Each cycle records triggeredBy + newTasks + result. * - Terminates when gap=0 (converged) or max cycles reached (escalated). * - Emits pdca-cycle-started per cycle, pdca-escalated on limit breach. * - Single-agent mode: degrades to CLI output listing fix tasks. */ import type { PdcaCycleRecord, PipelineInstance } from '../types/index.js'; import type { PostReleaseGapFoundEvent, OkrCheckCompletedEvent, PdcaCycleStartedEvent, PdcaEscalatedEvent, PdcaSummaryReport, DriveEventType } from './types.js'; /** Event sink for PDCA auto-driver emissions. */ export interface PdcaDriverEventSink { emit(event: DriveEventType, payload: PdcaCycleStartedEvent | PdcaEscalatedEvent): void; } /** CLI output adapter for single-agent degradation (AC-D05.10). */ export interface PdcaCliOutputAdapter { write(message: string): void; } export interface PdcaAutoDriverOptions { /** Event sink for pushing cycle events. */ eventSink: PdcaDriverEventSink; /** Maximum PDCA cycles before escalation. Default: 5. */ maxCycles?: number; /** CLI output for single-agent degradation. */ cliOutput?: PdcaCliOutputAdapter; /** Clock override for testing. */ now?: () => string; } /** Context for triggering a PDCA cycle. */ export interface PdcaTriggerContext { /** Source event type that triggered this cycle. */ source: 'post-release-gap-found' | 'okr-check-completed'; /** Human-readable reasons (KR IDs or FR gap descriptions). */ triggeredBy: string[]; /** Task identifiers extracted from fixTasks or suggestedTasks. */ newTasks: string[]; } export declare class PdcaAutoDriver { private readonly eventSink; private readonly maxCycles; private readonly cliOutput?; private readonly now; constructor(options: PdcaAutoDriverOptions); /** * Handle a post-release-gap-found event (FR-D03 → FR-D05 trigger). * AC-D05.1: Auto-creates PdcaCycleRecord and appends to pipeline. */ handleGapFound(pipeline: PipelineInstance, event: PostReleaseGapFoundEvent): PdcaCycleRecord | null; /** * Handle an okr-check-completed event with unachieved KRs (FR-D04 → FR-D05 trigger). * AC-D05.1: Auto-creates PdcaCycleRecord and appends to pipeline. */ handleOkrCheckWithGaps(pipeline: PipelineInstance, event: OkrCheckCompletedEvent): PdcaCycleRecord | null; /** * Notify the driver that fix tasks for a cycle are complete. * AC-D05.4: Auto-triggers next scan or terminates. * * @param pipeline - Current pipeline state (with updated pdcaCycles). * @param gapsClosed - Whether all gaps are now resolved. * @returns The cycle result and whether the loop should continue. */ notifyFixComplete(pipeline: PipelineInstance, gapsClosed: boolean): { result: PdcaCycleRecord['result']; shouldContinue: boolean; }; /** * Generate PDCA Summary Report after loop termination. * AC-D05.8: Summarizes all cycles with triggeredBy, newTasks, result. * AC-D05.9: Suitable for Ledger evidence chain (FR-10). */ generateSummaryReport(pipeline: PipelineInstance): PdcaSummaryReport; /** * Get the configured maximum cycles. * AC-D05.7: Configurable via sevo.config.json maxPdcaCycles. */ getMaxCycles(): number; /** * Start a new PDCA cycle. * AC-D05.1: Creates PdcaCycleRecord. * AC-D05.2: Records triggeredBy and newTasks. * AC-D05.3: Emits pdca-cycle-started event. * AC-D05.4: Appends to pipeline.pdcaCycles. */ private startCycle; /** Output cycle info to CLI for single-agent mode (AC-D05.10). */ private outputCycleToCli; } //# sourceMappingURL=pdca-auto-driver.d.ts.map