/**
 * GovernanceConfig -- Unified configuration for all governance modules.
 *
 * Loads configuration from (in precedence order):
 *   1. Constructor overrides (highest)
 *   2. Environment variables (GOVERNANCE_* prefix)
 *   3. .governance.json file (lowest)
 *
 * All modules accept GovernanceConfig instead of individual config objects.
 *
 * SECURITY (SYSTEMIC-H3, fail-open pattern audit 2026-04-21):
 *   - If `.governance.json` is missing, we return defaults (legitimate
 *     first-boot scenario).
 *   - If `.governance.json` EXISTS but is malformed / truncated /
 *     tampered, we THROW and refuse to proceed. A silent `{}` fallback
 *     on parse failure would let an attacker who can corrupt the file
 *     disable audit logging or expand capability bundles silently.
 *   - Operators can temporarily bypass with FORCE_EMPTY_GOVERNANCE_CONFIG=true
 *     (env) or --force-empty-config (CLI). When set, the override is
 *     AUDIT-LOGGED via `consumeForceEmptyOverride()` which returns a
 *     structured event the caller MUST push through
 *     `storage.appendAuditChain`.
 *
 * @connexum/ai-governance
 */
/**
 * Record of a FORCE_EMPTY_GOVERNANCE_CONFIG override.
 *
 * Returned by `GovernanceConfig.consumeForceEmptyOverride()` so the
 * boot path / server wiring can push it to the audit chain.
 */
export interface ForceEmptyConfigOverride {
    type: 'governance-config-force-empty';
    configPath: string;
    parseError: string;
    source: 'env' | 'cli';
    timestamp: string;
}
export interface GovernanceConfigOptions {
    /** Root directory for governance data (default: .governance/) */
    rootDir?: string;
    /** Directory for audit logs */
    logDir?: string;
    /** Directory for agent permissions */
    permissionsDir?: string;
    /** Directory for session state */
    stateDir?: string;
    /** Directory for memory files */
    memoryDir?: string;
    /** Directory for queue storage */
    queueDir?: string;
    /** Path to governance rules file */
    governanceFile?: string;
    /** Directory containing agent identity files */
    agentsDir?: string;
    /** Enable tamper detection (default: true) */
    tamperDetection?: boolean;
    /** Encryption passphrase (from env: GOVERNANCE_ENCRYPTION_KEY) */
    encryptionKey?: string;
    /** Agent auth secret seed (from env: GOVERNANCE_SECRET_SEED) */
    secretSeed?: string;
    /** Cycle timeout in ms (default: 300000) */
    cycleTimeoutMs?: number;
    /** Signature window in ms (default: 300000) */
    signatureWindowMs?: number;
    /** Log level (default: 'INFO') */
    logLevel?: string;
    /**
     * Plugin integrity configuration (PLUGIN-INTEGRITY-01).
     * Controls load-time SHA-256 verification for governance plugins.
     */
    pluginIntegrity?: {
        /**
         * Path to the trusted-plugin lockfile.
         * Default: `.governance/plugins.lock.json`
         */
        manifestPath?: string;
        /**
         * Disable load-time integrity checking. Default: `false` (fail-closed).
         * When true, an audit event `plugin:integrity-disabled` is emitted on
         * every plugin load so auditors can see the bypass on the chain.
         */
        disableIntegrity?: boolean;
    };
    /**
     * ASI-08 Cascading Failures — CircuitBreaker configuration.
     *
     * When present and enabled:true, the PreToolUse enforcement path calls
     * CircuitBreaker.allowExecution(agentId) before dispatching any tool call.
     * An OPEN breaker returns a structured DENY verdict and emits an audit event
     * (tagged ASI-08). Infrastructure errors in the breaker are handled
     * advisory-fail-open (Invariant 3): they never throw and never hard-block.
     *
     * The circuit-breaker check is per-agent: one agent's OPEN state does NOT
     * affect other agents.
     *
     * When absent or enabled:false, no circuit-breaker check is performed and
     * the existing PreToolUse chain is unchanged (backwards compatible).
     */
    circuitBreaker?: {
        /** Enable ASI-08 circuit-breaker enforcement in the PreToolUse path. Default: false. */
        enabled?: boolean;
        /**
         * Directory for persisting per-agent circuit-breaker state files.
         * Default: `${rootDir}/state/circuit-breakers`
         */
        stateDir?: string;
        /** Consecutive failures before the breaker opens. Default: 3. */
        failureThreshold?: number;
        /** Milliseconds before a tripped breaker attempts HALF_OPEN. Default: 600000 (10 min). */
        halfOpenAfterMs?: number;
    };
    /**
     * Memory governance configuration (P3-T1 Group 2).
     * Controls session-scoped memory, cross-session pseudonymisation,
     * memory-state audit chain verification, and retrieval source allowlisting.
     * All modules default to enabled with conservative settings.
     */
    memory?: {
        /** Session-scoped memory settings. */
        session?: {
            /** Enable session-scoped memory (default: true). */
            enabled?: boolean;
            /** Idle timeout in ms before session memory is cleared (default: 900000 = 15 min). */
            maxIdleMs?: number;
            /** Absolute max session duration in ms (default: 3600000 = 60 min). */
            maxSessionMs?: number;
            /**
             * Clear memory when a regulated pack exits (e.g. end of HIPAA block).
             * Default: false unless a bound pack sets requiresSessionMemoryIsolation.
             */
            clearOnRegulatedPackExit?: boolean;
        };
        /** Cross-session memory pseudonymisation settings. */
        crossSession?: {
            /** Enable cross-session memory (default: true). */
            enabled?: boolean;
            /**
             * Pseudonymisation pepper. Must be >= 32 chars.
             * Derives from GOVERNANCE_MEMORY_PEPPER env var if not set.
             * Default: random per-boot (not suitable for cross-restart reverse-lookup).
             */
            pepper?: string;
        };
        /** Memory-state audit chain settings. */
        chain?: {
            /** Enable hash-chain verification (default: true). */
            enabled?: boolean;
        };
        /** Retrieval source allowlisting settings. */
        retrievalAllowlist?: {
            /** Enable retrieval allowlisting (default: true). */
            enabled?: boolean;
            /**
             * Default policy when no allowlist entry matches.
             * 'deny' = fail-closed (default).
             * 'allow-with-audit' = log and allow.
             */
            defaultPolicy?: 'deny' | 'allow-with-audit';
        };
    };
}
export declare class GovernanceConfig {
    private static instance;
    /**
     * Pending FORCE_EMPTY override event. Populated during construction when
     * the operator bypasses a malformed config. The server boot path should
     * call `consumeForceEmptyOverride()` right after building the config so
     * the bypass is written to the audit chain.
     */
    private static pendingForceEmptyOverride;
    /**
     * One-time boot log guard so we do not spam the console when multiple
     * GovernanceConfig instances are created in the same process (tests,
     * CLI sub-commands).
     */
    private static bootLoggedMissingFile;
    private config;
    constructor(overrides?: GovernanceConfigOptions);
    /**
     * Get the singleton instance. Creates with defaults if not initialized.
     */
    static getInstance(overrides?: GovernanceConfigOptions): GovernanceConfig;
    /**
     * Reset the singleton (for testing).
     */
    static reset(): void;
    /**
     * If the operator used FORCE_EMPTY_GOVERNANCE_CONFIG / --force-empty-config
     * to bypass a malformed config, this returns the structured override event.
     * The server boot path MUST push this through `storage.appendAuditChain`
     * so the bypass is recorded in the tamper-evident audit chain.
     *
     * Returns null if no override was used. The value is consumed (cleared)
     * on first call so it cannot be double-logged.
     */
    static consumeForceEmptyOverride(): ForceEmptyConfigOverride | null;
    /**
     * Get the full resolved configuration.
     */
    getAll(): Required<GovernanceConfigOptions>;
    /**
     * Get a specific config value.
     */
    get<K extends keyof GovernanceConfigOptions>(key: K): Required<GovernanceConfigOptions>[K];
    /**
     * Ensure all required directories exist.
     */
    ensureDirectories(): void;
    /**
     * Export current config to .governance.json.
     */
    exportToFile(outputPath?: string): void;
    private loadConfigFile;
    /**
     * Handle a config file that exists but cannot be used.
     *
     * Policy:
     *   - Default: throw. Server refuses to boot with unverified config.
     *   - If FORCE_EMPTY_GOVERNANCE_CONFIG=true (env) OR the CLI flag
     *     --force-empty-config is active (set via the same env var by the
     *     CLI shim): log loudly, stash an audit-chain event for the caller
     *     to emit, and return `{}`.
     */
    private handleConfigFailure;
    private loadEnvConfig;
    private resolve;
}
//# sourceMappingURL=governance-config.d.ts.map