Repository navigation
feat(backend): Ohio outside-group funders/industries (PR 8) - #546
Conversation
Adds the funder leg of Ohio campaign finance (ohio_plan.md #3): - ohioOutsideGroupContributionAggregator: maryland pattern (donor + industry), MASTER_KEY matching, RPT_YEAR cycle window, pinned donor vocabulary (31-A/31-E/31-J-1; 31-A-2 + 31-CC known-excluded, unknowns fail closed), organization donors from the explicit NON_INDIVIDUAL column, and a pinned non-entity filter for union-PAC dues descriptions. - batchSync: one filtered pass over PAC_CON/PPC_CON per year for the 31-U spender committees, sliced per candidate; a funder artifact failure only disables this leg (stored breakdowns preserved). - sync: maryland industry enrichment (rules + cached/manual DB rows, no AI classifier by default), classification rows persisted so the manual industry-label queue picks unresolved donors up; committee-label queue needed no new code. Real-data smoke over the cached 2026 cycle: 1,290 filtered rows, 0 unknown forms, 6 org donors, 1,218 individuals skipped, 4 dues descriptions rejected; full local batch run 25/25 with PR 7's exact direct totals and the stale bundle correctly disabling the outside and funder legs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe Ohio finance pipeline now ingests PAC and party contributions for outside-group funder aggregation. Candidate sync enriches funder breakdowns with industry classifications, preserves unavailable data, removes stale empty results, and reports processing diagnostics. ChangesOhio outside-group funders
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant OhioSoSArtifacts
participant BatchSync
participant FunderAggregator
participant CandidateSync
participant SnapshotStore
OhioSoSArtifacts->>BatchSync: provide PAC and party contribution artifacts
BatchSync->>FunderAggregator: pass filtered 31-U contribution rows
FunderAggregator->>BatchSync: return funder breakdowns and row counts
BatchSync->>CandidateSync: provide outside finance and funder data
CandidateSync->>SnapshotStore: persist enriched outside breakdowns
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ping, de-binary the aggregator - The funder aggregator no longer caps donor rows: the sync layer classifies EVERY donor, rebuilds industry totals from all of them, and only then caps the persisted donor display rows (outsideMaxDonorBreakdownsPerGroup, default 50). The old order rebuilt a >50-donor group's industries from just the top 50 donors. - Replace five literal NUL bytes in the aggregator's key helpers with textual escapes - Git treated the file as binary, hiding its whole diff from review. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/src/pipeline/ohioFinance/ohioOutsideGroupContributionAggregator.ts`:
- Around line 270-275: Update the row validation condition in the Ohio
outside-group contribution aggregator to reject non-finite and fractional
amountCents values, while preserving the existing positive-value requirement.
Also reject non-finite reportYear values before applying the
cycleStartYear/electionYear bounds so every invalid row increments
unusableRowCount.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0f0afdd4-f07a-4b9d-b63c-c8c2c3192642
📒 Files selected for processing (5)
backend/src/pipeline/ohioFinance/ohioCandidateFinanceSync.tsbackend/src/pipeline/ohioFinance/ohioOutsideGroupContributionAggregator.tsbackend/tests/pipeline/ohioFinance/ohioCandidateFinanceSync.test.tsbackend/tests/pipeline/ohioFinance/ohioOutsideGroupContributionAggregator.test.tsohio_plan.md
🚧 Files skipped from review as they are similar to previous changes (2)
- backend/tests/pipeline/ohioFinance/ohioOutsideGroupContributionAggregator.test.ts
- ohio_plan.md
Eighth PR of the Ohio campaign-finance plan (
ohio_plan.md, scope item #3): who funds the committees behind a candidate's outside spending — donor + industry breakdowns, wired into the existing committee-label / industry-label manual queues. Matrix row: standard donor/industry outside breakdowns (maryland/tennessee pattern).What's here
ohioOutsideGroupContributionAggregator.ts— maryland pattern, adapted to Ohio bulk rows:RPT_YEAR ∈ {Y−1, Y}.NON_INDIVIDUALcolumn — no name heuristics, individuals never become labels.NON_INDIVIDUAL("CONTRIBUTION FROM DUES MONEY" $76K, "TRANSFER OF MEMBERSHIP DUES" $855K). A value is rejected (counted) only when it both starts like a generic description and carries dues/transfer context — entity-bearing values ("OHIO AFL-CIO/DUES MONEY") keep their verbatim label.Batch sync — after a year's outside aggregation succeeds, one filtered pass over
PAC_CON_{Y-1,Y}+PPC_CON_{Y-1,Y}keeps only rows for 31-U spender committees, then slices per candidate. A funder artifact failure only disables this leg (fundersnull→ the writer keeps stored breakdown rows; year summary carriesfundersAvailable/fundersError) — the outside totals still sync. Candidate-committee 31-U spenders are documented as not covered (their receipts live in the ~90 MB CAC_CON files; no bundle-covered spender is one on the real 2026 files).Sync — maryland's industry enrichment verbatim: the aggregator's static industry rows are discarded and rebuilt from merged classification state (rules + cached DB rows + manual verdicts), so a manual industry label always wins, and every unresolved donor persists a
classification_source='unknown'row. No AI classifier is constructed by default.Queues: zero new code. The committee-label due list already reads Ohio outside groups through the merged read path (live since PR 7), and the industry-label due list reads exactly the
'unknown'classification rows this PR persists;OHIO_SOSwas already inFINANCE_SUMMARY_SOURCES.Verification
npm run typecheck+npm testgreen (6,332 passed; +14 new: 11 aggregator, 3 sync/batch).🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation