All files / src/workflows/safe-outputs types.ts

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

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                                                                                                                    1x                           1x             1x                 1x          
// SPDX-FileCopyrightText: 2024-2026 Hack23 AB
// SPDX-License-Identifier: Apache-2.0
 
/**
 * @module Workflows/SafeOutputs/Types
 * @description Type definitions for Stage E — PR creation and safe output constraints.
 * Defines the contract for the `safeoutputs___create_pull_request` call that
 * every unified news-*.md workflow makes exactly once at the end of execution.
 */
 
// ─── PR Creation Constraints ─────────────────────────────────────────────────
 
/**
 * Parameters for the safe-outputs PR creation call.
 * Maps to the `safeoutputs___create_pull_request` tool interface.
 */
export interface SafeOutputsPRParams {
  /** PR title — must include article type and date. */
  readonly title: string;
  /** PR body — should contain the STAGE_C_GATE line and summary. */
  readonly body: string;
  /** Base branch (typically 'main'). */
  readonly base: string;
  /** Head branch (auto-generated by the workflow). */
  readonly head: string;
  /** Labels to apply to the PR. */
  readonly labels?: readonly string[];
  /** Whether to create as draft PR. */
  readonly draft?: boolean;
}
 
/**
 * Constraints enforced by the lint-prompts.js linter on safe-outputs usage.
 */
export interface SafeOutputsConstraints {
  /**
   * Maximum number of `safeoutputs___create_pull_request` calls allowed per workflow.
   * Always 1 for unified news-*.md workflows (news-translate.md is exempt).
   */
  readonly maxPRCalls: number;
  /**
   * Target minute by which the PR call should land.
   * Standard slugs: ≤ 42 minutes; electoral slugs: ≤ 47 minutes.
   */
  readonly targetMinute: number;
  /**
   * Hard deadline minute — PR MUST land by this time.
   * Standard: ≤ 45; electoral: ≤ 50.
   */
  readonly hardDeadlineMinute: number;
}
 
// ─── Forbidden Phrases ───────────────────────────────────────────────────────
 
/**
 * Phrases forbidden in agentic workflow files.
 * Detected by lint-prompts.js — presence causes lint failure.
 */
export const FORBIDDEN_PHRASES: readonly string[] = [
  'checkpoint pr',
  'checkpoint-pr',
  'keep-alive',
  'keepalive',
  'keep alive',
  'heartbeat',
  'progressive safe output',
];
 
/**
 * Forbidden tool references in workflow files.
 * push_repo_memory is not allowed in any news-*.md workflow.
 */
export const FORBIDDEN_TOOL_REFS: readonly string[] = ['safeoutputs___push_repo_memory'];
 
// ─── Default Constraints by Slug Type ────────────────────────────────────────
 
/**
 * Default safe-outputs timing constraints for standard article slugs.
 */
export const STANDARD_CONSTRAINTS: SafeOutputsConstraints = {
  maxPRCalls: 1,
  targetMinute: 42,
  hardDeadlineMinute: 45,
};
 
/**
 * Safe-outputs timing constraints for electoral-overlay article slugs.
 */
export const ELECTORAL_CONSTRAINTS: SafeOutputsConstraints = {
  maxPRCalls: 1,
  targetMinute: 47,
  hardDeadlineMinute: 50,
};