All files / types stakeholder.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

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                                                                29x                                                                                                                                                                      
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Types/Stakeholder
 * @description Multi-stakeholder perspective types for the enhanced political
 * analysis engine. These types model how parliamentary actions affect each
 * major stakeholder group and support iterative multi-pass analysis.
 */
 
/**
 * The six major stakeholder groups that are assessed for every parliamentary action.
 * - **political_groups**: EP political groups and their electoral blocs
 * - **civil_society**: NGOs, advocacy organisations, think-tanks
 * - **industry**: Business associations, trade bodies, chambers of commerce
 * - **national_govts**: Member state governments and their ministries
 * - **citizens**: EU citizens in general; voters and rights-holders
 * - **eu_institutions**: Commission, Council, Court of Justice, ECB etc.
 */
export type AnalysisStakeholderType =
  | 'political_groups'
  | 'civil_society'
  | 'industry'
  | 'national_govts'
  | 'citizens'
  | 'eu_institutions';
 
/**
 * Stable iteration order for all six stakeholder types.
 * Use this constant in any code that needs to iterate over all groups
 * to avoid duplicating the list in multiple files.
 */
export const ALL_STAKEHOLDER_TYPES: readonly AnalysisStakeholderType[] = [
  'political_groups',
  'civil_society',
  'industry',
  'national_govts',
  'citizens',
  'eu_institutions',
];
 
/**
 * The direction of impact on a stakeholder group.
 * - **positive**: The action clearly benefits the stakeholder
 * - **negative**: The action clearly harms or disadvantages the stakeholder
 * - **neutral**: The action has no material effect
 * - **mixed**: The action has both positive and negative consequences
 */
export type StakeholderImpact = 'positive' | 'negative' | 'neutral' | 'mixed';
 
/**
 * How important the impact is for the stakeholder group.
 */
export type StakeholderSeverity = 'high' | 'medium' | 'low';
 
/**
 * A detailed perspective on how a parliamentary action affects one
 * specific stakeholder group. Used in multi-stakeholder analysis to
 * map every action to its full range of societal consequences.
 */
export interface StakeholderPerspective {
  /** Which stakeholder group this perspective describes */
  readonly stakeholder: AnalysisStakeholderType;
  /** Direction of the impact on this stakeholder */
  readonly impact: StakeholderImpact;
  /** Magnitude of the impact */
  readonly severity: StakeholderSeverity;
  /** Human-readable reasoning explaining the impact */
  readonly reasoning: string;
  /** Evidence strings supporting the reasoning (data points, text references) */
  readonly evidence: readonly string[];
}
 
/**
 * Identifies which analysis pass produced a finding.
 * Mirrors the four-pass iterative refinement flow:
 * 1. `initial` — Baseline assessment from MCP data
 * 2. `stakeholder_challenge` — How each group's interests are affected
 * 3. `cross_perspective` — Conflicts and alignments across groups
 * 4. `final_refinement` — Balanced evidence-based conclusions
 */
export type AnalysisIterationType =
  | 'initial'
  | 'stakeholder_challenge'
  | 'cross_perspective'
  | 'final_refinement';
 
/**
 * A single pass in the iterative multi-pass analysis cycle.
 * Captures the intermediate thinking at each stage of refinement.
 */
export interface AnalysisIteration {
  /** Which pass number this is (1–4) */
  readonly pass: number;
  /** The type of analysis pass */
  readonly type: AnalysisIterationType;
  /** Short summary of what this pass adds or changes */
  readonly summary: string;
  /** Key findings produced in this pass */
  readonly findings: readonly string[];
}
 
/**
 * A row in the stakeholder outcome matrix: one parliamentary action mapped
 * to an outcome (winner / loser / neutral) for each of the six stakeholder
 * groups, plus a confidence rating.
 */
export interface StakeholderOutcomeMatrix {
  /** The parliamentary action being assessed */
  readonly action: string;
  /** How each stakeholder group fares as a result of the action */
  readonly outcomes: Readonly<Record<AnalysisStakeholderType, 'winner' | 'loser' | 'neutral'>>;
  /** Confidence in the outcome assessments */
  readonly confidence: 'high' | 'medium' | 'low';
}