Skip to content

feat(compliance): wire the EEO report to real data - #567

Merged
thinkclay merged 1 commit into
mainfrom
claude/eeo-report
Aug 11, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/eeo-report

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Closes #535. Adds GET /v1/employer/eeo-report backed by a pure, unit-tested aggregation module, and wires EEOReportScreen to it. Every MOCK_ constant is gone. SDK: Scaffald/sdk#18, merged.

Privacy shape, because it drove the design

core.eeo_self_identification holds protected-class data. Migration 305's policy is auth.uid() = user_id; migration 343 withheld UPDATE/DELETE from authenticated because a voluntary self-identification is an audit record.

Employers get counts, never rows. There is deliberately no endpoint returning an individual record and no filter that could narrow a cohort to one person. Cells below a minimum size are suppressed — an aggregate of one is an individual record, which is exactly what 343 was written to prevent.

The threshold is MIN_CELL_SIZE = 5, a common floor for published EEO tabulations. This is a default I chose, not a legal determination — flagging it explicitly because it is the kind of number that should be confirmed rather than inherited from a PR.

Four arithmetic bugs in what this replaces

  1. NaN% ✓ Pass. Adverse-impact ratios divided by the highest selection rate unconditionally. With nobody hired that is 0/0, and NaN < 0.8 is false — so an organisation that had hired no one rendered a passing badge on a document people file. impactRatio is now number | null; null renders as an em dash.
  2. The overall hire-rate tile divided the same way: NaN% rate.
  3. The flag tile counted only the three gender ratios, so a flag against an ethnicity — the dimension an EEO-1 exists for — never reached the summary.
  4. The ethnicity table had no four-fifths column at all. The ratio was computed and never displayed, so nobody could see which group was flagged. Found because a test asserted a flag badge that turned out not to render anywhere.

Correctness decisions

  • Withdrawn leaves the denominator and is reported separately (fix(ats): withdrawn applications are displayed as rejected, corrupting funnel and EEO counts #533, acceptance point 4). A withdrawal is not a rejection; counting one as such invents adverse impact that did not occur. There is a test showing the ratio it changes.
  • Stage counts derive from history, so someone rejected after a final interview still counts as having interviewed. Reading current status alone undercounts badly.
  • "Declined to State" appears in every dimension. The mock dropped it, so the tables did not add up to the applicant count.
  • Uncategorised requisitions roll into a visible bucket rather than vanishing — the fix is to categorise the jobs, which the employer can only know to do if the bucket is visible.
  • A suppressed group still sets the reference rate. Excluding it would let a small, highly-selected group hide and flatter every other ratio.

Coverage is stated on screen

Self-identification is voluntary. The screen now says "N of M applicants self-identified", because a ratio computed over 4 of 900 applicants is not evidence of anything and the reader needs that before acting on any number.

Verification

  • 13 Deno tests over a hand-computed fixture, every expected value written out in a comment above the assertion (acceptance point 3).
  • 13 screen tests.
  • Mutation-checked on both sides. Counting withdrawn in the denominator, deriving stages from current status only, dividing unconditionally, excluding suppressed groups from the reference rate, rendering null as 0%, and counting flags from gender only each turn a test red. My first pass at two of the screen assertions did not catch their mutations; I extracted countAdverseImpactFlags and tightened the null-ratio assertion until they did.
  • Driven end to end against a live local database. A 5-row fixture reproduced exactly: white 2 applicants / 2 interviewed / 1 offer, black 3 / 0 / 0, both suppressed, all ratios null because nobody was hired. Cross-organisation probe 403s. Fixture deleted afterwards.
  • Office suite 66 passed / 0 failed. deno lint and deno fmt --check clean.

Two things this does not do

Export stays disabled. The figures are real now, but there is still no export implementation — that button never had an onPress. Leaving it enabled would give a screen whose purpose is producing a filing a control that silently does nothing.

The report will read zero in every environment, because nothing collects self-identification yet: core.eeo_self_identification has 0 rows on local, dev, preview and prod. That is the honest result and the screen says so explicitly rather than implying a clean bill of health. The collection form is blocked on the self-ID wording, which is a product/legal call and still open.

Note migration 343 had not been applied to the local database (only dev/preview/prod), so these tables 403'd locally until I applied it — worth knowing for anyone running this branch.

Closes #535. The screen rendered hardcoded constants — invented applicant
counts, invented selection rates, invented adverse-impact ratios — on a
page that presents itself as a compliance artifact.

Adds GET /v1/employer/eeo-report, backed by a pure aggregation module, and
wires the screen to it. Every MOCK_ constant is gone.

Privacy shape first, because it drove the design. core.eeo_self_
identification holds protected-class data; migration 305's policy is
`auth.uid() = user_id` and 343 withheld UPDATE/DELETE from authenticated
because a self-identification is an audit record. Employers get counts,
never rows. There is deliberately no endpoint returning an individual
record and no filter that could narrow a cohort to one person. Cells below
a minimum size are suppressed — an aggregate of one *is* an individual
record, which is the thing 343 exists to prevent.

Four bugs found in the arithmetic while replacing it:

- Adverse-impact ratios divided by the highest selection rate
  unconditionally. With nobody hired that is 0/0, and `NaN < 0.8` is false,
  so the badge rendered "NaN% ✓ Pass" — a false all-clear on a filing.
  `impactRatio` is now `number | null`, and null renders as an em dash.
- The overall hire-rate tile divided the same way: "NaN% rate".
- The adverse-impact flag tile counted only the three gender ratios, so a
  flag against an ethnicity — the dimension an EEO-1 exists for — never
  reached the summary.
- The ethnicity table had no four-fifths column at all. The ratio was
  computed and never shown, so nobody could see which group was flagged.

Also: withdrawn applicants leave the selection-rate denominator and are
reported separately (#533). A withdrawal is not a rejection, and counting
one as such invents adverse impact that did not occur. "Declined to State"
now appears in every dimension — the mock dropped it, so the tables did
not add up to the applicant count. Uncategorised requisitions roll into a
visible bucket rather than vanishing. Stage counts derive from history, so
someone rejected after interviewing still counts as interviewed.

The screen now states its coverage: how many applicants self-identified
out of the total. Self-identification is voluntary, and a ratio over 4 of
900 applicants is not evidence of anything.

Verification: 13 Deno tests over a hand-computed fixture, every expected
value written out in a comment (acceptance point 3). 13 screen tests.
Mutation-checked on both sides — counting withdrawn in the denominator,
deriving stages from current status only, dividing unconditionally,
excluding suppressed groups from the reference rate, rendering null as 0%,
and counting flags from gender only each turn a test red. Driven end to
end against a live local database: a 5-row fixture reproduced exactly, and
a cross-organisation probe 403s.

Export stays disabled. The figures are real now, but there is still no
export implementation — that button never had an onPress.
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit 40634b0 into main Aug 11, 2026
11 of 12 checks passed
@thinkclay
thinkclay deleted the claude/eeo-report branch August 11, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant