/** * Live wiring for the unsure-comment classifier: Clef model evaluation * through @kody/clef/evaluate (Jev-shaped API, Workers AI). Falls back to * closed (every unsure comment stays unsure) when the model call fails. */ import evaluate from 'kody:@kody/clef/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-port.ts' const clefEvaluate: 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: clefEvaluate, cache: { get: getActionableVerdicts, put: putActionableVerdicts }, ...(backoff ? { skipReason: backoff } : {}), }) if (result.stats.error) await recordActionableModelFailure(result.stats.error) return result }