/**
 * UK Equality Act 2010 Compliance Pack
 *
 * Statute: Equality Act 2010 (consolidating prior anti-discrimination law).
 *
 * Jurisdiction: GB (England, Scotland, Wales). Northern Ireland has its
 *   own parallel anti-discrimination regime.
 * Authority: Equality and Human Rights Commission (EHRC) — primary
 *   enforcement body. Sectoral regulators (FCA, Ofcom, MHRA, ICO) apply
 *   the Act within their remits. Tribunals and courts adjudicate.
 *
 * Why this pack:
 *   - The Equality Act is the foundational UK anti-discrimination statute
 *     and the primary substantive law against AI-driven discriminatory
 *     outcomes. Any AI system whose outputs affect a person — hiring,
 *     credit, healthcare access, education, housing, content moderation,
 *     pricing — touches the Equality Act.
 *   - DSIT AI Framework (uk-ai-framework pack) Principle 3 (Fairness)
 *     references the Equality Act explicitly. The Equality Act is the
 *     statute behind the principle.
 *   - Maps to ICO AI guidance, EHRC AI guidance (2023), and the
 *     Public Sector Equality Duty (PSED, s.149).
 *
 * Nine protected characteristics (s.4–s.12):
 *   1. Age
 *   2. Disability
 *   3. Gender reassignment
 *   4. Marriage and civil partnership
 *   5. Pregnancy and maternity
 *   6. Race
 *   7. Religion or belief
 *   8. Sex
 *   9. Sexual orientation
 *
 * Forms of prohibited conduct:
 *   - Direct discrimination (s.13)
 *   - Indirect discrimination (s.19) — disparate-impact pattern; this is
 *     the most relevant lens for AI fairness audits.
 *   - Harassment (s.26)
 *   - Victimisation (s.27)
 *   - Failure to make reasonable adjustments for disability (s.20–s.22)
 *
 * Public Sector Equality Duty (s.149) — applies to public bodies and to
 *   private bodies exercising a public function. Requires due regard to
 *   eliminating discrimination, advancing equality of opportunity, and
 *   fostering good relations.
 *
 * Why separate from uk-ai-framework:
 *   - DSIT AI Framework is non-statutory principles guidance. The
 *     Equality Act is the underlying statute that gives those principles
 *     teeth. They co-apply; a customer needs both.
 *
 * Out of scope:
 *   - UK GDPR Article 22 automated decision-making (separate pack:
 *     uk-gdpr) — overlaps but distinct.
 *   - Northern Ireland anti-discrimination (separate parallel regime).
 *   - Specific employment-AI laws (already shipped: nyc-ll-144,
 *     illinois-aivia, maryland-hb1202, california-ab2930) which cover
 *     other jurisdictions' equivalents.
 *
 * @connexum/ai-governance
 */
export const UK_EQUALITY_ACT_CATEGORY_CLASSIFIERS = {
    PROTECTED_CHARACTERISTIC: {
        references: [
            'Equality Act 2010 ss.4–12 — nine protected characteristics',
        ],
        classifier: (input) => {
            if (/\b(?:age|date\s+of\s+birth|dob)\s*(?:band|range|bracket|filter)?\b/i.test(input))
                return true;
            if (/\b(?:disability|disabled|impairment|wheelchair|adjustment|accommodation)\b/i.test(input))
                return true;
            if (/\b(?:gender\s+reassignment|trans\s+(?:gender|sexual)|transition\s+status)\b/i.test(input))
                return true;
            if (/\b(?:marital\s+status|married|civil\s+partner|spouse)\b/i.test(input))
                return true;
            if (/\b(?:pregnancy|pregnant|maternity\s+leave|breastfeeding)\b/i.test(input))
                return true;
            if (/\b(?:race|ethnicity|ethnic\s+(?:origin|background|group)|nationality\s+filter)\b/i.test(input))
                return true;
            if (/\b(?:religion|religious\s+belief|faith|denomination|atheist)\b/i.test(input))
                return true;
            if (/\b(?:gender\s+(?:filter|criterion)|sex\s+(?:filter|criterion)|male\s+only|female\s+only)\b/i.test(input))
                return true;
            if (/\b(?:sexual\s+orientation|lgbt|gay|lesbian|bisexual|heterosexual)\b/i.test(input))
                return true;
            return false;
        },
    },
    DISPARATE_IMPACT_RECORD: {
        references: [
            'Equality Act 2010 s.19 — indirect discrimination; ICO + EHRC AI fairness guidance',
        ],
        classifier: (input) => {
            if (/\b(?:disparate\s+(?:impact|treatment)|disparity\s+(?:metric|score|ratio)|four\s+fifths\s+rule)\b/i.test(input))
                return true;
            if (/\b(?:fairness\s+(?:metric|audit|test|report)|bias\s+(?:audit|metric|disparity))\b/i.test(input))
                return true;
            if (/\b(?:demographic\s+parity|equal\s+opportunity\s+metric|equalised\s+odds)\b/i.test(input))
                return true;
            return false;
        },
    },
    REASONABLE_ADJUSTMENT_RECORD: {
        references: [
            'Equality Act 2010 ss.20–22 — duty to make reasonable adjustments',
        ],
        classifier: (input) => {
            if (/\b(?:reasonable\s+adjustment|accessibility\s+(?:adjustment|accommodation|alternative)|aac\s+request)\b/i.test(input))
                return true;
            if (/\b(?:wcag\s+exception|alt\s+text\s+missing|screen\s+reader\s+failure|keyboard\s+navigation\s+failure)\b/i.test(input))
                return true;
            return false;
        },
    },
    PSED_EVIDENCE: {
        references: [
            'Equality Act 2010 s.149 — Public Sector Equality Duty',
        ],
        classifier: (input) => {
            if (/\b(?:public\s+sector\s+equality\s+duty|psed\s+(?:assessment|evidence|review)|equality\s+impact\s+assessment|eia)\b/i.test(input))
                return true;
            if (/\b(?:s\s*149|section\s+149\s+equality\s+act|due\s+regard\s+(?:assessment|evidence))\b/i.test(input))
                return true;
            return false;
        },
    },
    DISCRIMINATION_COMPLAINT: {
        references: [
            'Equality Act 2010 ss.13, 19, 26, 27 — discrimination + harassment + victimisation; tribunal claims',
        ],
        classifier: (input) => {
            if (/\b(?:discrimination\s+(?:claim|complaint|tribunal|allegation)|equality\s+act\s+claim)\b/i.test(input))
                return true;
            if (/\b(?:harassment\s+claim|victimisation\s+claim|protected\s+(?:disclosure|act))\b/i.test(input))
                return true;
            if (/\b(?:ehrc\s+(?:investigation|review|notice|inquiry))\b/i.test(input))
                return true;
            return false;
        },
    },
    CREDENTIALS: {
        references: ['Cross-pack secrets safety; Equality Act evidence 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_EQUALITY_ACT_PACK = {
    categoryClassifiers: UK_EQUALITY_ACT_CATEGORY_CLASSIFIERS,
    id: 'uk-equality-act',
    aliases: [
        'equality-act',
        'equality-act-2010',
        'uk-equality-act-2010',
        'ehrc',
        'psed',
        'public-sector-equality-duty',
    ],
    name: 'UK Equality Act 2010 + Public Sector Equality Duty',
    version: '1.0.0',
    description: 'UK Equality Act 2010 covering nine protected characteristics (age, disability, gender reassignment, marriage and civil partnership, pregnancy and maternity, race, religion or belief, sex, sexual orientation) and prohibited conduct (direct s.13, indirect s.19, harassment s.26, victimisation s.27, reasonable-adjustment failure ss.20–22). Public Sector Equality Duty (s.149) layered for public bodies. Primary substantive law against AI-driven discriminatory outcomes; pairs with `uk-ai-framework` (DSIT AI Framework Principle 3 Fairness) which references this Act. Distinct from UK GDPR Art. 22 automated-decision-making (covered by `uk-gdpr`).',
    authority: 'Equality and Human Rights Commission (EHRC) + sectoral regulators (FCA / Ofcom / MHRA / ICO) + Tribunals',
    industries: ['technology', 'financial-services', 'healthcare', 'hr-employment', 'public-sector', 'education', 'retail', 'media', 'legal', 'housing'],
    requiredModules: [
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Default-deny on AI actions that branch on a protected characteristic without a documented lawful basis (e.g., genuine occupational requirement under Schedule 9). Direct-discrimination s.13 gate.',
            reference: 'Equality Act 2010 s.13; Schedule 9 (occupational requirements)',
        },
        {
            name: 'bias-monitor',
            required: true,
            reason: 'Continuous disparate-impact monitoring (s.19 indirect discrimination); demographic-parity / equal-opportunity metrics tracked across protected characteristics; alert when statistical disparity exceeds thresholds.',
            reference: 'Equality Act 2010 s.19; ICO + EHRC AI fairness guidance',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Detect protected-characteristic data in inputs and outputs; flag disparate-impact records, reasonable-adjustment requests, PSED evidence artefacts, and discrimination complaints.',
            reference: 'Equality Act 2010 ss.4–12 protected characteristics',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'PSED Equality Impact Assessment (EIA) registration for public bodies; bias-audit attestation cadence; reasonable-adjustment policy attestation.',
            reference: 'Equality Act 2010 s.149 PSED; EHRC PSED guidance',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'AI-output transparency for affected persons; reasonable-adjustment availability disclosure; PSED public-statement publication for public bodies.',
            reference: 'Equality Act 2010 ss.20–22 reasonable adjustments; PSED transparency expectations',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'High-risk consequential decisions affecting protected characteristics route to a human reviewer (T2 fairness review); reasonable-adjustment grant approval.',
            reference: 'Equality Act 2010 ss.13, 19, 20–22; ICO AI Art. 22 overlap',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident audit chain for protected-characteristic decisions, bias-audit results, reasonable-adjustment grants, PSED evidence, and discrimination-complaint investigations — required as tribunal evidence.',
            reference: 'Equality Act 2010 evidentiary requirements; tribunal disclosure',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Bias-disparity threshold alerts; reasonable-adjustment-failure alerts; discrimination-complaint routing to legal / HR.',
            reference: 'Equality Act 2010 ss.19, 20–22, 26 alert pathways',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'Tribunal claim period: discrimination claims must typically be brought within 3 months (employment) or 6 months (services / public functions) — but evidence must be retained for the limitation period plus the appeal window. 6-year retention aligns with Limitation Act 1980 default.',
            reference: 'Equality Act 2010 ss.123–124; Limitation Act 1980',
        },
        {
            name: 'supply-chain',
            required: true,
            reason: 'PSED s.149(3)(c) due regard for fostering good relations cascades to processors when a public function is contracted out; sub-supplier non-discrimination attestation.',
            reference: 'Equality Act 2010 s.149; sub-contractor accountability',
        },
    ],
    moduleConfig: {
        'governance-runtime': {
            directDiscriminationGateRequired: true,
            lawfulBasisForProtectedCharacteristicBranchRequired: true,
        },
        'bias-monitor': {
            indirectDiscriminationMonitoringRequired: true,
            protectedCharacteristicCoverage: [
                'age',
                'disability',
                'gender_reassignment',
                'marriage_civil_partnership',
                'pregnancy_maternity',
                'race',
                'religion_belief',
                'sex',
                'sexual_orientation',
            ],
            fourFifthsRuleAlertThreshold: 0.8,
        },
        'data-classifier': {
            enabledCategories: [
                'PROTECTED_CHARACTERISTIC',
                'DISPARATE_IMPACT_RECORD',
                'REASONABLE_ADJUSTMENT_RECORD',
                'PSED_EVIDENCE',
                'DISCRIMINATION_COMPLAINT',
                'CREDENTIALS',
            ],
            protectedCharacteristicAction: 'WARN',
            credentialsAction: 'BLOCK',
        },
        'attestation-manager': {
            psedEiaRequired: true, // for public bodies and contractors of public function
            biasAuditCadenceRequired: true,
            reasonableAdjustmentPolicyAttestationRequired: true,
        },
        'transparency-injector': {
            affectedPersonAiOutputDisclosureRequired: true,
            reasonableAdjustmentDisclosureRequired: true,
            psedPublicStatementRequired: true, // public bodies only
        },
        'approval-queue': {
            consequentialDecisionFairnessReviewRequired: true,
            reasonableAdjustmentApprovalRequired: true,
            reviewTier: 'T2',
        },
        'audit-integrity': {
            tribunalEvidenceTrackingRequired: true,
        },
        'event-bus': {
            biasDisparityAlertsRequired: true,
            reasonableAdjustmentFailureAlertsRequired: true,
            discriminationComplaintRoutingRequired: true,
        },
        'session-persistence': {
            retentionDaysMinimum: 2190, // 6 years (Limitation Act 1980 default)
        },
        'supply-chain': {
            subSupplierNonDiscriminationAttestationRequired: true,
        },
    },
    providerPolicy: {
        blockedProviders: ['deepseek', 'baidu', 'alibaba'],
        requiredCapabilities: ['DATA-RESIDENCY-UK-OR-EU', 'PROCESSOR-CONTRACT', 'BIAS-AUDIT-DATA-RETURN'],
        blockReasons: {
            deepseek: 'PRC jurisdiction. PRC routing creates evidentiary chain-of-custody gaps for tribunal disclosure on bias-audit data and protected-characteristic processing under the Equality Act.',
            baidu: 'PRC jurisdiction. Inadequate evidentiary chain for Equality Act tribunal disclosure.',
            alibaba: 'PRC jurisdiction. Inadequate evidentiary chain for Equality Act tribunal disclosure.',
        },
    },
    dataPolicy: {
        scanCategories: [
            'PROTECTED_CHARACTERISTIC',
            'DISPARATE_IMPACT_RECORD',
            'REASONABLE_ADJUSTMENT_RECORD',
            'PSED_EVIDENCE',
            'DISCRIMINATION_COMPLAINT',
            'CREDENTIALS',
        ],
        categoryActions: {
            PROTECTED_CHARACTERISTIC: 'WARN',
            DISPARATE_IMPACT_RECORD: 'WARN',
            REASONABLE_ADJUSTMENT_RECORD: 'WARN',
            PSED_EVIDENCE: 'WARN',
            DISCRIMINATION_COMPLAINT: 'WARN',
            CREDENTIALS: 'BLOCK',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256-GCM',
        minimumClassification: 'RESTRICTED',
    },
    retentionPolicy: {
        auditLogRetentionDays: 2190, // 6 years
        sessionRetentionDays: 2190,
        incidentRetentionDays: 2190,
        reference: 'Limitation Act 1980 — 6-year claim window; Equality Act 2010 ss.123–124 limitation periods + appeal windows',
        forceDelete: false,
        requiresLegalHoldSupport: true,
        sovereignty: ['gb', 'eu'],
    },
    incidentPolicy: {
        notificationDeadlineHours: 168, // 7 days for internal escalation; Equality Act has no statutory external deadline analogous to UK GDPR Art. 33
        reference: 'Equality Act 2010 internal escalation cadence; EHRC investigation cooperation',
        requiredRecipients: ['legal-counsel', 'hr-director', 'data-protection-officer', 'equality-diversity-lead'],
        formalNotificationRequired: false,
    },
    validators: [
        {
            id: 'uk-equality-direct-discrimination-gate',
            description: 'AI actions branching on a protected characteristic require documented lawful basis (Schedule 9 occupational requirement, positive action s.158/159, etc.) before execution.',
            reference: 'Equality Act 2010 s.13; Schedule 9',
            check: 'governance_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-indirect-discrimination-monitor',
            description: 'Disparate-impact monitoring active across all 9 protected characteristics; four-fifths rule threshold alert configured; fairness audit cadence current.',
            reference: 'Equality Act 2010 s.19; ICO + EHRC AI fairness guidance',
            check: 'bias_monitor_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-reasonable-adjustments',
            description: 'Reasonable-adjustment workflow active; WCAG 2.2 AA conformance + accessibility-statement published; AAC alternative-channel availability captured.',
            reference: 'Equality Act 2010 ss.20–22',
            check: 'transparency_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-psed-eia',
            description: 'Equality Impact Assessment registered for public bodies and private bodies exercising a public function; due-regard evidence chain captured.',
            reference: 'Equality Act 2010 s.149 PSED',
            check: 'attestation_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-fairness-review-queue',
            description: 'Consequential AI decisions affecting protected characteristics route to T2 fairness reviewer.',
            reference: 'Equality Act 2010 ss.13, 19; ICO AI Art. 22 overlap',
            check: 'approval_queue_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-tribunal-audit-trail',
            description: 'Tamper-evident audit trail captures protected-characteristic decisions, bias-audit results, reasonable-adjustment grants, and discrimination-complaint investigations as tribunal-grade evidence.',
            reference: 'Equality Act 2010 evidentiary expectations; tribunal disclosure',
            check: 'audit_trail_exists',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-retention-6-year',
            description: 'Discrimination evidence retained 6 years (Limitation Act default); legal-hold support active for live tribunal claims.',
            reference: 'Limitation Act 1980; Equality Act 2010 ss.123–124',
            check: 'retention_policy_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-supplier-flow-down',
            description: 'Sub-supplier non-discrimination attestation captured; PSED s.149(3)(c) cascade for public-function contractors.',
            reference: 'Equality Act 2010 s.149',
            check: 'subservice_registry_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'uk-equality-encryption',
            description: 'Protected-characteristic data encrypted at rest and in transit; bias-audit datasets encrypted.',
            reference: 'Equality Act 2010 evidentiary integrity',
            check: 'encryption_active',
            failSeverity: 'MEDIUM',
        },
    ],
};
//# sourceMappingURL=uk-equality-act.js.map