All files / scripts/agentic/gate-checks forward-indicators.ts

100% Statements 12/12
83.33% Branches 5/6
100% Functions 1/1
100% Lines 11/11

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                                            8x 8x 8x   7x 7x 7x 7x   8x 2x             5x               7x    
/**
 * @module scripts/agentic/gate-checks/forward-indicators
 * @description Check 8a — Validate forward-indicators.md has ≥10 dated
 *              indicators (ISO date, YYYYQn or +Nd/h offset).
 *
 * @see .github/prompts/05-analysis-gate.md §Check 8 (forward-indicators)
 * @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 forward-indicators.md for ≥10 dated indicators.
 */
export async function checkForwardIndicators(
  analysisDir: string,
): Promise<GateCheckResult[]> {
  const results: GateCheckResult[] = [];
  const filePath = join(analysisDir, 'forward-indicators.md');
  if (!existsSync(filePath)) return results;
 
  const content = await readFile(filePath, 'utf-8');
  const datePattern = /20[0-9]{2}-[0-1][0-9]-[0-3][0-9]|20[0-9]{2}Q[1-4]|\+[0-9]+\s*(h|d|day|week|month)/g;
  const matches = content.match(datePattern);
  const count = matches ? matches.length : 0;
 
  if (count < 10) {
    results.push({
      checkId: 'family-d-structure',
      passed: false,
      message: `forward-indicators.md: fewer than 10 dated indicators (found ${count})`,
      artifact: 'forward-indicators.md',
    });
  } else {
    results.push({
      checkId: 'family-d-structure',
      passed: true,
      message: `forward-indicators.md: ${count} dated indicators found`,
      artifact: 'forward-indicators.md',
    });
  }
 
  return results;
}