ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/modules/eeo/service.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/eeo/service.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision09015496d565a172bcaa15cfe9a8e4b072b13df0
Branchworkstream-b-screenmatch
Path or archive memberinternal/modules/eeo/service.go
Original SHA-256f1c4d15f38b442e31e0539a2513fac9007ab8057eea2d58dfe5e4e958c6ae2ff
Git blob SHA3e0eabf405e209118aed42c53881564c851c8abb
Reading-copy SHA-256f1c4d15f38b442e31e0539a2513fac9007ab8057eea2d58dfe5e4e958c6ae2ff

Original source ↗

Every recorded occurrence

These 57 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-b-screenmatch09015496d565a172bcaa15cfe9a8e4b072b13df0Open original
Janady13/missionmatch / internal/modules/eeo/service.gomaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-d-missionmatch3be46ba89edb737182075a2b320509b42dc916f8Open original
Janady13/missionmatch / internal/modules/eeo/service.gom5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-e-dataflow-deploy433815a042f9741411e60fa553fe72143e9b10dbOpen original
Janady13/missionmatch / internal/modules/eeo/service.gow3-ai-staffing-recommendations43d56387270ef4da4cabd794d97ca6a49909bc7dOpen original
Janady13/missionmatch / internal/modules/eeo/service.gows3-clearance4b8e7ce594c068621867f9c9deed0ec64ae6c553Open original
Janady13/missionmatch / internal/modules/eeo/service.gocollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-c-slatematch5cd60c918301b46ecd6ed3e03e20c395da0062e2Open original
Janady13/missionmatch / internal/modules/eeo/service.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/eeo/service.gows7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / internal/modules/eeo/service.gows6-retrieval6c56e29231ec05735927fa265c97d517499dfeafOpen original
Janady13/missionmatch / internal/modules/eeo/service.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/modules/eeo/service.goai-brain-liveaac32fc49c878cc5bca099459307611562d0bac1Open original
Janady13/missionmatch / internal/modules/eeo/service.gographrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / internal/modules/eeo/service.gows1-ontology-syncb596f449a32a1016fbd403c36505cc00a1ac9ee6Open original
Janady13/missionmatch / internal/modules/eeo/service.gotime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / internal/modules/eeo/service.goruthless-debug-sweepb7d742f8f032984be3817efffa3eb8b13b651c1fOpen original
Janady13/missionmatch / internal/modules/eeo/service.gomag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / internal/modules/eeo/service.gocapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original
Janady13/missionmatch / internal/modules/eeo/service.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/modules/eeo/service.gows8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / internal/modules/eeo/service.gophase2-eval-fairnessd361af254701975fe239927656ababb56374655eOpen original
Janady13/missionmatch / internal/modules/eeo/service.gophase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-a-shared-coree0de03ac3a1ec826bd15d0e048e3b02baa23eeffOpen original
Janady13/missionmatch / internal/modules/eeo/service.gows2-alias-relationshipe4dada4601c6eb101830f9d223a9655dfa120616Open original
Janady13/missionmatch / internal/modules/eeo/service.gopresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / internal/modules/eeo/service.gows9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / internal/modules/eeo/service.govendor-intelligencefe9796a19c261951d3f2565206c0c1b5ac294465Open original
Janady13/missionmatch / internal/modules/eeo/service.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/modules/eeo/service.gocollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / internal/modules/eeo/service.gows6-retrieval6c56e29231ec05735927fa265c97d517499dfeafOpen original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-a-shared-coree0de03ac3a1ec826bd15d0e048e3b02baa23eeffOpen original
Janady13/missionmatch / internal/modules/eeo/service.gom5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-c-slatematch5cd60c918301b46ecd6ed3e03e20c395da0062e2Open original
Janady13/missionmatch / internal/modules/eeo/service.gows1-ontology-syncb596f449a32a1016fbd403c36505cc00a1ac9ee6Open original
Janady13/missionmatch / internal/modules/eeo/service.gomaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / internal/modules/eeo/service.gows8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / internal/modules/eeo/service.gow3-ai-staffing-recommendations43d56387270ef4da4cabd794d97ca6a49909bc7dOpen original
Janady13/missionmatch / internal/modules/eeo/service.gomag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / internal/modules/eeo/service.gows3-clearance4b8e7ce594c068621867f9c9deed0ec64ae6c553Open original
Janady13/missionmatch / internal/modules/eeo/service.gophase2-eval-fairnessd361af254701975fe239927656ababb56374655eOpen original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-e-dataflow-deploy433815a042f9741411e60fa553fe72143e9b10dbOpen original
Janady13/missionmatch / internal/modules/eeo/service.goruthless-debug-sweepb7d742f8f032984be3817efffa3eb8b13b651c1fOpen original
Janady13/missionmatch / internal/modules/eeo/service.gotime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / internal/modules/eeo/service.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/eeo/service.gographrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / internal/modules/eeo/service.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/modules/eeo/service.gows9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / internal/modules/eeo/service.gows2-alias-relationshipe4dada4601c6eb101830f9d223a9655dfa120616Open original
Janady13/missionmatch / internal/modules/eeo/service.gopresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-b-screenmatch09015496d565a172bcaa15cfe9a8e4b072b13df0Open original
Janady13/missionmatch / internal/modules/eeo/service.gows7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / internal/modules/eeo/service.goai-brain-liveaac32fc49c878cc5bca099459307611562d0bac1Open original
Janady13/missionmatch / internal/modules/eeo/service.goworkstream-d-missionmatch3be46ba89edb737182075a2b320509b42dc916f8Open original
Janady13/missionmatch / internal/modules/eeo/service.gophase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / internal/modules/eeo/service.gocapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original

Recovered source transcript

// Package eeo computes adverse impact reporting over the segregated eeo schema. It is the ONLY code // path that reads demographic data, and it runs exclusively on the compliance database role through a // separate pool. The application and scoring roles have no grant on the eeo schema, so demographics // can never reach a score; they flow one way, into this report. The platform PRODUCES the four fifths // data for the deploying employer's independent audit; it does not itself constitute the audit. package eeo import ( "context" "errors" "time" "github.com/jackc/pgx/v5" "github.com/shopspring/decimal" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // ErrNoCompliance is returned when no compliance pool is configured, so adverse impact reporting is // unavailable (the endpoint returns 503 rather than silently producing an empty, misleading report). var ErrNoCompliance = errors.New("eeo: compliance database not configured") // fourFifths is the 0.80 impact ratio threshold (the EEOC Uniform Guidelines four fifths rule). A // group whose selection rate divided by the highest group rate falls below this is flagged. var fourFifths = decimal.RequireFromString("0.80") // Service computes adverse impact over the compliance pool. The pool authenticates as the compliance // role and is the only pool with eeo access. Every query runs inside a tenant transaction so RLS // scopes both the eeo and the outcome tables to the caller's org. type Service struct{ compliance *tenant.DB } // NewService builds the service. compliance may be nil (then AdverseImpact returns ErrNoCompliance). func NewService(compliance *tenant.DB) *Service { return &Service{compliance: compliance} } // candRow is one candidate's demographic group and whether they were selected at a stage. type candRow struct { gender string // display label, "unknown" when not provided race string genderUnknown bool // true only when the value is genuinely missing, not a real value named "unknown" raceUnknown bool selected bool } // AdverseImpact builds the report for the caller's org: a selection stage analysis over recorded slate // decisions and a screening stage analysis over served scores, each with four fifths impact ratios. func (s *Service) AdverseImpact(ctx context.Context, now time.Time) (Report, error) { if s.compliance == nil || s.compliance.Pool == nil { return Report{}, ErrNoCompliance } rep := Report{ GeneratedAt: now.UTC().Format(time.RFC3339), Source: "Voluntary self identification demographic data in the segregated eeo schema, joined to recorded AEDT outcomes. Read by the compliance role only.", Method: "Four fifths rule (EEOC Uniform Guidelines). Selection rate per demographic group divided by the highest group rate. A ratio below 0.80 is flagged. The unknown category is reported as a count and excluded from the ratio comparison. The platform supplies this data for an independent audit run by the deploying employer.", } err := s.compliance.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { sel, e := s.stageRows(ctx, tx, selectionQuery) if e != nil { return e } scr, e := s.stageRows(ctx, tx, screeningQuery) if e != nil { return e } from, to, e := dateRange(ctx, tx) if e != nil { return e } selNoDemo, e := countQuery(ctx, tx, selectionNoDemoQuery) if e != nil { return e } scrNoDemo, e := countQuery(ctx, tx, screeningNoDemoQuery) if e != nil { return e } rep.DataFrom, rep.DataTo = from, to rep.Selection = analyze("selection (recorded slate decisions)", sel, selNoDemo) rep.Screening = analyze("screening (served scores)", scr, scrNoDemo) return nil }) if err != nil { return Report{}, err } return rep, nil } func (s *Service) stageRows(ctx context.Context, tx pgx.Tx, query string) ([]candRow, error) { rows, err := tx.Query(ctx, query) if err != nil { return nil, err } defer rows.Close() var out []candRow for rows.Next() { var r candRow if err := rows.Scan(&r.gender, &r.race, &r.genderUnknown, &r.raceUnknown, &r.selected); err != nil { return nil, err } out = append(out, r) } return out, rows.Err() } func countQuery(ctx context.Context, tx pgx.Tx, query string) (int, error) { var n int err := tx.QueryRow(ctx, query).Scan(&n) return n, err } func dateRange(ctx context.Context, tx pgx.Tx) (string, string, error) { var from, to *time.Time err := tx.QueryRow(ctx, `SELECT min(created_at), max(created_at) FROM slate_members`).Scan(&from, &to) if err != nil { return "", "", err } fmtT := func(t *time.Time) string { if t == nil { return "" } return t.UTC().Format("2006-01-02") } return fmtT(from), fmtT(to), nil } // genderRace is the intersectional map key. Keying on a struct, not a delimiter joined string, means a // demographic value that happens to contain the display separator can never collide across cells. type genderRace struct{ gender, race string } // analyze rolls candidate rows into the three required cuts (by gender, by race or ethnicity, and the // intersectional cross tab) plus the unknown count. Whether a group is a known comparison group comes // from explicit per dimension flags carried out of SQL, never from overloading a sentinel string, so a // real demographic value of "unknown" is treated as known data. noDemographics is the count of decided // candidates with no consented demographics at all, surfaced to disclose consent coverage. func analyze(stage string, rows []candRow, noDemographics int) AnalysisSection { byGender := map[string]*tally{} byRace := map[string]*tally{} byBoth := map[genderRace]*tally{} unknown := 0 for _, r := range rows { add(byGender, r.gender, !r.genderUnknown, r.selected) add(byRace, r.race, !r.raceUnknown, r.selected) add(byBoth, genderRace{r.gender, r.race}, !r.genderUnknown && !r.raceUnknown, r.selected) if r.genderUnknown || r.raceUnknown { unknown++ } } bothStats := make([]groupStat, 0, len(byBoth)) for k, t := range byBoth { bothStats = append(bothStats, groupStat{label: k.gender + " / " + k.race, known: t.known, considered: t.considered, selected: t.selected}) } return AnalysisSection{ Stage: stage, TotalN: len(rows), UnknownCount: unknown, NoDemographicsCount: noDemographics, ByGender: impactRows(statsFrom(byGender)), ByRace: impactRows(statsFrom(byRace)), Intersectional: impactRows(bothStats), } } type tally struct { considered, selected int known bool } type groupStat struct { label string known bool considered, selected int } // add tallies a candidate into a group keyed by any comparable type (a gender or race label, or the // intersectional struct). func add[K comparable](m map[K]*tally, key K, known, selected bool) { t := m[key] if t == nil { t = &tally{known: known} m[key] = t } t.considered++ if selected { t.selected++ } } func statsFrom(m map[string]*tally) []groupStat { out := make([]groupStat, 0, len(m)) for label, t := range m { out = append(out, groupStat{label: label, known: t.known, considered: t.considered, selected: t.selected}) } return out } // impactRows computes the selection rate per group and the four fifths impact ratio against the // highest rate among KNOWN groups. A four fifths comparison needs at least two known groups: with // fewer, the lone known group would self reference to a passing 1.0000 and mask a real disparity, so // every known row emits n/a instead. Unknown groups are listed with their rate but are never the // reference and are never flagged, since the unknown bucket is a count, not a comparison group. func impactRows(groups []groupStat) []ImpactRow { ref := decimal.Zero knownCount := 0 rates := make([]decimal.Decimal, len(groups)) for i, g := range groups { r := decimal.Zero if g.considered > 0 { r = decimal.NewFromInt(int64(g.selected)).DivRound(decimal.NewFromInt(int64(g.considered)), 6) } rates[i] = r if g.known { knownCount++ if r.GreaterThan(ref) { ref = r } } } validRef := knownCount >= 2 && ref.GreaterThan(decimal.Zero) out := make([]ImpactRow, 0, len(groups)) for i, g := range groups { row := ImpactRow{Group: g.label, Considered: g.considered, Selected: g.selected, Rate: rates[i].StringFixed(4)} if g.known && validRef { ratio := rates[i].DivRound(ref, 6) row.ImpactRatio = ratio.StringFixed(4) row.Flagged = ratio.LessThan(fourFifths) } else { row.ImpactRatio = "n/a" } out = append(out, row) } sortRows(out) return out } // selectionQuery: the latest consented demographics per candidate joined to their recorded slate // decisions. A candidate is selected if approved on any slate. RLS scopes both tables to the org. const selectionQuery = ` WITH latest AS ( SELECT DISTINCT ON (candidate_id) candidate_id, COALESCE(NULLIF(gender, ''), 'unknown') AS gender, COALESCE(NULLIF(race_ethnicity, ''), 'unknown') AS race, (NULLIF(gender, '') IS NULL) AS gender_unknown, (NULLIF(race_ethnicity, '') IS NULL) AS race_unknown FROM eeo.candidate_demographics WHERE consent_given = true ORDER BY candidate_id, collected_at DESC ) SELECT l.gender, l.race, l.gender_unknown, l.race_unknown, bool_or(sm.decision = 'approved') AS selected FROM latest l JOIN slate_members sm ON sm.candidate_id = l.candidate_id GROUP BY l.candidate_id, l.gender, l.race, l.gender_unknown, l.race_unknown` // selectionNoDemoQuery counts decided candidates with no consented demographics, so the report // discloses how many recorded decisions are outside the four fifths analysis for want of self ID. const selectionNoDemoQuery = ` SELECT count(DISTINCT sm.candidate_id) FROM slate_members sm WHERE sm.decision IN ('approved', 'rejected') AND NOT EXISTS ( SELECT 1 FROM eeo.candidate_demographics d WHERE d.candidate_id = sm.candidate_id AND d.consent_given = true)` // screeningQuery: the latest consented demographics joined to served score events. A candidate is // screened in if any served score was band green. audit_logs is outside RLS, so the org filter is // explicit on the GUC. const screeningQuery = ` WITH latest AS ( SELECT DISTINCT ON (candidate_id) candidate_id, COALESCE(NULLIF(gender, ''), 'unknown') AS gender, COALESCE(NULLIF(race_ethnicity, ''), 'unknown') AS race, (NULLIF(gender, '') IS NULL) AS gender_unknown, (NULLIF(race_ethnicity, '') IS NULL) AS race_unknown FROM eeo.candidate_demographics WHERE consent_given = true ORDER BY candidate_id, collected_at DESC ), served AS ( SELECT (entity_id)::uuid AS candidate_id, bool_or((new_values->>'band') = 'green') AS screened_in FROM audit_logs WHERE action = 'aedt.score.served' AND entity_type = 'candidate' AND organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid AND entity_id IS NOT NULL GROUP BY entity_id ) SELECT l.gender, l.race, l.gender_unknown, l.race_unknown, bool_or(s.screened_in) AS selected FROM latest l JOIN served s ON s.candidate_id = l.candidate_id GROUP BY l.candidate_id, l.gender, l.race, l.gender_unknown, l.race_unknown` // screeningNoDemoQuery counts candidates with a served score event but no consented demographics. const screeningNoDemoQuery = ` SELECT count(DISTINCT (entity_id)::uuid) FROM audit_logs a WHERE a.action = 'aedt.score.served' AND a.entity_type = 'candidate' AND a.entity_id IS NOT NULL AND a.organization_id = NULLIF(current_setting('app.current_org_id', true), '')::uuid AND NOT EXISTS ( SELECT 1 FROM eeo.candidate_demographics d WHERE d.candidate_id = (a.entity_id)::uuid AND d.consent_given = true)`

Search equations, builds, manuscript text, and recovered sources.