/**
 * LPO 2024 AI Disclosure Pack
 *
 * PLACEHOLDER STATUS. Pack is not yet authoritative. 3 jurisdictions bundled;
 * per-jurisdiction obligations require Vera + counsel sign-off before status
 * promotion to ACTIVE.
 *
 * OPERATOR_VERIFICATION_REQUIRED: Before activating this pack in any
 * production deployment, confirm with Vera (Legal, CXNI-008) and qualified
 * counsel that the correct jurisdiction's rules apply:
 *   1. HK Law Society Practice Direction P (2024): Applies to solicitors
 *      practising in Hong Kong. Obligations: AI disclosure to clients, data
 *      confidentiality gates, practitioner supervision, citation verification.
 *      Verify: Practice Direction P, ss. 3-7.
 *   2. SRA Code of Conduct (UK): Applies to solicitors and firms regulated
 *      by the Solicitors Regulation Authority. Obligations: competence (Rule
 *      3.3), client disclosure, confidentiality (Rule 6.3). Verify: SRA 2024
 *      AI Guidance + Statement of Principle on AI and Technology Competence.
 *   3. Law Society of England & Wales AI Resource Hub (2024): Best-practice
 *      obligations for E&W solicitors. Verify: Technology and the Law Report
 *      2024 obligations checklist before citing as binding.
 *
 * F-NEW-VERA-PACK-FINAL-004 (2026-05-03): TODO replaced with structured
 * OPERATOR_VERIFICATION_REQUIRED notice per Vera closeout probe.
 *
 * This pack draws from multiple current sources:
 *   (a) The Legal Practitioners Ordinance (Cap. 159, Hong Kong) as
 *       supplemented by the Law Society of Hong Kong Practice Direction
 *       P on Use of Generative AI (issued 2024).
 *   (b) The Solicitors Regulation Authority (SRA, UK) Statement of
 *       Principle on AI and Technology Competence (2024).
 *   (c) The Law Society of England & Wales Technology and the Law
 *       Report 2024: Obligations for AI-Assisted Legal Work.
 *
 * This pack COMPLEMENTS aba.ts (US MRPC framework). Activate both for
 * firms with US + HK/UK practices.
 *
 * Core AI-disclosure obligations synthesised:
 *   1. Competence: Practitioners must understand material limitations of
 *      AI tools used in client work (equivalent to MRPC 1.1 covered in
 *      aba.ts -- HK/UK analogue).
 *   2. Disclosure to client: Client must be informed if AI is used in
 *      a material way in their matter.
 *   3. Confidentiality: Client data must not be input into AI tools
 *      without appropriate data processing agreements.
 *   4. Supervision: AI output must be reviewed by a qualified
 *      practitioner before use in client work.
 *   5. Accuracy: AI-generated citations, statutes, and case references
 *      must be independently verified.
 *   6. Billing: AI processing time may not be billed at standard rate
 *      without disclosure.
 *
 * This pack COMPLEMENTS aba.ts (US MRPC framework). Activate both for
 * firms with US + HK/UK practices.
 *
 * @connexum/ai-governance
 */
/**
 * LPO 2024 (Hong Kong Law Society AI Practice Direction) category classifiers.
 * Governs AI use in Hong Kong legal practice. Mirrors ABA privilege/work-product
 * obligations with HKLS-specific requirements (Practice Direction P 2024).
 */
export const LPO2024_CATEGORY_CLASSIFIERS = {
    PRIVILEGED: {
        references: ['HKLS Practice Direction P §4 -- professional confidentiality; legal advice privilege (HK common law)'],
        classifier: (input) => {
            if (/\b(?:legal\s+professional\s+privilege|LPP|client\s+confidential|privileged\s+communication)\b/i.test(input))
                return true;
            if (/\b(?:attorney.?client\s+privilege|solicitor.?client\s+privilege|legal\s+advice\s+privilege)\b/i.test(input))
                return true;
            return false;
        },
    },
    CLIENT_CONFIDENTIAL: {
        references: ['HKLS Practice Direction P §5 -- client confidential information'],
        classifier: (input) => {
            if (/\b(?:client\s+confidential|client\s+(?:data|information|file|record))\b/i.test(input))
                return true;
            if (/\b(?:matter\s+(?:file|record)|client\s+matter)\b/i.test(input))
                return true;
            return false;
        },
    },
    PII: {
        references: ['HKLS Practice Direction P + PDPO (Cap. 486) -- personal data of HK clients'],
        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;
            if (/\b(?:HKID|Hong\s+Kong\s+ID)[:\s#]*[A-Z]{1,2}\d{6}\([0-9A]\)/i.test(input))
                return true;
            return false;
        },
    },
    CREDENTIALS: {
        references: ['HKLS Practice Direction P §6 -- security of AI systems in legal practice'],
        classifier: (input) => {
            if (/\b(?:api[_-]?key|apikey)\s*[=:]\s*["']?[A-Za-z0-9_\-\/+]{16,}["']?/i.test(input))
                return true;
            if (/\bpassword\s*[=:]\s*["']?[A-Za-z0-9!@#$%^&*_\-]{8,}["']?/i.test(input))
                return true;
            if (/\bAKIA[A-Z0-9]{16}\b/.test(input))
                return true;
            if (/-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----/.test(input))
                return true;
            return false;
        },
    },
};
export const LPO2024_PACK = {
    categoryClassifiers: LPO2024_CATEGORY_CLASSIFIERS,
    /** P3.5: Privileged and client-confidential data are subject-keyed (each privilege holder is a specific individual or entity). */
    subjectKeyedCategories: ['PRIVILEGED', 'CLIENT_CONFIDENTIAL'],
    id: 'lpo2024',
    name: 'LPO 2024 AI Disclosure (Legal Practitioners)',
    version: '1.0.0',
    contentHash: '95b2b77fcb21e48551d296d3a43ebeb77ee894fcb668def11aa574323214da53',
    description: 'Synthesised AI disclosure framework for legal practitioners in common-law jurisdictions (primary reference: Hong Kong Law Society Practice Direction P 2024 + SRA UK 2024 AI Guidance). Covers client disclosure of AI use, practitioner competence obligations, confidentiality of client data in AI tools, supervised review of AI output, citation verification, and billing transparency. PLACEHOLDER STATUS -- pack bundles 3 jurisdictions (HK Law Society PD-P, SRA UK, Law Society E&W); Vera + counsel sign-off required per jurisdiction before production activation.',
    authority: 'Law Society of Hong Kong (Practice Direction P, 2024); SRA (UK, 2024 AI Guidance); Law Society of England & Wales',
    industries: ['legal', 'law-firm', 'in-house-legal', 'legal-ops', 'legal-tech'],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Competence enforcement; supervision gate for AI output before client delivery; billing transparency controls',
            reference: 'HKLS Practice Direction P, Section 3 (competence); SRA Principle 4 (acting with integrity)',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident record of AI use per matter; evidence for professional conduct proceedings if challenged',
            reference: 'HKLS Practice Direction P, Section 7 (record keeping); SRA Code of Conduct',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Detect PRIVILEGED and CLIENT_CONFIDENTIAL data; enforce no-input policy unless DPA/DPA equivalent in place',
            reference: 'HKLS Practice Direction P, Section 5 (confidentiality); LPO Cap. 159 s. 37B',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'Per-matter isolation; client consent for AI use on file; jurisdiction-scope tracking',
            reference: 'HKLS Practice Direction P, Section 4 (client consent); SRA Standard for AI use in legal services',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'Qualified practitioner review gate before AI output is delivered to client or filed; cite-check gate',
            reference: 'HKLS Practice Direction P, Section 3 (supervision); SRA 2024 AI Guidance (human review)',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'Supervising practitioner on file per matter; client consent on file; AI vendor DPA on file',
            reference: 'HKLS Practice Direction P, Sections 3-5; SRA Technology and Law Practice Framework',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'Client-facing disclosure that AI was used; billing transparency for AI-generated work',
            reference: 'HKLS Practice Direction P, Section 4 (disclosure to client); SRA Transparency Rules',
        },
        {
            name: 'supply-chain',
            required: true,
            reason: 'AI vendor due diligence; data processing agreement (DPA) before client data input; no-retention verification',
            reference: 'HKLS Practice Direction P, Section 5 (use of third-party AI providers); PDPO Cap. 486 (HK data protection)',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Confidentiality incident alerts; citation-error detection events; billing anomaly events',
            reference: 'HKLS Practice Direction P, Section 6 (incident response); SRA Reporting Obligations',
        },
    ],
    moduleConfig: {
        'data-classifier': {
            enabledCategories: [
                'PRIVILEGED',
                'CLIENT_CONFIDENTIAL',
                'PII',
                'CREDENTIALS',
            ],
            privilegedAction: 'BLOCK_UNLESS_CONSENTED',
            clientConfidentialAction: 'BLOCK_UNLESS_DPA_IN_PLACE',
        },
        'session-persistence': {
            perMatterIsolationRequired: true,
            clientConsentForAiRequired: true,
            jurisdictionScopeTrackingRequired: true,
        },
        'approval-queue': {
            practitionerReviewBeforeDeliveryRequired: true,
            citeCheckRequired: true,
        },
        'attestation-manager': {
            supervisingPractitionerRequiredPerMatter: true,
            clientConsentOnFileRequired: true,
            aiVendorDpaOnFileRequired: true,
        },
        'transparency-injector': {
            aiUseClientDisclosureRequired: true,
            billingTransparencyRequired: true,
        },
        'supply-chain': {
            vendorDpaRequired: true,
            vendorZeroRetentionRequired: true,
        },
        'governance-runtime': {
            competenceGateRequired: true,
            supervisionGateRequired: true,
        },
    },
    providerPolicy: {
        blockedProviders: [],
        requiredCapabilities: ['ZERO-RETENTION', 'DATA-PROCESSING-AGREEMENT'],
        blockReasons: {},
    },
    dataPolicy: {
        scanCategories: ['PRIVILEGED', 'CLIENT_CONFIDENTIAL', 'PII', 'CREDENTIALS'],
        categoryActions: {
            PRIVILEGED: 'BLOCK',
            CLIENT_CONFIDENTIAL: 'BLOCK',
            PII: 'WARN',
            CREDENTIALS: 'BLOCK',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256',
        minimumClassification: 'CONFIDENTIAL',
    },
    retentionPolicy: {
        sovereignty: ['UK'],
        // HKLS Practice Direction P: records of AI use on matter file for
        // at least the duration of the limitation period (typically 6 years in HK).
        auditLogRetentionDays: 2190,
        sessionRetentionDays: 2190,
        incidentRetentionDays: 2190,
        reference: 'HKLS Practice Direction P, Section 7 (record keeping); HK Limitation Ordinance Cap. 347 (6-year default)',
    },
    incidentPolicy: {
        // HKLS requires prompt notification to client of confidentiality breach; SRA: report to regulator within 24h for serious breach.
        notificationDeadlineHours: 24,
        reference: 'HKLS Practice Direction P, Section 6 (incident response); SRA Reporting Obligations (prompt notification)',
        requiredRecipients: ['affected-client', 'supervising-partner', 'managing-partner'],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'lpo2024-client-disclosure',
            description: 'Client informed of AI use in their matter before or promptly after AI is engaged',
            reference: 'HKLS Practice Direction P, Section 4; SRA Transparency Rules',
            check: 'lpo2024_client_disclosure_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'lpo2024-practitioner-supervision',
            description: 'Qualified practitioner review gate active before AI output delivered to client or filed',
            reference: 'HKLS Practice Direction P, Section 3; SRA 2024 AI Guidance',
            check: 'lpo2024_supervision_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'lpo2024-confidentiality-gate',
            description: 'Privileged and client-confidential data blocked from AI tools without DPA in place',
            reference: 'HKLS Practice Direction P, Section 5; PDPO Cap. 486',
            check: 'lpo2024_confidentiality_gate_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'lpo2024-vendor-dpa',
            description: 'Data Processing Agreement on file for every AI vendor before client data input',
            reference: 'HKLS Practice Direction P, Section 5; PDPO Cap. 486',
            check: 'lpo2024_vendor_dpa_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'lpo2024-cite-check',
            description: 'Citation verification gate active for AI-generated legal references',
            reference: 'HKLS Practice Direction P, Section 3; SRA Competence requirements',
            check: 'lpo2024_cite_check_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'lpo2024-billing-transparency',
            description: 'AI processing time billing disclosed and reviewed for reasonableness',
            reference: 'HKLS Practice Direction P, Section 8 (fees); SRA Code of Conduct for Solicitors',
            check: 'lpo2024_billing_transparency_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'lpo2024-audit-trail',
            description: 'Tamper-evident audit trail of AI use per matter maintained',
            reference: 'HKLS Practice Direction P, Section 7',
            check: 'audit_trail_exists',
            failSeverity: 'HIGH',
        },
        {
            id: 'lpo2024-per-matter-isolation',
            description: 'Per-matter isolation active; client data does not cross matter boundaries',
            reference: 'HKLS Practice Direction P, Section 5; LPO Cap. 159',
            check: 'lpo2024_per_matter_isolation_active',
            failSeverity: 'CRITICAL',
        },
    ],
};
//# sourceMappingURL=lpo2024.js.map