Skip to content

Show who introduced a 2027 bill and its session in the bill overview - #1646

Merged
DTrim99 merged 2 commits into
mainfrom
bill-overview-intake-fields
Dec 4, 2026
Merged

DTrim99 merged 2 commits into
mainfrom
bill-overview-intake-fields

Conversation

@DTrim99

@DTrim99 DTrim99 commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

From the 2027 sessions on, state bills are scored and published through App v3 (Teamverse p301; Tracked bills is milestone p453). This PR is the data groundwork for the bill overview. The Tracked bills section, session filter and state map are left to the p453 work.

What changes

  • Bill feed. TrackedBill gains six optional fields from the tracker's research rows:

    • sponsors, primary first, with party, district and OpenStates' entity type (organization for a committee);
    • introducedDate;
    • session, the OpenStates session identifier (for example 2027_28) and the session's start year;
    • billTextUrl;
    • appReportUrl, the saved App v3 report the review approved;
    • approvedAt.

    Nothing reads appReportUrl yet; approvedAt orders bills in the Tracked bills section (Tracked bills section in App v3: session map and list, example households on bill reports #1658). The contract also defines app_report_id and review_pr_url, which this PR doesn't read: the report page can use the first to open the saved report in place, and the second to link the review.

    The tracker defines these fields in its App v3 bill contract (state-legislative-tracker #241). The feed already reads research with select=*, so no query changes: a field appears once the tracker writes it.

  • Overview. BillOverviewLead adds one line when the fields exist, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027 session". It uses the import's bill text link before sourceUrl. The line comes from libs/flagship/billOverview.ts.

    • Session. The tracker stores the OpenStates identifier, so the line shows a session name only when it has a space ("2027-2028 Regular Session") and otherwise reads "2027 session" from the start year. If the tracker later stores the display name, it shows as written.
    • Sponsors. A sponsor gets a "(R-7)" tag only when it has a party; a committee ("Ways and Means") is named without one.
    • The overview and the report page share one date helper, formatLongDate.
  • Older analyses don't change. A row without the fields maps to the same TrackedBill as before. A sponsor is never taken from the tracker's author field, which is a post's author as often as a sponsor; the existing "no Sponsored by" test still holds.

Checks

  • bun run check in app/ (typecheck, eslint with no warnings allowed, prettier): passes.
  • The full app/ vitest suite: 8,142 passed, 10 skipped, 0 failed (after Pavel's review, at 98a993f).

Order

Nothing breaks if this merges before the tracker writes the fields: they are optional and read from select=*. Tracker migration 010 adds them to research, and /encode-bill fills them when it moves to scoring through the Public API (p451).

🤖 Generated with Claude Code

The tracker's 2027 import records each bill's sponsors, introduced date,
session and a link to its text (state-legislative-tracker #241 defines
the fields). The bill feed reads them from research rows when present,
and the overview adds "Introduced January 12, 2027 by Jane Doe (R-7) and
3 others · 2027-2028 Regular Session" and prefers the import's bill text
link. Older analyses read exactly as before: no sponsor is ever taken from
the tracker's author field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-calculator-next Ready Ready Preview Dec 3, 2026 7:22pm UTC
policyengine-website Ready Ready Preview Dec 3, 2026 7:22pm UTC

Request Review

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at dba4aaa

This PR reads six optional 2027 fields from the tracker's research rows into TrackedBill: sponsors, introduced date, session, bill text link, saved report link and approval time. The bill overview then shows one line, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027-2028 Regular Session". The "Bill text" link now prefers the import's bill_text_url. Rows without the new fields map to the same TrackedBill as before, and the author field is still never read as a sponsor.

Verdict: REQUEST_CHANGES

The code is clean and older analyses do not change. One item is about the data contract: the session name that the tracker will write is not the label that this PR expects.

SHOULD ADDRESS

1. The session label will show the OpenStates identifier, for example "2027_28 session".
app/src/api/billFeed.ts:812 reads research.session_name, and app/src/libs/flagship/billOverview.ts:34-36 prints it, with " session" added when the word is not there. The tests use "2027-2028 Regular Session" (billFeedMocks.ts:237, trackedBillMocks.ts:74). But the tracker stores a different value:

  • Tracker PR 241 (scripts/sql/010_add_app_v3_bill_fields.sql) defines research.session_name as "the bill's session label, as in processed_bills".
  • In processed_bills, session_name is the OpenStates session identifier. The importer test in tracker PR 243 asserts bill["session_name"] == "2027_28". The human name ("2027-2028 Regular Session") is only in the /jurisdictions data, and the importer does not store it.

When I call introducedLine with importer-shaped data, I get:

  • { name: '2027_28', year: 2027 } gives "Introduced January 12, 2027 · 2027_28 session".
  • { name: '20272028', year: 2027 } gives "20272028 session".

Thus every 2027 bill report will show an identifier, not a session name. Fix it on one side, and make the test fixtures agree with the tracker:

  • In the tracker, store the session's display name (for example a new session_label, or session_name set from the session's name). Then this PR reads that field.
  • Or, in this PR, do not print session.name when it looks like an identifier. Build the label from session_year instead (for example "2027 session"), until the tracker stores a display name.

Also change INTAKE_ROWS to use a real importer value ('2027_28'), so that the test shows what readers will see.

SUGGESTION

2. A sponsor without a party shows only a number. billOverview.ts:12. A sponsor with a district and no party gives "Jane Doe (7)". The PR's own test expects "B (3)". A bare number in parentheses does not tell a reader that it is a district. The tracker sets party to null for committee sponsors and for people without a linked record. Show the tag only when there is a party, or write "District 7".

3. A committee can be the named sponsor. The tracker keeps committee sponsors (entity_type: "organization", for example "Ways and Means"). When a committee is the primary sponsor, the line reads "Introduced by Ways and Means and 1 other". That is correct for committee bills, but the feed drops entity_type, so a later change cannot tell a committee from a person. Keep entity_type on BillSponsor, or add a test that states the intended text for a committee bill.

4. One date helper, two copies. longDate in billOverview.ts:3 is the same as formatDate in BillReport.page.tsx:44. Export one helper and use it in both places. Both copies parse the date as local midnight from the first 10 characters, so the date does not move in any time zone. I checked a timestamp input in two far-apart time zones, and both give "January 12, 2027".

5. appReportUrl and approvedAt have no reader yet. That is acceptable as groundwork for the Tracked bills work. The contract also defines app_report_id and review_pr_url, which this PR does not read. A short note in the description would help the next change.

What I checked

  • The fields against tracker PR 241 (docs/APP_V3_BILL_CONTRACT.md, migration 010). The names sponsors, introduced_date, bill_text_url, session_name, session_year, app_report_url and approved_at agree. session_year is INTEGER and the feed requires an integer, which agrees. introduced_date is DATE, so the feed gets "YYYY-MM-DD". The text link falls back to research.url, as the contract says.
  • The sponsor shape against tracker PR 243 (bill_sponsors in openstates_monitor.py, migration 009): name, primary, party and district agree. The importer sorts primary sponsors first, and the feed sorts them again. Blank names are dropped.
  • Older rows: intakeFields returns an empty object for a row without the fields, and the test checks that sponsors, session and billTextUrl are absent.
  • Design: the new line uses the existing Caption (typography.fontSize.xs, colors.text.secondary). There are no new colors or sizes. The text is in sentence case. The line is plain text, so it adds no new controls for keyboard or screen reader users.
  • A probe of introducedLine with importer-shaped data: session identifiers, committee sponsors, no party, Nebraska "Nonpartisan" ("N-7"), Massachusetts district names ("D-1st Hampden"), three primary sponsors, a timestamp date and an invalid date.
  • Local runs (Node 22.23.1, bun 1.3.9):
    • Targeted vitest (billFeed, billOverview, BillReport): 79 passed in 3 files.
    • App bun run test: 8,130 passed and 10 skipped in 612 files.
    • App typecheck, eslint (no warnings allowed) and prettier: pass.
    • calculator-app (which serves /[countryId]/report/bill/[billId]): typecheck and next build pass.
  • CI at this head: lint, typecheck, tests, build and visual regression pass.

Pavel's review of #1646:
- The tracker stores the OpenStates session identifier ("2027_28") in
  research.session_name, so the overview showed "2027_28 session". It now
  shows a session name only when it has a space ("2027-2028 Regular
  Session") and otherwise reads "2027 session" from session_year. The
  fixtures use the importer's real value.
- A sponsor without a party gets no tag; "Jane Doe (7)" read as nothing.
- The feed keeps OpenStates' entity_type on each sponsor, so a committee
  sponsor can be told from a person; a test states the committee line.
- BillReport and the overview share one date helper, formatLongDate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DTrim99 added a commit that referenced this pull request Dec 3, 2026
After #1646's review fix, the overview reads "2027 session" from the
year; the fixtures now carry OpenStates' real value ("2027_28").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DTrim99

DTrim99 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, Pavel. Fixed in 98a993f.

Should address

  1. The session label. I fixed it on the App v3 side so this PR doesn't wait on a tracker migration.
    • introducedLine shows session.name only when it has a space, as a display name like "2027-2028 Regular Session" does. Otherwise it reads "2027 session" from session_year.
    • So "2027_28", "20272028" and "2027S1" all read "2027 session". An identifier with no year shows nothing.
    • If the tracker later stores the display name, it shows as written.
    • INTAKE_ROWS and INTAKE_TRACKED_BILL now use the importer's real 2027_28, and a table test covers the identifier forms.
    • Tracker Clean up navbar and add Claude util functions #241's contract now says that research.session_name is the OpenStates identifier and that App v3 reads the year.

Suggestions

  1. No party. A sponsor without a party gets no tag ("Jane Doe", not "Jane Doe (7)"). The old "B (3)" expectation changed to match.
  2. Committees. BillSponsor keeps OpenStates' entity_type as entityType. A committee never gets a party tag, and a test states the intended line: "Introduced by Ways and Means and 1 other". The feed fixture includes a committee sponsor.
  3. Date helper. formatLongDate is exported from billOverview.ts, and BillReport.page.tsx uses it. Its tests include a timestamp with an offset.
  4. Unread fields. The description now says what reads appReportUrl and approvedAt. Tracked bills (Tracked bills section in App v3: session map and list, example households on bill reports #1658) orders by approvedAt. It also notes app_report_id and review_pr_url for the next change.

Checks at 98a993f:

  • bun run check passes.
  • The full app/ suite: 8,142 passed, 10 skipped.
  • All 12 CI checks pass.

#1658, which is stacked on this branch, now includes these changes; its fixtures use 2027_28 too.

@PavelMakarchuk PavelMakarchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review at 98a993f

This PR reads six optional 2027 fields from the tracker's research rows into TrackedBill: sponsors, introduced date, session, bill text link, saved report link and approval time. The bill overview shows one line, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027 session". The new commit changes how the line shows the session and sponsors, keeps OpenStates' entity_type on each sponsor, and shares one date helper with the report page.

Verdict: APPROVE

All five earlier items are fixed. I found two small new display cases, both suggestions.

Earlier items

  1. Session label shows the OpenStates identifier (SHOULD ADDRESS): fixed. sessionText (app/src/libs/flagship/billOverview.ts:33-42) shows session.name only when it has a space. Otherwise it reads "2027 session" from session_year. The fixtures now use the importer's 2027_28, and a table test covers the identifier forms. Tracker #241 (docs/APP_V3_BILL_CONTRACT.md, at ea9c1e6) now says that session_name is the identifier and that App v3 reads the year. My probe results:
    • 2027_28, 20272028, 2027-2028 (no space), 2027 and 2027S1, each with year 2027: "2027 session".
    • 2027-2028 with no year, 2025_26 with no year, a missing session, {}, and year 0: no session text. The line does not show "undefined" or an empty " · ".
    • "2027-2028 Regular Session": shown as written. "2027 First Special": "2027 First Special session".
    • Texas called session 891 and Massachusetts 194th, each with year 2025: "2025 session".
  2. A sponsor without a party shows only a number (SUGGESTION): fixed. sponsorLabel (billOverview.ts:19-25) adds a tag only when there is a party. "Jane Doe" with district 7 and no party reads "Jane Doe". A party with no district reads "Jane Doe (R)". Nebraska "Nonpartisan" still reads "(N-7)".
  3. A committee can be the named sponsor (SUGGESTION): fixed. BillSponsor.entityType keeps person or organization (app/src/api/billFeed.ts:107-108, 812-814). Other values, such as the importer's "", are dropped. A committee never gets a tag, even when a row gives it a party. A test states the committee line, and the feed fixture has a committee sponsor.
  4. One date helper, two copies (SUGGESTION): fixed. formatLongDate is exported from billOverview.ts, and BillReport.page.tsx uses it for "Analyzed" and "computed". It has tests for a date, a timestamp with an offset and an invalid value.
  5. appReportUrl and approvedAt have no reader yet (SUGGESTION): fixed. The description now says that Tracked bills (#1658) orders by approvedAt, and it notes app_report_id and review_pr_url for the next change.

SUGGESTION

6. A special session reads the same as the regular session. billOverview.ts:38-40. OpenStates special-session identifiers have no space, for example 2027S1. With year 2027, the line reads "2027 session", the same as a bill from the 2027 regular session. A reader cannot see that the bill is from a special session. A possible fix: when the identifier has a letter after the year (such as S1), write "2027 special session". Or accept this until the tracker stores a display name, and add the 2027S1 row to the test name so the choice is clear.

7. A federal session reads "120th Congress session". billOverview.ts:35-37. The feed includes federal bills, and the tracker's Congress monitor stores session_name as "119th Congress" (scripts/congress_monitor.py:250). That name has a space and no word "session", so the line adds " session". This behavior was also in the earlier head, and it shows only if /encode-bill copies the federal session_name into research. A possible fix: do not add " session" when the name ends in "Congress". Add a test row for it.

What I checked

  • Each earlier item, with the unit tests and a probe of introducedLine and formatLongDate. The probe used the session forms above, committee sponsors with and without entityType, a committee with a party, a party with no district, and Nebraska "Nonpartisan".
  • formatLongDate in three time zones (UTC-5, UTC+14 and UTC-11): "2027-01-12", "2027-01-12T23:30:00-08:00" and "2027-01-12T02:00:00Z" all give "January 12, 2027". "soon" and "" are returned as they are.
  • The fields against tracker PR 241 at ea9c1e6 (contract and migration 010) and PR 243 at e0cd58b (bill_sponsors in openstates_monitor.py). The importer writes entity_type as OpenStates gives it, or "". session_year is the first calendar year of the session, which agrees with "2027 session" for 2027_28.
  • The diff from dba4aaa to 98a993f: 8 files, 112 lines added and 34 removed. The local formatDate in BillReport.page.tsx is removed, and no other file used it.
  • Local runs (bun 1.3.9):
    • Targeted vitest (billFeed, billOverview, BillReport): 91 passed in 3 files.
    • App bun run test: 8,142 passed and 10 skipped in 612 files.
    • App typecheck, eslint and stylelint (no warnings allowed) and prettier: pass.
    • calculator-app (which serves the bill report page): typecheck and next build pass.
  • CI at this head: all 12 checks pass.

@DTrim99
DTrim99 merged commit 653f666 into main Dec 4, 2026
12 checks passed

This branch was successfully deployed

2 active deployments
Preview – policyengine-calculator-next — 98a993ff Deployed Dec 3, 2026 by vercel[bot]
Preview – policyengine-website — 98a993ff Deployed Dec 3, 2026 by vercel[bot]
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.

2 participants