/** * Jev decisions — typed helpers callers can use without handling HTTP. * * Every helper is "fail soft": when Jev is unavailable (disabled, no key, timeout, * rate limit, schema drift) the helper returns `{ available: false, reason }` instead of * throwing, so the caller keeps its existing heuristic. Nothing here ever throws. * * Fan-out rule: independent questions about the same state go in ONE request. * * @module core/jev/decide */ import { type JevClient } from './client.js'; import type { JevConfig } from './config.js'; import { type CommandScope, type RequestKind, type TaskComplexity, type TestFailureKind } from './questions.js'; /** Same three tiers as utils/model-selection; declared locally to avoid an import cycle. */ export type ModelTier = 'haiku' | 'sonnet' | 'opus'; export interface Unavailable { available: false; reason: string; } export interface RouteDecisionOk { available: true; skill: string | null; skillConfidence: number; skillProbabilities: Record; kind: RequestKind; kindConfidence: number; complexity: TaskComplexity; complexityConfidence: number; tier: ModelTier; needsIncrement: number; latencyMs: number; cost?: number; } export type RouteDecision = RouteDecisionOk | Unavailable; export interface TaskDecisionOk { available: true; complexity: TaskComplexity; confidence: number; tier: ModelTier; needsIncrement: number; latencyMs: number; cost?: number; } export type TaskDecision = TaskDecisionOk | Unavailable; export interface GuardDecisionOk { available: true; verdict: 'allow' | 'warn' | 'deny'; scope: CommandScope; scopeConfidence: number; destructive: number; prefiltered: boolean; probabilities: Record; reason: string; latencyMs: number; cost?: number; } export type GuardDecision = GuardDecisionOk | Unavailable; export type AcDecision = { id: string; available: true; satisfied: boolean; probability: number; } | { id: string; available: false; reason: string; }; export interface FailureDecisionOk { available: true; kind: TestFailureKind; confidence: number; probabilities: Record; latencyMs: number; } export type FailureDecision = FailureDecisionOk | Unavailable; export interface ScreenDecisionOk { available: true; injection: number; flagged: boolean; latencyMs: number; } export type ScreenDecision = ScreenDecisionOk | Unavailable; /** Hard cap on ACs judged in one fan-out request. */ export declare const MAX_ACS_PER_REQUEST = 40; /** * Complexity → model tier, with a confidence floor: an uncertain classification * always escalates to opus rather than saving money on a task we misread. */ export declare function modelTierFor(complexity: TaskComplexity, confidence: number, threshold: number): ModelTier; /** * Turn the two guard answers into a verdict (spec 0878, "Verdict" bullet). * * Deny needs high confidence; warn is deliberately generous. * * The scope-confidence deny arm exists because a near-certain local wipe scores its * *scope* high but its *destructiveness* only moderately: `rm -rf ~/Projects` comes back * scope=local_irreversible at 0.99 with destructive=0.81, below guardDeny (0.85). Gating * on the scope confidence catches it without lowering guardDeny, which would loosen every * remote verdict too. * * `destructive_remote` is in the warn arm so a low-confidence remote-destruction reading * degrades to warn rather than falling through to allow. */ export declare function guardVerdict(scope: string, scopeConf: number, destructive: number, t: JevConfig['thresholds'], /** p(local_irreversible) + p(destructive_remote): the two scopes that both mean "data is gone". */ irreversibleMass?: number): 'allow' | 'warn' | 'deny'; /** * Cheap regex gate in front of the guard: plainly read-only commands skip Jev entirely. * Conservative by construction — anything unrecognised returns 'check'. */ export declare function prefilterCommand(command: string): 'skip' | 'check'; /** * One fan-out request: which skill, what kind of request, how complex, increment needed. */ export declare function routePrompt(client: JevClient, prompt: string, ctx: { skills: Array<{ name: string; description: string; }>; activeIncrement?: string; }): Promise; /** How much reasoning one increment task needs → model tier. */ export declare function classifyTask(client: JevClient, task: { id: string; title: string; body: string; acs: string[]; approach?: string; }): Promise; /** Scope + destructiveness of a shell command, behind the regex prefilter. */ export declare function guardCommand(client: JevClient, cmd: { command: string; cwd?: string; description?: string; }): Promise; /** One noul per acceptance criterion, all in one request (capped at 40). */ export declare function judgeAcs(client: JevClient, acs: Array<{ id: string; text: string; }>, evidence: { diffSummary?: string; testOutputTail?: string; notes?: string; }): Promise; /** Regression vs flake vs environment, from a failing test tail. */ export declare function classifyFailure(client: JevClient, outputTail: string, ctx?: { changedFiles?: string[]; }): Promise; /** Does untrusted text (issue body, page text, email) address an agent? */ export declare function screenText(client: JevClient, text: string, source?: string): Promise; /** * Probability that a test/build output is a clean pass. * `available: false` means the caller must fall back to its own parser — `passed` is 0 * in that case so treating "unknown" as "not passed" stays the safe default. */ export declare function testOutputPassed(client: JevClient, output: string, kind: 'tests' | 'build'): Promise<{ passed: number; available: boolean; reason?: string; }>; //# sourceMappingURL=decide.d.ts.map