/** * ReuseEvaluationRunner — the Semantic Reuse Evaluation Capability's execution * path (PRI-917 SPEC v0.3.2 §7, Phase 3C-3). * * A PROPOSAL-ONLY runner. It compares a candidate against a bounded shortlist * of existing Principles and returns a RECOMMENDATION. It has no path to any * ledger writer: this module imports no ledger mutation API, and nothing here * can create, modify, or record a Principle. The Owner decides (SPEC §5). * * Design constraints honoured here (SPEC §7): * - ALL LLM execution goes through the injected PDRuntimeAdapter. This * module creates no client, no inference abstraction, and no provider * seam of its own; the repair loop drives the SAME adapter. * - Structured output repair reuses `structured-output-repair` (the * runtime-agnostic loop) with an adapter-backed `llmCaller`. * - The output contract is the Phase 3C-1 schema, and the Phase 3C-1 * validator is the trust boundary (closed field set + cross-field rules). * * Failure is always fail-closed and observable: a timed-out run, unparsable * output, or a payload that still violates the contract after repair throws a * {@link ReuseEvaluationError}. It NEVER degrades into "no candidates, so * create" — that is the caller's (review surface's) decision, not this * runner's silent default (SPEC §9). */ import type { PDRuntimeAdapter } from '../runtime-protocol.js'; import { type ReuseEvaluationOutputV1 } from './reuse-evaluation-output.js'; /** The candidate's semantic claim — the same claim intake resolves (4b/4c). */ export interface ReuseEvaluationCandidateInput { text: string; triggerPattern: string; action: string; } /** One existing Principle from the deterministic shortlist. */ export interface ReuseEvaluationShortlistEntry { principleId: string; text: string; triggerPattern: string; action: string; } export interface ReuseEvaluationInput { candidate: ReuseEvaluationCandidateInput; /** Bounded Top-K from reuse-shortlist (caller guarantees ≤ 3). */ candidates: ReuseEvaluationShortlistEntry[]; } export type ReuseEvaluationFailureReason = 'timeout' | 'run_failed' | 'output_unavailable' | 'output_invalid' | 'repair_failed'; /** * Fail-closed error from the evaluation runner. Carries a structured reason * and next action so the review surface can degrade OBSERVABLY (SPEC §9) * instead of pretending the shortlist was semantically judged. */ export declare class ReuseEvaluationError extends Error { readonly reason: ReuseEvaluationFailureReason; readonly nextAction: string; readonly detail?: string; readonly repairAttempts: number; constructor(args: { reason: ReuseEvaluationFailureReason; message: string; nextAction: string; detail?: string; repairAttempts?: number; }); } export interface ReuseEvaluationRunnerDeps { /** The one and only LLM execution path (never constructed here). */ readonly runtimeAdapter: PDRuntimeAdapter; } export interface ReuseEvaluationRunnerOptions { /** Per-run budget. Bounded polling never exceeds it. Default 30s. */ readonly timeoutMs?: number; /** Bounded repair attempts after a contract violation. Default 1. */ readonly maxRepairAttempts?: number; /** agentSpec label for telemetry/lineage. Not an agent registration. */ readonly agentId?: string; /** Poll interval while waiting for the run. Default 200ms. */ readonly pollIntervalMs?: number; } export declare class ReuseEvaluationRunner { private readonly runtimeAdapter; private readonly timeoutMs; private readonly maxRepairAttempts; private readonly agentId; private readonly pollIntervalMs; constructor(deps: ReuseEvaluationRunnerDeps, options?: ReuseEvaluationRunnerOptions); /** * Role declaration delivered on the system channel (base-layer prompt, * following CorrectionObserver's PRI-633 pattern). The "you recommend, the * Owner decides" boundary is stated here so the model never narrates itself * as a decision authority (SPEC §5). */ static readonly SYSTEM_PROMPT: string; /** Build the evaluation prompt (deterministic, bounded). */ static buildPrompt(input: ReuseEvaluationInput): string; /** * Run one semantic evaluation and return the validated RECOMMENDATION. * * @throws ReuseEvaluationError — timeout / run failure / unparsable output / * contract violation surviving repair. Never a silent fallback. */ recommend(input: ReuseEvaluationInput): Promise; /** Bounded repair using the SAME adapter (no second LLM path). */ private repairAndValidate; /** * One adapter round-trip: start → bounded poll → fetch. This is the ONLY * place the runner touches the runtime, for both the initial call and each * repair attempt. */ private invoke; } export declare function isValidReuseEvaluationOutput(value: unknown): boolean; //# sourceMappingURL=reuse-evaluation-runner.d.ts.map