All files / types intelligence.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                                                                                                                                                                                                                                                                                                         
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Types/Intelligence
 * @description Cross-article intelligence types for parliamentary trend tracking.
 * Enables trend detection, historical context linking, and unified intelligence
 * reporting across all article types.
 */
 
import type { ArticleCategory, LanguageCode } from './common.js';
 
/**
 * Describes a directional relationship between two articles.
 * - `follows_up`: Current article is a follow-up to the target (target is older)
 * - `preceded_by`: Current article precedes the target (target is newer)
 * - `related`: Articles share significant topic/actor overlap
 * - `contradicts`: Articles present opposing analyses
 * - `deepens`: Current article provides deeper analysis of the target
 */
export type CrossReferenceRelationship =
  | 'follows_up'
  | 'preceded_by'
  | 'related'
  | 'contradicts'
  | 'deepens';
 
/** Signal strength of a cross-reference link */
export type CrossReferenceStrength = 'strong' | 'moderate' | 'weak';
 
/**
 * A directional reference from one article to another.
 * Used to build navigational and analytical links between related content.
 */
export interface ArticleCrossReference {
  /** Identifier of the referenced article (YYYY-MM-DD-slug-lang) */
  targetArticleId: string;
  /** Nature of the relationship from the source article's perspective */
  relationship: CrossReferenceRelationship;
  /** Human-readable description of why these articles are linked */
  context: string;
  /** How strongly the two articles are related */
  strength: CrossReferenceStrength;
}
 
/** Trend category classifying the political domain */
export type TrendCategory = 'coalition' | 'legislative' | 'procedural' | 'political';
 
/** Direction of trend movement over time */
export type TrendDirection = 'strengthening' | 'weakening' | 'stable' | 'emerging';
 
/** Confidence level in a detected trend */
export type TrendConfidence = 'high' | 'medium' | 'low';
 
/**
 * A parliamentary trend detected across multiple articles.
 * Requires a minimum of 2 article references to be valid.
 */
export interface TrendDetection {
  /** Unique trend identifier */
  id: string;
  /** Human-readable trend name */
  name: string;
  /** Political domain this trend belongs to */
  category: TrendCategory;
  /** Current momentum direction */
  direction: TrendDirection;
  /** ISO date when this trend was first observed */
  firstSeen: string;
  /** ISO date when this trend was most recently updated */
  lastUpdated: string;
  /** Identifiers of articles that contribute evidence for this trend */
  articleReferences: string[];
  /** Key evidence points supporting the trend */
  evidence: string[];
  /** Reliability of the trend detection */
  confidence: TrendConfidence;
}
 
/** Lifecycle status of an article series */
export type ArticleSeriesStatus = 'ongoing' | 'concluded';
 
/**
 * A named series of articles tracking a single legislative procedure or topic.
 */
export interface ArticleSeries {
  /** Unique series identifier */
  id: string;
  /** Human-readable series name */
  name: string;
  /** Optional EP procedure reference (e.g. "2024/0001(COD)") */
  procedureRef?: string | undefined;
  /** Ordered list of article IDs in this series */
  articles: string[];
  /** Whether the series is still being updated */
  status: ArticleSeriesStatus;
  /** Brief editorial summary of the series arc */
  summary: string;
}
 
/**
 * Lightweight index entry for a single generated article.
 * The `id` follows the convention YYYY-MM-DD-slug-lang
 * (e.g. "2025-03-10-week-ahead-en" or "2025-02-14-ai-regulation-committee-fr").
 */
export interface ArticleIndexEntry {
  /** Article identifier: YYYY-MM-DD-slug-lang */
  id: string;
  /** ISO date string (YYYY-MM-DD) */
  date: string;
  /** Article category / type */
  type: ArticleCategory;
  /** Language code */
  lang: LanguageCode;
  /** Key topics covered in the article */
  keyTopics: string[];
  /** Key actors (MEPs, committees, political groups) mentioned */
  keyActors: string[];
  /** EP procedure references covered in the article */
  procedures: string[];
  /** Cross-references to other articles */
  crossReferences: ArticleCrossReference[];
  /** Trend IDs this article contributes evidence for */
  trendContributions: string[];
  /** Series ID if this article belongs to a series */
  seriesId?: string | undefined;
}
 
/**
 * The top-level intelligence index that aggregates cross-article analytics.
 * Uses `Record<string, string[]>` (not Map) for JSON serialisation compatibility.
 */
export interface IntelligenceIndex {
  /** All indexed articles */
  articles: ArticleIndexEntry[];
  /** Actor name → list of article IDs mentioning that actor */
  actors: Record<string, string[]>;
  /** Policy domain keyword → list of article IDs covering that domain */
  policyDomains: Record<string, string[]>;
  /** EP procedure reference → list of article IDs covering that procedure */
  procedures: Record<string, string[]>;
  /** Detected trends across articles */
  trends: TrendDetection[];
  /** Article series groupings */
  series: ArticleSeries[];
  /** ISO timestamp of last index update */
  lastUpdated: string;
}