Skip to content

feat(compliance): wire EEO report to real data from migration 305 #535

Closed

Description

@thinkclay

packages/scf-core/features/office/compliance/EEOReportScreen.tsx renders hardcoded constants. Migration 305_privacy_eeo_project_hiring.sql provides the real fields.

This is the follow-up to the issue that adds a "sample data" banner — that one removes the risk, this one removes the mock.

Work

  1. Build the EEO aggregation query over real applications and hires, grouped by job group.
  2. Wire EEOReportScreen to it; delete MOCK_JOB_GROUPS, GENDER_SUMMARY, VETERAN_SUMMARY.
  3. Verify the four-fifths-rule adverse-impact math (already implemented at line 219) against a known dataset.
  4. Ensure withdrawn applications are not counted as rejections (see the linked withdrawn issue) — this changes adverse-impact ratios.
  5. Remove the sample-data banner only once the numbers are real.

Depends on

  • Employer read path (needs org-scoped application data)
  • withdrawn vs rejected resolution (changes the math)

Acceptance

  • Report reflects actual applications and hires for the org.
  • Adverse-impact ratios verified against a fixture with known expected output.
  • No MOCK_ constants remain in the file.

Activity

  1. thinkclay commented on Aug 11, 2026

    @thinkclay
    ContributorAuthor

    Starting this surfaced two blockers. Neither is a reason to abandon it, but together they make this a feature rather than the wiring task the description implies.

    1. The tables cannot be read by anything

    Migration 305 created all seven of its tables with RLS enabled and zero GRANT statements. A missing GRANT fails before RLS is evaluated, so even service_role gets permission denied:

    core.eeo_self_identification    403
    core.eeo_reports                403
    (and the five privacy/hiring-project tables alongside them)
    

    Fixed in #558. Same class as 332_api_keys_grants and 335_scheduling_grants.

    2. Nothing collects EEO data

    grep -rn eeo_self_identification across packages/ and apps/ returns one hit — the generated types.ts. There is:

    • no self-identification form anywhere in the app,
    • no endpoint that writes the table,
    • no seed data.

    So with grants fixed, the table is still empty, and wiring the report to it produces an all-zero report.

    On a compliance screen, that is worse than the current labelled sample data. An adverse-impact panel showing 0 flags detected reads as "we checked and found no disparity". The truth would be "nobody has been asked". Those are very different statements to put in front of an auditor.

    The real shape of the work

    1. Grants — fix(db): grant the seven tables migration 305 created #558. Prerequisite; nothing else is possible without it.
    2. Collection — a voluntary self-identification step at application time, writing eeo_self_identification. This is the legally-sensitive part: EEOC/OFCCP have expectations about wording, voluntariness, the availability of "decline to state", and the separation of this data from hiring decisions. It should not be drafted by inference from a schema.
    3. Aggregation — a server-side endpoint computing counts by job group under service_role, returning aggregates only. 305's RLS correctly forbids employers reading individual rows, and that must not be widened.
    4. Wire the report, and have it distinguish no data collected from no adverse impact — an explicit empty state, not a zero.
    5. Remove the sample-data banner only at that point.

    Also unresolved: the mock groups applications by SOC code (47-2061, 11-9021). Nothing in the schema carries an occupation code on a job, so "job group" needs defining before aggregation can be written.

    Recommendation

    Land #558 now. Treat (2) as its own issue with product/legal input — I can build the form and endpoint once the wording is settled, but I should not invent the wording. (3) and (4) are then straightforward and I can take them.

    The banner from #524 stays in place throughout, which is the right default: the screen keeps saying it is not a compliance record until it is one.

  2. thinkclay commented on Aug 11, 2026

    @thinkclay
    ContributorAuthor

    Unblocked on all three environments. Migration 343 is applied and recorded on dev, preview and prod as of today.

    Before this, all seven tables migration 305 created had zero table-level GRANTs, so every access — including service_role — returned 42501 permission denied. They had been unreachable since creation, in production as well as locally. This issue could not have been implemented against a real database.

    Verified per environment rather than assumed:

    • All seven tables return 200 to service_role over PostgREST; each returned 42501 before.
    • anon is still denied on eeo_self_identification, eeo_reports and privacy_data_requests — it was granted nothing, deliberately.
    • RLS is still enabled on 7/7 in all three.
    • The grant fingerprint (72 rows across the three roles) is byte-identical on dev, preview and prod, so there is no environment drift to discover later.

    The EEO asymmetry from 305's policy is preserved intentionally: authenticated has SELECT, INSERT on eeo_self_identification and no UPDATE or DELETE. A voluntary self-identification is an audit record, not an editable field, and the RLS policy is auth.uid() = user_id, so an applicant reaches only their own row. Employers must never read individual rows — only aggregates computed server-side under service_role. Whatever this issue builds should keep that shape.

    Note for whoever picks this up: the wording decision on the self-ID form is still open and is a product/legal call, not an implementation detail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions