All files / scripts/agentic/gate-checks coalition-mathematics.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 1/1
100% Lines 9/9

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                                            7x 7x 7x   6x 6x   6x 2x             4x               6x    
/**
 * @module scripts/agentic/gate-checks/coalition-mathematics
 * @description Check 8b — Validate coalition-mathematics.md contains a
 *              seat-count / vote-breakdown table.
 *
 * @see .github/prompts/05-analysis-gate.md §Check 8 (coalition-mathematics)
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { readFile } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { join } from 'node:path';
 
import type { GateCheckResult } from '../gate-shared/types.js';
 
/**
 * Check coalition-mathematics.md for seat-count / vote-breakdown table.
 */
export async function checkCoalitionMathematics(
  analysisDir: string,
): Promise<GateCheckResult[]> {
  const results: GateCheckResult[] = [];
  const filePath = join(analysisDir, 'coalition-mathematics.md');
  if (!existsSync(filePath)) return results;
 
  const content = await readFile(filePath, 'utf-8');
  const hasTable = /^\|.*(Ja|Nej|Avstår|Frånvarande|Seats|Mandat)/m.test(content);
 
  if (!hasTable) {
    results.push({
      checkId: 'family-d-structure',
      passed: false,
      message: 'coalition-mathematics.md: missing seat-count / vote-breakdown table',
      artifact: 'coalition-mathematics.md',
    });
  } else {
    results.push({
      checkId: 'family-d-structure',
      passed: true,
      message: 'coalition-mathematics.md: vote/seat table present',
      artifact: 'coalition-mathematics.md',
    });
  }
 
  return results;
}