/** * ProactiveDriveEngine — orchestrates the proactive drive layer (Domain D). * * Integrates FR-D01 (auto gate trigger), FR-D02 (spec gap detection), * and FR-D03 (post-release auto scan) with the PipelineEngineFacade. * * Hooks into stage transitions via the event bus (EventLedger) and * emits drive-layer events for the host adapter to consume. * * (spec §Domain D, arc42 §5.1) */ import type { StageId, ArtifactRef, PdcaCycleRecord } from '../types/index.js'; import type { GateEngine } from '../gate/gate-engine.js'; import type { EventLedger } from '../pipeline-engine/ledger.js'; import type { PostReleaseValidationInput } from '../stages/post-release-validation-types.js'; import { StageTransitionTrigger } from './stage-transition-trigger.js'; import type { AutoTriggerResult } from './stage-transition-trigger.js'; import { SpecGapDetector } from './spec-gap-detector.js'; import type { FrReference, ImplementationModule } from './spec-gap-detector.js'; import type { AutoGapScanResult } from './post-release-auto-scanner.js'; import type { ProactiveDriveConfig, GateAutoTriggeredEvent, SpecGapDetectedEvent, PostReleaseGapFoundEvent, PostReleasePassedEvent, BackEdgeTriggeredEvent, DriveEventType, SpecGapReport } from './types.js'; /** Listener callback for drive events. */ export type DriveEventListener = (eventType: DriveEventType, payload: GateAutoTriggeredEvent | SpecGapDetectedEvent | PostReleaseGapFoundEvent | PostReleasePassedEvent | BackEdgeTriggeredEvent) => void; /** Result of processing a stage completion through the drive layer. */ export interface DriveProcessResult { /** Whether the drive layer blocked the transition (FR-D01 gate rejected). */ blocked: boolean; /** Events emitted during processing. */ emittedEvents: Array<{ type: DriveEventType; payload: unknown; }>; /** Gate auto-trigger result if applicable. */ gateResult?: AutoTriggerResult; /** Spec gap report if applicable. */ specGapReport?: SpecGapReport; /** Post-release scan result if applicable. */ postReleaseScanResult?: AutoGapScanResult; } /** * ProactiveDriveEngine — the main integration point for Domain D. * * Usage: * const drive = new ProactiveDriveEngine(gateEngine, ledger, config); * drive.onEvent((type, payload) => { ... }); * * // Called by PipelineEngineFacade when a stage completes: * const result = drive.onStageCompleted(pipelineId, fromStage, toStage, artifacts); * if (result.blocked) { // gate rejected, don't advance } */ export declare class ProactiveDriveEngine { private readonly transitionTrigger; private readonly specGapDetector; private readonly postReleaseScanner; private readonly ledger; private readonly config; private readonly listeners; /** Per-pipeline PDCA cycle tracking. */ private readonly pipelineCycles; /** Per-pipeline PDCA cycle records (AC-D03.7). */ private readonly pdcaCycleRecords; constructor(gateEngine: GateEngine, ledger: EventLedger, config?: Partial); /** * Register a listener for drive events. * Host adapters use this to convert events into actionable instructions. */ onEvent(listener: DriveEventListener): void; /** * Process a stage completion through the drive layer. * * Called by PipelineEngineFacade when a stage transitions from active → passed. * Evaluates all applicable drive behaviors (FR-D01, FR-D02, FR-D03). * * @param pipelineId - The pipeline instance ID. * @param completedStage - The stage that just completed. * @param nextStage - The stage that would be activated next. * @param artifacts - Artifacts from the completed stage. * @param context - Additional context for spec gap detection and post-release scan. */ onStageCompleted(pipelineId: string, completedStage: StageId, nextStage: StageId | null, artifacts: ArtifactRef[], context?: DriveContext): DriveProcessResult; /** * Get PDCA cycle records for a pipeline (AC-D03.7). */ getPdcaCycleRecords(pipelineId: string): readonly PdcaCycleRecord[]; /** * Get current cycle number for a pipeline. */ getCurrentCycle(pipelineId: string): number; /** * Get the back-edge stage queue (AC-D03.6). */ getBackEdgeStageQueue(): readonly string[]; /** * Access the underlying SpecGapDetector for pre-checks (AC-D02.4). */ getSpecGapDetector(): SpecGapDetector; /** * Access the underlying StageTransitionTrigger. */ getTransitionTrigger(): StageTransitionTrigger; /** * FR-D01: Process gate auto-trigger at a transition point. */ private processGateAutoTrigger; /** * FR-D02: Process spec gap detection at implement completion. */ private processSpecGapDetection; /** * FR-D03: Process post-release auto scan at verify completion. */ private processPostReleaseScan; /** * Emit an event to all registered listeners. * AC-D01.7: If no listeners, event is a no-op (degraded to no output). */ private emit; } /** Additional context for drive layer processing. */ export interface DriveContext { /** FR references for spec gap detection (FR-D02). */ frReferences?: FrReference[]; /** Implementation modules for spec gap detection (FR-D02). */ implementationModules?: ImplementationModule[]; /** Post-release validation input (FR-D03). */ postReleaseInput?: PostReleaseValidationInput; } //# sourceMappingURL=proactive-drive-engine.d.ts.map