Skip to content

fix: clarify IMF real GDP local-currency units#4072

Open
patrykcodex-del wants to merge 2 commits into
koala73:mainfrom
patrykcodex-del:fix/imf-real-gdp-lcu-field
Open

fix: clarify IMF real GDP local-currency units#4072
patrykcodex-del wants to merge 2 commits into
koala73:mainfrom
patrykcodex-del:fix/imf-real-gdp-lcu-field

Conversation

@patrykcodex-del
Copy link
Copy Markdown

@patrykcodex-del patrykcodex-del commented Jun 3, 2026

Summary

  • Use the IMF NGDP_R field for real GDP in local currency units instead of the ambiguous RGDP alias.
  • Update the country-data service fallback and seed/test fixtures so the real-GDP local-currency field is consistently named.
  • Bump the IMF growth seeder schema version from 2 to 3 for the stored data-shape rename, preserving the existing economic:imf:growth:v1 cache key and WEO aggregate filtering / ISO3→ISO2 behavior.

Test plan

  • npm run test:data -- tests/seed-imf-extended.test.mjs tests/imf-country-data.test.mts ✅ (10,483 passed / 0 failed / 6 skipped; full test:data suite runs due package script glob)
  • npm run typecheck
  • npx biome lint scripts/seed-imf-growth.mjs src/services/imf-country-data.ts tests/imf-country-data.test.mts tests/seed-imf-extended.test.mjs
  • npm run lint:safe-html
  • git diff --check origin/main...HEAD

Closes #3837

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

@patrykcodex-del is attempting to deploy a commit to the World Monitor Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the trust:caution Brin: contributor trust score caution label Jun 3, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 3, 2026

Greptile Summary

This PR renames the realGdp field to realGdpLcuB across the IMF growth seeder, the ImfGrowthEntry TypeScript interface, and all test fixtures to clarify that the value is real GDP in local currency units (billions). The economic:imf:growth:v1 cache key and all other seeder behaviour are preserved.

  • scripts/seed-imf-growth.mjs: Output field renamed from realGdprealGdpLcuB; the comment for NGDP_R gains a "billions" qualifier. Internal variable names are unchanged.
  • src/services/imf-country-data.ts: ImfGrowthEntry.realGdp renamed to realGdpLcuB; no production code path currently reads this field, so there is no runtime regression.
  • Tests: All fixture objects and the new 'realGdp' in countries.US === false assertion are updated consistently.

Confidence Score: 3/5

Safe to merge with one follow-up: the schema version should be bumped before any code that reads realGdpLcuB is deployed.

The rename is consistent across the seeder, the TypeScript interface, and all test fixtures, and no production code currently reads the renamed field so there is no immediate regression. However, the codebase convention requires the schemaVersion to increment whenever the stored data shape changes. Skipping that bump means Redis entries written before this deploy (TTL up to 35 days) will carry the old realGdp key; any future feature that reads realGdpLcuB deployed into that window would silently get undefined instead of the real-GDP value.

scripts/seed-imf-growth.mjs — the schemaVersion field should be bumped from 2 to 3 to match the field rename.

Important Files Changed

Filename Overview
scripts/seed-imf-growth.mjs Renames output field realGdprealGdpLcuB and clarifies the comment; internal variable names are unchanged. Missing schema-version bump (2→3) for the data-shape change.
src/services/imf-country-data.ts Interface ImfGrowthEntry field renamed from realGdp to realGdpLcuB; no consumers of the field exist in the service layer, so the rename is non-breaking at runtime.
tests/imf-country-data.test.mts All five fixture objects updated from realGdp: null to realGdpLcuB: null; changes are mechanical and consistent with the interface rename.
tests/seed-imf-extended.test.mjs New assertions verify realGdpLcuB is present with the correct value and that the old realGdp key is absent; good regression coverage for the rename.

Sequence Diagram

sequenceDiagram
    participant Railway as Railway Cron
    participant Seeder as seed-imf-growth.mjs
    participant IMF as IMF SDMX API
    participant Redis as Redis Cache
    participant Bootstrap as /api/bootstrap
    participant Client as SPA Client

    Railway->>Seeder: trigger (every ~35 days)
    Seeder->>IMF: fetch NGDP_R (+ 6 other indicators)
    IMF-->>Seeder: per-country series
    Seeder->>Seeder: buildGrowthCountries() maps ISO3→ISO2, writes realGdpLcuB
    Seeder->>Redis: "SET economic:imf:growth:v1 { countries: { US: { realGdpLcuB } } }"
    Client->>Bootstrap: "GET /api/bootstrap?keys=imfGrowth"
    Bootstrap->>Redis: GET economic:imf:growth:v1
    Redis-->>Bootstrap: cached payload
    Bootstrap-->>Client: ImfGrowthEntry[] with realGdpLcuB field
Loading

Comments Outside Diff (1)

  1. scripts/seed-imf-growth.mjs, line 169 (link)

    P1 Schema version not bumped for field rename

    The rename of realGdprealGdpLcuB is a data-shape change. The project's established convention (documented in _seed-envelope-source.mjs: "increments when data shape changes") and the inline comment on this very line show that a prior field addition (latestYear) triggered a 1→2 bump in PR feat(imf-weo): Sprint 4 IMF cohort — content-age (forecast-year semantics, 18mo budget) #3604. This PR should bump 2→3. Without that, cached data in Redis (TTL = 35 days) will continue serving the old realGdp key; any code that reads realGdpLcuB deployed before the cache naturally expires will silently receive undefined rather than the real-GDP value.

Reviews (1): Last reviewed commit: "fix: clarify IMF real GDP local-currency..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

trust:caution Brin: contributor trust score caution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(seeders): rename ambiguous-unit realGdp field in economic:imf:growth:v1

1 participant