/**
 * Inference Governance Integration Types
 *
 * Type definitions for the chrono-warp-drive Dynamo governance endpoint integration.
 * Provides external governance checking for inference-driven proposals.
 *
 * @version 1.0.0
 * @since 2026-05-11
 */
/**
 * Default governance configuration
 */
export const DEFAULT_GOVERNANCE_CONFIG = {
    enabled: false,
    endpointUrl: 'https://mcp-production-80e2.up.railway.app/governance',
    requestTimeoutMs: 10000,
    minConfidenceThreshold: 0.5,
    decisionLogic: {
        passConfidenceMin: 0.9,
        revisionConfidenceMax: 0.89,
        voteWeightMultiplier: 1.0,
    },
};
// ============================================================================
// Error Types
// ============================================================================
/**
 * Governance error codes
 */
export var GovernanceErrorCode;
(function (GovernanceErrorCode) {
    GovernanceErrorCode["REQUEST_FAILED"] = "REQUEST_FAILED";
    GovernanceErrorCode["TIMEOUT"] = "TIMEOUT";
    GovernanceErrorCode["INVALID_RESPONSE"] = "INVALID_RESPONSE";
    GovernanceErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
    GovernanceErrorCode["CONFIG_INVALID"] = "CONFIG_INVALID";
    GovernanceErrorCode["NOT_INITIALIZED"] = "NOT_INITIALIZED";
})(GovernanceErrorCode || (GovernanceErrorCode = {}));
/**
 * Base governance error
 */
export class GovernanceError extends Error {
    code;
    recoverable;
    context;
    constructor(message, code, recoverable, context) {
        super(message);
        this.code = code;
        this.recoverable = recoverable;
        this.context = context;
        this.name = 'GovernanceError';
        Error.captureStackTrace(this, this.constructor);
    }
}
/**
 * Request timeout error
 */
export class GovernanceTimeoutError extends GovernanceError {
    constructor(timeoutMs) {
        super(`Governance request timed out after ${timeoutMs}ms`, GovernanceErrorCode.TIMEOUT, true, { timeoutMs });
        this.name = 'GovernanceTimeoutError';
    }
}
/**
 * Network error
 */
export class GovernanceNetworkError extends GovernanceError {
    constructor(url, originalError) {
        super(`Network error calling governance endpoint: ${originalError.message}`, GovernanceErrorCode.NETWORK_ERROR, true, { url, originalError: originalError.message });
        this.name = 'GovernanceNetworkError';
    }
}
// ============================================================================
// Utility Types
// ============================================================================
/**
 * Type guard for valid governance response
 */
export function isValidGovernanceResponse(response) {
    if (typeof response !== 'object' || response === null)
        return false;
    const r = response;
    return (typeof r.success === 'boolean' &&
        typeof r.proposalId === 'string' &&
        typeof r.governanceIsotopeId === 'string' &&
        typeof r.recommendation === 'string' &&
        ['PASS', 'NEEDS_REVISION', 'REJECT'].includes(r.recommendation) &&
        typeof r.confidence === 'number' &&
        typeof r.voteWeight === 'number');
}
/**
 * Type guard for governance error
 */
export function isGovernanceError(error) {
    return (error instanceof GovernanceError ||
        (error instanceof Error && error.name === 'GovernanceError'));
}
