Skip to content

Commit 686710b

Browse files
authored
Merge pull request #2042 from Hack23/copilot/add-scb-riksbank-integration
[WIP] Add SCB and Riksbank quantitative integration for economic analysis
2 parents d2fd995 + 9d6938c commit 686710b

10 files changed

Lines changed: 975 additions & 2 deletions

File tree

.github/skills/data-science-for-intelligence/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ Apply this skill when:
2525
- ✅ Constructing influence networks from voting alignment patterns
2626
- ✅ Forecasting trends in party support or politician effectiveness
2727
- ✅ Clustering politicians or parties by voting similarity
28+
- ✅ Modelling Swedish economic transmission chains using IMF macro context plus SCB KPI/AKU/HEK/fuel-price series and Riksbank policy-rate/minutes signals
2829

2930
Do NOT use for:
3031
- ❌ Simple aggregation queries (use SQL views instead)
3132
- ❌ Real-time operational dashboards (use materialized views)
3233
- ❌ Causal inference without proper experimental design or quasi-experimental methods
34+
- ❌ Replacing IMF cross-country macro/fiscal indicators with SCB or Riksbank series; use SCB/Riksbank only as Swedish ground-truth complements
3335

3436
## Data Science Framework for CIA Platform
3537

.github/skills/riksdag-regering-mcp/SKILL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Provide comprehensive access to Swedish political data through the `riksdag-rege
2323
4. **Real-Time Access**: Latest parliamentary and government activities
2424
5. **GDPR Compliance**: Public interest basis (Article 6(1)(e)), no personal data beyond official capacity
2525
6. **Multi-Source Integration**: Riksdag documents + Government publications
26+
7. **Quantitative Context Handoff**: Pair parliamentary evidence with SCB/Riksbank helper outputs when domestic economic transmission matters; keep IMF as cross-country macro canon and SCB/Riksbank as Swedish ground truth.
2627

2728
## Available Tools (32 Total)
2829

@@ -112,6 +113,7 @@ Provide comprehensive access to Swedish political data through the `riksdag-rege
112113
- **Electoral Research**: Historical trends, party evolution
113114
- **Transparency Dashboards**: Real-time political metrics
114115
- **Risk Assessment**: Identify democratic accountability gaps
116+
- **Economic Transmission Analysis**: Combine Riksdag measures with `scripts/scb-fetch.ts` KPI/AKU/HEK/fuel presets and `scripts/riksbank-fetch.ts` policy-rate/minutes context for Swedish-specific impact estimates.
115117

116118
## Calling MCP Tools in Agentic Workflows
117119

analysis/templates/comparative-international.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ graph TB
159159
160160
---
161161

162+
## 🇸🇪 Swedish Ground-Truth Transmission Layer (SCB + Riksbank)
163+
164+
> Use this table whenever the Swedish measure depends on domestic price, labour-market, household-income or monetary-policy transmission. IMF remains primary for cross-country macro; SCB and Riksbank supply the Swedish-specific ground truth. Fetch with `tsx scripts/scb-fetch.ts preset --preset <cpi|aku|household-economy|fuel-prices> --persist` and `tsx scripts/riksbank-fetch.ts <repo-rate-path|minutes|fuel-price-context> --persist`.
165+
166+
| Transmission step | Swedish source | Required provenance | Current value | Timing / lag | Analytical use |
167+
|-------------------|----------------|---------------------|:-------------:|--------------|----------------|
168+
| Pump price / energy component → CPI | SCB `fuel-prices` (`PR0101A`) + SCB `cpi` (`0000003N`) | `economicProvenance.provider="scb"` || Monthly | Estimate direct CPI and disposable-income effect |
169+
| Labour-market slack | SCB `aku` (`000003V8`) | `economicProvenance.provider="scb"` || Quarterly | Judge whether Swedish unemployment divergence is structural or cyclical |
170+
| Household disposable-income exposure | SCB `household-economy` (`HE0110A`) | `economicProvenance.provider="scb"` || Annual / latest | Distributional incidence and voter-segment exposure |
171+
| Monetary-policy pass-through | Riksbank `repo-rate-path` + `minutes` | `economicProvenance.provider="riksbank"` || Per monetary-policy decision | Check whether fiscal relief conflicts with the Riksbank inflation path |
172+
173+
> **Interpretation:** State the Swedish mechanism explicitly: instrument → SCB/Riksbank metric → household / labour / sentiment channel → expected political salience. Never relabel SCB or Riksbank data as IMF; use IMF only for cross-country macro/fiscal comparators.
174+
175+
---
176+
162177
## 📘 Policy-Transfer Assessment
163178

164179
| Question | Answer | Evidence |
@@ -216,4 +231,3 @@ graph TB
216231
- [ ] **Cross-references resolve** — every `[link](file.md)` in this artifact points to a file that exists in the run folder (`analysis/daily/$ARTICLE_DATE/$SUBFOLDER/`) or to a methodology / template under `analysis/`.
217232
- [ ] **Mermaid renders** — every fenced ` ```mermaid ` block parses (no missing class definitions, no orphan nodes, no >40-node graphs that overflow viewport on mobile).
218233
- [ ] **Line-floor check** — artifact length ≥ the per-artifact floor in [`reference-quality-thresholds.json`](../methodologies/reference-quality-thresholds.json); shorter artifacts trigger Pass-2 rewrite, never a `[truncated]` note.
219-

analysis/templates/intelligence-assessment.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ flowchart TD
156156

157157
---
158158

159+
## 📊 Quantitative Transmission Check (SCB + Riksbank)
160+
161+
> Complete this block for assessments where economic transmission affects intent, timing or voter impact. It is a Swedish ground-truth layer and complements — but does not replace — IMF macro/fiscal context.
162+
163+
| Mechanism | Required source | economicProvenance provider | Latest signal | Intelligence implication |
164+
|-----------|-----------------|-----------------------------|:-------------:|--------------------------|
165+
| Price shock / relief channel | `tsx scripts/scb-fetch.ts preset --preset cpi` + `tsx scripts/scb-fetch.ts preset --preset fuel-prices` | `scb` || Does the measure materially affect household cost pressure? |
166+
| Labour-market sensitivity | `tsx scripts/scb-fetch.ts preset --preset aku` | `scb` || Does unemployment amplify or mute the political signal? |
167+
| Household exposure | `tsx scripts/scb-fetch.ts preset --preset household-economy` | `scb` || Which voter segments face the strongest disposable-income effect? |
168+
| Monetary-policy reaction function | `tsx scripts/riksbank-fetch.ts repo-rate-path` + `tsx scripts/riksbank-fetch.ts minutes` | `riksbank` || Does the Riksbank path support or contradict the claimed transmission? |
169+
170+
**Assessment note:** Cite concrete SCB/Riksbank values before making a forecast about disposable income, consumer sentiment or polling impact. If either source is unavailable, label the gap and fall back to cached `analysis/data/scb/` or `analysis/data/riksbank/` artifacts.
171+
172+
---
173+
159174
## 🚩 Red Flags (elevate scrutiny)
160175

161176
| Signal | Meaning | Recommended action |
@@ -211,4 +226,3 @@ flowchart TD
211226
- [ ] **Cross-references resolve** — every `[link](file.md)` in this artifact points to a file that exists in the run folder (`analysis/daily/$ARTICLE_DATE/$SUBFOLDER/`) or to a methodology / template under `analysis/`.
212227
- [ ] **Mermaid renders** — every fenced ` ```mermaid ` block parses (no missing class definitions, no orphan nodes, no >40-node graphs that overflow viewport on mobile).
213228
- [ ] **Line-floor check** — artifact length ≥ the per-artifact floor in [`reference-quality-thresholds.json`](../methodologies/reference-quality-thresholds.json); shorter artifacts trigger Pass-2 rewrite, never a `[truncated]` note.
214-

scripts/parliamentary-data/data-persistence.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export type PersistenceDocumentType =
8484
| 'imf'
8585
| 'statskontoret'
8686
| 'scb'
87+
| 'riksbank'
8788
| string; // extensible for generic MCP servers
8889

8990
/** Sidecar metadata written alongside data files. */
@@ -617,6 +618,55 @@ export function persistSCBData(
617618
return path.join(dir, filename);
618619
}
619620

621+
/**
622+
* Persist Riksbank public web/JSON artifacts.
623+
*
624+
* Stored under `analysis/data/riksbank/{kind}.json`. Riksbank data is public
625+
* and unauthenticated; provenance sidecars record the source URL/kind and the
626+
* TypeScript CLI used to retrieve it.
627+
*
628+
* @param kind - Logical artifact kind (e.g. 'repo-rate-path', 'minutes').
629+
* @param response - Raw or normalized Riksbank payload.
630+
* @param dataRoot - Override for the data root directory (for testing).
631+
* @returns Absolute path to the persisted data file.
632+
*/
633+
export function persistRiksbankData(
634+
kind: string,
635+
response: unknown,
636+
dataRoot: string = DATA_ROOT,
637+
): string {
638+
const dir = path.join(dataRoot, 'riksbank');
639+
ensureDir(dir);
640+
641+
const sanitized = sanitizeDokId(kind);
642+
const filename = `${sanitized}.json`;
643+
fs.writeFileSync(
644+
path.join(dir, filename),
645+
JSON.stringify(response, null, 2),
646+
'utf8',
647+
);
648+
649+
const candidateUrl = typeof response === 'object' && response !== null && 'url' in response
650+
? (response as { url?: unknown }).url
651+
: undefined;
652+
const sourceUrl = typeof candidateUrl === 'string' && candidateUrl.length > 0
653+
? candidateUrl
654+
: undefined;
655+
const metaFilename = `${sanitized}.meta.json`;
656+
fs.writeFileSync(
657+
path.join(dir, metaFilename),
658+
JSON.stringify({
659+
fetchedAt: new Date().toISOString(),
660+
mcpTool: 'riksbank-ts-client',
661+
kind,
662+
...(sourceUrl ? { url: sourceUrl } : {}),
663+
}, null, 2),
664+
'utf8',
665+
);
666+
667+
return path.join(dir, filename);
668+
}
669+
620670
/**
621671
* Return the absolute path to the data repository root.
622672
* Useful for callers that need to reference persisted files.

0 commit comments

Comments
 (0)