/**
 * PolicyTuningEngine: False positive reduction system for governance decisions.
 *
 * Tracks override patterns, computes confidence scores, generates tuning
 * reports, and suggests policy relaxations. Critical for channel partner
 * adoption: partners need to streamline what passes through to reduce
 * false positives for their clients.
 *
 * @module governance/policy-tuning
 */
export interface PolicyTuningConfig {
    /** Minimum overrides before a suggestion is generated */
    suggestionThreshold: number;
    /** Time window for computing rates (ms) */
    windowMs: number;
    /** Maximum override records to keep in memory */
    maxRecords: number;
    /** Enable shadow mode: log what WOULD be blocked without enforcing */
    shadowMode: boolean;
}
export interface OverrideFeedback {
    /** Unique ID for this feedback */
    id: string;
    /** The audit ID of the governance decision being overridden */
    auditId: string;
    /** The organization that submitted the feedback */
    orgId: string;
    /** The partner org (if feedback came through a partner) */
    partnerOrgId?: string;
    /** Tool that was blocked */
    tool: string;
    /** Agent that was blocked */
    agentName: string;
    /** Policy rule that triggered the block */
    policyRule: string;
    /** Why the user considers this a false positive */
    reason: string;
    /** Who submitted the override */
    submittedBy: string;
    /** When the override was submitted */
    timestamp: string;
}
export interface ConfidenceScore {
    /** Overall confidence in the decision (0.0 = likely false positive, 1.0 = certain) */
    score: number;
    /** Factors that contributed to the score */
    factors: ConfidenceFactor[];
}
export interface ConfidenceFactor {
    name: string;
    weight: number;
    value: number;
    description: string;
}
export interface TuningReport {
    /** Report period start */
    periodStart: string;
    /** Report period end */
    periodEnd: string;
    /** Organization ID */
    orgId: string;
    /** Total decisions in period */
    totalDecisions: number;
    /** Total overrides (false positives reported) */
    totalOverrides: number;
    /** Overall false positive rate */
    falsePositiveRate: number;
    /** Top false positives by tool */
    topByTool: TuningEntry[];
    /** Top false positives by agent */
    topByAgent: TuningEntry[];
    /** Top false positives by policy rule */
    topByPolicy: TuningEntry[];
    /** Suggested policy relaxations */
    suggestions: PolicySuggestion[];
}
export interface TuningEntry {
    key: string;
    overrideCount: number;
    totalDecisions: number;
    rate: number;
}
export interface PolicySuggestion {
    id: string;
    policyRule: string;
    tool: string;
    currentAction: 'DENY' | 'REQUIRE_APPROVAL';
    suggestedAction: 'ALLOW' | 'REQUIRE_APPROVAL' | 'SHADOW';
    overrideCount: number;
    confidence: number;
    rationale: string;
}
export interface ShadowDecision {
    /** What the decision would have been */
    wouldBlock: boolean;
    /** The policy rule that would have triggered */
    policyRule: string;
    /** Tool name */
    tool: string;
    /** Agent name */
    agentName: string;
    /** Timestamp */
    timestamp: string;
}
export interface DecisionRecord {
    auditId: string;
    orgId: string;
    tool: string;
    agentName: string;
    policyRule: string;
    decision: 'ALLOW' | 'DENY' | 'REQUIRE_APPROVAL';
    timestamp: string;
    overridden: boolean;
}
export declare class PolicyTuningEngine {
    private config;
    private decisions;
    private overrides;
    private shadowLog;
    constructor(config?: Partial<PolicyTuningConfig>);
    /**
     * Record a governance decision for tracking.
     */
    recordDecision(record: Omit<DecisionRecord, 'overridden'>): void;
    /**
     * Record a shadow mode decision (what WOULD have been blocked).
     */
    recordShadowDecision(shadow: ShadowDecision): void;
    /**
     * Submit override feedback (false positive report).
     */
    submitOverride(feedback: Omit<OverrideFeedback, 'id' | 'timestamp'>): OverrideFeedback;
    /**
     * Compute confidence score for a governance decision.
     *
     * Lower confidence = more likely to be a false positive based on
     * historical override patterns.
     */
    computeConfidence(tool: string, agentName: string, policyRule: string, orgId: string): ConfidenceScore;
    /**
     * Generate a tuning report for an organization.
     */
    generateReport(orgId: string, periodMs?: number): TuningReport;
    /**
     * Generate partner-level aggregate report across all client orgs.
     */
    generatePartnerReport(partnerOrgId: string, clientOrgIds: string[], periodMs?: number): {
        partnerOrgId: string;
        clientReports: TuningReport[];
        aggregateFalsePositiveRate: number;
        topSuggestionsAcrossClients: PolicySuggestion[];
    };
    /**
     * Get shadow mode log entries.
     */
    getShadowLog(orgId?: string): ShadowDecision[];
    /**
     * Check if shadow mode is enabled.
     */
    isShadowMode(): boolean;
    /**
     * Get all overrides for an org.
     */
    getOverrides(orgId: string): OverrideFeedback[];
    /**
     * Get decision count for an org.
     */
    getDecisionCount(orgId: string): number;
    /**
     * P1C-03: per-policy-rule confidence summary for the UI.
     *
     * Returns one row per distinct policyRule observed in the window:
     *   - decisions fired under this rule
     *   - how many were overridden by the operator
     *   - confidence score (higher = fewer overrides, policy trusted)
     *   - most-recent timestamp so the UI can sort "freshest first"
     */
    getRuleConfidences(orgId: string, windowMs?: number): Array<{
        policyRule: string;
        totalDecisions: number;
        overrides: number;
        overrideRate: number;
        confidence: number;
        lastSeenAt: string | null;
    }>;
    private aggregateBy;
    private generateSuggestions;
    private trimRecords;
}
//# sourceMappingURL=policy-tuning.d.ts.map