Conversation
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: size-xs Label Categories
For more information, see |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…t tests - scripts/scb-fetch.ts: CLI wrapper around SCBClient with economicProvenance (provider: scb) - scripts/riksbank-fetch.ts: CLI wrapper for Riksbank SWEA API with economicProvenance (provider: riksbank) - tests/imf-precedence-contract.test.ts: 49 tests enforcing IMF precedence, SCB/Riksbank never aliased as IMF - vitest.config.js: exclude new CLI scripts from coverage Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/6f638578-1618-4277-b44e-adab68cda0f6 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…test Agent-Logs-Url: https://github.com/Hack23/riksdagsmonitor/sessions/6f638578-1618-4277-b44e-adab68cda0f6 Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 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
Adds new CLI wrappers and a Vitest contract suite to harden the “economicProvenance provider” hierarchy (IMF-first, with SCB and Riksbank as distinct non-IMF providers) and prevent mis-attribution across data sources.
Changes:
- Added
scripts/scb-fetch.tsCLI wrapper emittingeconomicProvenance.provider = "scb"on all outputs. - Added
scripts/riksbank-fetch.tsCLI wrapper for SWEA API, emittingeconomicProvenance.provider = "riksbank"on all outputs. - Added
tests/imf-precedence-contract.test.tsto lock in provider precedence and inventory expectations; updated Vitest coverage exclusions accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
vitest.config.js |
Excludes the two new CLI scripts from coverage calculations (consistent with other CLI-only scripts). |
tests/imf-precedence-contract.test.ts |
Adds contract tests for provider identity/invariants, CLI arg parsing, and inventory/provider-selection expectations. |
scripts/scb-fetch.ts |
Introduces SCB PXWeb CLI wrapper with provenance wrapping + optional persistence. |
scripts/riksbank-fetch.ts |
Introduces Riksbank SWEA CLI wrapper (fetch + timeout) with provenance wrapping + persistence. |
| if (booleans.has('persist')) { | ||
| persistSCBData(`search-${query.replace(/\s+/g, '-')}`, payload, { query, limit }); | ||
| } |
| process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`); | ||
|
|
||
| if (booleans.has('persist')) { | ||
| persistSCBData(tableId, payload, { tableId }); |
| import { pathToFileURL } from 'node:url'; | ||
| import path from 'node:path'; | ||
| import fs from 'node:fs'; | ||
| import { fileURLToPath } from 'node:url'; |
| * `--persist` writes the raw response under `analysis/data/riksbank/` via | ||
| * {@link persistRiksbankData}. Outputs JSON (with `economicProvenance`) to | ||
| * stdout regardless. |
| function resolveDataRoot(): string { | ||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const repoRoot = path.resolve(__dirname, '..'); | ||
| return path.join(repoRoot, 'analysis', 'data'); | ||
| } |
| * `--persist` writes the raw response under `analysis/data/scb/` via | ||
| * {@link persistSCBData}. Outputs JSON (with `economicProvenance`) to | ||
| * stdout regardless. |
|
@copilot resolve the merge conflicts in this pull request |
Resolve add/add conflicts in scb-fetch.ts and riksbank-fetch.ts: - Take main's preset-based scb-fetch.ts (KPI/AKU/HEK/fuel-price presets) - Take main's web-fetch riksbank-fetch.ts (repo-rate-path/minutes/fuel-price-context) - Update imf-precedence-contract.test.ts to use new APIs - Remove coverage exclusions for scb-fetch/riksbank-fetch (covered by new test files) Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Merge conflicts resolved in commit |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Methodology hardening: stops WB/SCB/Riksbank data being mis-attributed as IMF. Adds two new CLI pipeline scripts and a contract test suite that locks in the
economicProvenanceprovider hierarchy from ECONOMIC_DATA_CONTRACT.md v2.1 (imf > scb > riksbank > worldBank).New scripts
scripts/scb-fetch.tsPreset-based CLI wrapper around
SCBClientfor PXWeb MCP queries. Exposes curated KPI/AKU/household-economy/fuel-price presets plus a free-formtablecommand. Every response includes aneconomicProvenanceblock —provideris always"scb", never"imf".tsx scripts/scb-fetch.ts list-presets tsx scripts/scb-fetch.ts preset --preset cpi [--persist] tsx scripts/scb-fetch.ts table --table-id TAB5765 --value-codes '{"Tid":"top(12)"}' [--persist]scripts/riksbank-fetch.tsWeb-fetch CLI wrapper for public Riksbank pages and documents. Fetches the policy-rate path, monetary-policy minutes, and fuel-price context from
www.riksbank.se.provideris always"riksbank".Both scripts emit a structured
economicProvenanceblock on every response:{ "provider": "scb", "economicProvenance": { "provider": "scb", // or "riksbank" — never "imf" "dataflow": "SCB PxWeb", // or "riksbank-web" "indicator": "0000003N", "retrieved_at": "2026-04-27T00:58:00.000Z" } }New test:
tests/imf-precedence-contract.test.ts(48 tests)Locks in the provider contract using the current APIs:
ImfDataPoint.provideris always"imf"— TypeScript literal type asserted at runtimeSCBEconomicProvenance.provideris"scb"— never"imf","riksbank", or"worldBank"RiksbankEconomicProvenance.provideris"riksbank"— never"imf"or"scb"fetchSCBTablePayloademitsprovider: "scb"even on network fail-soft (no-data path)fetchRiksbankPayloademitsprovider: "riksbank"on all response types (HTML, JSON, PDF)analysis/economic-indicators-inventory.jsonv4.1:macro,fiscal,monetary,externalSectordomains resolve to"imf";swedenPrimaryresolves to"scb"NY.GDP.MKTP.KD.ZG,FP.CPI.TOTL.ZG,SL.UEM.TOTL.ZS) point toimf:WEO:*replacementsassertRiksbankFetchTarget(HTTPS + allowlist enforcement)vitest.config.jsNo additional coverage exclusions required — both scripts are covered by the dedicated
tests/scb-fetch.test.tsandtests/riksbank-fetch.test.tstest files already present in the codebase.