Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | 36x 36x | /**
* @module analysis-framework/methodology-types
* @description Shared TypeScript types for the three ISMS-inspired political
* analysis methodologies:
*
* 1. **PoliticalClassification** — 7-dimension event classification
* (inspired by ISMS CLASSIFICATION.md — Impact Analysis Matrix)
* 2. **PoliticalRiskAssessment** — Likelihood × Impact risk scoring
* (inspired by ISMS Risk_Assessment_Methodology.md)
* 3. **PoliticalThreatAnalysis** — PRIDES threat framework
* (inspired by ISMS THREAT_MODEL.md — STRIDE → PRIDES adaptation)
*
* These types are consumed by:
* - `political-classification.ts`
* - `political-risk-assessment.ts`
* - `political-threat-analysis.ts`
* - Extended `DocumentAnalysisResult` in `types.ts`
*
* @author Hack23 AB
* @license Apache-2.0
*/
// ===========================================================================
// 1. POLITICAL CLASSIFICATION (inspired by ISMS CLASSIFICATION.md)
// ===========================================================================
// ---------------------------------------------------------------------------
// Classification dimension value types
// ---------------------------------------------------------------------------
/**
* Public Interest Sensitivity — adapted from ISMS Confidentiality levels.
* Measures how politically sensitive this event is in the public domain.
*
* - explosive: Imminent public controversy, coalition-threatening, media firestorm
* - sensitive: Politically charged, significant public interest
* - standard: Normal legislative activity with moderate public interest
* - routine: Administrative/procedural, low public visibility
*/
export type PublicInterestSensitivity = 'explosive' | 'sensitive' | 'standard' | 'routine';
/**
* Democratic Integrity Impact — adapted from ISMS Integrity levels.
* Measures whether this event affects democratic processes and norms.
*
* - critical: Threatens constitutional or democratic foundations
* - significant: Material impact on democratic participation or oversight
* - moderate: Noticeable procedural or governance effects
* - minor: Minimal democratic process implications
*/
export type DemocraticIntegrityImpact = 'critical' | 'significant' | 'moderate' | 'minor';
/**
* Policy Urgency — adapted from ISMS Availability levels.
* Measures how time-sensitive this is for citizens and policymakers.
*
* - immediate: Requires action within days; crisis or emergency context
* - short-term: Action needed within weeks; active parliamentary timeline
* - medium-term: Months-long implementation cycle; planned legislation
* - long-term: Strategic direction; multi-year or structural change
*/
export type PolicyUrgency = 'immediate' | 'short-term' | 'medium-term' | 'long-term';
/**
* Economic Impact — adapted from ISMS Financial Impact levels.
* Measures the fiscal and economic consequence of this event.
*
* - transformative: Macro-level change; affects GDP, national budget, or SEK billions+
* - major: Significant sectoral or fiscal consequence; large-scale redistribution
* - moderate: Notable but bounded economic effect; affects specific industries or groups
* - minimal: Limited fiscal consequence; administrative or procedural cost only
*/
export type EconomicImpact = 'transformative' | 'major' | 'moderate' | 'minimal';
/**
* Governance Impact — adapted from ISMS Operational Impact levels.
* Measures how this event affects government operations and institutional function.
*
* - systemic: Cross-government structural change; affects multiple agencies
* - significant: Major departmental or policy-area impact
* - procedural: Changes to administrative processes or regulations
* - routine: Standard governmental operations; no structural change
*/
export type GovernanceImpact = 'systemic' | 'significant' | 'procedural' | 'routine';
/**
* Political Capital Impact — adapted from ISMS Reputational Impact levels.
* Measures the effect on party or politician standing and electoral viability.
*
* - career-defining: Permanently alters political trajectory; election-determining
* - significant: Meaningful shift in public perception or party support
* - notable: Observable but temporary reputational effect
* - negligible: Minimal effect on political standing
*/
export type PoliticalCapitalImpact = 'career-defining' | 'significant' | 'notable' | 'negligible';
/**
* Legislative Impact — adapted from ISMS Regulatory Impact levels.
* Measures whether this event changes laws, regulations, or constitutional order.
*
* - constitutional: Affects fundamental law (RF) or constitutional principles
* - legislative: Creates or amends riksdag-level statute (lag)
* - regulatory: Changes government ordinances or agency regulations (förordning)
* - administrative: Internal government guidance or procedural decisions
*/
export type LegislativeImpact = 'constitutional' | 'legislative' | 'regulatory' | 'administrative';
/**
* Overall classification summary — aggregated across all 7 dimensions.
*
* - critical: Explosive, democratic-integrity-critical, immediate urgency
* - high: Multiple high-severity dimensions
* - medium: Mixed severity profile
* - low: Routine across most dimensions
*/
export type OverallClassification = 'critical' | 'high' | 'medium' | 'low';
// ---------------------------------------------------------------------------
// Classification result type
// ---------------------------------------------------------------------------
/** Complete 7-dimension political classification for a parliamentary document */
export interface PoliticalClassification {
/** How politically sensitive this event is in the public domain */
publicInterestSensitivity: PublicInterestSensitivity;
/** Whether this affects democratic processes and norms */
democraticIntegrityImpact: DemocraticIntegrityImpact;
/** How time-sensitive this is for citizens and policymakers */
policyUrgency: PolicyUrgency;
/** Fiscal and economic consequence */
economicImpact: EconomicImpact;
/** Effect on government operations and institutional function */
governanceImpact: GovernanceImpact;
/** Effect on party or politician standing */
politicalCapitalImpact: PoliticalCapitalImpact;
/** Whether this changes laws, regulations, or constitutional order */
legislativeImpact: LegislativeImpact;
/** Aggregated summary classification across all 7 dimensions */
overallClassification: OverallClassification;
/**
* Numeric classification score (0–100).
* Weighted composite of all 7 dimensions.
*/
classificationScore: number;
/**
* Rationale for the classification.
* Lists the primary signals that determined each dimension.
*/
rationale: string[];
}
// ===========================================================================
// 2. POLITICAL RISK ASSESSMENT (inspired by ISMS Risk_Assessment_Methodology.md)
// ===========================================================================
// ---------------------------------------------------------------------------
// Risk categories
// ---------------------------------------------------------------------------
/**
* Political risk categories for Swedish parliamentary context.
* Each maps to a distinct failure mode in governance or democratic function.
*/
export type PoliticalRiskCategory =
| 'coalition-stability' // Risk of government collapse or realignment
| 'policy-implementation' // Risk that proposed policies fail or stall
| 'democratic-process' // Risk to democratic norms and institutions
| 'economic-policy' // Risk from fiscal/monetary policy decisions
| 'social-cohesion' // Risk of societal division or unrest
| 'international-standing'; // Risk to Sweden's international position
// ---------------------------------------------------------------------------
// Likelihood scale (adapted from ISMS)
// ---------------------------------------------------------------------------
/**
* Likelihood levels for political risk assessment.
* Adapted from ISMS probability scale to Swedish parliamentary context.
*
* - almost-certain: Multiple parliamentary signals confirm (80-99%)
* - likely: Strong indicators from committee/debate activity (60-79%)
* - possible: Mixed signals, uncertain outcome (40-59%)
* - unlikely: Weak indicators, strong opposition (20-39%)
* - rare: Exceptional circumstances required (5-19%)
* - exceptional: Black swan political events (<5%)
*/
export type LikelihoodLevel =
| 'almost-certain' // 80-99% — Multiple signals confirm
| 'likely' // 60-79% — Strong committee/debate indicators
| 'possible' // 40-59% — Mixed signals
| 'unlikely' // 20-39% — Weak indicators, strong opposition
| 'rare' // 5-19% — Exceptional circumstances
| 'exceptional'; // <5% — Black swan events
/** Numeric probability midpoint for each likelihood level (0–1) */
export const LIKELIHOOD_PROBABILITY: Readonly<Record<LikelihoodLevel, number>> = {
'almost-certain': 0.90,
'likely': 0.70,
'possible': 0.50,
'unlikely': 0.30,
'rare': 0.12,
'exceptional': 0.02,
};
// ---------------------------------------------------------------------------
// Impact scale (adapted from ISMS)
// ---------------------------------------------------------------------------
/**
* Impact levels for political risk assessment.
* Adapted from ISMS consequence scale to political domain.
*
* - transformative: Constitutional or regime-level change
* - critical: Major policy shift affecting millions of citizens
* - high: Significant legislative change
* - moderate: Notable policy adjustment
* - low: Minor procedural change
* - minimal: Routine parliamentary activity
*/
export type RiskImpactLevel =
| 'transformative' // Constitutional/regime-level change
| 'critical' // Major policy shift affecting millions
| 'high' // Significant legislative change
| 'moderate' // Notable policy adjustment
| 'low' // Minor procedural change
| 'minimal'; // Routine parliamentary activity
/** Numeric impact weight for scoring each impact level (0–10) */
export const IMPACT_WEIGHT: Readonly<Record<RiskImpactLevel, number>> = {
transformative: 10,
critical: 8,
high: 6,
moderate: 4,
low: 2,
minimal: 1,
};
// ---------------------------------------------------------------------------
// Risk assessment result type
// ---------------------------------------------------------------------------
/** Complete political risk assessment for a single risk category */
export interface PoliticalRiskAssessment {
/** The risk category being assessed */
riskCategory: PoliticalRiskCategory;
/** Likelihood that this risk materialises */
likelihood: LikelihoodLevel;
/** Severity of impact if this risk materialises */
impact: RiskImpactLevel;
/**
* Composite risk score (0–100).
* Computed as: (likelihood_probability × impact_weight × 10), clamped to 0–100.
*/
riskScore: number;
/**
* Priority tier derived from risk score.
* - critical: ≥70
* - high: ≥50
* - medium: ≥30
* - low: <30
*/
priority: 'critical' | 'high' | 'medium' | 'low';
/**
* Evidence from parliamentary data supporting this assessment.
* Should reference dok_id values, voting records, or speech excerpts.
*/
evidence: string[];
/** Confidence level in this risk assessment */
confidence: 'high' | 'medium' | 'low';
/** Factors that reduce the probability or impact of this risk */
mitigatingFactors: string[];
/** Factors that increase the probability or impact of this risk */
escalatingFactors: string[];
}
/** Aggregated risk profile for a parliamentary document or event */
export interface PoliticalRiskProfile {
/** Individual risk assessments per category */
riskAssessments: PoliticalRiskAssessment[];
/** Highest priority risk (for article focus) */
dominantRisk: PoliticalRiskCategory;
/**
* Composite risk score (0–100), aggregated across all categories.
* Weighted by risk priority.
*/
compositeRiskScore: number;
/**
* Overall risk level derived from composite score.
* - critical: ≥70
* - high: ≥50
* - medium: ≥30
* - low: <30
*/
overallRiskLevel: 'critical' | 'high' | 'medium' | 'low';
}
// ===========================================================================
// 3. POLITICAL THREAT ANALYSIS — PRIDES FRAMEWORK
// (inspired by ISMS THREAT_MODEL.md — STRIDE → PRIDES)
// ===========================================================================
// ---------------------------------------------------------------------------
// PRIDES threat categories
// ---------------------------------------------------------------------------
/**
* PRIDES framework — Political adaptation of ISMS STRIDE threat model.
*
* | ISMS STRIDE | Political PRIDES |
* |-----------------------|------------------------------|
* | Spoofing | Polarization |
* | Tampering | Regulatory Overreach |
* | Repudiation | Institutional Erosion |
* | Information Disclosure| Democratic Deficit |
* | Denial of Service | Economic Disruption |
* | Elevation of Privilege| Societal Impact |
*/
export type PridesCategory =
| 'polarization' // P — Intentional division, misleading rhetoric
| 'regulatory-overreach' // R — Abuse of legislative power, norm erosion
| 'institutional-erosion' // I — Weakening of democratic institutions
| 'democratic-deficit' // D — Lack of transparency, restricted public access
| 'economic-disruption' // E — Policy-driven economic harm, fiscal irresponsibility
| 'societal-impact'; // S — Disproportionate impact on vulnerable groups
// ---------------------------------------------------------------------------
// Threat agent classification
// ---------------------------------------------------------------------------
/**
* Political threat agents — adapted from ISMS threat actor classification.
* Identifies the actor whose actions create or amplify the threat.
*/
export type ThreatAgent =
| 'ruling-coalition' // Policy agenda risks, power concentration
| 'opposition-parties' // Obstruction, populist pressure, destabilisation
| 'external-actors' // Foreign influence, EU regulatory pressure
| 'special-interests' // Lobbying, regulatory capture, corporate influence
| 'media' // Narrative manipulation, selective reporting
| 'institutional'; // Bureaucratic inertia, implementation failures
// ---------------------------------------------------------------------------
// Threat severity
// ---------------------------------------------------------------------------
/**
* Severity levels for PRIDES threat analysis.
*
* - critical: Immediate and fundamental threat to democratic function
* - high: Serious and near-term threat requiring political response
* - medium: Moderate threat with observable indicators
* - low: Latent or low-probability threat, early warning
*/
export type ThreatSeverity = 'critical' | 'high' | 'medium' | 'low';
// ---------------------------------------------------------------------------
// Threat analysis result type
// ---------------------------------------------------------------------------
/** PRIDES threat analysis for a single threat category */
export interface PoliticalThreatAnalysis {
/** Which PRIDES category this threat belongs to */
pridesCategory: PridesCategory;
/** Actors whose actions manifest or amplify this threat */
threatAgents: ThreatAgent[];
/** Severity of this threat to democratic governance */
severity: ThreatSeverity;
/**
* Observable indicators from parliamentary data (MCP sources).
* Should reference specific speeches, votes, documents, or patterns.
*/
indicators: string[];
/**
* Democratic safeguards and countermeasures available.
* Institutional or procedural responses that mitigate this threat.
*/
countermeasures: string[];
/**
* Rationale linking the observable signals to the PRIDES category.
* Should be evidence-based, not generic.
*/
rationale: string;
}
/** Aggregated PRIDES threat profile for a parliamentary document or event */
export interface PoliticalThreatProfile {
/** Individual PRIDES threat analyses detected */
threatAnalyses: PoliticalThreatAnalysis[];
/**
* Primary threat category, selected from `threatAnalyses`.
*
* Determined by the highest `severity` among detected threats. When multiple
* threats share the same highest severity, a deterministic PRIDES category
* ordering is used as a tie-breaker:
* polarization → regulatory-overreach → institutional-erosion →
* democratic-deficit → economic-disruption → societal-impact.
*
* Evidence density (for example, number of `indicators`) is not used for
* selection.
*
* `null` when no significant threats are detected (valid JSON output).
*/
primaryThreat: PridesCategory | null;
/**
* Overall threat level across all PRIDES categories.
* Derived from the highest-severity individual threat.
*/
overallThreatLevel: ThreatSeverity | 'none';
/**
* Active threat agents across all detected threats (deduplicated).
*/
activeThreatAgents: ThreatAgent[];
}
// ===========================================================================
// 4. COMBINED METHODOLOGY RESULT
// ===========================================================================
/**
* Combined output of all three political analysis methodologies for a
* single parliamentary document.
*
* This is attached to `DocumentAnalysisResult` as `methodologyAnalysis`
* (see `types.ts`).
*/
export interface MethodologyAnalysis {
/** 7-dimension political classification */
classification: PoliticalClassification;
/** Likelihood × Impact risk profile across 6 risk categories */
riskProfile: PoliticalRiskProfile;
/** PRIDES threat analysis across detected threat categories */
threatProfile: PoliticalThreatProfile;
}
|