Skip to content

fix(imf): align SDMX 3.0 access with post-2026-05 dataflow refactor#2405

Merged
pethers merged 4 commits into
mainfrom
copilot/improve-imf-sdmx-access
May 11, 2026
Merged

fix(imf): align SDMX 3.0 access with post-2026-05 dataflow refactor#2405
pethers merged 4 commits into
mainfrom
copilot/improve-imf-sdmx-access

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

Fix IMF SDMX 3.0 access — verified live calls

Live-tested IMF SDMX 3.0 against api.imf.org/external/sdmx/3.0 (with IMF_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

Dataflow Working SDMX 3.0 path
CPI v5.0.0 /data/IMF.STA,CPI,5.0.0/SWE.CPI._T.IX.M
GFS_COFOG v11.0.0 /data/IMF.STA,GFS_COFOG,11.0.0/SWE.S13.G2MF.GF02_T.POGDP_PT.A
IMTS v1.0.0 (replaces DOTS) /data/IMF.STA,IMTS,1.0.0/SWE.XG_FOB_USD.USA.A
MFS_IR v8.0.1 /data/IMF.STA,MFS_IR,8.0.1/SWE.MMRT_RT_PT_A_PT.M
ER v4.0.1 /data/IMF.STA,ER,4.0.1/SWE.USD_XDC.PA_RT.M
PCPS v9.0.0 (under IMF.RES) /data/IMF.RES,PCPS,9.0.0/G001.POILBRE.USD.M

Changes

  • Code: imf-context.ts, check-imf-connectivity.ts (envelope shapes), imf-fetch.ts, world-bank-context.ts
  • Inventory: analysis/imf/indicators-inventory.json + analysis/economic-indicators-inventory.json
  • Docs: analysis/imf/{data-dictionary,agentic-integration,use-cases,indicator-policy-mapping,README}.md
  • Agent / prompt / skill: .github/aw/ECONOMIC_DATA_CONTRACT.md, .github/copilot-instructions.md, .github/prompts/02-mcp-access.md, .github/skills/economic-policy-analysis/SKILL.md
  • Tests: imf-context, imf-precedence-contract, imf-inventory, world-bank-context, imf-connectivity
  • PR review feedback addressed (commit b27a23c):
    • use-cases.md COFOG Health/Education examples → v11.0.0 ISO3 paths
    • use-cases.md commentary uses GFS_COFOG:GF07_T / GFS_COFOG:GF09_T
    • agentic-integration.md Recipe C label IFSCPI
    • agentic-integration.md Recipe D label DOTSIMTS
    • agentic-integration.md Recipe E PCPS path uses IMF.RES,PCPS,9.0.0/G001.POILBRE.USD.M
    • agentic-integration.md Recipe F COFOG path → v11.0.0 ISO3
    • data-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.json clients.codes description matches actual imf-codes.ts reality
    • ECONOMIC_DATA_CONTRACT.md COFOG codes consistently GF{02,07,09,10}_T
    • ECONOMIC_DATA_CONTRACT.md ER citations use USD_XDC.PA_RT / EUR_XDC.PA_RT
    • tests/imf-connectivity.test.ts covers sdmx-empty-series silent-drift case
  • npm run lint clean
  • All 224 IMF-related tests pass (including the new empty-series test)

@github-actions github-actions Bot added documentation Documentation updates testing Test coverage refactor Code refactoring skill Skill configuration agentic-workflow Agentic workflow changes agent Agent configuration size-l Large change (250-1000 lines) labels May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🏷️ Automatic Labeling Summary

This 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

  • 🗳️ Content: news, dashboard, visualization, intelligence
  • 💻 Technology: html-css, javascript, workflow, security
  • 📊 Data: cia-data, riksdag-data, data-pipeline, schema
  • 🌍 I18n: i18n, translation, rtl
  • 🔒 ISMS: isms, iso-27001, nist-csf, cis-controls
  • 🏗️ Infrastructure: ci-cd, deployment, performance, monitoring
  • 🔄 Quality: testing, accessibility, documentation, refactor
  • 🤖 AI: agent, skill, agentic-workflow

For more information, see .github/labeler.yml.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers pethers marked this pull request as ready for review May 11, 2026 08:48
Copilot AI review requested due to automatic review settings May 11, 2026 08:48
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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..POILAPSP key 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" \

Comment thread analysis/imf/use-cases.md
Comment on lines 236 to 240
# 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
Comment thread analysis/imf/use-cases.md Outdated

# 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" \
Comment thread analysis/imf/use-cases.md Outdated
**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.
Comment thread analysis/imf/agentic-integration.md Outdated
@@ -374,13 +374,13 @@ tsx scripts/imf-fetch.ts weo --country SWE --indicator LUR --years 15 --p

# Recipe C — High-frequency inflation (monthly, IFS)
Comment thread analysis/imf/agentic-integration.md Outdated
--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)
Comment on lines 179 to 184
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');
});
Comment thread analysis/imf/data-dictionary.md Outdated
@@ -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.
Comment thread analysis/imf/indicators-inventory.json Outdated
"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)",
Comment thread .github/aw/ECONOMIC_DATA_CONTRACT.md Outdated
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
Comment thread .github/aw/ECONOMIC_DATA_CONTRACT.md Outdated
`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 ·
@pethers
Copy link
Copy Markdown
Member

pethers commented May 11, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…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>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 11, 2026

@copilot apply changes based on the comments in this thread

Addressed all 11 review comments in ad423b6:

  • use-cases.md: COFOG Health/Education examples now use v11.0.0 ISO3 paths; commentary cites GFS_COFOG:GF07_T / GFS_COFOG:GF09_T instead of legacy G07/G09.
  • agentic-integration.md: Recipe C label IFSCPI, Recipe D DOTSIMTS, Recipe E PCPS path uses IMF.RES,PCPS,9.0.0, Recipe F COFOG path → v11.0.0 ISO3.
  • data-dictionary.md §1.2: country-codes bullet rewritten to say SDMX 3.0 dataflows accept ISO3 directly (legacy IMF AREA codes retired); §1.3 transport matrix now lists CPI/IMTS with versions.
  • indicators-inventory.json: clients.codes description now accurately describes what scripts/imf-codes.ts contains (ISO3 peer-set + legacy-only mapping kept for backward compat).
  • ECONOMIC_DATA_CONTRACT.md: COFOG codes consistently GF{02,07,09,10}_T; ER EUR citation uses EUR_XDC.PA_RT instead of retired ENDE_XDC_EUR_RATE.
  • tests/imf-connectivity.test.ts: added empty-series stub mode and a regression test asserting CPI probe reports ok=false, error='sdmx-empty-series'.

All 224 IMF-related tests pass; lint clean.

@pethers pethers requested a review from Copilot May 11, 2026 09:11
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@pethers pethers merged commit 2daa9d4 into main May 11, 2026
18 checks passed
@pethers pethers deleted the copilot/improve-imf-sdmx-access branch May 11, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent Agent configuration agentic-workflow Agentic workflow changes documentation Documentation updates refactor Code refactoring size-l Large change (250-1000 lines) skill Skill configuration testing Test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants