Skip to content

Add canonical federal voting analytics - #114

Open
capituwuistgoonsquad wants to merge 1 commit into
mainfrom
codex/federal-voting-analytics
Open

Add canonical federal voting analytics#114
capituwuistgoonsquad wants to merge 1 commit into
mainfrom
codex/federal-voting-analytics

Conversation

@capituwuistgoonsquad

@capituwuistgoonsquad capituwuistgoonsquad commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Outcome

Deliver the first complete Phase 7 analytics capability from the reviewed official House and Senate facts.

  • Add a live Federal voting analytics view with per-chamber/Congress coverage, participation, Yea/Nay, Present, and Not Voting summaries.
  • Rank canonical same-scope peers by exact shared Yea/Nay votes with a ten-vote minimum, without implying causation or endorsement.
  • Make every comparison inspectable through paginated agreement/difference records, official roll-call links, and bounded exact Congress.gov measure metadata.
  • Replace the legacy federal co-voting presentation in Connections with official alignment and direct evidence links. Keep retained state/historical co-voting in a visibly separate compatibility lane.

Data and security boundary

Migration 0038_canonical_federal_voting_analytics.sql installs one owner-only verified read model and three bounded SECURITY DEFINER RPCs. Browser roles receive function execution only; the internal view, provenance, roll-call, vote, measure, and link tables remain closed. The metric excludes Present and Not Voting, never reads legacy voting_records, and changes no scraper writer or source request budget.

Scraper preflight now requires the 0038 marker and all three RPCs so live schema drift fails closed.

Production rollout evidence

Migration 0038 is applied. Live anonymous-role validation covered representative House and Senate profiles:

  • summary category counts and participation rates reconciled with zero mismatches;
  • both rankings returned only exact same-chamber/Congress peers above the ten-vote floor, with zero count or rate mismatches;
  • 24 House and 39 Senate pair-evidence rows exactly matched their ranked agreement/difference totals;
  • browser execution grants were present, public execution was absent, and private-table/internal-view ACL violations were zero;
  • service-role zero-row preflight calls succeeded.

The optimized ranking path kept representative production probes below one second per chamber. No scraper run was needed because this is a read-only analytics/release slice.

Validation

  • npm run typecheck
  • npm run lint
  • PYTHONPATH=scraper python3 -m unittest discover -s scraper/tests -p 'test_*.py' — 389 passed
  • git diff --check
  • Local npm run build completed Next.js compilation plus its lint/type phase, then stopped at page-data collection because this workstation does not have the frontend's public Supabase build variables. Repository CI has the configured build environment and is the full static-export proof.

Greptile Summary

This change adds canonical federal voting analytics to profile voting and Connections views, including participation summaries, same-scope alignment rankings, and paginated shared-vote evidence.

The potential defect where a comparison could lose its selected chamber/Congress scope or paginate incorrectly was disproved by an executed adapter harness: House/119 remained in both requests, page offsets advanced from 0 to 25, and lookahead pagination returned 25 records followed by the final record. Focused migration and UI contract tests and frontend typechecking also passed.

Confidence Score: 5/5

The verified comparison flow preserves the selected congressional scope and handles consecutive evidence pages correctly.

No publishable defects remain. The changed adapter was exercised with a mocked RPC boundary across two pages, and focused migration/UI contract tests plus frontend typechecking completed successfully.

Files Needing Attention: No files require changes from this review; the exercised paths were frontend/src/lib/votingAnalytics.ts and migrations/0038_canonical_federal_voting_analytics.sql.

T-Rex T-Rex Logs

What T-Rex did

  • Verified through the parent commit that the federal voting analytics adapter was introduced by this PR.
  • Confirmed in the before-capture step that the analytics adapter did not exist before the PR.
  • Executed the after harness against a mocked RPC boundary and validated the two test pages used by the migration, with limit 26 and offsets 0 and 25, preserving the House/119 scope and producing 25 then 1 records with proper continuation.
  • Ran the focused federal voting migration/UI contract suite and frontend TypeScript validation, and all 15 contract checks plus the typecheck completed successfully.
  • The focused review reported no security defects.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "Add canonical federal voting analytics" | Re-trigger Greptile

Signed-off-by: capituwuistgoonsquad <ultimamaster13@gmail.com>
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.

1 participant