"use strict";
/**
 * FRCP Rule 26 Compliance Pack
 *
 * Federal Rules of Civil Procedure Rule 26 governs required disclosures
 * and the scope of discovery in US federal civil litigation. The 2015
 * amendments introduced proportionality as the governing standard for
 * discovery scope (Rule 26(b)(1)) and added the duty to preserve
 * electronically stored information (ESI) with corresponding sanctions
 * under Rule 37(e) for spoliation.
 *
 * AI systems in legal departments and law firms are increasingly
 * involved in:
 *   (a) e-discovery review and document classification
 *   (b) generation of ESI that itself becomes discoverable
 *   (c) automated legal hold and preservation workflows
 *   (d) expert system opinion generation (Rule 26(a)(2))
 *
 * Key FRCP 26 obligations for AI:
 *   - Rule 26(a)(1): Initial disclosures must cover all AI-generated
 *     documents or data that are responsive. AI systems creating
 *     evidence must be within the scope of initial disclosures.
 *   - Rule 26(b)(1): Proportionality standard. AI must not over-collect
 *     (burden/expense) or under-collect (relevance). Defensible
 *     collection methodology required.
 *   - Rule 26(b)(3): Work product doctrine. AI-generated legal strategy
 *     outputs may be protected; classification required.
 *   - Rule 26(f): Meet-and-confer obligation. Parties must discuss ESI
 *     preservation and format. AI system capabilities and output formats
 *     are subject to Rule 26(f) discussion.
 *   - Rule 26(a)(2): Expert disclosures. AI-generated expert opinions
 *     require disclosure of the basis and reasoning.
 *   - Rule 37(e): Failure to preserve ESI. Sanctions for AI systems
 *     that auto-delete discoverable information.
 *
 * Companion rules: FRCP 34 (production format), FRCP 37 (sanctions),
 * FRCP 11 (signing / certification -- integrates with ABA pack's
 * hallucinated-citation risk).
 *
 * @connexum/ai-governance
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.FRCP26_PACK = exports.FRCP26_CATEGORY_CLASSIFIERS = void 0;
/**
 * FRCP Rule 26 (Federal Rules of Civil Procedure -- Discovery) category classifiers.
 * Governs eDiscovery: privilege protection, work-product doctrine, ESI (responsive documents).
 * This pack governs process flows (litigation hold, claw-back, privilege log).
 */
exports.FRCP26_CATEGORY_CLASSIFIERS = {
    PRIVILEGED: {
        references: ['Fed. R. Evid. 502 -- attorney-client privilege; FRCP 26(b)(3)(A) work-product'],
        classifier: (input) => {
            if (/\b(?:attorney.?client\s+privilege|privileged\s+(?:communication|document)|legal\s+advice)\b/i.test(input))
                return true;
            if (/\b(?:confidential\s+(?:legal|attorney|client)|privileged\s+(?:and\s+)?confidential)\b/i.test(input))
                return true;
            return false;
        },
    },
    ATTORNEY_WORK_PRODUCT: {
        references: ['FRCP 26(b)(3) -- work-product protection; mental impressions and strategies'],
        classifier: (input) => {
            if (/\b(?:attorney\s+work\s+product|work\s+product|trial\s+preparation\s+(?:material|document))\b/i.test(input))
                return true;
            if (/\b(?:litigation\s+strategy|case\s+assessment|mental\s+impressions)\b/i.test(input))
                return true;
            return false;
        },
    },
    RESPONSIVE_ESI: {
        references: ['FRCP 26(b)(1) -- scope of discovery; responsive electronically stored information'],
        classifier: (input) => {
            if (/\b(?:responsive\s+(?:document|ESI|record)|discovery\s+(?:response|production|request)|litigation\s+hold)\b/i.test(input))
                return true;
            if (/\b(?:Bates\s+(?:number|stamp)|production\s+set|custodian\s+data)\b/i.test(input))
                return true;
            return false;
        },
    },
    PII: {
        references: ['FRCP 5.2 -- privacy protection; redaction of personal identifiers in court filings'],
        classifier: (input) => {
            if (/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/.test(input))
                return true;
            if (/\b\d{3}-\d{2}-\d{4}\b/.test(input))
                return true;
            return false;
        },
    },
};
exports.FRCP26_PACK = {
    categoryClassifiers: exports.FRCP26_CATEGORY_CLASSIFIERS,
    id: 'frcp26',
    /**
     * GAP-S1-01: site/packs.html public codes for this pack.
     * LG-03 = Privilege + Work Product (FRCP 26(b)(3) / Fed R Evid 502)
     * LG-04 = E-Discovery FRCP 26/34
     * Both map to this pack, which covers the full Rule 26 e-discovery framework
     * including privilege preservation and work-product protection.
     */
    aliases: ['LG-03', 'LG-04'],
    name: 'FRCP Rule 26 (E-Discovery)',
    version: '1.0.0',
    description: 'Federal Rules of Civil Procedure Rule 26 compliance for AI systems involved in US federal civil discovery. Covers proportionality (Rule 26(b)(1) 2015 amendment), ESI preservation and legal hold (Rule 37(e)), initial disclosures (Rule 26(a)(1)), work-product protection (Rule 26(b)(3)), expert disclosure (Rule 26(a)(2)), and meet-and-confer obligations (Rule 26(f)).',
    authority: 'US Federal Judiciary (Judicial Conference of the United States)',
    industries: ['legal', 'law-firm', 'legal-ops', 'in-house-legal', 'legal-tech', 'ediscovery'],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Proportionality enforcement on collection scope; legal hold workflow; auto-deletion suspension',
            reference: 'FRCP 26(b)(1) (proportionality); FRCP 37(e) (preservation duty)',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident audit trail of all AI document decisions for defensible discovery; chain-of-custody evidence',
            reference: 'FRCP 37(e) (need for evidence of preservation steps); FRCP 26(a)(1) (initial disclosure of AI decisions)',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Classify ESI as PRIVILEGED, WORK_PRODUCT, RESPONSIVE, or NON-RESPONSIVE; privilege screen before production',
            reference: 'FRCP 26(b)(3) (work product); FRCP 26(b)(5) (claiming privilege)',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'Per-matter ESI preservation state; legal hold notification tracking; meet-and-confer record',
            reference: 'FRCP 26(f) (meet-and-confer); FRCP 37(e) (preservation trigger tracking)',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'Human attorney review gate before production of AI-reviewed documents; expert disclosure approval',
            reference: 'FRCP 26(a)(1)(A)(ii) (disclosure supervised by attorney); FRCP 26(a)(2) (expert disclosure)',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'Defensible collection methodology documentation; legal hold certification; AI process attestation for meet-and-confer',
            reference: 'FRCP 26(g) (certification of discovery responses); FRCP 26(f) (ESI protocol)',
        },
        {
            name: 'supply-chain',
            required: true,
            reason: 'E-discovery vendor due diligence; chain-of-custody controls for third-party AI processing',
            reference: 'FRCP 26(b)(1); FRCP 34(b) (production format specifications)',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Litigation hold trigger events; auto-deletion suspension events; privilege-clawback notification stream',
            reference: 'FRCP 37(e) (preservation duty triggered by litigation reasonably anticipated); FRCP 26(b)(5)(B) (clawback)',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'Disclosure of AI involvement in document review; methodology transparency for meet-and-confer',
            reference: 'FRCP 26(f)(3)(C) (ESI form of production); FRCP 26(a)(2)(B) (expert methodology disclosure)',
        },
    ],
    moduleConfig: {
        'data-classifier': {
            enabledCategories: [
                'PRIVILEGED',
                'ATTORNEY_WORK_PRODUCT',
                'RESPONSIVE_ESI',
                'NON_RESPONSIVE_ESI',
                'PII',
            ],
            privilegedAction: 'BLOCK_UNLESS_CONSENTED',
            workProductAction: 'BLOCK_UNLESS_CONSENTED',
        },
        'session-persistence': {
            perMatterIsolationRequired: true,
            legalHoldNotificationTrackingRequired: true,
            meetAndConferRecordRequired: true,
            autoDeleteSuspensionRequired: true,
        },
        'governance-runtime': {
            proportionalityEnforced: true,
            legalHoldWorkflowRequired: true,
            autoDeleteSuspensionRequired: true,
        },
        'approval-queue': {
            preProductionAttorneyReviewRequired: true,
            expertDisclosureApprovalRequired: true,
        },
        'attestation-manager': {
            defensibleCollectionMethodologyRequired: true,
            legalHoldCertificationRequired: true,
        },
        'transparency-injector': {
            aiReviewMethodologyDisclosureRequired: true,
        },
    },
    providerPolicy: {
        blockedProviders: [],
        requiredCapabilities: ['CHAIN-OF-CUSTODY', 'AUDIT-TRAIL'],
        blockReasons: {},
    },
    dataPolicy: {
        scanCategories: [
            'PRIVILEGED',
            'ATTORNEY_WORK_PRODUCT',
            'RESPONSIVE_ESI',
            'PII',
        ],
        categoryActions: {
            PRIVILEGED: 'BLOCK',
            ATTORNEY_WORK_PRODUCT: 'BLOCK',
            RESPONSIVE_ESI: 'LOG',
            PII: 'WARN',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256',
        minimumClassification: 'CONFIDENTIAL',
    },
    retentionPolicy: {
        sovereignty: ['US'],
        // Rule 37(e) requires preservation once litigation is "reasonably anticipated".
        // No specific statutory period; typical litigation hold spans the case + appeals.
        // Pax1 default: 7 years audit log aligned with ABA pack.
        auditLogRetentionDays: 2555,
        sessionRetentionDays: 2555,
        incidentRetentionDays: 2555,
        reference: 'FRCP 37(e) (preserve when litigation reasonably anticipated); FRCP 26(a)(1) -- no hard expiry; 7-year Pax1 default',
    },
    incidentPolicy: {
        // Inadvertent production of privileged documents triggers FRCP 26(b)(5)(B):
        // notify promptly (no fixed deadline; courts interpret as "reasonably prompt").
        notificationDeadlineHours: 72,
        reference: 'FRCP 26(b)(5)(B) (prompt notification of inadvertent production); Pax1 default 72h',
        requiredRecipients: ['supervising-attorney', 'opposing-counsel', 'ethics-counsel'],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'frcp26-legal-hold',
            description: 'Legal hold workflow active; auto-deletion suspended on litigation trigger',
            reference: 'FRCP 37(e) (preservation duty)',
            check: 'frcp26_legal_hold_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'frcp26-privilege-screen',
            description: 'Privilege and work-product screen active before AI-reviewed documents are produced',
            reference: 'FRCP 26(b)(3); FRCP 26(b)(5)',
            check: 'frcp26_privilege_screen_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'frcp26-proportionality',
            description: 'Proportionality controls active on AI collection scope',
            reference: 'FRCP 26(b)(1) (2015 amendment -- proportionality standard)',
            check: 'frcp26_proportionality_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'frcp26-attorney-review-gate',
            description: 'Human attorney review gate required before production of AI-classified documents',
            reference: 'FRCP 26(a)(1)(A)(ii); FRCP 26(g) (certification)',
            check: 'frcp26_attorney_review_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'frcp26-chain-of-custody',
            description: 'Tamper-evident chain-of-custody audit trail for all AI-processed ESI',
            reference: 'FRCP 37(e) (evidence of preservation steps); authentication under FRE 901',
            check: 'audit_trail_exists',
            failSeverity: 'HIGH',
        },
        {
            id: 'frcp26-clawback-notification',
            description: 'Event bus active for privilege-clawback notification stream',
            reference: 'FRCP 26(b)(5)(B) (clawback); FRCP 26(e) (supplementation)',
            check: 'monitoring_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'frcp26-methodology-disclosure',
            description: 'AI review methodology disclosure active for meet-and-confer and expert disclosure',
            reference: 'FRCP 26(f)(3)(C); FRCP 26(a)(2)(B)',
            check: 'frcp26_methodology_disclosure_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'frcp26-defensible-collection',
            description: 'Defensible collection methodology documented and attested',
            reference: 'FRCP 26(g); Sedona Principles Third Edition',
            check: 'frcp26_defensible_collection_active',
            failSeverity: 'MEDIUM',
        },
    ],
};
//# sourceMappingURL=frcp26.js.map