Skip to content

Adopt IMF data alongside World Bank (Economic Data Contract v2.0)#1872

Merged
pethers merged 12 commits intomainfrom
copilot/investigate-replace-economic-indicators
Apr 20, 2026
Merged

Adopt IMF data alongside World Bank (Economic Data Contract v2.0)#1872
pethers merged 12 commits intomainfrom
copilot/investigate-replace-economic-indicators

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Swap the third-party c-cf/imf-data-mcp Python MCP (stdio, uvx) for the repo's pure-TypeScript scripts/imf-client.ts, exposed to agentic workflows through a new thin CLI (scripts/imf-fetch.ts) invoked via the bash tool. Eliminates Python / uvx from the agentic runtime, drops pypi.org + files.pythonhosted.org from every workflow firewall allowlist, and brings IMF under the same npm / SBOM governance as World Bank and SCB.

Code

  • New scripts/imf-fetch.ts — thin CLI over ImfClient + persistIMFData. Commands: weo, compare, sdmx, list-indicators, help.
  • scripts/parliamentary-data/data-persistence.tspersistIMFData() provenance tag flipped imf-data-mcpimf-ts-client.
  • scripts/imf-client.ts + scripts/imf-context.ts — JSDoc pruned of references to the retired MCP.

Configs / workflows (pure removal)

  • .github/copilot-mcp.jsonimf MCP server entry removed.
  • .github/workflows/copilot-setup-steps.ymlpython3 / pipx / uv install + uvx pre-warm + verification block dropped.
  • All 12 .github/workflows/news-*.md frontmatters — imf: MCP block removed; pypi.org + files.pythonhosted.org removed from both network: and safe-outputs: allowlists.

Docs / governance

  • ECONOMIC_DATA_CONTRACT.md v2.0 + SHARED_PROMPT_PATTERNS.md — MCP 4-call discovery flow replaced by tsx scripts/imf-fetch.ts … idiom.
  • ADR 0001 — Decision + Consequences rewritten around the TS-only stack; c-cf/imf-data-mcp moved to "Alternatives rejected".
  • THREAT_MODEL.md TB-6a — PyPI / upstream-repo / uvx vectors retired.
  • FUTURE_THREAT_MODEL.md IMF row MEDIUM → LOW.
  • SECURITY_ARCHITECTURE.md + package.jsonx-external-mcp manifest emptied.
  • analysis/schemas/economic-data.schema.jsonsource.imf description updated.
  • analysis/imf/{README,use-cases}.md, analysis/economic-indicators-inventory.json, agents — all narrate IMF as a TS client + CLI, not an MCP.

PR review feedback addressed

  • Comment 1 (validate-economic-context.ts) — added \bIMF\b / \bSCB\b word boundaries to hasAttribution().
  • Comment 2 (imf-client.ts) — 429 back-off rewritten to documented exponential 1 s → 2 s → 4 s, honours Retry-After (capped at 30 s).
  • Comment 3 (imf-fetch.ts) — SDMX persist-key comment rewritten to match the path-segment heuristic.
  • Comment 4 (imf-fetch.ts) — local module imports switched to .js specifiers. Fixed the TS5097 CI error on the TypeScript type-check (scripts) step.
  • Comment 5 (load-economic-context.ts) — module header no longer claims IMF is an MCP tool.
  • Comment 6 (load-economic-context.ts) — file vs loaded types split (EconomicContextSourceFile with optional imf; EconomicContextSource with required imf).

CI failures fixed

  • TypeScript type-check (scripts) — fixed by comment Fix MCP server paths and add rule-based Copilot instructions #4 (.js import specifiers).
  • Unit Tests (Vitest)tests/analysis-quality-validation.test.ts was failing because analysis/daily/2026-04-20/propositions/data-download-manifest.md line 99 contained the literal string "[PLACEHOLDER]" in a self-audit bullet ("✅ 0 [PLACEHOLDER] patterns"), which the test's \[PLACEHOLDER\] detector regex correctly flagged as an unfilled placeholder. Rephrased the bullet to ✅ 0 bracketed "PLACEHOLDER" patterns. — preserves the audit claim without the literal token. tests/analysis-quality-validation.test.ts now passes: 35 / 35.

Validation

  • npx tsc --project tsconfig.scripts.json --noEmitclean.
  • npx tsc --project tsconfig.lib.json --noEmitclean.
  • ESLint on all changed files — clean.
  • Targeted tests: imf-client, data-persistence, imf-context, imf-codes, validate-economic-context, economic-context-multi-provider, analysis-quality-validation — 168 / 168 pass.

Net result

IMF access is now exactly parallel to World Bank and SCB: a plain npm TypeScript module. No Python, no uvx, no third-party MCP. Firewall egress shrinks to the three IMF origins (data.imf.org, api.imf.org, www.imf.org). Supply-chain surface drops accordingly — TB-6a is now LOW rather than MEDIUM.

@github-actions github-actions Bot added documentation Documentation updates security Security improvements workflow GitHub Actions workflows riksdag-data Riksdag-Regering MCP data schema Data schema changes isms ISMS compliance changes ci-cd CI/CD pipeline changes testing Test coverage refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes size-xl Extra large change (> 1000 lines) labels Apr 20, 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,security,workflow,riksdag-data,schema,isms,ci-cd,testing,refactor,size-xl,news,agentic-workflow

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

@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

@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

@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

@github-actions github-actions Bot added dependencies Dependency updates iso-27001 ISO 27001 controls labels Apr 20, 2026
@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

…ale schema description

Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/48ad87bd-eaf9-41e8-907f-ecfc8895487a

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@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 April 20, 2026 14:57
Copilot AI review requested due to automatic review settings April 20, 2026 14:57
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

This PR migrates IMF data ingestion from an external Python MCP (uvx/stdio) to an in-repo TypeScript client + thin CLI, updating the Economic Data Contract to v2.0 so workflows, validators, persistence, and documentation treat IMF as a first-class provider alongside World Bank and SCB.

Changes:

  • Add a pure-TypeScript IMF client + CLI (scripts/imf-client.ts, scripts/imf-fetch.ts) and persist IMF responses under analysis/data/imf/… with sidecar provenance.
  • Extend the economic-context loader/validator and statistical-claims mapping to support IMF provider/projection metadata and attribution.
  • Remove IMF MCP/PyPI runtime expectations from workflows/setup and update docs, schema, ADR, and threat models accordingly.

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/validate-economic-context.test.ts Updates validator expectations for IMF-inclusive attribution messaging.
tests/statistical-claims-detector.test.ts Adds coverage ensuring IMF indicator codes propagate into detected claims.
tests/imf-context.test.ts New tests for IMF policy/committee indicator mapping utilities.
tests/imf-codes.test.ts New tests for ISO3↔IMF AREA mappings and related helpers.
tests/imf-client.test.ts New tests for IMF client parsing, retry/backoff behavior, projections, and SDMX passthrough.
tests/economic-context-multi-provider.test.ts New tests validating v1/v2 economic-data loader behavior with mixed providers.
tests/data-persistence.test.ts Adds tests for persistIMFData() persistence layout + metadata sidecar.
scripts/validate-economic-context.ts Extends attribution + validation messaging to include IMF and structured attribution logic.
scripts/statistical-claims-detector.ts Adds optional imfIndicator field to claim patterns and outputs.
scripts/parliamentary-data/data-persistence.ts Adds persistIMFData() and registers imf persistence type.
scripts/imf-fetch.ts New tsx CLI to fetch/persist IMF WEO/compare/SDMX data for workflows.
scripts/imf-context.ts New IMF indicator catalogue + lookup helpers for domains/committees/citations.
scripts/imf-codes.ts New canonical code mappings for IMF datamapper vs SDMX area codes.
scripts/imf-client.ts New REST client for IMF Datamapper JSON + SDMX 3.0 with retries/timeouts.
scripts/data-transformers/load-economic-context.ts Extends loader to accept v2 provider/projection metadata and source.imf[] (with v1 back-compat).
package.json Empties/notes x-external-mcp to reflect TS-only IMF integration under npm/SBOM governance.
docs/adr/0001-adopt-imf-data-alongside-world-bank.md Adds ADR documenting the TS-only IMF approach and its consequences.
analysis/schemas/economic-data.schema.json Updates schema descriptions and adds optional provider/projection metadata + source.imf.
analysis/imf/use-cases.md New IMF integration use-cases documenting CLI usage and example artefacts.
analysis/imf/indicator-policy-mapping.md New mapping document aligning committees/policy areas with IMF indicators.
analysis/imf/README.md New IMF integration overview (why/strategy/surface/rate-limit discipline).
analysis/economic-indicators-inventory.json New multi-provider inventory v4.0 including IMF entries and provider-selection rules.
THREAT_MODEL.md Adds TB-6a threat model entry for direct IMF HTTP access via TS client (no MCP).
SECURITY_ARCHITECTURE.md Notes x-external-mcp tracking and that IMF is now in npm/SBOM scope.
README.md Updates data-source list to include IMF and clarifies narrowed WB role.
FUTURE_THREAT_MODEL.md Adds future-threat row for IMF integration and reduces risk rating.
.github/workflows/news-weekly-review.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-week-ahead.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-translate.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-realtime-monitor.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-propositions.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-motions.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-monthly-review.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-month-ahead.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-interpellations.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-evening-analysis.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-committee-reports.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/news-article-generator.md Adds IMF origins to network/safe-outputs allowlists after MCP removal.
.github/workflows/economic-context-audit.yml Documents the v1→v2 grace window for attribution/schema evolution.
.github/workflows/copilot-setup-steps.yml Removes Python runtime setup and documents IMF as TS client invoked via tsx.
.github/aw/SHARED_PROMPT_PATTERNS.md Updates economic indicator discovery/fetch guidance to use TS CLI for IMF.
.github/aw/ECONOMIC_DATA_CONTRACT.md Updates contract to v2.0: IMF-first macro/fiscal, provider/projection rules, grace window.
.github/agents/news-journalist.md Updates agent guidance to include IMF projections where relevant.
.github/agents/intelligence-operative.md Updates tooling matrix to describe IMF access via bash/tsx instead of MCP.
.github/agents/data-pipeline-specialist.md Updates pipeline guidance to include IMF TS client/CLI, caching, and rate-limit rules.

Comment thread scripts/validate-economic-context.ts Outdated
Comment on lines +156 to +157
export function hasAttribution(html: string): boolean {
return /World Bank|världsbanken|verdensbank|weltbank|banco mundial|banque mondiale|wereldbank|البنك الدولي|הבנק העולמי|世界銀行|세계은행|世界银行|SCB|Statistics Sweden|Statistiska centralbyrån/i.test(html);
return /IMF|International Monetary Fund|Internationella valutafonden|Internationaler Währungsfonds|Fondo Monetario Internacional|Fonds monétaire international|Internationaal Monetair Fonds|صندوق النقد الدولي|קרן המטבע הבינלאומית|国際通貨基金|국제통화기금|国际货币基金组织|World Bank|världsbanken|verdensbank|weltbank|banco mundial|banque mondiale|wereldbank|البنك الدولي|הבנק העולמי|世界銀行|세계은행|世界银行|SCB|Statistics Sweden|Statistiska centralbyrån/i.test(html);
Comment thread scripts/imf-client.ts
Comment on lines +308 to +314
if (response.status === 429 && attempt < this.maxRetries) {
// Respect IMF advertised rate limit (~10 req / 5 s).
const delay = 1_000 * (attempt + 1) + 1_000;
clearTimeout(timeoutId);
await new Promise((resolve) => setTimeout(resolve, delay));
return this.fetchWithRetry(url, attempt + 1, extraHeaders);
}
Comment thread scripts/imf-fetch.ts
Comment on lines +155 to +160
if (booleans.has('persist')) {
// Derive a reasonable cache key from --indicator / --country when given;
// otherwise fall back to hashing the SDMX path so caches collide cleanly
// on re-runs with identical queries.
const indicator = flags.get('indicator') ?? pathWithQuery.split('/').slice(-2)[0] ?? 'sdmx';
const country = flags.get('country') ?? 'all';
Comment thread scripts/imf-fetch.ts Outdated
Comment on lines +34 to +35
import { ImfClient, IMF_WEO_INDICATORS, IMF_FM_INDICATORS } from './imf-client.ts';
import { persistIMFData } from './parliamentary-data/data-persistence.ts';
Comment on lines 6 to 8
* The loader bridges the data produced by workflow agents (which call
* World Bank / SCB MCP tools) and the HTML renderer in
* World Bank / IMF / SCB MCP tools) and the HTML renderer in
* `content-generators/economic-dashboard-section.ts`. When the JSON file
Comment on lines 45 to +56
export interface EconomicContextSource {
/** World Bank indicator IDs actually queried (e.g. `NY.GDP.MKTP.KD.ZG`). */
worldBank: string[];
/** SCB table IDs actually queried (e.g. `TAB1291`). */
scb: string[];
/**
* IMF citation strings actually queried (e.g. `WEO:NGDP_RPCH`,
* `FM:GGXWDG_NGDP`). Present when schema version ≥ 2.0. Always
* populated as an array by the loader — may be empty on v1 files.
*/
imf: string[];
}
@pethers
Copy link
Copy Markdown
Member

pethers commented Apr 20, 2026

@copilot apply changes based on the comments in this thread and fix TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)
TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)Failing after 45sTypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)
TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)Failing after 45s

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot apply changes based on the comments in this thread and fix [TypeScript & JavaScript Testing...

Addressed all six review comments and the failing TypeScript type-check (scripts) step in commit a4c2597:

  1. hasAttribution() now uses \bIMF\b / \bSCB\b word boundaries.
  2. ImfClient.fetchWithRetry() back-off is now documented exponential 1 s → 2 s → 4 s and honours Retry-After (capped at 30 s).
  3. imf-fetch.ts SDMX-persist comment rewritten to match the path-segment heuristic (no more misleading "hash" claim).
  4. imf-fetch.ts imports switched from ./foo.ts./foo.js — this was also the exact cause of the CI TS5097 failure; npx tsc --project tsconfig.scripts.json --noEmit is now clean locally.
  5. load-economic-context.ts module header no longer calls IMF an "MCP tool".
  6. Split into EconomicContextSourceFile (with imf?: string[]) for the on-disk v1-compatible shape and kept EconomicContextSource (with required imf: string[]) for the loader's normalised output; the unknown double-cast is gone.

Targeted tests (imf-client, data-persistence, imf-context, imf-codes, validate-economic-context, economic-context-multi-provider): 133 / 133 pass. Both tsc projects + ESLint on all changed files are clean.

@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
Copy link
Copy Markdown
Member

pethers commented Apr 20, 2026

@copilot TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)
TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)Failing after 2m

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot TypeScript & JavaScript Testing / Unit Tests (Vitest) (pull_request)
TypeScript ...

Fixed in ba56841. The failing test was tests/analysis-quality-validation.test.tsanalysis/daily/2026-04-20/propositions/data-download-manifest.md:99 contained the literal "[PLACEHOLDER]" inside a self-audit bullet ("✅ 0 [PLACEHOLDER] patterns"), which the test's \[PLACEHOLDER\] detector regex (correctly) treated as an unfilled placeholder. Rephrased to ✅ 0 bracketed "PLACEHOLDER" patterns. — preserves the audit meaning without the literal token. analysis-quality-validation now passes 35/35.

@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 requested a review from Copilot April 20, 2026 15:30
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR migrates IMF data access from a third-party Python MCP/uvx runtime to an in-repo, pure-TypeScript client + thin CLI, expanding the economic-data contract to v2.0 (IMF + provider/projection metadata) and updating validators, persistence, workflows, and documentation accordingly.

Changes:

  • Add TypeScript-based IMF client (scripts/imf-client.ts), supporting Datamapper (WEO) plus SDMX 3.0 passthrough, and expose it via scripts/imf-fetch.ts.
  • Extend economic context loading/validation/persistence to support source.imf[] and per-point provider/projection/projectionVintage.
  • Remove Python/uvx setup and MCP references; update workflows allowlists, docs, ADR, schema, threat model, and tests.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/validate-economic-context.test.ts Updates expectations for IMF-inclusive attribution messaging.
tests/statistical-claims-detector.test.ts Adds assertions for IMF indicator propagation in detected claims.
tests/imf-context.test.ts New tests for IMF policy/committee mapping helpers.
tests/imf-codes.test.ts New tests for IMF ISO3↔AREA mappings and helpers.
tests/imf-client.test.ts New tests for IMF client parsing, retry/backoff, and SDMX passthrough.
tests/economic-context-multi-provider.test.ts New tests validating schema v1/v2 back-compat and mixed providers.
tests/data-persistence.test.ts Adds coverage for persistIMFData pathing and sidecar metadata.
scripts/validate-economic-context.ts Accepts IMF attribution and IMF sources in economic-data validation.
scripts/statistical-claims-detector.ts Adds optional imfIndicator metadata to detected claims.
scripts/parliamentary-data/data-persistence.ts Adds persistIMFData and updates persistence document types.
scripts/imf-fetch.ts New CLI wrapper for agentic workflows (weo/compare/sdmx/list-indicators).
scripts/imf-context.ts New IMF indicator catalogue + lookups for domains/committees/peers.
scripts/imf-codes.ts New canonical IMF code mapping utilities for datasets/country codes.
scripts/imf-client.ts New TypeScript REST client for IMF Datamapper + SDMX with retries.
scripts/data-transformers/load-economic-context.ts Loads schema v2 fields and normalizes v1 artefacts to v2 defaults.
package.json Records empty external MCP manifest (x-external-mcp) post-migration.
docs/adr/0001-adopt-imf-data-alongside-world-bank.md ADR documenting TS-only IMF approach and consequences.
analysis/schemas/economic-data.schema.json Schema v2: adds source.imf[] and per-point provider/projection fields.
analysis/imf/use-cases.md Documents IMF CLI usage patterns and example artefacts.
analysis/imf/indicator-policy-mapping.md Defines committee→IMF indicator mapping reference.
analysis/imf/README.md Explains IMF integration rationale, code surface, and rate limits.
analysis/economic-indicators-inventory.json New multi-provider inventory (IMF inline + WB reference + SCB).
analysis/daily/2026-04-20/propositions/data-download-manifest.md Rewords placeholder self-audit line to satisfy placeholder detector.
THREAT_MODEL.md Adds TB-6a threat boundary for IMF TS client (no MCP).
SECURITY_ARCHITECTURE.md Notes external MCP manifest is empty; IMF is npm/SBOM covered.
README.md Adds IMF as an integrated data source and clarifies WB’s narrowed role.
FUTURE_THREAT_MODEL.md Lowers IMF integration risk profile (TypeScript client, no new runtime).
.github/workflows/news-weekly-review.md Adds IMF origins to workflow allowlists.
.github/workflows/news-week-ahead.md Adds IMF origins to workflow allowlists.
.github/workflows/news-translate.md Adds IMF origins to workflow allowlists.
.github/workflows/news-realtime-monitor.md Adds IMF origins to workflow allowlists.
.github/workflows/news-propositions.md Adds IMF origins to workflow allowlists.
.github/workflows/news-motions.md Adds IMF origins to workflow allowlists.
.github/workflows/news-monthly-review.md Adds IMF origins to workflow allowlists.
.github/workflows/news-month-ahead.md Adds IMF origins to workflow allowlists.
.github/workflows/news-interpellations.md Adds IMF origins to workflow allowlists.
.github/workflows/news-evening-analysis.md Adds IMF origins to workflow allowlists.
.github/workflows/news-committee-reports.md Adds IMF origins to workflow allowlists.
.github/workflows/news-article-generator.md Adds IMF origins to workflow allowlists.
.github/workflows/economic-context-audit.yml Documents v2 cutover grace window and mixed v1/v2 acceptance.
.github/workflows/copilot-setup-steps.yml Removes Python setup; documents IMF as TS client invoked via tsx.
.github/aw/SHARED_PROMPT_PATTERNS.md Updates discovery protocol and IMF fetching idioms for agents.
.github/aw/ECONOMIC_DATA_CONTRACT.md Contract v2.0: IMF-first macro/fiscal + projection metadata rules.
.github/agents/news-journalist.md Updates agent guidance to incorporate IMF projections where relevant.
.github/agents/intelligence-operative.md Documents IMF usage via bash+tsx CLI (no MCP).
.github/agents/data-pipeline-specialist.md Documents IMF client/CLI usage, caching, and rate-limit discipline.
Comments suppressed due to low confidence (5)

scripts/imf-client.ts:1

  • The catch path retries for all thrown errors, including non-retriable HTTP errors (e.g. 400/401/403/404) because !response.ok throws and is then retried here. This can cause unnecessary repeated requests and slower failures. Consider only retrying in the catch for network/abort errors, and for HTTP responses only retrying on 5xx (and 429, which you already handle explicitly), while letting other 4xx fail immediately.
    scripts/imf-client.ts:1
  • In the 429 path you clearTimeout(timeoutId) before waiting, but in the generic catch retry path the timeout isn’t cleared until the recursive retry returns (because recursion happens inside catch, delaying finally). This can keep timers alive longer than necessary and adds avoidable wakeups. Align the generic retry path with the 429 path by clearing the timeout before sleeping/recursing (and/or restructuring to ensure finally runs before scheduling retries).
    scripts/imf-fetch.ts:1
  • The header documents exit code 2 for bad CLI arguments, but an unknown command currently falls into default and exits successfully (code 0) after printing help. Treat unknown commands as invalid args (print help + error to stderr and process.exit(2)) to avoid workflows silently succeeding on typos.
    scripts/imf-fetch.ts:1
  • compare currently triggers one request per country (via compareCountriesWeogetLatestWeoIndicatorgetWeoIndicator). Several docs/comments in this PR describe compare as “one batched Datamapper call across several countries”; that’s not what the implementation does, which matters for IMF rate limits and workflow latency. Either (mandatory) update the documentation/comments to reflect the N-request behavior, or (optional, if the API supports it) implement a true batched fetch; additionally consider inserting a small per-country delay in the loop to better respect the published rate limit when countries is large.
    scripts/data-transformers/load-economic-context.ts:1
  • projectionVintage is added whenever present, even if projection is false. This contradicts the local type doc (“Present only when projection=true”) and the contract language, and can confuse downstream consumers. Consider only copying projectionVintage when enriched.projection === true (and optionally dropping/ignoring it otherwise).

Comment thread analysis/schemas/economic-data.schema.json Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
@pethers pethers merged commit 17d5b31 into main Apr 20, 2026
12 checks passed
@pethers pethers deleted the copilot/investigate-replace-economic-indicators branch April 20, 2026 15:40
@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

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 ci-cd CI/CD pipeline changes cis-controls CIS Controls dependencies Dependency updates documentation Documentation updates isms ISMS compliance changes iso-27001 ISO 27001 controls news News articles and content generation nist-csf NIST CSF compliance refactor Code refactoring riksdag-data Riksdag-Regering MCP data schema Data schema changes security Security improvements size-xl Extra large change (> 1000 lines) testing Test coverage workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants