/**
 * BatchModeGovernor -- Amortised governance gate for high-volume classification.
 *
 * A classification agent processing 1,000 documents per cycle pays governance
 * overhead 1,000 times under per-call gating.  Batch mode amortises that cost:
 * gate ONCE per batch with composite metadata, then process all items.
 *
 * Opt-in semantics:
 *   - Operator must explicitly configure allowed tool names (no wildcards).
 *   - Pack binding is mandatory on every call -- empty binding throws.
 *   - Strict packs (HIPAA, GDPR, PCI DSS, HMDA, DORA) allow low-risk only.
 *   - Non-strict packs allow low-risk and medium-risk.
 *   - High-risk batches ALWAYS throw regardless of pack -- no escape hatch.
 *   - Batch size ceiling is 1,000 items (governance-overhead amortisation
 *     breakeven); operators may configure lower but not higher.
 *
 * Compliance bindings:
 *   - SOC 2 CC6.1: access control -- operator-explicit allowlist
 *   - HIPAA 164.312(a)(1): minimum-necessary; low-risk only under strict pack
 *   - GDPR Art. 5(1)(c): data minimisation; risk-profiled gating
 *   - PCI DSS Req 7: restrict access by business need
 *   - EU AI Act Art. 9: risk management; risk-profile declaration required
 *   - ISO 42001 A.6.1.4: resource management for AI systems
 *
 * BUILD_PLAN_V3_FULL_LIFECYCLE.md line 275: "Batch-mode governance for
 * high-volume classification (reduced per-call overhead)".
 *
 * Related siblings:
 *   - PR #14: tool-rate-limiter (per-call gate, consulted atomically per batch)
 *   - PR #12/#30: cycle-token-budget (batch reports Sigma tokens once)
 *   - PR #26: post-tool-audit-enrichment (redaction patterns mirrored here)
 *   - PR #33: skip-api-empty-queue (operator-supplied adapter pattern)
 *
 * @connexum/ai-governance
 */
export declare class BatchModeNotAllowedError extends Error {
    readonly agentId: string;
    readonly reason: string;
    readonly packBinding: string[];
    constructor(opts: {
        agentId: string;
        reason: string;
        packBinding: string[];
    });
}
export declare class BatchSizeExceededError extends Error {
    readonly agentId: string;
    readonly requested: number;
    readonly limit: number;
    readonly packBinding: string[];
    constructor(opts: {
        agentId: string;
        requested: number;
        limit: number;
        packBinding: string[];
    });
}
export declare class ToolNotInBatchAllowlistError extends Error {
    readonly agentId: string;
    readonly toolName: string;
    readonly allowedToolNames: string[];
    readonly packBinding: string[];
    constructor(opts: {
        agentId: string;
        toolName: string;
        allowedToolNames: string[];
        packBinding: string[];
    });
}
export declare class BatchModeRestrictedByPackError extends Error {
    readonly agentId: string;
    readonly riskProfile: string;
    readonly restrictingPacks: string[];
    constructor(opts: {
        agentId: string;
        riskProfile: string;
        restrictingPacks: string[];
    });
}
export declare class BatchHighRiskForbiddenError extends Error {
    readonly agentId: string;
    readonly packBinding: string[];
    constructor(opts: {
        agentId: string;
        packBinding: string[];
    });
}
export declare class BatchHeterogeneousRiskError extends Error {
    readonly agentId: string;
    readonly batchRiskProfile: string;
    readonly itemIndex: number;
    constructor(opts: {
        agentId: string;
        batchRiskProfile: string;
        itemIndex: number;
    });
}
export declare class EmptyPackBindingError extends Error {
    readonly agentId: string;
    constructor(agentId: string);
}
export declare class BatchNotConfiguredError extends Error {
    readonly agentId: string;
    constructor(agentId: string);
}
export declare class BatchIdNotFoundError extends Error {
    readonly batchId: string;
    readonly agentId: string;
    constructor(opts: {
        batchId: string;
        agentId: string;
    });
}
export declare class BatchToolNameDivergedError extends Error {
    readonly agentId: string;
    readonly batchId: string;
    readonly declaredToolName: string;
    readonly divergedItemIndex: number;
    readonly actualToolName: string;
    constructor(opts: {
        agentId: string;
        batchId: string;
        declaredToolName: string;
        divergedItemIndex: number;
        actualToolName: string;
    });
}
export declare class WildcardToolNameError extends Error {
    readonly agentId: string;
    constructor(agentId: string);
}
/** Hard ceiling for batch size. Operators may configure lower but not higher. */
export declare const MAX_BATCH_SIZE_CEILING = 1000;
/**
 * Threshold above which a LARGE_LOW_RISK_BATCH_DECLARED audit marker is
 * emitted (PT-BATCH-3 compensating control).
 */
export declare const LARGE_BATCH_AUDIT_THRESHOLD = 500;
/**
 * Pack IDs considered strict for batch-mode purposes.
 * Strict packs: low-risk only. Medium-risk batches are refused.
 */
export declare const STRICT_PACK_IDS: ReadonlySet<string>;
export type BatchRiskProfile = 'low' | 'medium' | 'high';
/** A single item in a classification batch. Must NOT carry item content. */
export interface BatchItem {
    /**
     * Opaque item identifier (hash or surrogate key -- never raw content).
     * Used only for correlation, never logged raw.
     */
    itemId: string;
    /**
     * PT-BATCH-1 guard: items MUST NOT carry a per-item riskProfile override.
     * This field's presence triggers BatchHeterogeneousRiskError.
     */
    riskProfile?: never;
}
/** A result for a single classification item. */
export interface BatchItemResult {
    /** Must match an itemId from the original batch. */
    itemId: string;
    /** Classification outcome (e.g. 'spam', 'ham', 'benign', 'malicious'). */
    classification: string;
    /** Whether this item was processed successfully. */
    success: boolean;
    /** Error code if success is false. No raw error message content in audit. */
    errorCode?: string;
    /**
     * PT-BATCH-2 guard: the actual tool used to process this item.
     * Must match the batch-level toolName or BatchToolNameDivergedError is thrown.
     */
    toolName?: string;
    /**
     * Tokens consumed for this item (for budget aggregation).
     * Optional -- if absent, batch-level token totals are not calculated.
     */
    tokensConsumed?: number;
}
/** Batch envelope passed to guardPreBatch. */
export interface BatchEnvelope {
    /** Tool name for all items. Must be in the configured allowlist. */
    toolName: string;
    /** The items to classify. No raw content allowed in this array. */
    items: BatchItem[];
    /** Uniform risk profile for the entire batch. Per-item overrides are rejected. */
    riskProfile: BatchRiskProfile;
}
/** Return value from guardPreBatch when the batch passes. */
export interface BatchGuardResult {
    allowed: true;
    batchId: string;
}
/** Return value from getBatchStats. */
export interface BatchStats {
    batchesToday: number;
    itemsToday: number;
    avgBatchSize: number;
    lastBatchAt: string | null;
}
/** Operator configuration for a single (orgId, agentId) scope. */
export interface BatchModeConfig {
    maxBatchSize: number;
    allowedToolNames: string[];
    packBinding: string[];
    configuredBy: string;
    configuredAt: string;
}
export type BatchAuditEventType = 'governance:batch-processed' | 'governance:batch-incomplete-at-cycle-end' | 'governance:batch-tool-name-diverged' | 'governance:large-low-risk-batch-declared';
export type BatchAuditSeverity = 'NOTICE' | 'WARNING' | 'ERROR';
export interface BatchAuditEvent {
    type: BatchAuditEventType;
    severity: BatchAuditSeverity;
    orgId: string;
    agentId: string;
    cycleId: string;
    batchId: string;
    toolName: string;
    itemCount: number;
    riskProfile: BatchRiskProfile;
    /** Only present on governance:batch-processed events. */
    successCount?: number;
    errorCount?: number;
    classificationDistribution?: Record<string, number>;
    durationMs?: number;
    packBinding: string[];
    timestamp: string;
    prevSha: string;
}
/** Minimal interface for the ToolRateLimiter (PR #14 sibling). */
export interface RateLimiterAdapter {
    /** Record a single invocation against the sliding window. */
    hook(agentId: string, toolName: string, activePackIds: string[]): void;
}
/** Minimal interface for the CycleTokenBudgetEnforcer (PR #12/#30 sibling). */
export interface TokenBudgetAdapter {
    /** Report token usage against the cycle budget. */
    recordUsage(agentId: string, cycleId: string, tokensUsed: number, activePackIds: string[]): void;
}
export declare class BatchModeGovernor {
    /** key: `${orgId}::${agentId}` -> BatchModeConfig */
    private readonly configs;
    /** key: batchId -> ActiveBatch (cleared on recordBatchResult) */
    private readonly activeBatches;
    /** key: `${orgId}::${agentId}` -> DailyStats */
    private readonly dailyStats;
    /**
     * SHA-256 chain: the hash of the last emitted audit event per
     * `${orgId}::${agentId}`. Initialised to the zero hash.
     */
    private readonly auditChain;
    private rateLimiter;
    private tokenBudget;
    /** Callback for emitting audit events. Caller routes to AuditLogger / EventBus. */
    private onAuditEvent;
    /**
     * Wire the PR #14 rate limiter.
     * The batch governor calls hook() N times atomically before releasing items.
     */
    setRateLimiter(adapter: RateLimiterAdapter): void;
    /**
     * Wire the PR #12/#30 token budget enforcer.
     * After recordBatchResult the governor reports Sigma tokens once.
     */
    setTokenBudget(adapter: TokenBudgetAdapter): void;
    /**
     * Register the audit event callback.
     * The callback receives fully-formed BatchAuditEvent objects with
     * prev-SHA chained. The caller routes them to the audit log.
     */
    setAuditCallback(callback: (event: BatchAuditEvent) => void): void;
    /**
     * Operator-only configuration.
     *
     * @param orgId            Organisation / tenant identifier.
     * @param agentId          Agent being configured.
     * @param opts.maxBatchSize Ceiling: operator may set 1..(MAX_BATCH_SIZE_CEILING).
     * @param opts.allowedToolNames  Explicit tool names. Wildcards rejected.
     * @param opts.packBinding  Mandatory pack binding for this configuration.
     * @param approverIdentity  OperatorRoles.checkPermission result -- caller must
     *                          verify 'governance.configure' before calling this.
     */
    configure(orgId: string, agentId: string, opts: {
        maxBatchSize: number;
        allowedToolNames: string[];
        packBinding: string[];
    }, approverIdentity: string): void;
    /**
     * Pre-batch gate. Validates the batch envelope in one roundtrip.
     *
     * On success: calls the rate limiter N times atomically and returns a
     * { allowed: true, batchId } token the caller passes to recordBatchResult.
     *
     * On failure: throws one of the typed BatchMode errors.
     */
    guardPreBatch(orgId: string, agentId: string, cycleId: string, batch: BatchEnvelope, packBinding: string[]): BatchGuardResult;
    /**
     * Post-batch gate. Emits one enriched audit event covering the batch.
     *
     * No raw item content enters the audit payload. Only aggregate statistics
     * (count, success, error, classification distribution) are captured.
     *
     * @param batchId   Token returned by guardPreBatch.
     * @param results   Per-item results (no raw content).
     * @param packBinding Mandatory. Should match what was passed to guardPreBatch.
     */
    recordBatchResult(orgId: string, agentId: string, cycleId: string, batchId: string, results: BatchItemResult[], packBinding: string[]): void;
    /**
     * Called when a cycle ends (e.g. cycle-timeout fires).
     * Any batches still open on the cycle are abandoned and an
     * INCOMPLETE_BATCH_AT_CYCLE_END event severity ERROR is emitted per batch.
     */
    abandonCycleBatches(orgId: string, agentId: string, cycleId: string): void;
    /**
     * Returns daily statistics for an (orgId, agentId) scope.
     * Statistics reset at midnight UTC each day.
     */
    getBatchStats(orgId: string, agentId: string): BatchStats;
    private configKey;
    private todayKey;
    private updateDailyStats;
    /**
     * Emit an audit event with prev-SHA chaining.
     * The chain is keyed per (orgId, agentId) -- one chain per agent.
     * Item content is NEVER included in any audit payload.
     */
    private emitAuditEvent;
    /**
     * Expose the current chain hash for a given (orgId, agentId).
     * Useful for tests and audit-integrity verification.
     */
    getChainHash(orgId: string, agentId: string): string;
    /**
     * Check whether a given (orgId, agentId) scope has been configured.
     */
    isConfigured(orgId: string, agentId: string): boolean;
}
//# sourceMappingURL=batch-mode-governance.d.ts.map