export type FeedbackSeverity = "error" | "warning" | "info"; export type FeedbackStatus = "open" | "resolved" | "superseded"; export type FeedbackVerdict = "pass" | "fail" | "blocked"; export interface FeedbackLocation { path: string; startLine?: number; endLine?: number; } export interface FeedbackFinding { id?: string; rule?: string; location?: FeedbackLocation | string | null; message?: string; severity?: FeedbackSeverity; status?: FeedbackStatus; firstObservedIn?: number; lastObservedIn?: number; trace?: string | null; blocking?: boolean; keepForContext?: boolean; } export interface FeedbackRound { /** 1-based attempt number. Missing values are normalized from array order. */ index?: number; /** pass/fail/blocked (or boolean, where false = fail and true = pass). */ verdict?: FeedbackVerdict | boolean; /** Structured findings from a verifier or host check. */ findings?: FeedbackFinding[]; /** Short free-form failure/verifier text. Converted into a normalized finding. */ feedback?: string; message?: string; /** Optional host-side stageCheck result; failed checks are normalized into findings. */ localChecks?: unknown; /** Optional trace snippet for the round. */ trace?: string; } export interface CompactFeedbackRequest { rounds: FeedbackRound[]; maxTokens?: number; previousDelta?: CorrectionDelta | null; auditLogId?: string; canonicalStateRef?: string; } export interface OpenRootCause { rank: number; findingId: string; rule: string; location: FeedbackLocation | null; severity: FeedbackSeverity; firstSeen: number; lastSeen: number; message: string; trace: string | null; blocking: boolean; } export interface CorrectionDelta { attempt: number; lastVerdict: FeedbackVerdict; openRootCauses: OpenRootCause[]; resolvedSummary: string | null; omitted: { count: number; auditLogId: string; } | null; constraints: string[]; /** Deterministic monotonic marker (round-N), never wall-clock time. */ generatedAt: string; } export declare const MAX_CORRECTION_DELTA_TOKENS = 512; export declare const CORRECTION_DELTA_JSON_SCHEMA: { readonly $schema: "https://json-schema.org/draft/2020-12/schema"; readonly $id: "https://kneutral.org/schemas/correction-delta.v1.json"; readonly title: "Correction Delta"; readonly type: "object"; readonly additionalProperties: false; readonly required: readonly ["attempt", "lastVerdict", "openRootCauses", "resolvedSummary", "omitted", "constraints", "generatedAt"]; readonly properties: { readonly attempt: { readonly type: "integer"; readonly minimum: 1; }; readonly lastVerdict: { readonly type: "string"; readonly enum: readonly ["pass", "fail", "blocked"]; }; readonly openRootCauses: { readonly type: "array"; readonly items: { readonly type: "object"; readonly additionalProperties: false; readonly required: readonly ["rank", "findingId", "rule", "location", "severity", "firstSeen", "lastSeen", "message", "trace", "blocking"]; readonly properties: { readonly rank: { readonly type: "integer"; readonly minimum: 1; }; readonly findingId: { readonly type: "string"; }; readonly rule: { readonly type: "string"; }; readonly location: { readonly oneOf: readonly [{ readonly type: "object"; readonly additionalProperties: false; readonly required: readonly ["path"]; readonly properties: { readonly path: { readonly type: "string"; }; readonly startLine: { readonly type: "integer"; readonly minimum: 1; }; readonly endLine: { readonly type: "integer"; readonly minimum: 1; }; }; }, { readonly type: "null"; }]; }; readonly severity: { readonly type: "string"; readonly enum: readonly ["error", "warning", "info"]; }; readonly firstSeen: { readonly type: "integer"; readonly minimum: 1; }; readonly lastSeen: { readonly type: "integer"; readonly minimum: 1; }; readonly message: { readonly type: "string"; }; readonly trace: { readonly oneOf: readonly [{ readonly type: "string"; }, { readonly type: "null"; }]; }; readonly blocking: { readonly type: "boolean"; }; }; }; }; readonly resolvedSummary: { readonly oneOf: readonly [{ readonly type: "string"; }, { readonly type: "null"; }]; }; readonly omitted: { readonly oneOf: readonly [{ readonly type: "object"; readonly additionalProperties: false; readonly required: readonly ["count", "auditLogId"]; readonly properties: { readonly count: { readonly type: "integer"; readonly minimum: 1; }; readonly auditLogId: { readonly type: "string"; }; }; }, { readonly type: "null"; }]; }; readonly constraints: { readonly type: "array"; readonly items: { readonly type: "string"; }; }; readonly generatedAt: { readonly type: "string"; }; }; }; export declare class FeedbackCompactionError extends Error { readonly issues: string[]; constructor(message: string, issues?: string[]); } /** * Deterministic five-stage Feedback Compactor: * normalize -> group -> resolve/deduplicate -> relevance-rank -> bounded Delta. */ export declare function compactFeedback(request: CompactFeedbackRequest): CorrectionDelta; /** Prompt-ready rendering. The Worker should receive only this rendered Delta, not raw logs. */ export declare function renderCorrectionDelta(delta: CorrectionDelta): string; export declare function validateCorrectionDelta(delta: unknown): { ok: boolean; errors: string[]; };