All files / src/aggregator artifact-order.ts

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

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                                                                                                    21x                                                                                                                                                                                                                                                                                                                                                                                 21x     21x         21x     21x           21x     21x  
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Aggregator/ArtifactOrder
 * @description Canonical ordering of analysis artifacts in the aggregated
 * article markdown. The order reads like an intelligence product:
 * boardroom summary → facts → forces → assessment → scenarios → self-audit.
 *
 * Every entry lists the artifact paths (relative to the analysis run dir)
 * that belong in that section, in priority order. Missing artifacts are
 * silently skipped. Artifacts that match no section go to the
 * "Supplementary intelligence" bucket so nothing is ever dropped.
 */
 
/** One section in the aggregated document. */
export interface ArtifactSection {
  /** Stable id used for HTML anchors (lowercase-kebab). */
  readonly id: string;
  /** English section title (other languages come from translated MD). */
  readonly title: string;
  /**
   * Ordered list of artifact paths relative to the run dir. May contain
   * either exact file paths (e.g. `intelligence/synthesis-summary.md`) or
   * directory prefixes ending with `/` (e.g. `threat-assessment/`) to
   * include every remaining `.md` under that folder in lexical order.
   */
  readonly artifacts: readonly string[];
}
 
/**
 * Canonical ordering. Order is shaped for a political-intelligence
 * journalist: news-arc first (story → stakes → forecast), then deep
 * structural context, then provenance/audit appendices:
 *
 *  1. Executive brief   2. Synthesis        3. Significance
 *  4. Actors & forces   5. Coalitions       6. Stakeholders
 *  7. Economic          8. Risk             9. Threat
 * 10. Scenarios        11. Forward (What to Watch)  12. Electoral arc
 * 13. PESTLE & history 14. Continuity      15. Deep analysis
 * 16. Documents        17. Extended        18. MCP audit
 * 19. Quality & reflection.
 *
 * Rationale: Stakeholder Map (who is affected) flows directly into
 * Economic Context (macro stakes) without the structural-frame
 * detour of PESTLE. Risk → Threat → Scenarios → Forward Projection →
 * Electoral Arc forms a coherent "consequences and forecast" block.
 * PESTLE & historical-baseline then opens the deep-context section
 * for readers who want structural backdrop after the news.
 */
export const ARTIFACT_SECTIONS: readonly ArtifactSection[] = [
  {
    id: 'executive-brief',
    title: 'Executive Brief',
    artifacts: ['executive-brief.md', 'extended/executive-brief.md'],
  },
  {
    id: 'synthesis',
    title: 'Synthesis Summary',
    artifacts: ['intelligence/synthesis-summary.md', 'synthesis.md'],
  },
  {
    id: 'significance',
    title: 'Significance',
    artifacts: [
      'classification/significance-classification.md',
      'classification/sensitivity-assessment.md',
      'classification/priority-matrix.md',
      'classification/issue-classification.md',
      'intelligence/significance-scoring.md',
      'significance-assessment.md',
    ],
  },
  {
    id: 'actors-forces',
    title: 'Actors & Forces',
    artifacts: [
      'classification/actor-mapping.md',
      'classification/forces-analysis.md',
      'classification/impact-matrix.md',
      'classification/stakeholder-classification.md',
      'actor-mapping.md',
      'political-forces.md',
      'impact-assessment.md',
      // Catch-all for any other classification/*.md not consumed above
      // (keeps non-canonical artifact names out of the Supplementary bucket
      // and inside their journalist-correct section).
      'classification/',
    ],
  },
  {
    id: 'coalitions-voting',
    title: 'Coalitions & Voting',
    artifacts: [
      'intelligence/coalition-dynamics.md',
      'intelligence/voting-patterns.md',
      'existing/voting-patterns.md',
    ],
  },
  {
    id: 'stakeholder-map',
    title: 'Stakeholder Map',
    artifacts: [
      'intelligence/stakeholder-map.md',
      'existing/stakeholder-impact.md',
      'stakeholder-perspectives.md',
    ],
  },
  {
    id: 'economic-context',
    title: 'Economic Context',
    artifacts: ['intelligence/economic-context.md'],
  },
  {
    id: 'risk',
    title: 'Risk Assessment',
    artifacts: [
      'risk-scoring/risk-matrix.md',
      'risk-scoring/quantitative-swot.md',
      'risk-scoring/political-capital-risk.md',
      'risk-scoring/legislative-velocity-risk.md',
      'risk-scoring/political-risk.md',
      'risk-scoring/legislative-risk.md',
      'risk-scoring/economic-risk.md',
      'risk-scoring/institutional-risk.md',
      'risk-matrix.md',
      'quantitative-swot.md',
      // Catch-all for any other risk-scoring/*.md (e.g. naming variants) so
      // they render under Risk Assessment instead of Supplementary.
      'risk-scoring/',
    ],
  },
  {
    id: 'threat',
    title: 'Threat Landscape',
    artifacts: [
      'intelligence/political-threat-landscape.md',
      'intelligence/threat-model.md',
      'threat-assessment/',
    ],
  },
  {
    id: 'scenarios',
    title: 'Scenarios & Wildcards',
    artifacts: [
      'intelligence/scenario-forecast.md',
      'intelligence/wildcards-blackswans.md',
      'scenario-forecast.md',
    ],
  },
  {
    id: 'forward-projection',
    title: 'What to Watch',
    artifacts: [
      'intelligence/forward-projection.md',
      'intelligence/legislative-pipeline-forecast.md',
      'intelligence/parliamentary-calendar-projection.md',
      'forward/forward-projection.md',
      'forward/legislative-pipeline-forecast.md',
      'forward/parliamentary-calendar-projection.md',
      'extended/forward-indicators.md',
    ],
  },
  {
    id: 'electoral-arc',
    title: 'Electoral Arc & Mandate',
    artifacts: [
      'intelligence/term-arc.md',
      'intelligence/seat-projection.md',
      'intelligence/mandate-fulfilment-scorecard.md',
      'intelligence/presidency-trio-context.md',
      'intelligence/commission-wp-alignment.md',
    ],
  },
  {
    id: 'pestle-context',
    title: 'PESTLE & Context',
    artifacts: [
      'intelligence/pestle-analysis.md',
      'intelligence/historical-baseline.md',
      'pestle-analysis.md',
    ],
  },
  {
    id: 'continuity',
    title: 'Cross-Run Continuity',
    artifacts: [
      'intelligence/cross-run-diff.md',
      'existing/cross-session-intelligence.md',
      'intelligence/cross-session-intelligence.md',
      'existing/session-baseline.md',
      'intelligence/session-baseline.md',
      'existing/pipeline-health.md',
    ],
  },
  {
    id: 'deep-analysis',
    title: 'Deep Analysis',
    artifacts: ['existing/deep-analysis.md'],
  },
  {
    id: 'documents',
    title: 'Document Analysis',
    artifacts: [
      'documents/document-analysis-index.md',
      'documents/',
      'existing/per-file-political-intelligence.md',
      'existing/committee-productivity.md',
    ],
  },
  {
    id: 'extended-intel',
    title: 'Extended Intelligence',
    artifacts: ['extended/', 'media-framing.md'],
  },
  {
    id: 'mcp-reliability',
    title: 'MCP Reliability Audit',
    artifacts: ['intelligence/mcp-reliability-audit.md'],
  },
  {
    id: 'quality-reflection',
    title: 'Analytical Quality & Reflection',
    artifacts: [
      'intelligence/analysis-index.md',
      'intelligence/reference-analysis-quality.md',
      'intelligence/workflow-audit.md',
      'intelligence/methodology-reflection.md',
      'article-index.md',
      'methodology-reflection.md',
    ],
  },
];
 
/** Id of the catch-all bucket for artifacts not matched by any section. */
export const SUPPLEMENTARY_SECTION_ID = 'supplementary-intelligence';
 
/** Display title for the catch-all bucket. */
export const SUPPLEMENTARY_SECTION_TITLE = 'Supplementary Intelligence';
 
/** Id of the tradecraft references appendix. Prefixed with `aggregator-`
 * to avoid id collisions with artifact headings that happen to slug to
 * `tradecraft-references`. */
export const TRADECRAFT_SECTION_ID = 'aggregator-tradecraft-references';
 
/** Display title for the tradecraft references appendix. */
export const TRADECRAFT_SECTION_TITLE = 'Tradecraft References';
 
/** Id of the analysis index / manifest appendix. Prefixed with `aggregator-`
 * to avoid id collisions with artifact headings (e.g. an artifact literally
 * named `analysis-index.md` that contains its own `### Analysis Index`
 * heading, which markdown-it-anchor would slug to the same id). */
export const MANIFEST_SECTION_ID = 'aggregator-analysis-index';
 
/** Display title for the analysis index / manifest appendix. */
export const MANIFEST_SECTION_TITLE = 'Analysis Index';