Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@kentcdodds/ship-pr

Progressive ship-pr loop for agents: PR status, Bugbot, review sort, human review feedback, 7-day decisions, merge, deploy, wrap-up.

FollowFork

Files

actionable-live.ts

32 lines · 1.3 KB · TypeScript
/**
 * 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<ClassifyUnsureResult> {
	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
}