import { classifyUnsureComments } from './actionable-live.ts' import { fetchSnapshot } from './github-port.ts' import type { PrLocator } from './input.ts' import { computeShip, type ComputeOptions } from './status.ts' import { listDecisions, listEvents } from './storage-port.ts' /** * Fetch PR state + active decisions/events, ask the cheap model about human * comments the rules mark unsure (cached, fail closed), and compute the * progressive report. */ export async function loadShip(locator: PrLocator, options: Omit) { const [snapshot, decisions, events] = await Promise.all([ fetchSnapshot(locator), listDecisions(locator.key), listEvents(locator.key), ]) const classified = await classifyUnsureComments(snapshot).catch((error) => ({ verdicts: new Map(), stats: { unsure: 0, cached: 0, modelCalls: 0, classified: 0, failedClosed: 0, error: String(error).slice(0, 120) }, })) const report = computeShip(snapshot, decisions, events, { ...options, now: Date.now(), verdicts: classified.verdicts, classifierStats: { model: '@kody/clef (typesafe/jev)', ...classified.stats }, }) return { snapshot, decisions, events, report } }