/**
 * Operation Verification Gate System for CLEO
 *
 * Implements 4-layer validation gate system for dispatch operations:
 * Layer 1: Schema Validation (JSON Schema compliance)
 * Layer 2: Semantic Validation (Business rules)
 * Layer 3: Referential Validation (Cross-entity integrity)
 * Layer 4: Protocol Validation (RCASD-IVTR+C lifecycle)
 *
 * Moved to core for proper layering (formerly in dispatch).
 *
 * @task T2936
 * @task T5707
 * @epic T2908
 */
import { type ProtocolType } from '../compliance/protocol-enforcement.js';
import { ErrorCategory, ErrorSeverity, ProtocolExitCode } from '../compliance/protocol-types.js';
/**
 * Gate layer enumeration
 */
export declare enum GateLayer {
    SCHEMA = 1,
    SEMANTIC = 2,
    REFERENTIAL = 3,
    PROTOCOL = 4
}
/**
 * Gate status for each layer
 */
export declare enum GateStatus {
    PENDING = "pending",
    PASSED = "passed",
    FAILED = "failed",
    BLOCKED = "blocked",
    SKIPPED = "skipped"
}
/**
 * Violation detail for a specific gate layer
 */
export interface GateViolation {
    layer: GateLayer;
    severity: ErrorSeverity;
    code: string;
    message: string;
    field?: string;
    value?: unknown;
    constraint?: string;
    fix?: string;
}
/**
 * Result from a single gate layer validation
 */
export interface LayerResult {
    layer: GateLayer;
    status: GateStatus;
    passed: boolean;
    violations: GateViolation[];
    duration_ms: number;
}
/**
 * Complete verification result across all 4 layers
 */
export interface VerificationResult {
    passed: boolean;
    layers: Record<GateLayer, LayerResult>;
    totalViolations: number;
    exitCode: ProtocolExitCode;
    category: ErrorCategory;
    summary: string;
    blockedAt?: GateLayer;
}
/**
 * Operation context for gate validation
 */
export interface OperationContext {
    domain: string;
    operation: string;
    gateway: 'query' | 'mutate';
    params?: Record<string, unknown>;
    taskId?: string;
    protocolType?: ProtocolType;
}
/**
 * Main Verification Gate class
 *
 * Orchestrates 4-layer validation and determines pass/fail status.
 * Each layer must pass before proceeding to the next.
 */
export declare class VerificationGate {
    private protocolEnforcer;
    private strictMode;
    constructor(strictMode?: boolean);
    /**
     * Execute all 4 gate layers sequentially
     *
     * Stops at first failure unless in advisory mode.
     */
    verifyOperation(context: OperationContext): Promise<VerificationResult>;
    /**
     * Run a single validation layer with timing
     */
    private runLayer;
    /**
     * Build success result when all gates pass
     */
    private buildSuccessResult;
    /**
     * Build failure result when a gate fails
     */
    private buildFailureResult;
    /**
     * Determine semantic layer exit code from violations
     */
    private determineSemanticExitCode;
    /**
     * Determine referential layer exit code from violations
     */
    private determineReferentialExitCode;
    /**
     * Determine protocol layer exit code from violations
     */
    private determineProtocolExitCode;
    /**
     * Check if an operation requires gate validation
     *
     * All mutate operations require validation.
     * Query operations skip validation for performance.
     */
    static requiresValidation(context: OperationContext): boolean;
    /**
     * Get human-readable layer name
     */
    static getLayerName(layer: GateLayer): string;
}
/**
 * Factory function for creating verification gates
 */
export declare function createVerificationGate(strictMode?: boolean): VerificationGate;
/**
 * Export gate layer sequence for external use
 */
export declare const GATE_SEQUENCE: readonly [GateLayer.SCHEMA, GateLayer.SEMANTIC, GateLayer.REFERENTIAL, GateLayer.PROTOCOL];
/**
 * Workflow gate names per protocol specification Section 7.1
 *
 * @task T3141
 */
export declare enum WorkflowGateName {
    IMPLEMENTED = "implemented",
    TESTS_PASSED = "testsPassed",
    QA_PASSED = "qaPassed",
    CLEANUP_DONE = "cleanupDone",
    SECURITY_PASSED = "securityPassed",
    DOCUMENTED = "documented"
}
/**
 * Workflow gate status values per Section 7.3
 */
export type WorkflowGateStatus = null | 'passed' | 'failed' | 'blocked';
/**
 * Agent responsible for each gate per Section 7.2
 */
export type WorkflowGateAgent = 'coder' | 'testing' | 'qa' | 'cleanup' | 'security' | 'docs';
/**
 * Individual workflow gate definition per Section 7.2
 */
export interface WorkflowGateDefinition {
    name: WorkflowGateName;
    agent: WorkflowGateAgent;
    dependsOn: WorkflowGateName[];
    description: string;
}
/**
 * State of a single workflow gate
 */
export interface WorkflowGateState {
    name: WorkflowGateName;
    status: WorkflowGateStatus;
    agent: WorkflowGateAgent;
    updatedAt: string | null;
    failureReason?: string;
}
/**
 * Complete workflow gate definitions per Section 7.2
 */
export declare const WORKFLOW_GATE_DEFINITIONS: WorkflowGateDefinition[];
/**
 * Ordered workflow gate sequence per Section 7.1
 */
export declare const WORKFLOW_GATE_SEQUENCE: WorkflowGateName[];
/**
 * WorkflowGateTracker
 *
 * Tracks the status of all 6 workflow verification gates for a task.
 * Implements Section 7.4 failure cascade behavior: when a gate fails,
 * all downstream gates reset to null.
 *
 * @task T3141
 */
export declare class WorkflowGateTracker {
    private gates;
    constructor();
    /**
     * Get the status of a specific gate
     */
    getGateStatus(gateName: WorkflowGateName): WorkflowGateStatus;
    /**
     * Get the full state of a specific gate
     */
    getGateState(gateName: WorkflowGateName): WorkflowGateState | undefined;
    /**
     * Get all gate states
     */
    getAllGates(): WorkflowGateState[];
    /**
     * Check if a gate can be attempted (all dependencies passed)
     */
    canAttempt(gateName: WorkflowGateName): boolean;
    /**
     * Mark a gate as passed.
     */
    passGate(gateName: WorkflowGateName, agent?: string): boolean;
    /**
     * Mark a gate as failed.
     *
     * Per Section 7.4: When a gate fails, all downstream gates reset to null.
     */
    failGate(gateName: WorkflowGateName, reason?: string): boolean;
    /**
     * Reset a gate and all downstream gates to null.
     */
    private cascadeReset;
    /**
     * Update blocked status for all gates based on current state.
     */
    updateBlockedStatus(): void;
    /**
     * Check if all gates have passed
     */
    allPassed(): boolean;
    /**
     * Get all gates that are currently blocked or have null status
     */
    getPendingGates(): WorkflowGateState[];
    /**
     * Get the next gate that can be attempted
     */
    getNextAttemptable(): WorkflowGateName | null;
    /**
     * Get downstream gates of a given gate (not including the gate itself)
     */
    getDownstreamGates(gateName: WorkflowGateName): WorkflowGateName[];
    /**
     * Serialize gate states to a plain record
     */
    toRecord(): Record<string, WorkflowGateStatus>;
    /**
     * Restore gate states from a record
     */
    fromRecord(record: Record<string, WorkflowGateStatus>): void;
    /**
     * Check if a gate name is valid
     */
    private isValidGate;
}
/**
 * Validate a workflow gate name string
 */
export declare function isValidWorkflowGateName(name: string): name is WorkflowGateName;
/**
 * Get the definition for a workflow gate
 */
export declare function getWorkflowGateDefinition(name: WorkflowGateName): WorkflowGateDefinition | undefined;
//# sourceMappingURL=operation-verification-gates.d.ts.map