Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions scripts/run-backfill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ VINTAGES=(
118-82
118-158
119-73
119-142
)

TOTAL=${#VINTAGES[@]}
Expand All @@ -49,9 +50,9 @@ for i in "${!VINTAGES[@]}"; do
echo "[$n/$TOTAL] Vintage $v"
echo "────────────────────────────────────────"

# Run in a separate process with generous heap (8GB)
# Run in a separate process with generous heap (default 6GB; override with BACKFILL_HEAP_MB)
# The orchestrator's resume logic will skip already-committed vintages
if node --max-old-space-size=8192 "$PROJECT_ROOT/dist/index.js" backfill \
if node --max-old-space-size=${BACKFILL_HEAP_MB:-6144} "$PROJECT_ROOT/dist/index.js" backfill \
--phase olrc --target "$TARGET" --vintages "$ACCUMULATED" 2>&1; then
echo " ✓ done"
else
Expand All @@ -69,4 +70,4 @@ echo "Inspect with:"
echo " cd $TARGET"
echo " git log --oneline --decorate"
echo " git tag -l"
echo " git diff annual/2013..annual/2025 --stat"
echo " git diff annual/2013..annual/2026 --stat"
1 change: 1 addition & 0 deletions scripts/seed-all-vintages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ VINTAGES=(
118-82
118-158
119-73
119-142
)

echo "=== Seeding ${#VINTAGES[@]} OLRC vintages ==="
Expand Down
6 changes: 4 additions & 2 deletions src/backfill/olrc-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ async function transformVintage(
totalSections += titleIr.sections.length;
totalFiles += writeResult.filesWritten;
}
} catch {
// Skip titles that fail to parse — non-fatal for backfill
} catch (error) {
// Skip titles that fail to parse — non-fatal for backfill, but never silent
const message = error instanceof Error ? error.message : String(error);
process.stderr.write(`[backfill] ✗ title ${target.cacheKey} skipped (${vintage}): ${message}\n`);
continue;
}
}
Expand Down
33 changes: 19 additions & 14 deletions src/backfill/olrc-planner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export interface OlrcVintageEntry {
}

/**
* Known OLRC release points sourced from
* https://uscode.house.gov/download/priorreleasepoints.htm
* Known OLRC release points. Dates are the "current through" public-law dates
* OLRC lists for each release point (https://uscode.house.gov/priorreleasepoints.html;
* pre-119th-Congress entries verified against the archived priorreleasepoints.htm).
*
* As of November 2026 OLRC only hosts 119th-Congress release points; older ZIPs
* return 404 and must be sourced from an archive (e.g. the Wayback Machine).
*
* Each entry uses the actual OLRC release-point identifier (which may differ
* from the public-law number the site advertises on the main download page).
Expand All @@ -25,31 +29,32 @@ export interface OlrcVintageEntry {
*/
export const KNOWN_VINTAGES: OlrcVintageEntry[] = [
// 113th Congress (2013–2015)
{ vintage: '113-21', congress: 113, lawNumber: '21', year: 2013, releaseDate: '2013-06-15', congressBoundary: false },
{ vintage: '113-21', congress: 113, lawNumber: '21', year: 2013, releaseDate: '2013-07-18', congressBoundary: false },
{ vintage: '113-296', congress: 113, lawNumber: '296', year: 2014, releaseDate: '2014-12-19', congressBoundary: true },

// 114th Congress (2015–2017)
{ vintage: '114-38', congress: 114, lawNumber: '38', year: 2015, releaseDate: '2015-07-30', congressBoundary: false },
{ vintage: '114-329', congress: 114, lawNumber: '329', year: 2017, releaseDate: '2017-01-03', congressBoundary: true },
{ vintage: '114-38', congress: 114, lawNumber: '38', year: 2015, releaseDate: '2015-07-28', congressBoundary: false },
{ vintage: '114-329', congress: 114, lawNumber: '329', year: 2017, releaseDate: '2017-01-06', congressBoundary: true },

// 115th Congress (2017–2019)
{ vintage: '115-51', congress: 115, lawNumber: '51', year: 2017, releaseDate: '2017-08-14', congressBoundary: false },
{ vintage: '115-442', congress: 115, lawNumber: '442', year: 2019, releaseDate: '2019-01-03', congressBoundary: true },
{ vintage: '115-51', congress: 115, lawNumber: '51', year: 2017, releaseDate: '2017-08-18', congressBoundary: false },
{ vintage: '115-442', congress: 115, lawNumber: '442', year: 2019, releaseDate: '2019-01-14', congressBoundary: true },

// 116th Congress (2019–2021)
{ vintage: '116-91', congress: 116, lawNumber: '91', year: 2019, releaseDate: '2019-12-20', congressBoundary: false },
{ vintage: '116-344', congress: 116, lawNumber: '344', year: 2021, releaseDate: '2021-01-03', congressBoundary: true },
{ vintage: '116-91', congress: 116, lawNumber: '91', year: 2019, releaseDate: '2019-12-19', congressBoundary: false },
{ vintage: '116-344', congress: 116, lawNumber: '344', year: 2021, releaseDate: '2021-01-13', congressBoundary: true },

// 117th Congress (2021–2023)
{ vintage: '117-81', congress: 117, lawNumber: '81', year: 2021, releaseDate: '2021-11-15', congressBoundary: false },
{ vintage: '117-262', congress: 117, lawNumber: '262', year: 2022, releaseDate: '2022-12-22', congressBoundary: true },
{ vintage: '117-81', congress: 117, lawNumber: '81', year: 2021, releaseDate: '2021-12-27', congressBoundary: false },
{ vintage: '117-262', congress: 117, lawNumber: '262', year: 2022, releaseDate: '2022-12-21', congressBoundary: true },

// 118th Congress (2023–2025)
{ vintage: '118-82', congress: 118, lawNumber: '82', year: 2024, releaseDate: '2024-01-29', congressBoundary: false },
{ vintage: '118-158', congress: 118, lawNumber: '158', year: 2024, releaseDate: '2024-12-23', congressBoundary: true },
{ vintage: '118-82', congress: 118, lawNumber: '82', year: 2024, releaseDate: '2024-09-20', congressBoundary: false },
{ vintage: '118-158', congress: 118, lawNumber: '158', year: 2024, releaseDate: '2024-12-21', congressBoundary: true },

// 119th Congress (2025–)
{ vintage: '119-73', congress: 119, lawNumber: '73', year: 2025, releaseDate: '2025-03-14', congressBoundary: false },
{ vintage: '119-73', congress: 119, lawNumber: '73', year: 2026, releaseDate: '2026-01-23', congressBoundary: false },
{ vintage: '119-142', congress: 119, lawNumber: '142', year: 2026, releaseDate: '2026-11-10', congressBoundary: false },
];

export interface OlrcBackfillPlan {
Expand Down
5 changes: 3 additions & 2 deletions src/sources/olrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ import type {
} from '../utils/manifest.js';
import { logNetworkEvent } from '../utils/logger.js';

const DOWNLOAD_TIMEOUT_MS = 500;
const DOWNLOAD_TIMEOUT_MS = 30_000;
const DOWNLOAD_RETRY_COUNT = 1;
const MAX_XML_ENTRY_BYTES = 64 * 1024 * 1024;
const MAX_LARGE_TITLE_XML_ENTRY_BYTES = 128 * 1024 * 1024;
const MAX_TOTAL_XML_BYTES = 256 * 1024 * 1024;
const OLRC_HOME_URL = 'https://uscode.house.gov/';
const OLRC_LISTING_URL = 'https://uscode.house.gov/download/download.shtml';
// OLRC moved its download listing from /download/download.shtml to /download.html in its 2026 site redesign.
const OLRC_LISTING_URL = 'https://uscode.house.gov/download.html';
const OLRC_LEGACY_LISTING_URL = 'https://uscode.house.gov/download/annualtitlefiles.shtml';
const FIXTURE_ENV_PREFIX = 'US_CODE_TOOLS_TITLE_';
const RESERVED_EMPTY_TITLE = 53;
Expand Down
6 changes: 3 additions & 3 deletions tests/adversary-round5-issue5.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ describe('adversary regressions for issue #5 — round 5', () => {
});
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
return makeTextResponse(listingHtml, 'text/html');
}

Expand All @@ -277,9 +277,9 @@ describe('adversary regressions for issue #5 — round 5', () => {
});

const nonListingUrls = requestedUrls.filter(
(url) => url !== 'https://uscode.house.gov/' && url !== 'https://uscode.house.gov/download/download.shtml',
(url) => url !== 'https://uscode.house.gov/' && url !== 'https://uscode.house.gov/download.html',
);
expect(requestedUrls).toContain('https://uscode.house.gov/download/download.shtml');
expect(requestedUrls).toContain('https://uscode.house.gov/download.html');
expect(requestedUrls).not.toContain('https://uscode.house.gov/download/annualtitlefiles.shtml');
expect(nonListingUrls.length).toBe(53);
expect(nonListingUrls.every((url) => url.includes(`/releasepoints/us/pl/${latestVintage}/`))).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/issue21-historical-olrc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ globalThis.fetch = async (input, init) => {
});
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
return new Response(htmlForListing(spec.vintages), {
status: 200,
headers: { 'Content-Type': 'text/html; charset=utf-8' },
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/backfill-olrc-planner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('OLRC backfill planner', () => {
it('resolves known vintages by id', () => {
const entry = resolveVintageEntry('119-73');
expect(entry).toBeDefined();
expect(entry!.year).toBe(2025);
expect(entry!.year).toBe(2026);
expect(entry!.congress).toBe(119);
});

Expand All @@ -23,7 +23,7 @@ describe('OLRC backfill planner', () => {
it('assigns annual tags for each vintage', () => {
const plan = buildOlrcBackfillPlan(['113-21', '119-73']);
expect(plan.tags.get('annual/2013')).toBe('113-21');
expect(plan.tags.get('annual/2025')).toBe('119-73');
expect(plan.tags.get('annual/2026')).toBe('119-73');
});

it('assigns congress boundary tags', () => {
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/sources/olrc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ describe('OLRC source and cache behavior', () => {
}
}, 45000);

it('defaults OLRC vintage discovery to download.shtml instead of probing annualtitlefiles.shtml first', async () => {
it('defaults OLRC vintage discovery to download.html instead of probing annualtitlefiles.shtml first', async () => {
const modulePath = resolve(process.cwd(), 'src', 'sources', 'olrc.ts');
const mod = await safeImport(modulePath);
ensureModuleLoaded(modulePath, mod);
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('OLRC source and cache behavior', () => {
});
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
expect(init?.headers).toBeDefined();
const headers = new Headers(init?.headers);
expect(headers.get('cookie') ?? headers.get('Cookie')).toContain('JSESSIONID=current-only');
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('OLRC source and cache behavior', () => {
const result = await fetchOlrcSource({ force: false });
expect((result as any)?.ok).toBe(true);
expect(requests).toContain('https://uscode.house.gov/');
expect(requests).toContain('https://uscode.house.gov/download/download.shtml');
expect(requests).toContain('https://uscode.house.gov/download.html');
expect(requests).toContain('https://uscode.house.gov/download/releasepoints/us/pl/119/73/xml_usc01@119-73.zip');
expect(requests).not.toContain('https://uscode.house.gov/download/annualtitlefiles.shtml');
} finally {
Expand All @@ -344,7 +344,7 @@ describe('OLRC source and cache behavior', () => {
}
});

it('bootstraps homepage cookies before requesting download.shtml and releasepoint ZIPs', async () => {
it('bootstraps homepage cookies before requesting download.html and releasepoint ZIPs', async () => {
const modulePath = resolve(process.cwd(), 'src', 'sources', 'olrc.ts');
const mod = await safeImport(modulePath);
ensureModuleLoaded(modulePath, mod);
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('OLRC source and cache behavior', () => {
});
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
return new Response(`
<html><body>
<a href="/download/releasepoints/us/pl/119/73/xml_usc01@119-73.zip">Title 1</a>
Expand All @@ -396,7 +396,7 @@ describe('OLRC source and cache behavior', () => {
const result = await fetchOlrcSource({ force: false, cacheRoot });
expect((result as any)?.ok).toBe(true);

const listing = requests.find((request) => request.url === 'https://uscode.house.gov/download/download.shtml');
const listing = requests.find((request) => request.url === 'https://uscode.house.gov/download.html');
const zip = requests.find((request) => request.url.endsWith('xml_usc01@119-73.zip'));

expect(requests[0]?.url).toBe('https://uscode.house.gov/');
Expand All @@ -408,7 +408,7 @@ describe('OLRC source and cache behavior', () => {
}
});

it('retries homepage bootstrap after a transient bootstrap failure before touching download.shtml', async () => {
it('retries homepage bootstrap after a transient bootstrap failure before touching download.html', async () => {
const modulePath = resolve(process.cwd(), 'src', 'sources', 'olrc.ts');
const mod = await safeImport(modulePath);
ensureModuleLoaded(modulePath, mod);
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('OLRC source and cache behavior', () => {
});
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
expect(headers.get('cookie') ?? headers.get('Cookie')).toContain('JSESSIONID=recovered-session');
return new Response(`
<html><body>
Expand All @@ -474,14 +474,14 @@ describe('OLRC source and cache behavior', () => {
'https://uscode.house.gov/',
'https://uscode.house.gov/',
]);
expect(requests[2]?.url).toBe('https://uscode.house.gov/download/download.shtml');
expect(requests[2]?.url).toBe('https://uscode.house.gov/download.html');
} finally {
globalThis.fetch = originalFetch;
rmSync(cacheRoot, { recursive: true, force: true });
}
});

it('parses download.shtml releasepoint listings by newest numeric vintage and ignores appendix links', async () => {
it('parses download.html releasepoint listings by newest numeric vintage and ignores appendix links', async () => {
const modulePath = resolve(process.cwd(), 'src', 'sources', 'olrc.ts');
const mod = await safeImport(modulePath);
ensureModuleLoaded(modulePath, mod);
Expand All @@ -500,7 +500,7 @@ describe('OLRC source and cache behavior', () => {
return new Response('ok', { status: 200, headers: { 'Set-Cookie': 'JSESSIONID=listing-session; Path=/; HttpOnly' } });
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
return new Response(`
<html><body>
<a href="/download/releasepoints/us/pl/118/200/xml_usc01@118-200.zip">older title 1</a>
Expand Down Expand Up @@ -578,7 +578,7 @@ describe('OLRC source and cache behavior', () => {
return new Response('ok', { status: 200, headers: { 'Set-Cookie': 'JSESSIONID=reserved-empty; Path=/; HttpOnly' } });
}

if (url === 'https://uscode.house.gov/download/download.shtml') {
if (url === 'https://uscode.house.gov/download.html') {
return new Response(`
<html><body>
<a href="/download/releasepoints/us/pl/119/73/xml_usc01@119-73.zip">Title 1</a>
Expand Down
Loading