/**
 * Semantic Governance Integration - Intent Pipeline Integration
 *
 * Provides seamless integration of semantic governance validation into the
 * intent evaluation pipeline. This service acts as a bridge between the
 * semantic governance validators and the intent processing system.
 *
 * Features:
 * - Pre-action semantic validation during intent evaluation
 * - Post-action output validation
 * - Semantic signals for trust engine integration
 * - Credential management per agent/tenant
 * - Metrics and observability
 *
 * @packageDocumentation
 * @module @vorion/semantic-governance/integration
 */
import { Registry } from 'prom-client';
import { TrustTier, InferenceLevel, type SemanticGovernanceCredential, type PreActionResult, type PostActionResult, type DomainCode, type InferenceOperation, type InjectionScanResult } from './types.js';
/**
 * Semantic signal emitted during validation for trust engine integration
 */
export interface SemanticSignal {
    /** Signal type identifier */
    type: string;
    /** Signal value (positive for good, negative for bad) */
    value: number;
    /** Signal weight (0-1) */
    weight: number;
    /** Signal severity level */
    severity: 'low' | 'medium' | 'high' | 'critical';
    /** Source of the signal */
    source: string;
    /** Additional metadata */
    metadata?: Record<string, unknown>;
}
/**
 * Result of semantic validation during intent evaluation
 */
export interface IntentSemanticValidationResult {
    /** Whether the validation passed */
    valid: boolean;
    /** Overall reason for failure */
    reason?: string;
    /** Pre-action validation result */
    preAction?: PreActionResult;
    /** Post-action validation result */
    postAction?: PostActionResult;
    /** Semantic signals for trust engine */
    signals: SemanticSignal[];
    /** Validation duration in milliseconds */
    durationMs: number;
    /** Warnings (validation passed but with concerns) */
    warnings?: string[];
}
/**
 * Configuration for semantic governance integration
 */
export interface SemanticGovernanceIntegrationConfig {
    /** Whether to enable semantic validation in the pipeline */
    enabled: boolean;
    /** Default trust tier for unknown agents */
    defaultTrustTier: TrustTier;
    /** Default inference level limit */
    defaultInferenceLevel: InferenceLevel;
    /** Whether to block on semantic validation failure */
    blockOnFailure: boolean;
    /** Whether to emit trust signals on validation events */
    emitTrustSignals: boolean;
    /** Control plane sources for dual-channel enforcement */
    controlPlaneSources?: string[];
    /** How to treat data plane content */
    dataPlaneTreatment?: 'block' | 'sanitize' | 'warn';
}
/**
 * Default integration configuration
 */
export declare const DEFAULT_INTEGRATION_CONFIG: SemanticGovernanceIntegrationConfig;
/**
 * Context for semantic validation during intent evaluation
 */
export interface IntentValidationContext {
    /** Intent ID */
    intentId: string;
    /** Tenant ID */
    tenantId: string;
    /** Entity ID (agent DID) */
    entityId: string;
    /** Intent type */
    intentType?: string;
    /** Intent goal */
    goal: string;
    /** Intent context data */
    context?: Record<string, unknown>;
    /** Trust score */
    trustScore?: number;
    /** Trust level */
    trustLevel?: number;
    /** System instruction (if any) */
    instruction?: string;
    /** Message source */
    messageSource?: string;
    /** Whether message is authenticated */
    authenticated?: boolean;
    /** External context sources */
    contextSources?: Array<{
        providerId: string;
        content: unknown;
        signature?: string;
        timestamp?: Date;
    }>;
    /** Requested inference operations */
    inferenceOperations?: InferenceOperation[];
}
/**
 * Context for post-action validation
 */
export interface OutputValidationContext extends IntentValidationContext {
    /** Action output */
    output: unknown;
    /** External endpoints accessed */
    externalEndpoints?: string[];
    /** Derived knowledge produced */
    derivedKnowledge?: Array<{
        id: string;
        type: string;
        content: unknown;
        sourceDomains: DomainCode[];
    }>;
}
/**
 * Semantic Governance Integration Service
 *
 * Provides integration between semantic governance validators and the intent
 * evaluation pipeline. Manages credentials, performs validation, and emits
 * trust signals.
 */
export declare class SemanticGovernanceIntegration {
    private readonly config;
    private readonly credentialManager;
    private readonly governanceService;
    private readonly instructionValidator;
    private readonly outputValidator;
    private readonly inferenceValidator;
    private readonly contextValidator;
    private readonly dualChannelEnforcer;
    private readonly agentCredentialCache;
    /**
     * Create a new SemanticGovernanceIntegration
     *
     * @param config - Integration configuration
     */
    constructor(config?: Partial<SemanticGovernanceIntegrationConfig>);
    /**
     * Validate an intent during the evaluation phase
     *
     * This is called during the intent evaluation worker to perform semantic
     * validation before the action is executed.
     *
     * @param context - Intent validation context
     * @returns Semantic validation result with signals
     */
    validateIntent(context: IntentValidationContext): Promise<IntentSemanticValidationResult>;
    /**
     * Validate action output during post-action phase
     *
     * @param context - Output validation context
     * @returns Semantic validation result with signals
     */
    validateOutput(context: OutputValidationContext): Promise<IntentSemanticValidationResult>;
    /**
     * Scan content for injection patterns without full validation
     *
     * @param content - Content to scan
     * @returns Injection scan result
     */
    scanForInjection(content: string): InjectionScanResult;
    /**
     * Classify a message channel (control vs data plane)
     *
     * @param source - Message source
     * @param authenticated - Whether message is authenticated
     * @returns Channel classification
     */
    classifyChannel(source: string, authenticated: boolean): 'control' | 'data';
    /**
     * Create or update a credential for an agent
     *
     * @param agentId - Agent identifier (DID)
     * @param tenantId - Tenant identifier
     * @param config - Optional credential configuration
     * @returns Created/updated credential
     */
    registerAgent(agentId: string, tenantId: string, config?: {
        carId?: string;
        allowedInstructionHashes?: string[];
        inferenceLevel?: InferenceLevel;
        piiAllowed?: boolean;
    }): Promise<SemanticGovernanceCredential>;
    /**
     * Ensure a credential exists for an agent, creating one if needed
     */
    private ensureCredential;
    /**
     * Map trust level (0-5) to TrustTier enum
     */
    private mapTrustLevel;
    /**
     * Infer domain codes from intent type
     */
    private inferDomains;
    /**
     * Determine severity based on validation result
     */
    private determineSeverity;
    /**
     * Get the metrics registry
     */
    getMetricsRegistry(): Registry;
    /**
     * Clear credential cache
     */
    clearCache(): void;
    /**
     * Check if semantic governance is enabled
     */
    isEnabled(): boolean;
    /**
     * Get current configuration
     */
    getConfig(): SemanticGovernanceIntegrationConfig;
}
/**
 * Create a SemanticGovernanceIntegration with default configuration
 */
export declare function createSemanticGovernanceIntegration(config?: Partial<SemanticGovernanceIntegrationConfig>): SemanticGovernanceIntegration;
/**
 * Get the singleton integration instance
 */
export declare function getSemanticGovernanceIntegration(): SemanticGovernanceIntegration;
/**
 * Reset the singleton instance (for testing)
 */
export declare function resetSemanticGovernanceIntegration(): void;
/**
 * Get integration metrics as Prometheus text format
 */
export declare function getIntegrationMetrics(): Promise<string>;
/**
 * Get integration metrics content type
 */
export declare function getIntegrationMetricsContentType(): string;
//# sourceMappingURL=integration.d.ts.map