fix(imf): align SDMX 3.0 access with post-2026-05 dataflow refactor#2405
Conversation
Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/2a9bc1b3-d4c3-4fac-bf70-3a95d70ce854 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: documentation,testing,refactor,skill,size-l,agentic-workflow,agent Label Categories
For more information, see |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
Pull request overview
Updates Riksdagsmonitor’s IMF SDMX 3.0 integration surface (code, inventories, docs, prompts/skills, and tests) to match the IMF post‑2026‑05 SDMX refactor (IFS → CPI/MFS_IR/ER, DOTS → IMTS, PCPS agency/version changes, ISO3 country keys, and updated indicator codes).
Changes:
- Refactors IMF “database/dataflow” identifiers and canonical SDMX paths across the codebase (CPI/IMTS/ER + updated COFOG/FX/rate indicators).
- Hardens the IMF connectivity preflight to accept multiple SDMX-JSON envelope shapes and detect “200 OK but empty series” drift.
- Refreshes inventories, prompts, skills, and tests to enforce the updated citation + provenance contract.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/imf-context.ts | Updates the IMF database union and indicator catalogue for post‑refactor dataflows/codes. |
| scripts/check-imf-connectivity.ts | Updates SDMX probe from IFS→CPI and adds stricter SDMX envelope/series validation. |
| scripts/imf-fetch.ts | Updates CLI documentation and persist cache-key example to the new CPI SDMX path. |
| scripts/world-bank-context.ts | Updates IMF citation examples referenced by economic-context detection docs. |
| analysis/imf/indicators-inventory.json | Rewrites SDMX metadata (agencies/versions/dimensions/paths) for CPI/IMTS/PCPS/ER + COFOG updates. |
| analysis/economic-indicators-inventory.json | Refreshes IMF provider database list and refresh cadence after refactor. |
| analysis/imf/data-dictionary.md | Updates SDMX examples and dataflow documentation for the new SDMX 3.0 shapes. |
| analysis/imf/agentic-integration.md | Updates agentic workflow recipes and guidance to the new canonical IMF paths/codes. |
| analysis/imf/use-cases.md | Updates worked examples to use the new SDMX 3.0 dataflows/codes. |
| analysis/imf/indicator-policy-mapping.md | Updates committee→indicator mappings to post‑refactor IMF codes/dataflows. |
| analysis/imf/README.md | Updates high-level guidance and committee mappings for new codes/dataflows. |
| .github/aw/ECONOMIC_DATA_CONTRACT.md | Updates the contract’s canonical IMF citation list to post‑refactor identifiers. |
| .github/copilot-instructions.md | Refreshes “IMF Quick Reference” commands and examples to the new SDMX paths. |
| .github/prompts/02-mcp-access.md | Updates the IMF CLI usage examples and refactor notes for agents. |
| .github/skills/economic-policy-analysis/SKILL.md | Updates skill recipes/provider table for CPI/IMTS/COFOG/ER changes. |
| tests/imf-context.test.ts | Updates expected codes and committee matrix entries to new indicators. |
| tests/imf-precedence-contract.test.ts | Updates expected IMF database list to post‑refactor set (incl. ER). |
| tests/imf-inventory.test.ts | Updates expected canonical dataflow list after refactor. |
| tests/world-bank-context.test.ts | Updates economic-context detection tests to new IMF citation patterns. |
| tests/imf-connectivity.test.ts | Updates SDMX stub + expectations for the CPI probe and new envelope shape. |
Comments suppressed due to low confidence (1)
analysis/imf/agentic-integration.md:387
- Recipe E’s PCPS example still uses the old
IMF.RES,PCPS,4.0.0/M..POILAPSPkey shape, which is inconsistent with the PR’s post‑2026‑05 PCPS v9.0.0 paths (e.g.,G001.POILAPSP.USD.M). Update the recipe to the new version/key format so it remains copy/paste runnable.
--indicator XG_FOB_USD --country SWE --persist
# Recipe E — Commodity pass-through (MJU, FiU inflation drivers)
tsx scripts/imf-fetch.ts sdmx \
--path "/data/IMF.RES,PCPS,4.0.0/M..POILAPSP?startPeriod=2022-01" \
| # COFOG 07 — Health (SoU) | ||
| tsx scripts/imf-fetch.ts sdmx \ | ||
| --path "/data/IMF.STA,GFS_COFOG,4.0.0/A.144.G.G07._Z._Z._Z._Z.XDC_R_B1GQ?startPeriod=2015" \ | ||
| --indicator G07 --country SWE --persist | ||
| --indicator GF07_T --country SWE --persist | ||
| sleep 1 |
|
|
||
| # COFOG 09 — Education (UbU) | ||
| tsx scripts/imf-fetch.ts sdmx \ | ||
| --path "/data/IMF.STA,GFS_COFOG,4.0.0/A.144.G.G09._Z._Z._Z._Z.XDC_R_B1GQ?startPeriod=2015" \ |
| **Commentary**: | ||
|
|
||
| > On the IMF GFS COFOG vintage for 2024 (T+1), Sweden's general-government spending by function allocated **1.6 %** of GDP to defence (function 02, `GFS_COFOG:G02`), **7.2 %** to health (function 07, `G07`), and **6.8 %** to education (function 09, `G09`). The defence ratio has climbed from 1.1 % in 2019 — consistent with the FöU-driven NATO-readiness ramp. Health tracks close to the OECD median; education retains Sweden's historical above-median position. | ||
| > On the IMF GFS COFOG vintage for 2024 (T+1), Sweden's general-government spending by function allocated **1.6 %** of GDP to defence (function 02, `GFS_COFOG:GF02_T`), **7.2 %** to health (function 07, `G07`), and **6.8 %** to education (function 09, `G09`). The defence ratio has climbed from 1.1 % in 2019 — consistent with the FöU-driven NATO-readiness ramp. Health tracks close to the OECD median; education retains Sweden's historical above-median position. |
| @@ -374,13 +374,13 @@ tsx scripts/imf-fetch.ts weo --country SWE --indicator LUR --years 15 --p | |||
|
|
|||
| # Recipe C — High-frequency inflation (monthly, IFS) | |||
| --path "/data/IMF.STA,CPI,5.0.0/SWE.CPI._T.IX.M?startPeriod=2023-01" \ | ||
| --indicator _T.IX --country SWE --persist | ||
|
|
||
| # Recipe D — Trade partner analysis (NU / UU articles, DOTS) |
| it('marks non-object SDMX responses as not ok', async () => { | ||
| const probes = await runProbes(makeStubClient({ sdmx: 'non-object' })); | ||
| const ifs = probes.find((p) => p.dataflow === 'IFS'); | ||
| const ifs = probes.find((p) => p.dataflow === 'CPI'); | ||
| expect(ifs?.ok).toBe(false); | ||
| expect(ifs?.error).toBe('non-object-response'); | ||
| }); |
| @@ -32,7 +32,7 @@ IMF public data is exposed on two transports, both unauthenticated and both on t | |||
| - Country codes: **IMF AREA numeric** (`144`=SWE, `128`=DNK, `142`=NOR, `172`=FIN, `134`=DEU) for IFS/GFS/BOP. WEO still uses ISO-3 here. | |||
| "library": "scripts/imf-client.ts (ImfClient class)", | ||
| "codes": "scripts/imf-codes.ts (ISO3_TO_IMF_AREA for IFS/GFS/BOP numeric area codes)", | ||
| "context": "scripts/imf-context.ts (policy-area ↔ committee mapping, IMF_NORDIC_PEERS)" | ||
| "codes": "scripts/imf-codes.ts (ISO3 codes for SDMX 3.0 \u2014 the legacy 3-digit IMF AREA codes were retired in the 2026-05 SDMX 3.0 refactor; SDMX 3.0 dataflows now accept ISO3 directly as COUNTRY)", |
| cyclically-adjusted balance. | ||
| - `WEO:GGR_NGDP` for revenue / GDP · `WEO:GGX_NGDP` for expenditure / | ||
| GDP · `GFS_COFOG:G02 / G07 / G09 / G10` for COFOG functional | ||
| GDP · `GFS_COFOG:GF02_T / G07 / G09 / G10` for COFOG functional |
| `ER:ENDA_XDC_USD_RATE` / `ER:ENDE_XDC_EUR_RATE` for exchange rates · | ||
| `IMTS:XG_FOB_USD`, `IMTS:MG_CIF_USD` for bilateral trade flows. | ||
| - `MFS_IR:MMRT_RT_PT_A_PT` for the Riksbank policy rate · | ||
| `ER:USD_XDC.PA_RT` / `ER:ENDE_XDC_EUR_RATE` for exchange rates · |
|
@copilot apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…els, sdmx-empty-series test Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/e1dc449d-c9f0-4387-9558-14cb4e41353b Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Addressed all 11 review comments in
All 224 IMF-related tests pass; lint clean. |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Fix IMF SDMX 3.0 access — verified live calls
Live-tested IMF SDMX 3.0 against
api.imf.org/external/sdmx/3.0(withIMF_SDMX_SUBSCRIPTION_KEY) and discovered every documented dataflow example was now broken because of the IMF 2026-05 SDMX 3.0 refactor.Verified live (2026-05-11) — all return
series=1/data/IMF.STA,CPI,5.0.0/SWE.CPI._T.IX.M/data/IMF.STA,GFS_COFOG,11.0.0/SWE.S13.G2MF.GF02_T.POGDP_PT.A/data/IMF.STA,IMTS,1.0.0/SWE.XG_FOB_USD.USA.A/data/IMF.STA,MFS_IR,8.0.1/SWE.MMRT_RT_PT_A_PT.M/data/IMF.STA,ER,4.0.1/SWE.USD_XDC.PA_RT.M/data/IMF.RES,PCPS,9.0.0/G001.POILBRE.USD.MChanges
imf-context.ts,check-imf-connectivity.ts(envelope shapes),imf-fetch.ts,world-bank-context.tsanalysis/imf/indicators-inventory.json+analysis/economic-indicators-inventory.jsonanalysis/imf/{data-dictionary,agentic-integration,use-cases,indicator-policy-mapping,README}.md.github/aw/ECONOMIC_DATA_CONTRACT.md,.github/copilot-instructions.md,.github/prompts/02-mcp-access.md,.github/skills/economic-policy-analysis/SKILL.mdimf-context,imf-precedence-contract,imf-inventory,world-bank-context,imf-connectivityb27a23c):use-cases.mdCOFOG Health/Education examples → v11.0.0 ISO3 pathsuse-cases.mdcommentary usesGFS_COFOG:GF07_T/GFS_COFOG:GF09_Tagentic-integration.mdRecipe C labelIFS→CPIagentic-integration.mdRecipe D labelDOTS→IMTSagentic-integration.mdRecipe E PCPS path usesIMF.RES,PCPS,9.0.0/G001.POILBRE.USD.Magentic-integration.mdRecipe F COFOG path → v11.0.0 ISO3data-dictionary.md§1.2 country-codes bullet rewritten (ISO3 for all dataflows)data-dictionary.md§1.3 transport matrix rewritten (CPI/IMTS, version notes)indicators-inventory.jsonclients.codesdescription matches actualimf-codes.tsrealityECONOMIC_DATA_CONTRACT.mdCOFOG codes consistentlyGF{02,07,09,10}_TECONOMIC_DATA_CONTRACT.mdER citations useUSD_XDC.PA_RT/EUR_XDC.PA_RTtests/imf-connectivity.test.tscoverssdmx-empty-seriessilent-drift casenpm run lintclean