Skip to content

Pin the Fed's 18 November SCF 2022 summary reissue and the full extract - #1829

Draft
MaxGhenis wants to merge 5 commits into
mainfrom
hub/scf-reissue-pins
Draft

MaxGhenis wants to merge 5 commits into
mainfrom
hub/scf-reissue-pins

Conversation

@MaxGhenis

@MaxGhenis MaxGhenis commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Draft. The generated identities land here before it leaves draft.

What changed at the Fed

The Federal Reserve reissued scfp2022s.zip on 18 November 2026 (Last-Modified 15:38:13 GMT). Main still pins the earlier zip (d4e139c6…), so a build machine without a cached copy of its member (6ff73d52…) can't fetch the SCF 2022 summary extract at main: the download fails the zip pin.

The reissue (zip 47475314…, member ab53e33e…, 34,487,960 bytes) holds the same records. Read through read_scf_2022_summary_extract and compared with the original 2022-dollar member on the 16 columns the two loaders read:

  • both files have the same 22,975 rows, with (y1, yy1) keys in the same order;
  • the weight and the five demographic columns match;
  • the eight dollar columns, divided by the Fed's 4789/4376 factor, differ by at most 3.5e-16 relative wherever the original holds a nonzero value (4.8e-7 absolute), and their weighted totals by at most 1.8e-16 relative;
  • neither file holds a sentinel code in those 16 columns.

The first commit: pins

  • us_runtime/scf_wealth.py pins the reissue. The reader also converts the member main pinned on 17 November (6ff73d52…), so a copy passed with --scf-summary-extract reads 2022 dollars.
  • A new require_pinned_scf_2022_summary_extract refuses a member that no pin names. The release builder calls it on the resolved path before the wealth and auto-loan stages read the file. The reader alone takes an unpinned file as it stands, so test fixtures still load.
  • us_runtime/scf_auto_loans.py pins the full SCF 2022 extract: the 8,856,125-byte zip 409e6811… the Fed served on 1 December (UTC) with Last-Modified 18 October 2023, and its member 61e2fceb…. Until now the fetch returned a cached p22i6.dta unchecked.
  • sources.yaml and source_stages.json carry the same pins. Route A's input row and the national build runbook point at the reissue.

That commit's message says a machine that cached 6ff73d52… still reads 2022 dollars. The default fetch doesn't reuse that member: it installs the reissue and keeps the old file beside it. Only an explicit --scf-summary-extract path reads it.

Commits two to five: review rounds 1 to 3, and the runbook

  • Checked bytes. The guard returns the digest it accepted, and the builder hands it to both loaders, with the full-extract pin for the auto-loan loader. Each loader reads the file once, refuses bytes with another digest, and parses the same buffer. A file replaced after the check fails the build. The builder accepts only the current reissue from a fetch; an explicit --scf-summary-extract may name any pinned member.
  • File names. The readers parse bytes that open with a Stata header as Stata, whatever their file name. They decompress other bytes as the name implies (.dta.gz and the like), as the path-based reads did before.
  • Cache installs. Installs into a cache directory take an exclusive flock. Under the lock the helper removes temporary files named .<member>.*.partial and re-hashes the cached member. If it already holds the new bytes, nothing changes. Otherwise the helper keeps the old bytes under <member>.<their SHA-256>, as a hard link or, where the file system refuses hard links, as a new file created with O_EXCL. It reuses an entry at that name only when a regular file there holds those bytes. It leaves any other entry there untouched, symlinks included, and gives the copy the next suffix (.1, .2 and so on). Then it writes the new bytes to a unique temporary file, fsyncs it, and replaces the member with one os.replace. A failed download, write or publish leaves the cached member in place.
  • Runbook. Move the US engine to policyengine-us 2.145.3 and prepare the Route A national build #1676 merged into main on 30 November, so the fifth commit points the Settings block's COMMIT at a main commit that contains these pins, and leaves REQUIRE_ON_MAIN at its default of 1. Rounds 2 and 3 still had it name Move the US engine to policyengine-us 2.145.3 and prepare the Route A national build #1676's head. Its SCF paragraph describes the cache-hit and download paths, and says that Route A's prefetch uses the default cache even when SCF points elsewhere.
  • Wording. Comments, help text and the changelog state what the receipts show.

Still to come here

  • The generated identities: the F0 contract pins, the US bundle, the spec-engine coverage report and the manifest field counts. Regenerating the US bundle imports policyengine-us.

The download URLs for the four Fed SCF files and the pins for the 2025 summary extract go in a separate pull request with its own review. On 30 November the Fed served the 2025 file with Last-Modified 18 November 2026 and a digest other than main's pin.

CI should fail on those generated identities until then. Each test job stops at its first failure, so a red job shows one failure and hides any later ones. On the first commit:

  • engine-us stopped at the configuration field count (51,015 expected, 51,017 found);
  • both engine-free legs stopped at test_no_committed_local_adjudication_is_about_to_lapse, a UK expiry check that stops main's legs at 88fadfa8 too, from 1 December.

Their logs don't show whether the SCF tests ran before the stop. The tests added in review rounds 1 to 3 have run only on macOS so far.

microcosm#1830 holds the review items left for later, with two more points from round 2.

Checked locally, at the fourth commit (the fifth changes only the runbook)

  • test_us_scf_wealth.py, test_us_scf_auto_loans.py and test_us_release_frees_after_last_use.py: 105 passed.
  • test_us_fiscal_refresh_builder.py -k "test_main_writes_diagnostics_before_post_calibration_gate_failure or scf": 28 passed.
  • The eight tests added for round 3's findings fail against the third commit's code and pass at the fourth. They cover a symlink at the keep name, pointing at the member or at nothing, on both copy paths. They also cover an entry another writer makes at that name during the copy, and a raw member under a .gz name for both readers, in Stata formats 114 and 118.
  • The install failure tests inject a stream write that stops halfway, an fsync failure after a complete write, and a failed publish. Each leaves the complete old member and no temporary file. Round 3's replay injected only the fsync failure, so its "partial write" label overstated it.
  • 24 mutants, each run against the tests meant to catch it. 22 fail those tests. Two survive, and neither changes what the cache holds in these cases:
    • m17 gives the temporary file one fixed name but keeps O_EXCL and mode 0600. Installers that take the lock never stage at once, and the next install removes a leftover of that name.
    • m19 checks the keep name with exists(), which misses a dangling symlink. Both ways of writing the copy refuse an existing name, so the copy still takes the next suffix.
  • ruff format --check and ruff check pass on the six touched Python files.
  • I didn't run the engine lanes or the generated-identity tests locally.

🤖 Generated with Claude Code

MaxGhenis and others added 5 commits November 30, 2026 19:50
The Federal Reserve reissued scfp2022s.zip on 2026-11-18, so the pinned
member (6ff73d52) no longer downloads. Pin the reissue (zip 47475314,
member ab53e33e) and keep converting the earlier member, so a build
machine that cached it still reads 2022 dollars. A new
require_pinned_scf_2022_summary_extract refuses any other member before
the wealth and auto-loan stages read it; the reader alone would take an
unpinned file as it is. Pin the full SCF 2022 extract (zip 409e6811,
member 61e2fceb), which was unpinned, and point Route A at the reissue.

Generated identities are not re-pinned here; they move once, with the
remaining source pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The release guard hashed the summary extract, and each loader then reopened
the path. Each loader now reads the file once, refuses bytes whose digest
differs from the one the guard accepted, and parses the same buffer. The
auto-loan loader holds a --scf-full-extract override to the full-extract pin.

Both fetchers write a verified download to a .partial file, move a cached
member with another digest aside to <member>.<12 hex digits>, then rename the
new file into place. A failed download leaves the cache as it was.

Comments, the runbook and the help text now state what the receipts show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…at was hashed

Review round 2 found that the install helper could lose the old member or
leave the canonical path missing. It moved the cached member aside by its
pre-download digest, wrote a shared .partial name, and renamed twice. Now
installs into a cache directory take an exclusive flock. Under it the helper
removes stale .partial files and re-hashes the canonical member. If that
member already holds the new bytes, it returns. Otherwise it hard-links the
old member to <member>.<full SHA-256>, never overwriting a file of that name.
It writes the new bytes to a unique temporary file, fsyncs it, and replaces
the canonical path with one os.replace.

The readers pass pandas the compression that the file name implies, since a
buffer has no name to infer it from. A fetched summary extract must be the
current reissue. The runbook's Settings block now names a #1676 head that has
taken main with these pins.

This also corrects the first commit's message. The default fetch does not
reuse a cached 6ff73d52 member: it installs the reissue and keeps the old file
beside it. Only an explicit --scf-summary-extract path reads that member.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Stata as raw

The install keeps the old member beside the new one. A symlink at the
keep name used to count as the copy when it pointed at the member, so the
old bytes were lost once the member was replaced. Any entry there that is
not a regular file holding those bytes now counts as taken, and the copy
takes the next suffix. Where hard links are refused, the copy is created
with O_EXCL, so it never replaces an entry made after the name was found
free; a copy that fails partway is removed.

The payload reader parses bytes that open with a Stata header as Stata,
whatever the file is called, and infers compression from the name only
for other bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#1676 merged into main on 30 November 2026 as merge commit 0ba5e85,
so the Settings block can no longer name its head, and the next build
runs from a main commit that contains these SCF pins. REQUIRE_ON_MAIN
keeps the example's default of 1.

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

Copy link
Copy Markdown
Contributor Author

Review stopped at round 4 with four P1 findings open, so no more commits land here and it will not merge. As the Microcosm hub, I chose a rework over a call for Max: none of the four asks for a judgment.

Head: 8f4c920dae49c2cd6dea9bab1fa3ffd11ced94c2. Round 4 closed round 2's install finding (R2-1) and raised these:

  1. The raw-Stata header check in _read_stata_payload can send a valid TAR or ZIP whose first bytes read <stata_dta> to the raw parser. Round 3's name-based inference routed both correctly.
  2. _regular_file_bytes raises IsADirectoryError on a directory at the keep name and leaves its descriptor open, though its docstring promises to skip one.
  3. _write_new_file's failure cleanup checks the inode and then unlinks by name, so it can remove a file another writer put there in between.
  4. Section 4 of the runbook still says main lacks STOP_BEFORE_RELEASE and --probe. main has both, and the driver's comment at tools/route_a/route_a.sh:310 repeats the claim.

Each of the first three sits in code a review fix added. The rework deletes that code:

  • The fetches cache each member under a directory named for its SHA-256 and never write to an existing rscfp2022.dta or p22i6.dta. The lock, the backup copy and its fallback all go.
  • The readers infer compression from the file name, as round 3 did. A raw member under a .gz name moves to microcosm#1830.
  • The runbook's move to building from main goes in its own docs pull request.

The pins, the release guard and the checked-bytes parsing carry over unchanged. The rework opens as a new pull request with its own review rounds, and I'll link it here.

Reviews: rounds 1 to 4 ran on Sol lanes. The Microcosm hub's run folder holds their reports, runs/scf-route-b-2026-11-30/: round 1 at review-r3/round1-out.md, rounds 2 to 4 at review-r2/out.md, review-r3/out.md and review-r4/out.md.

@MaxGhenis

Copy link
Copy Markdown
Contributor Author

Replaced by microcosm#1833, which starts its own review. It keeps these pins, the release guard and the checked-bytes parsing. It swaps the cache install that drew three of round 4's findings for a cache keyed by SHA-256: each member goes in <cache>/<SHA-256>/<member>, and the fetch never writes the earlier <cache>/<member>. The fourth finding, the runbook's claim about main, moved to microcosm#1832. I'll leave this one open until Max rules on closing it.

🤖 Generated with Claude Code

This branch has not been deployed

No deployments
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