/**
 * UK ICO Open Case Compliance Pack
 *
 * Framework:
 *   Information Commissioner's Office (ICO) — UK supervisory authority
 *   for UK GDPR + Data Protection Act 2018. This pack covers the
 *   operational posture an organisation must adopt when subject to an
 *   open ICO investigation, audit, or enforcement action — distinct
 *   from the general UK GDPR pack which covers ongoing compliance.
 *
 *   Regulatory basis (key citations):
 *   - UK GDPR Article 17(3)(b) — exemption from the right to erasure
 *     for the establishment, exercise, or defence of legal claims
 *   - DPA 2018 Schedule 2 Part 5 — exemptions for crime, taxation, etc.
 *   - DPA 2018 Section 142 — ICO information notices
 *   - DPA 2018 Section 146 — ICO assessment notices
 *   - DPA 2018 Section 148 — destroying / falsifying information
 *     during an ICO investigation is a criminal offence
 *
 * Jurisdiction: UK-wide
 * Authority: ICO (Information Commissioner's Office)
 *
 * Why this pack:
 *   - When the ICO opens a case, the organisation must apply a legal-
 *     hold posture to all in-scope data. This OVERRIDES the GDPR Right
 *     to Erasure (Art. 17(3)(b)) for the duration of the case.
 *   - Standard retention rules are suspended on tagged data.
 *   - Cross-border transfers of tagged data require ICO case-officer
 *     sign-off in many cases.
 *   - DPA 2018 s.148 makes destroying / falsifying / concealing
 *     information during an ICO investigation a criminal offence —
 *     senior-manager personal liability.
 *
 *   This pack is the operational scaffolding that survives the case
 *   lifecycle. It is registered ALONGSIDE the `uk-gdpr` pack — both
 *   apply during an open case.
 *
 * Constitution additions captured:
 *   - `legal_hold_active: boolean` — true while the case is open
 *   - `ico_case_reference: string` — opaque ICO case reference
 *   - `case_opened_at: ISO8601` — audit-chain trigger
 *   - `case_closed_at: ISO8601 | null` — clears the hold
 *
 * Data-element rulings:
 *   - **BLOCKED**: deletion of any record carrying
 *     `pack_binding: ['UK_ICO_OPEN_CASE']`
 *   - **REVIEWED**: cross-border transfers of tagged data
 *   - **ALLOWED**: read-access by ICO case investigators with audit
 *     trail entry
 *
 * Out of scope:
 *   - General UK GDPR ongoing compliance (separate pack: `uk-gdpr`)
 *   - Pre-case ICO complaint triage (separate operational process)
 *
 * Source spec: `docs/findings/F-NEW-PACK-UK-ICO-OPEN-CASE.md`
 *
 * @connexum/ai-governance
 */
export const UK_ICO_OPEN_CASE_CATEGORY_CLASSIFIERS = {
    ICO_CASE_REFERENCE: {
        references: [
            'DPA 2018 s.142 ICO information notice; DPA 2018 s.146 assessment notice',
        ],
        classifier: (input) => {
            if (/\bico\s+(?:case|reference|notice|investigation|enforcement|audit)\s+(?:[a-z]{2,4}[-/]\d{4,8}|number\s+\w+)/i.test(input))
                return true;
            if (/\b(?:rfn|case[\s-]?ref|ico[\s-]?ref)[:\s]+[a-z0-9-]{6,32}\b/i.test(input))
                return true;
            if (/\b(?:s\.?\s*142\s+notice|s\.?\s*146\s+notice|s\.?\s*149\s+enforcement\s+notice)\b/i.test(input))
                return true;
            return false;
        },
    },
    LEGAL_HOLD_DECISION: {
        references: [
            'UK GDPR Art. 17(3)(b) — exemption from right to erasure for legal claims',
        ],
        classifier: (input) => {
            if (/\b(?:legal\s+hold|hold\s+order|preservation\s+notice|litigation\s+hold)\b/i.test(input))
                return true;
            if (/\b(?:art\.?\s*17\s*\(3\)\s*\(b\)|article\s+17\s+exemption|erasure\s+exemption)\b/i.test(input))
                return true;
            return false;
        },
    },
    ATTEMPTED_ERASURE: {
        references: [
            'DPA 2018 s.148 — criminal offence to destroy / falsify during ICO investigation',
        ],
        classifier: (input) => {
            if (/\b(?:delete\s+from|drop\s+table|truncate\s+table)\b/i.test(input))
                return true;
            if (/\b(?:erasure\s+request\s+(?:granted|attempted)|erase[d]?\s+record|sar\s+erasure)\b/i.test(input))
                return true;
            if (/\b(?:rm\s+-rf|prisma\.delete|orm\.delete|hard\s+delete)\b/i.test(input))
                return true;
            return false;
        },
    },
    CROSS_BORDER_TRANSFER: {
        references: [
            'UK GDPR Arts. 44-46 — international transfers; tagged-data approval flow',
        ],
        classifier: (input) => {
            if (/\b(?:cross[\s-]?border\s+transfer|international\s+transfer|third[\s-]?country\s+transfer)\b/i.test(input))
                return true;
            if (/\b(?:transfer\s+impact\s+assessment|tia\s+ico|scc\s+ico|adequacy\s+assessment)\b/i.test(input))
                return true;
            return false;
        },
    },
    ICO_RESPONSE: {
        references: [
            'ICO information-notice + assessment-notice response evidence',
        ],
        classifier: (input) => {
            if (/\b(?:ico\s+(?:response|disclosure|cooperation|reply)|response\s+to\s+ico)\b/i.test(input))
                return true;
            if (/\b(?:s\.?\s*150\s+penalty\s+notice|enforcement\s+notice\s+response|appeal\s+notice\s+ico)\b/i.test(input))
                return true;
            return false;
        },
    },
    CREDENTIALS: {
        references: ['Cross-pack secrets safety; ICO case artefacts must not embed credentials'],
        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 (/-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----/.test(input))
                return true;
            return false;
        },
    },
};
export const UK_ICO_OPEN_CASE_PACK = {
    categoryClassifiers: UK_ICO_OPEN_CASE_CATEGORY_CLASSIFIERS,
    id: 'uk-ico-open-case',
    aliases: [
        'uk-ico',
        'ico-open-case',
        'ico-investigation',
        'ico-legal-hold',
        'ico-enforcement',
    ],
    name: 'UK ICO Open Case (Legal-Hold Posture)',
    version: '1.0.0',
    contentHash: '08e6ceb0dea795507d83630c214332781f3021b7ac5b6bf8f05196fb6832009d',
    description: 'Operational legal-hold posture pack for organisations subject to an open ICO investigation, audit, or enforcement action. Overrides UK GDPR Right to Erasure (Art. 17(3)(b)) for tagged data; suspends standard retention; gates cross-border transfers; surfaces legal-hold status on every governance decision touching subject-keyed data. DPA 2018 s.148 criminalises destruction / falsification during an ICO investigation — pack default-denies DELETE / DROP / TRUNCATE on tagged data and routes attempts to T1 mandatory review with audit-chain capture. Registered ALONGSIDE the `uk-gdpr` pack — both apply during an open case. Pairs with Wave 2 forthcoming `caldicott-principles` (PR #406) where NHS data is in scope. Source: F-NEW-PACK-UK-ICO-OPEN-CASE finding spec.',
    authority: 'Information Commissioner\'s Office (ICO)',
    industries: ['technology', 'financial-services', 'healthcare', 'retail', 'public-sector', 'professional-services', 'media', 'education', 'charity', 'hr-employment', 'legal'],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Default-deny on DELETE / DROP / TRUNCATE / hard-delete operations against records tagged with pack_binding=UK_ICO_OPEN_CASE; legal-hold status surfaced on every decision touching subject-keyed data.',
            reference: 'UK GDPR Art. 17(3)(b); DPA 2018 s.148',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'ICO case reference recorded; case-opened / case-closed timestamps captured; senior-manager named for ICO correspondence; legal-hold scope (which packs / which datasets) attested.',
            reference: 'DPA 2018 s.142 information notice; DPA 2018 s.146 assessment notice',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'T1 mandatory review on any operation against tagged data; cross-border transfer approval; case-closure decision approval (clearing the hold).',
            reference: 'UK GDPR Art. 17(3)(b); ICO case-officer sign-off practice',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident audit chain partition under ico-case-<reference> scope; every decision touching tagged data captured; attempted-erasure events captured even when blocked; criminal-evidence-grade chain.',
            reference: 'DPA 2018 s.148 criminal-evidence retention',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Detect ICO case references, legal-hold decisions, attempted-erasure operations, cross-border transfers of tagged data, and ICO response correspondence.',
            reference: 'F-NEW-PACK-UK-ICO-OPEN-CASE classifier scope',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'UNTIL_HOLD_LIFTED retention semantics: standard retention rules suspended for tagged data; explicit case-closure event clears the hold; tagged data preserved indefinitely until then.',
            reference: 'UK GDPR Art. 17(3)(b); litigation-hold operational practice',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Attempted-erasure alerts to senior manager + DPO + legal counsel; ICO information-notice deadline tracking; case-state-change events broadcast.',
            reference: 'DPA 2018 s.148 escalation; ICO notice response deadlines',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'When responding to a Subject Access Request or erasure request on tagged data, surface the legal-hold notice with Art. 17(3)(b) citation and case reference (per ICO data-subject communication guidance).',
            reference: 'UK GDPR Arts. 12-15 + Art. 17(3)(b) exemption notice',
        },
        {
            name: 'agent-auth',
            required: true,
            reason: 'ICO case-officer access binding (read-only by default); senior-manager named-role binding for ICO correspondence; DPO + legal counsel role binding for legal-hold decisions.',
            reference: 'ICO case-officer access protocol; UK GDPR Art. 37 DPO',
        },
        {
            name: 'supply-chain',
            required: true,
            reason: 'Sub-processors notified of legal-hold scope; processor-contract flow-down of legal-hold obligations; sub-processor attempted-erasure cascade prevention.',
            reference: 'UK GDPR Art. 28 processor obligations under legal hold',
        },
    ],
    moduleConfig: {
        'governance-runtime': {
            legalHoldDefaultDenyOnDeleteRequired: true,
            legalHoldStatusSurfacedOnEveryDecisionRequired: true,
            attemptedErasureBlocked: true,
        },
        'attestation-manager': {
            icoCaseReferenceRequired: true,
            caseOpenedAtTimestampRequired: true,
            caseClosedAtTimestampOptional: true,
            seniorManagerForIcoCorrespondenceRequired: true,
            legalHoldScopeAttestationRequired: true,
        },
        'approval-queue': {
            tier1MandatoryReviewOnTaggedOperations: true,
            crossBorderTransferApprovalRequired: true,
            caseClosureApprovalRequired: true,
            reviewTier: 'T1',
            reviewerCompetence: 'ICO_CASE_HANDLER',
        },
        'audit-integrity': {
            icoCaseScopedAuditPartitionRequired: true,
            attemptedErasureCapturedEvenWhenBlocked: true,
            criminalEvidenceGradeChainRequired: true,
        },
        'data-classifier': {
            enabledCategories: [
                'ICO_CASE_REFERENCE',
                'LEGAL_HOLD_DECISION',
                'ATTEMPTED_ERASURE',
                'CROSS_BORDER_TRANSFER',
                'ICO_RESPONSE',
                'CREDENTIALS',
            ],
            attemptedErasureAction: 'BLOCK',
            credentialsAction: 'BLOCK',
        },
        'session-persistence': {
            retentionMode: 'UNTIL_HOLD_LIFTED',
            retentionDaysMinimum: 0, // overridden by the hold
            standardRetentionSuspended: true,
        },
        'event-bus': {
            attemptedErasureAlertsRequired: true,
            icoNoticeDeadlineTrackingRequired: true,
            caseStateChangeEventsRequired: true,
        },
        'transparency-injector': {
            legalHoldNoticeOnSarRequired: true,
            art17ExemptionCitationRequired: true,
        },
        'agent-auth': {
            icoCaseOfficerAccessBindingRequired: true,
            seniorManagerRoleBindingRequired: true,
        },
        'supply-chain': {
            processorLegalHoldFlowDownRequired: true,
            subProcessorErasureCascadePreventionRequired: true,
        },
    },
    providerPolicy: {
        blockedProviders: ['deepseek', 'baidu', 'alibaba'],
        requiredCapabilities: ['DATA-RESIDENCY-UK-OR-EU', 'PROCESSOR-CONTRACT', 'LEGAL-HOLD-COMPATIBLE'],
        blockReasons: {
            deepseek: 'PRC jurisdiction. Legal-hold evidence chain must be UK-resident; PRC routing creates evidentiary chain-of-custody gaps for ICO investigation under DPA 2018 s.148.',
            baidu: 'PRC jurisdiction. Inadequate evidence chain for ICO investigation.',
            alibaba: 'PRC jurisdiction. Inadequate evidence chain for ICO investigation.',
        },
    },
    dataPolicy: {
        scanCategories: [
            'ICO_CASE_REFERENCE',
            'LEGAL_HOLD_DECISION',
            'ATTEMPTED_ERASURE',
            'CROSS_BORDER_TRANSFER',
            'ICO_RESPONSE',
            'CREDENTIALS',
        ],
        categoryActions: {
            ICO_CASE_REFERENCE: 'WARN',
            LEGAL_HOLD_DECISION: 'WARN',
            ATTEMPTED_ERASURE: 'BLOCK',
            CROSS_BORDER_TRANSFER: 'WARN',
            ICO_RESPONSE: 'WARN',
            CREDENTIALS: 'BLOCK',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256-GCM',
        minimumClassification: 'RESTRICTED',
    },
    retentionPolicy: {
        // UNTIL_HOLD_LIFTED — standard retention is suspended. We use an
        // upper-bound integer for the audit-log retention to satisfy the
        // policy contract; in practice the case-closure event re-triggers
        // standard retention which then runs from that point forward.
        auditLogRetentionDays: 36500, // 100 years upper-bound while held
        sessionRetentionDays: 36500,
        incidentRetentionDays: 36500,
        reference: 'UK GDPR Art. 17(3)(b); DPA 2018 s.148; UNTIL_HOLD_LIFTED retention semantics',
        forceDelete: false,
        requiresLegalHoldSupport: true,
        sovereignty: ['gb', 'eu'],
    },
    incidentPolicy: {
        notificationDeadlineHours: 24, // ICO information-notice response windows are tight
        reference: 'DPA 2018 s.142 information notice; ICO notice response practice',
        requiredRecipients: ['ico-case-handler', 'data-protection-officer', 'senior-manager-ico-correspondence', 'legal-counsel'],
        formalNotificationRequired: true,
    },
    validators: [
        {
            id: 'uk-ico-legal-hold-active',
            description: 'Legal-hold posture active for tagged data; ICO case reference recorded; case-opened-at timestamp captured.',
            reference: 'UK GDPR Art. 17(3)(b); F-NEW-PACK-UK-ICO-OPEN-CASE',
            check: 'attestation_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-ico-erasure-default-deny',
            description: 'DELETE / DROP / TRUNCATE / hard-delete operations on tagged data default-denied; attempted-erasure events captured tamper-evidently.',
            reference: 'DPA 2018 s.148; UK GDPR Art. 17(3)(b)',
            check: 'governance_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-ico-cross-border-approval',
            description: 'Cross-border transfers of tagged data routed for ICO case-officer approval; transfer-impact-assessment recorded.',
            reference: 'UK GDPR Arts. 44-46 + ICO case practice',
            check: 'approval_queue_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-ico-audit-chain-partitioned',
            description: 'Audit-chain entries partitioned under ico-case-<reference> scope; every decision touching tagged data captured.',
            reference: 'F-NEW-PACK-UK-ICO-OPEN-CASE audit-chain partitioning',
            check: 'audit_trail_exists',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-ico-senior-manager-named',
            description: 'Senior manager for ICO correspondence named and current; DPO + legal counsel role bindings active.',
            reference: 'DPA 2018 s.148 senior-manager personal liability',
            check: 'rbac_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-ico-information-notice-tracking',
            description: 'ICO information-notice + assessment-notice deadlines tracked; response evidence captured tamper-evidently.',
            reference: 'DPA 2018 ss.142, 146',
            check: 'monitoring_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-ico-sar-legal-hold-notice',
            description: 'Subject Access Request + erasure request response includes legal-hold notice with Art. 17(3)(b) citation and case reference.',
            reference: 'UK GDPR Arts. 12-15 + Art. 17(3)(b) exemption notice',
            check: 'transparency_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-ico-supplier-flow-down',
            description: 'Sub-processors notified of legal-hold scope; processor-contract flow-down of obligations recorded.',
            reference: 'UK GDPR Art. 28 processor obligations under legal hold',
            check: 'subservice_registry_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-ico-encryption',
            description: 'Tagged data encrypted at rest and in transit; ICO correspondence encrypted.',
            reference: 'UK GDPR Art. 32(1)(a)',
            check: 'encryption_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'uk-ico-credential-block',
            description: 'Plaintext credentials blocked from ICO case artefacts and audit-chain entries.',
            reference: 'F-NEW-PACK-UK-ICO-OPEN-CASE credential safety',
            check: 'data_classifier_active',
            failSeverity: 'CRITICAL',
        },
    ],
};
//# sourceMappingURL=uk-ico-open-case.js.map