import { FRESHNESS_BOUNDS, withinDeadline } from './model-policy-freshness-sources'; import { assessFreshness, observationIsOlder, renderFreshnessReport, sameCatalog, validLifecycle, validState, type CatalogIdentity, type FreshnessObservation, type FreshnessReport, type FreshnessState, type LifecycleFinding } from './model-policy-freshness'; export const FRESHNESS_ISSUE_MARKER = ''; export const FRESHNESS_REGION_BEGIN = ''; export const FRESHNESS_REGION_END = ''; const STATE_BEGIN = ''; const STATE_END = ''; const HISTORY_BEGIN = ''; const HISTORY_END = ''; export const FRESHNESS_ISSUE_AUTHOR = 'github-actions[bot]'; export type TrackingIssue = { number: number; body: string; state: 'open' | 'closed'; author: string }; export type FreshnessGitHub = { defaultCatalog: (signal: AbortSignal) => Promise<{ defaultBranch: string; sourceSha256: string }>; listIssues: (signal: AbortSignal) => Promise; readIssue: (number: number, signal: AbortSignal) => Promise; createIssue: (body: string, signal: AbortSignal) => Promise; updateIssue: (number: number, update: { body: string; state: 'open' | 'closed' }, signal: AbortSignal) => Promise; }; export type StoredIssue = { state: FreshnessState | null; lifecycle: LifecycleFinding[]; recoveryRequired: boolean; problem: string | null }; const KNOWN_MARKERS = [FRESHNESS_ISSUE_MARKER, FRESHNESS_REGION_BEGIN, FRESHNESS_REGION_END, STATE_BEGIN, STATE_END, HISTORY_BEGIN, HISTORY_END]; function markerLines(body: string, marker?: string): { start: number; end: number; text: string }[] { return [...body.matchAll(/[^\r\n]+/g)].flatMap(line => { const text = line[0]; const matches = marker === undefined ? /^[\uFEFF \t]*(?: