All files / src/types significance.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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                                                                                                                                                                                                                                                                                                               
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Types/Significance
 * @description Type definitions for the significance scoring engine and
 * synthesis summary generator.
 *
 * The significance scoring engine produces a 5-dimension composite score
 * (0–10) used for publication prioritisation decisions.  Dimensions and
 * weights follow the analysis template specification:
 *
 * | Dimension                  | Weight |
 * |----------------------------|--------|
 * | Parliamentary Significance | 0.25   |
 * | Policy Impact              | 0.25   |
 * | Public Interest            | 0.20   |
 * | Temporal Urgency           | 0.15   |
 * | Institutional Relevance    | 0.15   |
 *
 * The synthesis summary generator aggregates per-file analysis outputs
 * into a single editorial briefing consumed by article generators.
 */
 
import type { ConfidenceLevel } from './analysis.js';
 
// ─── Significance Scoring ─────────────────────────────────────────────────────
 
/** Publication decision produced by the scoring engine */
export type PublicationDecision = 'publish' | 'hold' | 'skip';
 
/** Names of the five scoring dimensions */
export type SignificanceDimension =
  | 'parliamentarySignificance'
  | 'policyImpact'
  | 'publicInterest'
  | 'temporalUrgency'
  | 'institutionalRelevance';
 
/**
 * Result of scoring a single EP event / document across five dimensions.
 *
 * Each dimension is scored 0–10.  The `composite` value is the weighted
 * average.  The `decision` is derived from composite thresholds:
 *
 * | Score      | Decision  |
 * |------------|-----------|
 * | 0.0 – 3.9  | skip      |
 * | 4.0 – 5.9  | hold      |
 * | ≥ 6.0      | publish   |
 */
export interface SignificanceScore {
  /** Parliamentary significance dimension (0–10) */
  readonly parliamentarySignificance: number;
  /** Policy impact dimension (0–10) */
  readonly policyImpact: number;
  /** Public interest dimension (0–10) */
  readonly publicInterest: number;
  /** Temporal urgency dimension (0–10) */
  readonly temporalUrgency: number;
  /** Institutional / cross-group relevance dimension (0–10) */
  readonly institutionalRelevance: number;
  /** Weighted composite score (0–10) */
  readonly composite: number;
  /** Publication decision derived from composite thresholds */
  readonly decision: PublicationDecision;
}
 
/** Input for a single event to be scored */
export interface SignificanceScoringInput {
  /** Human-readable event title */
  readonly title: string;
  /** EP reference identifier (procedure ID, adopted text ref, etc.) */
  readonly reference?: string;
  /** Raw dimension scores provided by the caller (each 0–10) */
  readonly parliamentarySignificance: number;
  readonly policyImpact: number;
  readonly publicInterest: number;
  readonly temporalUrgency: number;
  readonly institutionalRelevance: number;
}
 
/** Batch scoring result for multiple events */
export interface SignificanceBatchResult {
  /** Individual event scores, ranked by composite descending */
  readonly scores: readonly SignificanceScore[];
  /** Count of events per decision category */
  readonly summary: {
    readonly publish: number;
    readonly hold: number;
    readonly skip: number;
  };
}
 
// ─── Synthesis Summary ────────────────────────────────────────────────────────
 
/** A single finding extracted from a per-file analysis */
export interface SynthesisFinding {
  /** Source analysis method that produced this finding */
  readonly method: string;
  /** Source filename */
  readonly file: string;
  /** Confidence level from the analysis frontmatter */
  readonly confidence: ConfidenceLevel;
  /** One-line summary of the finding */
  readonly summary: string;
}
 
/** Aggregated SWOT counts across all per-file analyses */
export interface AggregatedSWOT {
  /** Number of strength entries found across all files */
  readonly strengths: number;
  /** Number of weakness entries found across all files */
  readonly weaknesses: number;
  /** Number of opportunity entries found across all files */
  readonly opportunities: number;
  /** Number of threat entries found across all files */
  readonly threats: number;
}
 
/** Risk level distribution across all per-file analyses */
export interface RiskOverview {
  /** Number of critical-level risk items */
  readonly critical: number;
  /** Number of high-level risk items */
  readonly high: number;
  /** Number of medium-level risk items */
  readonly medium: number;
  /** Number of low-level risk items */
  readonly low: number;
}
 
/** Complete synthesis summary aggregating all per-file analyses */
export interface SynthesisSummary {
  /** Unique synthesis identifier (SYN-YYYY-MM-DD-{8-char-UUID}) */
  readonly synthesisId: string;
  /** ISO date of the analysis */
  readonly date: string;
  /** Number of analysis files processed */
  readonly documentsAnalyzed: number;
  /** Aggregated confidence across all sources */
  readonly overallConfidence: ConfidenceLevel;
  /** Top findings ranked by confidence (high → medium → low) */
  readonly topFindings: readonly SynthesisFinding[];
  /** Aggregated SWOT summary */
  readonly swot: AggregatedSWOT;
  /** Risk level distribution */
  readonly riskOverview: RiskOverview;
  /** Editorial recommendations */
  readonly editorialRecommendations: readonly string[];
}