/** * Live wiring for the unsure-comment classifier: the cheap model through * `@kentcdodds/jev/evaluate` and the verdict cache in package storage. * Everything fails closed; see `./actionable-model.ts` for the policy. */ import evaluate from 'kody:@kentcdodds/jev/evaluate' import { classifyUnsure, type ClassifyUnsureResult, type ModelEvaluate } from './actionable-model.ts' import { unsureHumanComments } from './human.ts' import type { PrSnapshot } from './snapshot.ts' import { actionableModelBackoff, getActionableVerdicts, putActionableVerdicts, recordActionableModelFailure, } from './storage.ts' const jevEvaluate: ModelEvaluate = async (input) => await evaluate(input as never) export async function classifyUnsureComments(snapshot: PrSnapshot): Promise { const items = unsureHumanComments(snapshot) if (!items.length) { return { verdicts: new Map(), stats: { unsure: 0, cached: 0, modelCalls: 0, classified: 0, failedClosed: 0 } } } const backoff = await actionableModelBackoff() const result = await classifyUnsure(items, { evaluate: jevEvaluate, cache: { get: getActionableVerdicts, put: putActionableVerdicts }, ...(backoff ? { skipReason: backoff } : {}), }) if (result.stats.error) await recordActionableModelFailure(result.stats.error) return result }