Repository navigation
Closed
Copy link
Description
Summary
Replace the Congress.gov API (fetch_bills.py) with GPO govinfo bulk data for both bill discovery and text retrieval. This removes the API-key/rate-limit dependency, recovers bill titles the committee API drops, and lets discovery generalize beyond appropriations (search by number or title), which matches how users actually find bills and supports diffing any bill.
Validated with a local prototype (parity test against existing fixtures + a discovery demo). Key results are inlined below; the prototype branch can be pushed for reproduction on request.
Why
- Byte-identical text. govinfo
BILLSXML is byte-for-byte identical to the congress.gov "Formatted XML" we download today — verified on all 12 existing test fixtures (12/12 exact match). Same legacybill.dtdformat, sobill_tree.pyneeds no parser changes (it is NOT USLM; the default/bulkdata/BILLS/path is legacy DTD). - No API key, no rate limit. Covers 113th Congress forward.
- Titles + discovery for free.
BILLSTATUSbulk carries title, subjects, and committee/subcommittee codes — the title is exactly what the committee API omits today. - The "firehose" was a paging artifact. 450k bills / 250-per-page is only a problem via the API. As bulk ZIPs, a whole chamber-congress is ~14 MB and a trivial local index (measured: 5,649 Senate bills in the 118th).
Target architecture
| Concern | Source |
|---|---|
| Search by number | direct URL construction (no index, any bill) |
| Search by title | local index built from BILLSTATUS per-type ZIP |
| Full text for diff | BILLS bulk XML (byte-identical to today) |
Appropriations becomes a label/facet, not a discovery gate.
URL shapes:
- text:
bulkdata/BILLS/{congress}/{session}/{type}/BILLS-{congress}{type}{number}{ver}.xml - status:
bulkdata/BILLSTATUS/{congress}/{type}/BILLSTATUS-{congress}{type}{number}.xml - per-type ZIP:
bulkdata/BILLSTATUS/{congress}/{type}/BILLSTATUS-{congress}-{type}.zip
Implementation notes / gotchas (found during prototyping)
- Resolve version codes from the BILLS directory listing (prefix-match
BILLS-118s4690*), not by mapping human-readable version labels — BILLSTATUS says "Reported to Senate" while the API/our fixtures say "reported-in-senate". The vocabularies differ. - Do not filter by text-version count. All appropriations test bills have exactly 1 published version (Senate bills are reported as original bills); a >=2-version filter drops every one. Diffs are against external baselines (budget request / prior year / companion), not intra-bill versions.
- Appropriations facet: committee referral (
ssap00/hsap00, 45 bills in 118th S) is more precise than the "Appropriations" subject term (50); they diverge slightly. Pick committee for precision or union for recall. - Session in path: govinfo splits
BILLSby session (1/2). Resolve session from the directory listing rather than probing both.
Out of scope / unaffected
- Pre-introduction draft PDFs still have no XML upstream anywhere; this change does not address them.
- The law API is explicitly rejected as an alternative: it only covers enacted bills, losing all in-progress versions (the bulk of diff value).
Acceptance
- govinfo-backed fetch produces byte-identical XML to current pipeline on existing fixtures (regression guard)
- Discovery by bill number works for any bill type/congress
- Title search works over a BILLSTATUS-built index, with appropriations as a facet
- No Congress.gov API key required to run the fetch pipeline
- Version codes resolved from directory listing (not label mapping)
Migrated from willhea/civic_tech_appropriations_bills#61 (original author @willhea).
Sub-issues
Collapse Sub-issuesSub-issues
Loading 7 sub-issues
Activity
willhea commentedon Jun 24, 2026
Status update. Moving off In review → Backlog; flagging for discussion before we commit.
This isn't actually in review — there's no open PR. The current state is: prototyped and validated (byte-identical govinfo
BILLSXML on all 12 fixtures, discovery demo), but no implementation merged.fetch_bills.pyondevelopstill uses the Congress.gov API v3 as its only source — no govinfo bulkdata client, no key-less fallback.Want to revisit this together before scheduling the work — open questions to settle:
Leaving open in Backlog pending that discussion.
willhea commentedon Jun 24, 2026
Partial coverage from PR #24 (
bill-index). Reviewed against this issue — it addresses the discovery/metadata half, not the text-fetch half.What PR #24 addresses
Delivers discovery + a metadata index via govinfo bulk data:
fetch_bill_archives.pydownloads govinfoBILLSTATUSbulk ZIPs (bulkdata/BILLSTATUS/{congress}/{type}/BILLSTATUS-{congress}-{type}.zip) and extracts per-bill metadata, including the title the committee API drops. No key, no rate limit on this path.bill_index/bill_index.py— CSV-backed metadata manager keyed by thecongress-type-number[:version]slug convention; generalizes discovery beyond appropriations (the 100K+ billlarge_bills.csvindex proves it).download-all --file <csv>drives bulk text download off any slug list, so appropriations is no longer a discovery gate.Maps to the issue's "title search / discovery / appropriations-as-facet" acceptance items.
Where Congress.gov API-key reliance still lives (NOT migrated)
The full-text fetch — the core diff input — still goes through the keyed Congress.gov API:
fetch_text_versions()calls/bill/{congress}/{type}/{number}/textviaapi_get(...), which requiresapi_key. There is zerobulkdata/BILLS/(text) usage anywhere on the branch — onlyBILLSTATUS(metadata). The headline win (byte-identicalBILLSXML from govinfo, no parser change) is not implemented.get_xml_url/get_pdf_urlreadFormatted XML/PDFURLs out of the API'stextVersionsresponse, so you must call the keyed API first to enumerate versions.main()callsget_api_key()unconditionally; evendownload-all --fileflows throughfetch_text_versions → api_get. With no key it falls back toDEMO_KEY(30 req/hr) rather than running key-free. So the acceptance item "No Congress.gov API key required to run the fetch pipeline" is not met.fetch_all_committee_bills) remains for the year-rangedownload-allpath — also keyed.Remaining work to close this issue
BILLS/{congress}/{session}/{type}/directory listing (prefix-match) and downloadBILLS-...xmldirectly, instead of via the APItextVersionsURLs.get_api_key()optional so the pipeline runs key-free.Net: PR #24 covers the metadata/discovery half; the text-retrieval half (the part that actually removes the key/rate-limit dependency) is still open. Keeping this in Backlog for the revisit discussion.
docs: normalize ADR 0004 status to match the template convention
willhea commentedon Jun 28, 2026
Crediting prior groundwork: @RolfHendriks's PR #24 ("Bill index") already landed foundational pieces for this migration —
bill_indexfor accumulating bill metadata, bulk-data bill fetching via the shared API, and CSV-backed batch download (fetch_bills, default formatboth). That work is a substantial head start on the govinfo bulk-data switch tracked here. Not assigning, since the full migration is still open and unclaimed — flagging the lineage so the contribution is visible and reusable.docs: add a CLI command-reference table
feat(fetch): govinfo bulk-text access layer + corpus builder (#10)
fix(fetch): key BILLSTATUS date join by version code; run byte-identi…
Merge pull request #222 from AgoraDMV/feat/govinfo-10-order-versions
Merge pull request #224 from AgoraDMV/feat/govinfo-10-version-codes
willhea commentedon Jul 18, 2026
Reopening: closed as COMPLETED on 2026-07-18 appears premature. The migration is still in progress — steps 5–11 of the approved plan remain, PR #225 (step 4, enumeration) is an open draft, and verification this session surfaced a completeness gap now tracked in #226 (govinfo doesn't mirror Congress.gov 1:1; ~0.1% of versions need an automatic API fallback, blocking the
--sourcewiring). #10 stays the umbrella epic until that work lands.23 remaining items
rhucversion code with an authoritative label (deferred from #10 step 3) #223willhea commentedon Jul 19, 2026
Closing — migration complete
All 7 sub-issues closed (7/7).
--source govinfois the keyless default for discovery and text fetch, with the Congress.gov API path retained behind--source api.What shipped
rhucversion code with an authoritative labelVERSION_CODES— all 53 authoritative govinfo codes, so no real code falls through to an unreadable raw-code filename<type>spelling resolves to a version codeBoundary decisions worth carrying forward
Deliberately out of scope, tracked independently and not blocking this epic:
Releasing to
mainis a separate decision and is not part of this epic.test(corpus): fail when an allowlist entry names a fixture that is gone
docs(adr): rewrite 0004 as a current-state record
ci(#404): add a cwd-independence job, the oracle the regex only appro…
ci(#404): add a cwd-independence job, the oracle the regex only appro…
ci(#404): add a cwd-independence job, the oracle the regex only appro…
ci(#404): add a cwd-independence job, the oracle the regex only appro…