P4 groundwork: manifest, four-stage builder and provenance/ for business_cycle - #109
Merged
Conversation
…ess_cycle Closes the Phase 6 backfill and settles #13, as the on-ramp to the P4 dynamic-snapshot pilot. - lectures/business_cycle_data.csv.yml: the last unmanifested dataset gets its manifest — class dynamic-snapshot, cadence annual, the first `pattern` column entry (YR\d{4}), consumers empty (intro's business_cycle still makes the live wbgapi call the builder reproduces; adoption is the P4 decision). integrity.upstream is `diverged` / `upstream-moved`: a full re-run against live WDI on 2026-09-01 revised 236 of 320 overlap cells (max 1.5 pp) and appended YR2024-YR2025. Register entry on #39 to follow. - builders/business_cycle.py: fetch -> pre-process -> validate -> write. validate() asserts the grid, the five economies, percent units, the one structural null and recency, and bounds the overlap window against the committed snapshot at 5 pp with a printed revision summary — equality is the wrong test for a revised aggregate. --out-dir gives a dry run. Not run into lectures/: the bytes are unchanged (a migration moves bytes). - provenance/: the two World Bank metadata dumps leave the published tree (#13, option 3). Not served, no manifests, regenerated every run; README says why they exist and what they are evidence for. - migration.yml record (landed, P4), manifest-schema.yml documents the `pattern` form, CATALOG.md regenerated, and the counts in AGENTS.md, builders/README.md, requirements.txt and four PLAN.md boxes updated. Gates: check_consumed_files 41 manifests / 0 errors; strict audit problem set unchanged against the same clones; builder dry run passes on live WDI. See #13, #14, #39. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…hape Three interfaces, three audiences. An upstream interface change fails the builder's validate(), writes nothing, and opens an issue here — consumers are unaffected by construction and the change is absorbed in pre_process. A successful refresh reaches each consumer per a new per-consumer `on_refresh` field (rebuild | review), sketched in manifest-schema.yml for the Phase 5 fan-out. A deliberate published-schema change is a new filename plus a hand-opened issue in every consumer repo. Recorded ahead of the workflows so they are written to a stated policy. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Groundwork for the P4 dynamic-snapshot pilot by fully onboarding the business_cycle_data.csv dataset into the repo’s manifest/builder/provenance conventions, while keeping the published dataset bytes unchanged.
Changes:
- Added a full sidecar manifest for
lectures/business_cycle_data.csv(classed asdynamic-snapshot, with cadence, schema patterning, and upstream-delta documentation). - Refactored
builders/business_cycle.pyinto the four-stage fetch → pre-process → validate → write structure and moved metadata/info dumps out of the publishedlectures/tree intoprovenance/. - Updated repo bookkeeping/docs (
CATALOG.md,migration.yml,PLAN.md,AGENTS.md,builders/README.md,manifest-schema.yml,requirements.txt) to reflect completion of the Phase 6 backfill and the newpatternschema concept.
Reviewed changes
Copilot reviewed 9 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| requirements.txt | Updates pandas usage commentary to include business_cycle.py. |
| provenance/README.md | Introduces and documents the new unserved provenance/ directory purpose. |
| provenance/business_cycle_metadata.md | Moves World Bank series metadata dump into provenance. |
| provenance/business_cycle_info.md | Moves wb.series.info(...) dump into provenance. |
| PLAN.md | Marks Phase 5/6/7 checkboxes as completed for business_cycle groundwork. |
| migration.yml | Adds a P4 business_cycle_data.csv record and status bookkeeping. |
| manifest-schema.yml | Documents columns[].pattern as an alternative to enumerated column names. |
| lectures/business_cycle_data.csv.yml | Adds the missing dataset manifest for the dynamic snapshot. |
| CATALOG.md | Regenerates catalog to include the new manifested dataset (41 total). |
| builders/README.md | Updates builder inventory to reflect business_cycle as a dynamic snapshot and provenance output relocation. |
| builders/business_cycle.py | Refactors builder into four stages with validation and provenance output. |
| AGENTS.md | Updates repo map/counts and adds a policy section about refresh/break/schema-change notifications. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
migration.yml: `landed` means file + manifest by the file's own lifecycle definition, and the manifest arrived with #109, not with the #10 flatten that placed the bytes — the record now says so. business_cycle.py: every write goes through a same-directory temp file and os.replace(), so an interrupted run cannot leave a truncated file where the last-good snapshot was — the docstring made that promise and the direct to_csv() did not keep it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Sep 1, 2026
Closed
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.
The on-ramp to the P4 dynamic-snapshot pilot: the last unmanifested dataset gets its manifest, its builder gets the four-stage contract, and the two World Bank metadata dumps leave the published tree. Closes the Phase 6 backfill and settles #13 (option 3, as recommended there on 2026-08-06). Two commits: the work, then a short policy note.
The finding that shaped it. Re-running the builder against live WDI (
lastupdated2026-07-13) does not reproduce the committed CSV: the World Bank revised 236 of the 320 overlap cells (63 of 64 year columns; median change 0.0 pp, 99th percentile 1.0, max 1.5) and appendedYR2024/YR2025. This is a genuine tracking snapshot, so equality is the wrong overlap test anddivergedis its normal state between refreshes.What changes
lectures/business_cycle_data.csv.yml—class: dynamic-snapshot,cadence: annual,integrity.upstream: diverged / upstream-movedwith the measured delta, the firstpatterncolumn entry (YR\d{4}, as Builder architecture: four-stage template, traceback-clean failures, notebook policy (Phase 5) #14 recommended for a column set that grows),consumers: []. Intro'sbusiness_cyclestill makes the live wbgapi call the builder reproduces; whether it adopts the snapshot is the P4 decision, not this PR's.builders/business_cycle.py— fetch → pre-process → validate → write.validate()asserts the grid, the five economies, percent units, the one structural null (YR1960) and recency, and bounds the overlap window against the committed snapshot at 5 pp (3× the largest routine revision observed) with a printed revision summary — the review surface for a future refresh PR.--out-dirgives a dry run. The bytes inlectures/are unchanged; a refresh is a separate, reviewed PR.provenance/— both dumps move here (git mv), with a README saying what they are evidence for. Not served (the Pages job assemblessite/,lectures/andaudit.jsononly), no manifests, regenerated every run. Zero readers org-wide by code search and audit.migration.ymlrecord (landed, P4),manifest-schema.ymldocuments thepatternform,CATALOG.mdregenerated (41 datasets), counts corrected inAGENTS.md,builders/README.mdandrequirements.txt, and fourPLAN.mdboxes ticked (Phase 5 retrofit; Phase 6 manifest and classify; Phase 7 dynamic re-run — "and they do not agree, by design").AGENTS.mdsection, "Refresh, break, or schema change — who gets told", and a per-consumeron_refresh: rebuild | reviewfield sketched in the schema. An upstream interface change failsvalidate(), writes nothing and opens an issue here (consumers unaffected by construction; the change is absorbed inpre_process); a successful refresh fans out to consumers peron_refresh; a deliberate schema change is a new filename plus hand-opened consumer issues. Recorded ahead of the Phase 5 workflows so they are written to a stated policy.Judgement calls, flagged for review:
retrieved: null(the bytes came from the builder at QuantEcon/data b857c5c, 2025-02-16, but AGENTS.md says not to reconstruct a date from git history — the vintage is pinned by content instead); the 5 pp bound;date_range.end: 2023as the concrete newest column rather than the schema'snull; the dumps moved rather than deleted, since they are what the licence fields cite. The catalog's summary line now says "1 awaiting repoint" for alandedrecord with no consumer — the renderer's vocabulary, left for a later tidy.Gates.
check_consumed_files: 41 manifests, 0 errors. Strict audit scan against the same local clones: problem set identical before and after. Builder dry run against live WDI: passes, prints the overlap summary above. The register entry this manifest'sintegrity.upstreampoints at is posted on #39 alongside this PR.See #13, #14, #39.
🤖 Generated with Claude Code