/**
 * UK Equality Act 2010 + ICO-EHRC Joint AI Bias Guidance Pack
 *
 * Statute: Equality Act 2010 (c.15).
 *   - Nine protected characteristics (ss.4–12): age, disability, gender
 *     reassignment, marriage and civil partnership, pregnancy and maternity,
 *     race, religion or belief, sex, sexual orientation.
 *   - Direct discrimination (s.13), indirect discrimination / disparate
 *     impact (s.19), harassment (s.26), victimisation (s.27).
 *   - Failure to make reasonable adjustments for disability (ss.20–22).
 *   - Public Sector Equality Duty (PSED, s.149): public bodies must have
 *     due regard to eliminating discrimination, advancing equality of
 *     opportunity, and fostering good relations.
 *
 * Guidance: ICO + EHRC joint publication "Artificial intelligence and the
 *   Equality Act 2010" (2024).
 *   - Provides a risk-based AI bias assessment framework.
 *   - Specifies when an Equality Impact Assessment (EIA) is mandatory
 *     before deploying an AI system in a public-sector context.
 *   - Recommends the 80% rule (4/5ths rule) as an initial screening
 *     threshold for disparate-impact ratio: if the selection rate for a
 *     protected-characteristic group is less than 80% of the rate for the
 *     most-favoured group, the disparity warrants investigation.
 *     (Source: ICO-EHRC joint guidance, 2024; aligns with US EEOC Uniform
 *     Guidelines 29 CFR 1607.4(D) which established the 4/5ths rule.)
 *
 * Why this pack is separate from uk-equality-act:
 *   - uk-equality-act covers the statute broadly (all sectors, all forms
 *     of prohibited conduct).
 *   - This pack targets the AI-specific enforcement layer: quantitative
 *     disparate-impact thresholds, mandatory EIA gates for public-sector
 *     AI deployment, ICO-EHRC joint guidance compliance, BLOCKED verdicts
 *     for AI decisions with a disparate-impact ratio outside the 80% rule,
 *     T2 review for high-bias-risk AI systems, and 7-year audit retention
 *     aligned with UK public-sector record-keeping norms.
 *
 * Jurisdiction: GB (England, Scotland, Wales).
 *   Northern Ireland uses parallel anti-discrimination law — see
 *   ni-equality pack.
 * Authority: EHRC (Equality and Human Rights Commission) + ICO
 *   (Information Commissioner's Office, joint guidance co-author).
 *
 * Retention: 7 years — matches UK public-sector record-keeping norms
 *   (Public Records Act 1958; Cabinet Office retention schedule).
 *
 * @connexum/ai-governance
 */
// ---------------------------------------------------------------------------
// Category classifiers — 9 protected-characteristic classifiers + AI-bias
// ---------------------------------------------------------------------------
export const UK_EQUALITY_ACT_AI_BIAS_CATEGORY_CLASSIFIERS = {
    // 1. Age — Equality Act 2010 s.5
    PROTECTED_CHARACTERISTIC_AGE: {
        references: [
            'Equality Act 2010 s.5 — age protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: age-based disparate impact',
        ],
        classifier: (input) => {
            if (/\b(?:age(?:\s+band|\s+bracket|\s+range|\s+group|\s+filter|\s+score)?)\b/i.test(input))
                return true;
            if (/\b(?:date\s+of\s+birth|dob|year\s+of\s+birth|birth\s+year)\b/i.test(input))
                return true;
            if (/\b(?:under[\s-]?(?:\d{2})|over[\s-]?(?:\d{2})|aged?\s+\d{2}[\s-](?:to|\-)\s*\d{2})\b/i.test(input))
                return true;
            if (/\b(?:older\s+worker|younger\s+worker|retirement\s+age|age\s+discrimination)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 2. Disability — Equality Act 2010 s.6
    PROTECTED_CHARACTERISTIC_DISABILITY: {
        references: [
            'Equality Act 2010 s.6 — disability protected characteristic; ss.20–22 reasonable adjustments',
            'ICO-EHRC joint guidance (2024) — AI bias risk: disability-based exclusion',
        ],
        classifier: (input) => {
            if (/\b(?:disabilit(?:y|ies)|disabled\s+person|impairment|long[\s-]?term\s+condition)\b/i.test(input))
                return true;
            if (/\b(?:reasonable\s+adjustment|accessibility\s+accommodation|assistive\s+technolog)\b/i.test(input))
                return true;
            if (/\b(?:wheelchair\s+user|chronic\s+illness\s+filter|mental\s+health\s+flag)\b/i.test(input))
                return true;
            if (/\b(?:pip\s+recipient|attendance\s+allowance|universal\s+credit\s+disability\s+element)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 3. Gender reassignment — Equality Act 2010 s.7
    PROTECTED_CHARACTERISTIC_GENDER_REASSIGNMENT: {
        references: [
            'Equality Act 2010 s.7 — gender reassignment protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: gender-reassignment data',
        ],
        classifier: (input) => {
            if (/\b(?:gender\s+reassignment|transgender|trans\s+(?:gender|sexual|man|woman|person)|gender\s+transition)\b/i.test(input))
                return true;
            if (/\b(?:transition\s+status|transitioned|pre[\s-]?op|post[\s-]?op\s+trans|gender\s+recognition\s+certificate)\b/i.test(input))
                return true;
            if (/\b(?:grc\s+holder|gender\s+dysphoria\s+record)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 4. Marriage and civil partnership — Equality Act 2010 s.8
    PROTECTED_CHARACTERISTIC_MARRIAGE_CIVIL_PARTNERSHIP: {
        references: [
            'Equality Act 2010 s.8 — marriage and civil partnership protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: marital-status filters',
        ],
        classifier: (input) => {
            if (/\b(?:marital\s+status|married|civil\s+partner(?:ship)?|spouse|widowed|divorced|separated)\b/i.test(input))
                return true;
            if (/\b(?:cohabiting\s+couple|single\s+person\s+filter|marriage\s+certificate|civil\s+partnership\s+certificate)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 5. Pregnancy and maternity — Equality Act 2010 s.18
    PROTECTED_CHARACTERISTIC_PREGNANCY_MATERNITY: {
        references: [
            'Equality Act 2010 ss.17–18 — pregnancy and maternity protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: pregnancy/maternity-leave data',
        ],
        classifier: (input) => {
            if (/\b(?:pregnan(?:t|cy)|maternity\s+(?:leave|pay|allowance|period)|breastfeeding)\b/i.test(input))
                return true;
            if (/\b(?:statutory\s+maternity|smp|shared\s+parental\s+leave(?:\s+flag)?)\b/i.test(input))
                return true;
            if (/\b(?:due\s+date\s+filter|post[\s-]?natal|antenatal)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 6. Race — Equality Act 2010 s.9
    PROTECTED_CHARACTERISTIC_RACE: {
        references: [
            'Equality Act 2010 s.9 — race protected characteristic (colour, nationality, ethnic or national origins)',
            'ICO-EHRC joint guidance (2024) — AI bias risk: race/ethnicity proxy signals in training data',
        ],
        classifier: (input) => {
            if (/\b(?:race|ethnicit(?:y|ies)|ethnic\s+(?:group|background|origin|minority)|racial\s+group)\b/i.test(input))
                return true;
            if (/\b(?:nationality(?:\s+filter)?|national\s+origin|country\s+of\s+birth\s+filter|colour\s+(?:discrimination|filter))\b/i.test(input))
                return true;
            if (/\b(?:bame|bipoc|ethnic\s+data\s+field|racial\s+proxy|zip\s+code\s+proxy\s+race)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 7. Religion or belief — Equality Act 2010 s.10
    PROTECTED_CHARACTERISTIC_RELIGION_OR_BELIEF: {
        references: [
            'Equality Act 2010 s.10 — religion or belief protected characteristic (including non-belief)',
            'ICO-EHRC joint guidance (2024) — AI bias risk: religion/belief proxies in AI inputs',
        ],
        classifier: (input) => {
            if (/\b(?:religion|religious\s+(?:belief|group|affiliation)|faith|denomination|sect|creed)\b/i.test(input))
                return true;
            if (/\b(?:atheist|agnostic|humanist|non[\s-]?belief|philosophical\s+belief)\b/i.test(input))
                return true;
            if (/\b(?:dietary\s+requirement\s+(?:filter|flag)|prayer\s+break\s+flag|religious\s+observance)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 8. Sex — Equality Act 2010 s.11
    PROTECTED_CHARACTERISTIC_SEX: {
        references: [
            'Equality Act 2010 s.11 — sex protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: sex-based disparate impact in AI models',
        ],
        classifier: (input) => {
            if (/\b(?:sex\s+(?:filter|discrimination|criterion|field)|gender\s+(?:filter|criterion|pay\s+gap\s+flag))\b/i.test(input))
                return true;
            if (/\b(?:male\s+only|female\s+only|male[\s/]female\s+ratio|gender\s+parity\s+flag)\b/i.test(input))
                return true;
            if (/\b(?:sex[\s-]?based\s+scoring|gender[\s-]?based\s+pricing\s+flag|actuarial\s+sex\s+factor)\b/i.test(input))
                return true;
            return false;
        },
    },
    // 9. Sexual orientation — Equality Act 2010 s.12
    PROTECTED_CHARACTERISTIC_SEXUAL_ORIENTATION: {
        references: [
            'Equality Act 2010 s.12 — sexual orientation protected characteristic',
            'ICO-EHRC joint guidance (2024) — AI bias risk: sexual-orientation inference from proxy data',
        ],
        classifier: (input) => {
            if (/\b(?:sexual\s+orientation|sexuality|gay|lesbian|bisexual|heterosexual|homosexual|lgbtq\+?)\b/i.test(input))
                return true;
            if (/\b(?:same[\s-]?sex\s+(?:couple|partner|filter)|civil\s+partnership\s+sexual\s+orientation)\b/i.test(input))
                return true;
            if (/\b(?:orientation\s+proxy\s+signal|sexual\s+orientation\s+inference)\b/i.test(input))
                return true;
            return false;
        },
    },
    // AI-bias-specific classifiers
    AI_BIAS_RISK_ASSESSMENT: {
        references: [
            'ICO-EHRC joint guidance (2024) — AI bias risk assessment methodology',
            'Equality Act 2010 s.149 PSED — public bodies must assess AI systems for equality impact',
        ],
        classifier: (input) => {
            if (/\b(?:ai\s+bias\s+(?:risk|assessment|audit)|bias\s+risk\s+assessment\s+ai)\b/i.test(input))
                return true;
            if (/\b(?:algorithmic\s+bias\s+(?:test|audit|evaluation)|fairness\s+(?:metric|evaluation|audit))\b/i.test(input))
                return true;
            if (/\b(?:ico[\s-]ehrc\s+guidance|ehrc\s+ai\s+(?:bias|guidance)|equality\s+act\s+ai\s+assessment)\b/i.test(input))
                return true;
            if (/\b(?:bias\s+risk\s+score|model\s+fairness\s+report|protected\s+group\s+disparity)\b/i.test(input))
                return true;
            return false;
        },
    },
    EQUALITY_IMPACT_ASSESSMENT: {
        references: [
            'Equality Act 2010 s.149 — Public Sector Equality Duty (PSED) requires EIA before significant policy/system changes',
            'ICO-EHRC joint guidance (2024) — mandatory EIA before deploying AI in public-sector contexts',
        ],
        classifier: (input) => {
            if (/\b(?:equality\s+impact\s+assessment|eia\s+(?:report|document|gate|completed)|psed\s+assessment)\b/i.test(input))
                return true;
            if (/\b(?:public\s+sector\s+equality\s+duty\s+assessment|equality\s+analysis\s+(?:document|record))\b/i.test(input))
                return true;
            if (/\b(?:protected\s+characteristic\s+impact\s+assessment|equalities\s+assessment)\b/i.test(input))
                return true;
            if (/\b(?:s\.?\s*149\s+(?:duty|assessment|compliance)|section\s+149\s+equality\s+duty)\b/i.test(input))
                return true;
            return false;
        },
    },
    INDIRECT_DISCRIMINATION_INDICATOR: {
        references: [
            'Equality Act 2010 s.19 — indirect discrimination: a provision, criterion or practice (PCP) that puts a protected-characteristic group at a particular disadvantage',
            'ICO-EHRC joint guidance (2024) — indirect discrimination risk in AI decision pipelines',
        ],
        classifier: (input) => {
            if (/\b(?:indirect\s+discrimination|disparate\s+impact\s+(?:analysis|finding|alert)|adverse\s+impact\s+(?:ratio|finding))\b/i.test(input))
                return true;
            if (/\b(?:provision[\s,]\s*criterion[\s,]\s*(?:or\s+)?practice|pcp\s+(?:analysis|flag|review))\b/i.test(input))
                return true;
            if (/\b(?:neutral\s+criterion\s+(?:disparately\s+affecting|putting\s+at\s+disadvantage)|group\s+disadvantage\s+flag)\b/i.test(input))
                return true;
            if (/\b(?:s\.?\s*19\s+(?:indirect\s+discrimination|analysis)|equality\s+act\s+s19)\b/i.test(input))
                return true;
            return false;
        },
    },
    DISPARATE_IMPACT_TEST_RESULT: {
        references: [
            'ICO-EHRC joint guidance (2024) — 80% rule (4/5ths rule) as initial screening threshold for disparate-impact ratio',
            'Equality Act 2010 s.19 — disparate impact as form of indirect discrimination',
        ],
        classifier: (input) => {
            if (/\b(?:disparate[\s-]?impact\s+(?:ratio|test|result|score)|four[\s-]?fifths\s+(?:rule|test)|4\/5(?:ths)?\s+rule)\b/i.test(input))
                return true;
            if (/\b(?:80\s*(?:%|percent)\s+(?:rule|threshold|screening)|adverse\s+impact\s+ratio[\s=:]\s*0\.[0-7]\d*)\b/i.test(input))
                return true;
            if (/\b(?:selection\s+rate\s+ratio|pass\s+rate\s+(?:disparity|gap)\s+protected|group\s+disparity\s+ratio)\b/i.test(input))
                return true;
            if (/\b(?:disparate\s+impact\s+ratio\s+(?:below|outside|exceeds?)\s+(?:80|0\.8))\b/i.test(input))
                return true;
            return false;
        },
    },
    PROTECTED_CHARACTERISTIC_DECISION_AGAINST: {
        references: [
            'Equality Act 2010 ss.13, 19 — AI decision that adversely affects a person on grounds of a protected characteristic',
            'ICO-EHRC joint guidance (2024) — high-risk AI decisions affecting protected-characteristic holders require human review',
        ],
        classifier: (input) => {
            if (/\b(?:decision\s+against\s+protected\s+(?:characteristic|group)|ai\s+decision\s+affecting\s+protected)\b/i.test(input))
                return true;
            if (/\b(?:adverse\s+(?:ai\s+)?decision\s+(?:on|due\s+to)\s+protected|protected\s+group\s+denial)\b/i.test(input))
                return true;
            if (/\b(?:automated\s+refusal\s+protected\s+characteristic|high[\s-]?bias[\s-]?risk\s+ai\s+decision)\b/i.test(input))
                return true;
            return false;
        },
    },
    CREDENTIALS: {
        references: ['UK GDPR Art. 32 — security; Equality Act 2010 s.149 PSED compliance infrastructure'],
        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;
        },
    },
};
// ---------------------------------------------------------------------------
// Pack definition
// ---------------------------------------------------------------------------
export const UK_EQUALITY_ACT_AI_BIAS_PACK = {
    categoryClassifiers: UK_EQUALITY_ACT_AI_BIAS_CATEGORY_CLASSIFIERS,
    id: 'uk-equality-act-ai-bias',
    aliases: [
        'uk-equality-act-ai',
        'equality-act-ai-bias',
        'ico-ehrc-ai-bias',
        'ehrc-ai-guidance',
        'uk-ai-equality',
    ],
    name: 'UK Equality Act 2010 + ICO-EHRC Joint AI Bias Guidance',
    version: '1.0.0',
    contentHash: 'c966ee9484818417047c5d1b4ca4fadc2a8dbf86be4b16f7919ab4bc9abef72e',
    description: 'Equality Act 2010 AI-bias-specific enforcement layer for GB (England, Scotland, Wales). ' +
        'Covers all nine protected characteristics (ss.4–12), direct discrimination (s.13), indirect ' +
        'discrimination / disparate impact (s.19), and Public Sector Equality Duty (PSED, s.149). ' +
        'Implements ICO-EHRC joint guidance "Artificial intelligence and the Equality Act 2010" (2024): ' +
        'mandatory Equality Impact Assessment (EIA) before public-sector AI deployment; BLOCK on AI ' +
        'decisions with disparate-impact ratio outside the 80% (4/5ths) rule; T2 human review for ' +
        'high-bias-risk AI decisions; 7-year audit retention aligned with UK public-sector records. ' +
        'Protected-characteristic data classified as REVIEWED; disparate-impact results outside 80% rule BLOCKED. ' +
        'Pair with uk-equality-act (broad statute pack) and uk-gdpr (Art. 22 automated decision-making).',
    authority: 'EHRC (Equality and Human Rights Commission) + ICO (Information Commissioner\u2019s Office, joint guidance co-author) + UK Employment Tribunals / County Courts',
    industries: [
        'public-sector',
        'financial-services',
        'healthcare',
        'technology',
        'education',
        'retail',
        'housing',
        'employment',
        'insurance',
    ],
    requiredModules: [
        {
            name: 'bias-monitor',
            required: true,
            reason: 'Core enforcement engine for this pack. Monitors AI outputs for disparate impact across all nine Equality Act protected characteristics. Implements the ICO-EHRC 80% (4/5ths) rule threshold: if a protected-characteristic group selection rate is < 80% of the most-favoured group, a REVIEWED flag is raised and the system triggers the T2 review queue.',
            reference: 'Equality Act 2010 s.19 — indirect discrimination; ICO-EHRC joint guidance (2024) — 80% rule screening threshold; EHRC employment code of practice §4.11',
        },
        {
            name: 'governance-runtime',
            required: true,
            reason: 'Enforcement gate for AI decisions flagged as high-bias-risk. Ensures that AI systems subject to PSED (s.149) cannot deploy or make consequential decisions without a completed EIA gate check. Blocks AI decisions with disparate-impact ratios outside the 80% rule until T2 review is completed.',
            reference: 'Equality Act 2010 s.149 — Public Sector Equality Duty; ICO-EHRC joint guidance (2024) — mandatory EIA before public-sector AI deployment; s.19 — indirect discrimination gate',
        },
        {
            name: 'approval-queue',
            required: true,
            reason: 'T2 human review gate for any AI decision flagged as high-bias-risk (protected-characteristic decision with disparate-impact ratio outside 80% rule). Enables the contestability pathway required by EHRC guidance. Routes to equality specialist or DPO for review before decision is actioned.',
            reference: 'ICO-EHRC joint guidance (2024) — human review gate for high-bias-risk AI decisions; Equality Act 2010 s.149 PSED due-regard duty; EHRC Statutory Code of Practice §16',
        },
        {
            name: 'attestation-manager',
            required: true,
            reason: 'Tracks and archives EIA documents, AI bias risk assessments, disparate-impact test results, and PSED compliance evidence. EIA must be completed and approved before a public-sector AI deployment is authorised. Attestation records retained for 7 years per UK public-sector norm.',
            reference: 'Equality Act 2010 s.149 PSED — documented due-regard process; ICO-EHRC joint guidance (2024) — EIA documentation; Cabinet Office retention schedule — 7-year public-sector records',
        },
        {
            name: 'audit-integrity',
            required: true,
            reason: 'Tamper-evident audit chain for all protected-characteristic classifications, disparate-impact test results, EIA decisions, and T2 review outcomes. Required for EHRC investigation evidence and Employment Tribunal disclosure.',
            reference: 'EHRC investigatory powers (Equality Act 2006 s.20); Employment Tribunal disclosure requirements; ICO investigation powers; ICO-EHRC joint guidance (2024) — record-keeping',
        },
        {
            name: 'data-classifier',
            required: true,
            reason: 'Classifies protected-characteristic data, EIA documents, disparate-impact test results, and bias risk assessments. Protected-characteristic data classified as REVIEWED by default; BLOCKED where disparate-impact ratio is outside the 80% rule threshold. Enforces packBinding on all classified records per Invariant 7 strict tenant scoping.',
            reference: 'Equality Act 2010 ss.4–12 — protected characteristics; ICO-EHRC joint guidance (2024) — data classification for AI bias detection; UK GDPR Art. 9 (special-category data overlap for race, religion, sexual orientation)',
        },
        {
            name: 'transparency-injector',
            required: true,
            reason: 'Mandatory disclosure when an AI decision involves a protected characteristic or when a disparate-impact flag has been raised. Enables affected persons to understand that an AI was used and to exercise their contestability rights under EHRC guidance.',
            reference: 'ICO-EHRC joint guidance (2024) — transparency obligations for AI decisions affecting protected groups; Equality Act 2010 s.149 PSED — accessible information about equality analysis',
        },
        {
            name: 'event-bus',
            required: true,
            reason: 'Routes disparate-impact alerts, EIA-missing events, and high-bias-risk decision flags to the T2 approval queue and compliance team. Enables real-time monitoring of protected-characteristic decision rates across the AI pipeline.',
            reference: 'ICO-EHRC joint guidance (2024) — real-time AI bias monitoring; Equality Act 2010 s.149 PSED — ongoing monitoring obligation; EHRC Statutory Code §4.14',
        },
        {
            name: 'encryption-layer',
            required: true,
            reason: 'Protected-characteristic data is highly sensitive (overlaps UK GDPR Art. 9 special categories for race, religion, sexual orientation, disability, health). Invariant 7 requires strictest tenant scoping and RLS. All protected-characteristic records and EIA documents encrypted at rest and in transit.',
            reference: 'UK GDPR Art. 9 + Art. 32 — special-category data security; Locked Invariant 7 — protected-characteristic data strictest tenant scoping + RLS; ICO security guidance for special categories',
        },
        {
            name: 'session-persistence',
            required: true,
            reason: 'Seven-year retention for all EIA documents, disparate-impact test results, bias risk assessments, and protected-characteristic AI decision records. Matches UK public-sector record-keeping norms (Public Records Act 1958; Cabinet Office schedule).',
            reference: 'Cabinet Office Guidance on Records Management — 7-year public-sector retention; Public Records Act 1958; ICO-EHRC joint guidance (2024) — retention for AI bias evidence',
        },
    ],
    moduleConfig: {
        'bias-monitor': {
            equalityActProtectedCharacteristicsRequired: true,
            disparateImpactThresholdPercent: 80,
            disparateImpactRule: '4/5ths',
            blockedBelowThreshold: true,
            monitoredCharacteristics: [
                'age',
                'disability',
                'gender-reassignment',
                'marriage-civil-partnership',
                'pregnancy-maternity',
                'race',
                'religion-or-belief',
                'sex',
                'sexual-orientation',
            ],
        },
        'governance-runtime': {
            highBiasRiskDecisionsGated: true,
            eiaRequiredForPublicSectorDeployment: true,
            disparateImpactBlockEnabled: true,
            publicSectorEqualityDutyEnforced: true,
        },
        'approval-queue': {
            t2ReviewForHighBiasRiskDecisionsRequired: true,
            equalitySpecialistReviewRequired: true,
            contestabilityPathwayRequired: true,
            reviewTier: 'T2',
        },
        'attestation-manager': {
            eiaBeforeDeploymentRequired: true,
            eiaApprovalGated: true,
            aisBiasRiskAssessmentDocumented: true,
            disparateImpactTestResultsArchived: true,
            retentionYearsForEiaDocuments: 7,
        },
        'audit-integrity': {
            tamperEvidentRequired: true,
            protectedCharacteristicDecisionsAudited: true,
            disparateImpactResultsAudited: true,
            eiaDecisionsAudited: true,
        },
        'data-classifier': {
            enabledCategories: [
                'PROTECTED_CHARACTERISTIC_AGE',
                'PROTECTED_CHARACTERISTIC_DISABILITY',
                'PROTECTED_CHARACTERISTIC_GENDER_REASSIGNMENT',
                'PROTECTED_CHARACTERISTIC_MARRIAGE_CIVIL_PARTNERSHIP',
                'PROTECTED_CHARACTERISTIC_PREGNANCY_MATERNITY',
                'PROTECTED_CHARACTERISTIC_RACE',
                'PROTECTED_CHARACTERISTIC_RELIGION_OR_BELIEF',
                'PROTECTED_CHARACTERISTIC_SEX',
                'PROTECTED_CHARACTERISTIC_SEXUAL_ORIENTATION',
                'AI_BIAS_RISK_ASSESSMENT',
                'EQUALITY_IMPACT_ASSESSMENT',
                'INDIRECT_DISCRIMINATION_INDICATOR',
                'DISPARATE_IMPACT_TEST_RESULT',
                'PROTECTED_CHARACTERISTIC_DECISION_AGAINST',
                'CREDENTIALS',
            ],
            // Protected-characteristic data: REVIEWED (human sign-off required)
            // Disparate-impact result outside 80% rule: BLOCKED
            // EIA documents: REVIEWED
            // Credentials: BLOCK always
            protectedCharacteristicAction: 'WARN',
            disparateImpactOutsideThresholdAction: 'BLOCK',
            eiaDocumentAction: 'WARN',
            credentialsAction: 'BLOCK',
        },
        'transparency-injector': {
            aiUseDisclosureForProtectedCharacteristicDecisions: true,
            disparateImpactFlagDisclosureRequired: true,
            equalityActComplianceStatementRequired: true,
        },
        'event-bus': {
            disparateImpactAlertsRouted: true,
            eiaMissingEventsRouted: true,
            highBiasRiskDecisionFlagsRouted: true,
            protectedCharacteristicDecisionRateMonitored: true,
        },
        'encryption-layer': {
            algorithm: 'aes-256-gcm',
            tlsMinVersion: '1.2',
            protectedCharacteristicDataEncryptionRequired: true,
            specialCategoryOverlapEnforced: true,
        },
        'session-persistence': {
            // 7 years — UK public-sector record-keeping norm
            retentionDaysMinimum: 2555,
        },
    },
    providerPolicy: {
        blockedProviders: ['deepseek', 'baidu', 'alibaba'],
        requiredCapabilities: ['DATA-RESIDENCY-UK-OR-EU', 'PROCESSOR-CONTRACT'],
        blockReasons: {
            deepseek: 'PRC National Intelligence Law jurisdiction. AI bias data and protected-characteristic records require UK or EU data residency per UK GDPR Art. 44 and EHRC guidance on data security for protected groups.',
            baidu: 'PRC jurisdiction. No UK adequacy decision. Protected-characteristic data routed to PRC violates UK GDPR Art. 44; incompatible with EHRC data security expectations for equality monitoring.',
            alibaba: 'PRC jurisdiction. No UK adequacy decision. Protected-characteristic data and EIA documents must remain within UK/EU boundary per Locked Invariant 7 strict tenant scoping.',
        },
    },
    dataPolicy: {
        scanCategories: [
            'PROTECTED_CHARACTERISTIC_AGE',
            'PROTECTED_CHARACTERISTIC_DISABILITY',
            'PROTECTED_CHARACTERISTIC_GENDER_REASSIGNMENT',
            'PROTECTED_CHARACTERISTIC_MARRIAGE_CIVIL_PARTNERSHIP',
            'PROTECTED_CHARACTERISTIC_PREGNANCY_MATERNITY',
            'PROTECTED_CHARACTERISTIC_RACE',
            'PROTECTED_CHARACTERISTIC_RELIGION_OR_BELIEF',
            'PROTECTED_CHARACTERISTIC_SEX',
            'PROTECTED_CHARACTERISTIC_SEXUAL_ORIENTATION',
            'AI_BIAS_RISK_ASSESSMENT',
            'EQUALITY_IMPACT_ASSESSMENT',
            'INDIRECT_DISCRIMINATION_INDICATOR',
            'DISPARATE_IMPACT_TEST_RESULT',
            'PROTECTED_CHARACTERISTIC_DECISION_AGAINST',
            'CREDENTIALS',
        ],
        categoryActions: {
            PROTECTED_CHARACTERISTIC_AGE: 'WARN',
            PROTECTED_CHARACTERISTIC_DISABILITY: 'WARN',
            PROTECTED_CHARACTERISTIC_GENDER_REASSIGNMENT: 'WARN',
            PROTECTED_CHARACTERISTIC_MARRIAGE_CIVIL_PARTNERSHIP: 'WARN',
            PROTECTED_CHARACTERISTIC_PREGNANCY_MATERNITY: 'WARN',
            PROTECTED_CHARACTERISTIC_RACE: 'WARN',
            PROTECTED_CHARACTERISTIC_RELIGION_OR_BELIEF: 'WARN',
            PROTECTED_CHARACTERISTIC_SEX: 'WARN',
            PROTECTED_CHARACTERISTIC_SEXUAL_ORIENTATION: 'WARN',
            AI_BIAS_RISK_ASSESSMENT: 'WARN',
            EQUALITY_IMPACT_ASSESSMENT: 'WARN',
            INDIRECT_DISCRIMINATION_INDICATOR: 'WARN',
            DISPARATE_IMPACT_TEST_RESULT: 'BLOCK',
            PROTECTED_CHARACTERISTIC_DECISION_AGAINST: 'WARN',
            CREDENTIALS: 'BLOCK',
        },
        encryptionRequired: true,
        encryptionStandard: 'AES-256-GCM',
        // Protected-characteristic data overlaps UK GDPR Art. 9 special categories
        minimumClassification: 'RESTRICTED',
    },
    retentionPolicy: {
        // 7 years — UK public-sector record-keeping norm.
        // Cabinet Office retention schedule; Public Records Act 1958.
        // EIA documents, disparate-impact test results, bias risk assessments.
        auditLogRetentionDays: 2555, // 7 years
        sessionRetentionDays: 2555,
        incidentRetentionDays: 2555,
        reference: 'Cabinet Office Guidance on Records Management — 7-year public-sector retention; Public Records Act 1958; ICO-EHRC joint guidance (2024) — AI bias audit evidence retention; Employment Tribunal limitation periods (Equality Act 2010 s.123 — 3 months from act, extendable to 6 months for ACAS early conciliation)',
        forceDelete: false,
        requiresLegalHoldSupport: true,
        sovereignty: ['gb', 'eu'],
    },
    incidentPolicy: {
        // EHRC has no mandatory 72h notification window analogous to ICO breach notification.
        // Using 72h as baseline, consistent with UK GDPR Art. 33 (parallel data breach when
        // protected-characteristic data involved) and EHRC investigation trigger norms.
        notificationDeadlineHours: 72,
        reference: 'UK GDPR Art. 33 — 72-hour ICO notification (when protected-characteristic data is also personal data involved in breach); EHRC Statutory Code of Practice — reporting obligations; ICO-EHRC joint guidance (2024) — incident response for AI bias events',
        requiredRecipients: ['data-protection-officer', 'equality-lead', 'chief-information-security-officer'],
        formalNotificationRequired: true,
    },
    validators: [
        // Protected-characteristic classifiers (9)
        {
            id: 'uk-equality-ai-bias-age-classifier-active',
            description: 'Age (s.5) classifier active: AI inputs and outputs scanned for age-based protected characteristic data — date of birth, age bands, age filters.',
            reference: 'Equality Act 2010 s.5 — age; ICO-EHRC joint guidance (2024) — age-based AI bias risk',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-disability-classifier-active',
            description: 'Disability (s.6) classifier active: AI inputs and outputs scanned for disability flags, impairment data, reasonable-adjustment records.',
            reference: 'Equality Act 2010 s.6 + ss.20–22 reasonable adjustments; ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-gender-reassignment-classifier-active',
            description: 'Gender reassignment (s.7) classifier active: AI inputs and outputs scanned for gender-transition status, GRC data.',
            reference: 'Equality Act 2010 s.7 — gender reassignment; ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-marriage-civil-partnership-classifier-active',
            description: 'Marriage and civil partnership (s.8) classifier active: AI inputs scanned for marital-status filters.',
            reference: 'Equality Act 2010 s.8 — marriage and civil partnership; ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'MEDIUM',
        },
        {
            id: 'uk-equality-ai-bias-pregnancy-maternity-classifier-active',
            description: 'Pregnancy and maternity (ss.17–18) classifier active: AI inputs scanned for pregnancy status, maternity leave flags.',
            reference: 'Equality Act 2010 ss.17–18 — pregnancy and maternity; ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-race-classifier-active',
            description: 'Race (s.9) classifier active: AI inputs and outputs scanned for race, ethnicity, nationality, colour, national-origin proxy signals.',
            reference: 'Equality Act 2010 s.9 — race; ICO-EHRC joint guidance (2024) — race/ethnicity proxy signals',
            check: 'data_classifier_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-religion-belief-classifier-active',
            description: 'Religion or belief (s.10) classifier active: AI inputs scanned for religious affiliation, faith proxies, philosophical-belief signals.',
            reference: 'Equality Act 2010 s.10 — religion or belief (including non-belief); ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-sex-classifier-active',
            description: 'Sex (s.11) classifier active: AI inputs and outputs scanned for sex-based scoring, gender-based pricing, actuarial sex factors.',
            reference: 'Equality Act 2010 s.11 — sex; ICO-EHRC joint guidance (2024) — sex-based disparate impact',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-sexual-orientation-classifier-active',
            description: 'Sexual orientation (s.12) classifier active: AI inputs scanned for sexual-orientation inference, proxy-signal detection.',
            reference: 'Equality Act 2010 s.12 — sexual orientation; ICO-EHRC joint guidance (2024)',
            check: 'data_classifier_active',
            failSeverity: 'HIGH',
        },
        // AI-bias-specific validators
        {
            id: 'uk-equality-ai-bias-disparate-impact-gate',
            description: 'Disparate-impact gate active: AI decisions with disparate-impact ratio below 80% (4/5ths rule) for any protected characteristic are BLOCKED pending T2 human review. Equality Act 2010 s.19 indirect discrimination — a provision, criterion or practice (PCP) that puts a protected group at a particular disadvantage.',
            reference: 'Equality Act 2010 s.19 — indirect discrimination; ICO-EHRC joint guidance (2024) — 80% (4/5ths) rule; EHRC employment code §4.11',
            check: 'uk_equality_ai_bias_disparate_impact_gate',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-eia-public-sector-gate',
            description: 'EIA gate active: mandatory Equality Impact Assessment (EIA) completed and approved in attestation-manager before any public-sector AI system deployment. Enforces Public Sector Equality Duty (s.149) due-regard obligation.',
            reference: 'Equality Act 2010 s.149 — Public Sector Equality Duty (PSED); ICO-EHRC joint guidance (2024) — mandatory EIA before public-sector AI deployment',
            check: 'uk_equality_ai_bias_eia_public_sector_gate',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-t2-review-high-bias-risk',
            description: 'T2 human review required for any AI decision flagged as high-bias-risk (protected-characteristic decision with disparate-impact ratio outside 80% rule). Routes to approval-queue with equality specialist tier.',
            reference: 'ICO-EHRC joint guidance (2024) — human review gate for high-bias-risk AI decisions; Equality Act 2010 s.149 PSED due-regard duty',
            check: 'approval_queue_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-bias-monitor-active',
            description: 'AI bias monitor active: real-time monitoring of AI decision rates across all nine protected characteristics. Detects disparate-impact patterns as they accumulate in the decision pipeline.',
            reference: 'ICO-EHRC joint guidance (2024) — ongoing AI bias monitoring obligation; Equality Act 2010 s.149 PSED — ongoing monitoring of equality impact',
            check: 'bias_monitor_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-audit-trail',
            description: 'Tamper-evident audit trail covering protected-characteristic classifications, disparate-impact test results, EIA decisions, and T2 review outcomes. Required for EHRC investigation evidence and Employment Tribunal disclosure.',
            reference: 'EHRC investigatory powers (Equality Act 2006 s.20); Employment Tribunal disclosure; ICO-EHRC joint guidance (2024) — record-keeping',
            check: 'audit_trail_exists',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-retention-7-year',
            description: 'Seven-year retention enforced for all EIA documents, disparate-impact test results, and protected-characteristic AI decision records. Matches UK public-sector record-keeping norms (Cabinet Office schedule, Public Records Act 1958).',
            reference: 'Cabinet Office Guidance on Records Management — 7-year public-sector retention; Public Records Act 1958; ICO-EHRC joint guidance (2024)',
            check: 'retention_policy_active',
            failSeverity: 'HIGH',
        },
        {
            id: 'uk-equality-ai-bias-encryption-protected-data',
            description: 'Protected-characteristic data and EIA documents encrypted at rest and in transit (AES-256-GCM / TLS 1.2+). Locked Invariant 7: strictest tenant scoping + RLS for protected-characteristic data.',
            reference: 'UK GDPR Art. 32 — security; Locked Invariant 7 (protected-characteristic data strictest tenant scoping + RLS); ICO security guidance for special categories',
            check: 'encryption_active',
            failSeverity: 'CRITICAL',
        },
        {
            id: 'uk-equality-ai-bias-transparency-active',
            description: 'Transparency disclosure active for AI decisions involving protected characteristics or disparate-impact flags. Enables affected persons to exercise contestability rights.',
            reference: 'ICO-EHRC joint guidance (2024) — transparency for AI decisions affecting protected groups; Equality Act 2010 s.149 PSED accessible equality information',
            check: 'transparency_active',
            failSeverity: 'HIGH',
        },
    ],
};
//# sourceMappingURL=uk-equality-act-ai-bias.js.map