/**
 * ECPA (Electronic Communications Privacy Act) Compliance Pack
 *
 * Title I: Wire and Electronic Communications Interception (Wiretap Act)
 *   18 U.S.C. §§ 2510-2523
 * Title II: Stored Wire and Electronic Communications (SCA)
 *   18 U.S.C. §§ 2701-2713
 * Title III: Pen Registers and Trap/Trace Devices
 *   18 U.S.C. §§ 3121-3127
 *
 * ECPA governs:
 *   - Interception of wire, oral, and electronic communications (Title I)
 *   - Access to stored electronic communications (Title II / SCA)
 *   - Collection of communications metadata (Title III)
 *
 * AI agent relevance (2026):
 *   - AI agents that summarise, analyse, or route email / chat / call recordings
 *     are in scope for ECPA Title II (stored comms) and potentially Title I
 *     (real-time interception) when the agent operates in-line in the
 *     communications path.
 *   - Broker-dealer agents subject to FINRA 3110 communications supervision
 *     must also satisfy ECPA Title II for stored communications review.
 *   - Cloud-hosted AI agents accessing customer email / Slack / Teams records
 *     through APIs may be SCA-covered if operating without customer consent.
 *
 * Key AI governance controls:
 *   1. Communications content is stripped of sender/recipient PII before
 *      being passed to an LLM provider (STRIP_AND_TAG on COMMS_CONTENT).
 *   2. Agent processing of real-time comms requires operator attestation
 *      that a Title I exception applies (consent, provider, or operator
 *      exception per 18 U.S.C. § 2511(2)).
 *   3. Communications metadata (to/from/timestamp/subject) is classified
 *      and stripped; it is not freely disclosable.
 *   4. Stored communications are only accessed under SCA authority --
 *      consent, lawful process, or provider/system-provider exception.
 *
 * Relationship to other packs:
 *   - FINRA 3110: broker-dealer comms supervision; ECPA applies to the
 *     underlying storage and interception layer.
 *   - HIPAA: patient communications (email, portal messages) are both
 *     PHI and ECPA-covered; both packs should be active.
 *   - GDPR: electronic communications metadata is personal data; combine
 *     GDPR + ECPA for EU-origin communications.
 *
 * @connexum/ai-governance PR-2
 */
export const ECPA_PACK = {
    id: 'ecpa',
    aliases: ['title-iii', 'wiretap-act', 'sca', 'stored-communications-act'],
    name: 'ECPA (Electronic Communications Privacy Act)',
    version: '1.0.0',
    contentHash: '0bae470e248f5db8292deb5fc61852277594c8e1bd0bff23fe300a909e6bf00b',
    description: 'Electronic Communications Privacy Act (18 U.S.C. §§ 2510-2713, 3121-3127). ' +
        'Governs interception (Title I Wiretap), access to stored communications (Title II SCA), ' +
        'and pen register / trap-trace collection (Title III). Applies to AI agents that ' +
        'process, analyse, or route electronic communications including email, chat, ' +
        'voice recordings, and call metadata.',
    authority: 'U.S. Department of Justice / Federal Courts',
    industries: [
        'financial-services', 'legal', 'healthcare', 'enterprise-comms',
        'telecom', 'cloud-services', 'government', 'law-enforcement',
    ],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Deny-by-default; requires affirmative exception for comms interception',
            reference: '18 U.S.C. § 2511(1) -- interception prohibited without exception',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident log of every communications-access event',
            reference: '18 U.S.C. § 2703 -- SCA lawful access requires documented authority',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Identify communications content and metadata before agent processing',
            reference: '18 U.S.C. § 2510(12) -- definition of electronic communication',
        },
        {
            name: 'agent-auth',
            required: true,
            reason: 'Identity of agent accessing stored communications must be auditable',
            reference: '18 U.S.C. § 2703(b) -- voluntary disclosure; SCA access authority',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'Real-time interception requires operator attestation of legal exception',
            reference: '18 U.S.C. § 2511(2)(a) -- provider exception; § 2511(2)(d) -- consent',
        },
        {
            name: 'encryption-layer',
            required: true,
            reason: 'Communications content encrypted in transit and at rest',
            reference: '18 U.S.C. § 2511(2)(a)(ii) -- provider may encrypt to protect comms',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'Access sessions to stored communications time-limited and auditable',
            reference: '18 U.S.C. § 2703(d) -- specific facts articulable standard for access',
        },
        {
            name: 'incident-notifier',
            required: true,
            reason: 'Unauthorized access to electronic communications is a federal crime',
            reference: '18 U.S.C. § 2701(a) -- unlawful access to stored communications',
        },
    ],
    moduleConfig: {
        'data-classifier': {
            enabledCategories: ['COMMS_CONTENT', 'COMMS_METADATA', 'REAL_TIME_INTERCEPT', 'PII'],
            defaultAction: 'BLOCK',
        },
        'governance-runtime': {
            denyByDefaultRequired: true,
            minimumNecessaryEnforced: true,
        },
        'agent-auth': {
            mfaRequired: false, // ECPA does not mandate MFA; HIPAA/FINRA layering adds it
            auditedAccessRequired: true,
        },
        'audit-integrity': {
            maxEntriesPerFile: 10000,
            retentionYears: 3,
        },
        'approval-queue': {
            requireAttestationForRealTimeInterception: true,
            attestationNote: '18 U.S.C. § 2511(2) -- provider, operator, or consent exception must be documented',
        },
    },
    providerPolicy: {
        blockedProviders: [], // no blanket provider block; ECPA is US-jurisdiction
        requiredCapabilities: ['data-processing-agreement'],
        blockReasons: {},
    },
    dataPolicy: {
        scanCategories: [
            'COMMS_CONTENT',
            'COMMS_METADATA',
            'REAL_TIME_INTERCEPT',
            'STORED_COMMS',
            'PII',
            'CREDENTIALS',
        ],
        categoryActions: {
            COMMS_CONTENT: 'STRIP_AND_TAG', // strip sender/recipient PII from comm content
            COMMS_METADATA: 'STRIP_AND_TAG', // to/from/timestamp/subject stripped
            REAL_TIME_INTERCEPT: 'REQUIRE_APPROVAL', // Title I -- require attestation of legal exception
            STORED_COMMS: 'WARN', // Title II SCA -- warn and log; access requires authority
            PII: 'STRIP_AND_TAG',
            CREDENTIALS: 'BLOCK',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256',
        minimumClassification: 'CONFIDENTIAL',
        /**
         * PR-2: PII Shield -- ECPA.
         *
         * STRICT mode: electronic communications content and metadata are
         * stripped and pseudonymised at the agent boundary. This prevents
         * LLM providers from receiving identifying communications metadata
         * (sender name, email, phone) that would constitute a disclosure
         * under ECPA Title II without lawful authority.
         *
         * REAL_TIME_INTERCEPT stays in REQUIRE_APPROVAL -- it cannot be
         * handled by stripping alone. Title I requires an affirmative legal
         * exception to be documented before any real-time processing occurs.
         *
         * References:
         *   18 U.S.C. § 2511(1) -- unlawful interception prohibition
         *   18 U.S.C. § 2701(a) -- unlawful access to stored communications
         *   18 U.S.C. § 2510(12) -- electronic communication definition
         */
        pii_shield: {
            pii_shield_mode: 'STRICT',
            strip_classes: ['comms', 'gdpr-contact'],
            uuid_scope: 'per_session',
            date_handling: 'relative_offset',
            age_aggregation_threshold: 89,
            ner_pre_scan: true,
            pre_send_phi_scan: true,
            auto_remediate_on_register: true,
            provider_memory_disabled_required: true,
        },
    },
    retentionPolicy: {
        sovereignty: ['US'],
        // 3-year general record retention (DOJ guidance + ECPA enforcement practice)
        auditLogRetentionDays: 1095,
        sessionRetentionDays: 1095,
        incidentRetentionDays: 1095,
        reference: '18 U.S.C. § 2703 -- government access standards; DOJ ECPA guidance: 3-year minimum audit record',
        forceDelete: false,
        requiresLegalHoldSupport: true,
    },
    incidentPolicy: {
        notificationDeadlineHours: 72, // align with GDPR / SOX standard
        reference: '18 U.S.C. § 2701(a) -- unlawful access is a federal felony; incident response within 72 hours',
        requiredRecipients: ['legal-counsel', 'security-officer', 'doj-if-required'],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'ecpa-comms-classifier',
            description: 'Communications content classifier active',
            reference: '18 U.S.C. § 2510(12)',
            check: 'data_classifier_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'ecpa-audit-trail',
            description: 'Tamper-evident audit trail for every communications-access event',
            reference: '18 U.S.C. § 2703',
            check: 'audit_trail_exists',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'ecpa-deny-by-default',
            description: 'Deny-by-default active; interception requires affirmative exception',
            reference: '18 U.S.C. § 2511(1)',
            check: 'governance_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'ecpa-encryption',
            description: 'Communications encrypted in transit and at rest',
            reference: '18 U.S.C. § 2511(2)(a)(ii)',
            check: 'encryption_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'ecpa-approval-gate',
            description: 'Real-time interception requires operator approval queue attestation',
            reference: '18 U.S.C. § 2511(2)',
            check: 'approval_queue_active',
            failSeverity: 'HIGH',
        },
    ],
    recommendedHookProfile: 'strict',
    requiresRetrievalAuditLogging: true,
    requiresCitations: false,
    requiresRagSourceAllowlist: false,
    maxAutonomyLevelWithoutAttestation: 2,
    requiresActionIsolation: 'sourced-only',
};
//# sourceMappingURL=ecpa.js.map