import { Buffer } from "node:buffer"; import * as nodeFs from "node:fs"; import { type ReviewOmissions } from "./review-fit"; export type CandidateRequest = { commit_id: string; event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT"; body: string; comments: Array<{ path: string; line: number; side: "LEFT" | "RIGHT"; start_line?: number; start_side?: "LEFT" | "RIGHT"; body: string; }>; }; export declare const LIMITS: Readonly<{ body: 24000; comment: 4000; total: 48000; }>; export type Size = { codePoints: number; utf8Bytes: number; }; export type Measurements = { body: Size; comments: Array; total: Size; }; export type Violation = { field: "body" | `comments[${number}].body` | "total"; unit: keyof Size; limit: number; actual: number; reason: "limit-exceeded"; }; export type CandidateRejection = { ok: false; reason: "unknown-field" | "missing-field" | "invalid-field"; field: string; }; export type MeasureResult = CandidateRejection | { ok: boolean; canonical: string; sha256: string; measurements: Measurements; violations: Violation[]; }; export type ReviewPayloadFs = { readFileSync(path: string): Buffer; writeFileSync(path: string, data: Uint8Array): void; realpathSync(path: string): string; statSync(path: string): Pick; lstatSync(path: string): Pick; }; export type ReviewPayloadOptions = { reviewStateRoot: string; fs?: ReviewPayloadFs; }; type PathRejection = { ok: false; reason: "path-outside-root" | "path-resolution-error" | "not-regular-file"; path: string; }; type ParseReason = "parse-error" | "duplicate-key" | "encoding-error"; export type FreezeResult = { ok: true; artifactPath: string; sha256: string; measurements: Measurements; fitted: boolean; omitted: ReviewOmissions; } | CandidateRejection | PathRejection | { ok: false; reason: "candidate-bom" | `candidate-${ParseReason}` | "candidate-read-error" | "artifact-write-error" | "artifact-read-error"; } | { ok: false; reason: "readback-mismatch"; expectedBytes: number; actualBytes: number; }; export type VerifyResult = { ok: boolean; sha256Match: boolean; canonical: boolean; violations: Violation[]; measurements: Measurements | null; reason?: PathRejection["reason"] | CandidateRejection["reason"] | `artifact-${ParseReason}` | "artifact-read-error" | "artifact-bom" | "artifact-crlf" | "missing-final-lf" | "non-canonical" | "budget-violation" | "sha256-mismatch"; field?: string; path?: string; }; export type PreviewResult = (VerifyResult & { ok: false; }) | (CandidateRequest & { ok: true; sha256: string; measurements: Measurements; }); /** R3/R4 serialize exact strings and ordered API keys; invalid input throws a TypeError with a CandidateRejection cause. */ export declare function canonicalize(req: CandidateRequest): string; /** * R3 measures rendered candidates; R4 and writer/R5 repeat the same checks. * Decoded bodies and the entire canonical serialization are the size oracle, * read before any write. Either unit exceeding its ceiling rejects posting; * no option or empty comments array disables a ceiling. Only `canonical` * contains payload text; diagnostics contain fields and measurements only. */ export declare function measure(req: unknown): MeasureResult; /** * R4 freezes before preview/authorization, which belong to the caller. Schema and * measured canonical bytes are the oracle before writing: oversized candidates * are fitted and remeasured, never size-rejected. A failed fit is an internal * invariant error before artifact writes, not a budget rejection. Length and byte * equality of the full read-back precede returning the written artifact's digest; * any integrity failure withholds that descriptor. No option disables these * checks, and no failure result contains review text. */ export declare function freeze(candidatePath: string, artifactPath: string, opts: ReviewPayloadOptions): FreezeResult; /** * Writer/R5 verify without writing. The trusted expected digest and canonical * reserialization are the oracles for the bytes read on this call, before posting. * Any path, read, schema, format, digest or budget failure rejects posting; no * option disables a check. This does not attest to bytes changed after the read. */ export declare function verify(artifactPath: string, expectedSha256: string, opts: ReviewPayloadOptions): VerifyResult; /** * R4 previews only the bytes accepted by verify's containment, schema, canonical, * digest and budget checks. Capture that read before decoding; a second unchecked * read could show different text. Any verification failure withholds review text, * and no option disables verification. Writes are disabled even for injected * filesystems. This preview does not attest to bytes changed after its read. */ export declare function preview(artifactPath: string, expectedSha256: string, opts: ReviewPayloadOptions): PreviewResult; /** Measure a contained candidate file without returning its review text or writing it. */ export declare function measureFile(candidatePath: string, opts: ReviewPayloadOptions): CandidateRejection | PathRejection | { ok: boolean; sha256: string; measurements: Measurements; violations: Violation[]; } | { readonly ok: false; readonly reason: "candidate-read-error"; } | { readonly ok: false; readonly reason: "candidate-bom"; } | { readonly ok: false; readonly reason: "candidate-encoding-error" | "candidate-parse-error" | "candidate-duplicate-key"; }; /** * The host directory captured at registration is the root oracle, never tool args * or process cwd. Closed operation-specific keys are checked before any file I/O; * relative paths retain traversal segments for checkedPath to reject. R3/R4 receive * a failure for missing host context, invalid args or containment failures. No * argument disables containment. Only freeze writes, after the core's preflight checks. */ export declare function createReviewToolExecutors(directory: string): { payload(input: unknown): string; }; export {}; //# sourceMappingURL=review-payload.d.ts.map