Cap bills during daily scraper refreshes - #291
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ThatXliner
marked this pull request as ready for review
August 16, 2026 15:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
--recent 100 --retain 100prune-billsas a manual, read-only-by-default inventory and repair commandWhy
Fetching the newest 100 bills bounds source API work, but it does not bound storage: the membership of that window changes every day, so the database retains the union of every historical window. The first implementation fixed storage growth with a weekly job, but selected victims in JavaScript and therefore transferred bill metadata from Supabase solely to make a database-local decision.
Retention now runs at the natural end of each daily bill refresh. A single data-modifying CTE selects overflow, deletes dependent rows, and returns only counts. Each jurisdiction remains independent, so federal activity cannot displace state measures.
Impact and safety
The current production read-only preview selects 1,104 bills: 27 California, 20 Missouri, 18 Texas, and 1,039 federal bills. North Carolina is already below the cap. No production rows were deleted while preparing this PR.
Routine deletion is opt-in through the supervisor's explicit
--retain 100argument and is only accepted alongside--recentfor the Congress or Open States scraper. Targeted fetches, bulk imports, cursor walks, and non-bill scrapers cannot invoke it. Retention uses a transaction plus lock and statement timeouts; a busy database fails the job for a later retry rather than waiting indefinitely. PostgreSQL autovacuum makes deleted space reusable, although reported physical disk size may not fall immediately.Checks
pnpm --filter @acme/scraper test(130 passed)pnpm --filter @acme/scraper buildpnpm --filter @acme/supervisor test(37 passed)pnpm --filter @acme/supervisor buildgit diff --check