All files / scripts/agentic/gate-checks artifact-existence.ts

100% Statements 9/9
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 161x 161x 47x           114x 1x             113x               7x    
/**
 * @module scripts/agentic/gate-checks/artifact-existence
 * @description Check 1 — Verify all 23 required artifacts exist and are non-empty.
 *
 * @see .github/prompts/05-analysis-gate.md §Check 1
 * @author Hack23 AB
 * @license Apache-2.0
 */
 
import { existsSync, statSync } from 'node:fs';
import { join } from 'node:path';
 
import { REQUIRED_ARTIFACT_FILENAMES } from '../artifact-inventory.js';
import type { GateCheckResult } from '../gate-shared/types.js';
 
/**
 * Verify all 23 required artifacts exist and are non-empty.
 */
export function checkArtifactExistence(analysisDir: string): GateCheckResult[] {
  const results: GateCheckResult[] = [];
  for (const filename of REQUIRED_ARTIFACT_FILENAMES) {
    const filePath = join(analysisDir, filename);
    if (!existsSync(filePath)) {
      results.push({
        checkId: 'artifact-existence',
        passed: false,
        message: `Missing artifact: ${filename}`,
        artifact: filename,
      });
    } else if (statSync(filePath).size === 0) {
      results.push({
        checkId: 'artifact-existence',
        passed: false,
        message: `Empty artifact (zero bytes): ${filename}`,
        artifact: filename,
      });
    } else {
      results.push({
        checkId: 'artifact-existence',
        passed: true,
        message: `Artifact present: ${filename}`,
        artifact: filename,
      });
    }
  }
  return results;
}