@pymodel/verdict-mcp 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -77,6 +77,16 @@ The server speaks MCP over stdio by default and exposes tools named `verdict_*`.
77
77
  | `verdict_review` | Is this patch actually done, per the request? |
78
78
  | `verdict_gate` | Does the patch pass review *and* do the completion claims verify? |
79
79
 
80
+ ### Images
81
+
82
+ `verdict_screen`, `verdict_verify`, `verdict_noul`, `verdict_classify`, `verdict_decide` and
83
+ `verdict_gate` take an optional `images` list: up to 8 PNG, JPEG or WebP images, 5 MiB each and
84
+ 20 MiB in all, that every question in the call looks at. Over stdio an entry can be an absolute
85
+ file path, which verdict-mcp reads and checks itself, so an agent can screen a screenshot before
86
+ it views it. Over HTTP only base64 data URLs are accepted, so a remote caller cannot make the
87
+ server read files. Images go only to a local Verdict server started with the vision projector;
88
+ the hosted providers refuse them, and a server without image support fails the call at once.
89
+
80
90
  Full arguments, output shapes, limits, and failure modes:
81
91
  [tool reference](https://github.com/PyModel/verdict-mcp/blob/main/packages/verdict-mcp/skills/verdict/reference/tools.md).
82
92
 
@@ -88,8 +98,9 @@ Full arguments, output shapes, limits, and failure modes:
88
98
  | `JEV_API_KEY` | Optional bearer token for the local endpoint |
89
99
  | `JEV_PROVIDER` | Force a provider: `local`, `typesafe`, `openrouter`, `cloudflare`, or `vercel` |
90
100
  | `VERDICT_MCP_MODEL` | Model slug for providers that route by model; default `jev-latest`. The Verdict app ignores it. |
91
- | `VERDICT_MCP_REQUEST_TIMEOUT_MS` | Whole-request deadline; default `60000` |
92
- | `VERDICT_MCP_MAX_ATTEMPTS` | Attempts for 408, 409, 429, and 5xx; default `3` |
101
+ | `VERDICT_MCP_REQUEST_TIMEOUT_MS` | Whole-request deadline; default `600000`, since a 27B model can take minutes on a long input |
102
+ | `VERDICT_MCP_MAX_ATTEMPTS` | Attempts for 408, 409, 429, and 5xx other than 501; default `3` |
103
+ | `VERDICT_MCP_CLIENT` | Agent name sent to the local endpoint in `X-Verdict-Client`, so the Verdict app can show which agent made each request; default is the name the MCP client reports (for example `claude-code`) |
93
104
  | `VERDICT_MCP_TRANSPORT` | Set to `http` to start the HTTP transport instead of stdio |
94
105
 
95
106
  ## HTTP mode
package/dist/http.js CHANGED
@@ -1,15 +1,8 @@
1
- // Opt-in stateless Streamable HTTP transport (`verdict-mcp --http`).
2
- //
3
- // Serves MCP 2026-07-28 per request and 2025-era clients through the SDK's
4
- // stateless fallback: no sessions, no Mcp-Session-Id, nothing held between
5
- // requests, so any number of replicas can sit behind a plain load balancer.
6
1
  import { createServer as createNodeServer } from "node:http";
7
2
  import { timingSafeEqual } from "node:crypto";
8
3
  import { createMcpHandler } from "@modelcontextprotocol/server";
9
4
  import { toNodeHandler } from "@modelcontextprotocol/node";
10
5
  const LOOPBACK_DEFAULT = "127.0.0.1";
11
- // Fixed-string rejection: never echo the rejected Host/Origin back (reflection
12
- // of attacker-controlled values), unlike the SDK's guards.
13
6
  const FORBIDDEN_BODY = JSON.stringify({ jsonrpc: "2.0", error: { code: -32000, message: "Forbidden" }, id: null });
14
7
  function forbidden(res) {
15
8
  res.writeHead(403, { "content-type": "application/json" }).end(FORBIDDEN_BODY);
@@ -36,7 +29,6 @@ function isLoopbackOrigin(origin) {
36
29
  }
37
30
  }
38
31
  export async function serveHttp(factory, env = process.env) {
39
- // Loopback by default: binding a public interface is an explicit act.
40
32
  const host = env.HOST || LOOPBACK_DEFAULT;
41
33
  const port = Number(env.PORT || 8080);
42
34
  if (!Number.isInteger(port) || port < 0 || port > 65535) {
@@ -44,18 +36,13 @@ export async function serveHttp(factory, env = process.env) {
44
36
  }
45
37
  const token = Buffer.from(env.VERDICT_MCP_AUTH_TOKEN ?? "");
46
38
  const maxInFlight = Number(env.VERDICT_MCP_MAX_CONCURRENCY ?? 16);
47
- // Opt-in for clients that can only be configured with a URL (claude.ai custom
48
- // connectors, some cloud agents): the token may also arrive as /mcp/<token>.
49
39
  const pathToken = env.VERDICT_MCP_PATH_TOKEN === "1";
50
- // The server spends the operator's Jev key on every call; never expose it unauthenticated.
51
40
  if (token.length === 0 && !isLoopbackHost(host)) {
52
41
  throw new Error("VERDICT_MCP_AUTH_TOKEN is required when HTTP mode binds a non-loopback HOST");
53
42
  }
54
43
  if (pathToken && token.length === 0) {
55
44
  throw new Error("VERDICT_MCP_PATH_TOKEN requires VERDICT_MCP_AUTH_TOKEN");
56
45
  }
57
- // The path form compares the segment raw, so a token containing characters
58
- // a client may percent-encode could never match. Refuse at startup instead.
59
46
  if (pathToken && /[^\w.\-~]/.test(env.VERDICT_MCP_AUTH_TOKEN ?? "")) {
60
47
  throw new Error("VERDICT_MCP_PATH_TOKEN requires a URL-safe token (letters, digits, . _ - ~)");
61
48
  }
@@ -69,19 +56,13 @@ export async function serveHttp(factory, env = process.env) {
69
56
  const authorized = (header, fromPath) => {
70
57
  if (token.length === 0)
71
58
  return true;
72
- // The path segment is compared raw, never URI-decoded: decoding throws on
73
- // malformed escapes, and a throw here would take down the process.
74
59
  if (fromPath !== undefined)
75
60
  return matches(fromPath);
76
61
  return matches(header?.startsWith("Bearer ") ? header.slice(7) : "");
77
62
  };
78
- // On loopback, reject foreign Host/Origin headers so a web page cannot reach
79
- // the server through DNS rebinding (the spec's Origin-validation MUST).
80
63
  const onLoopback = isLoopbackHost(host);
81
64
  const logError = (error) => console.error(`[verdict-mcp] http: ${error.message}`);
82
65
  const mcp = toNodeHandler(createMcpHandler(factory, {
83
- // The tool list never changes: refuse subscriptions/listen in-band
84
- // instead of letting a client park an idle SSE stream on a slot.
85
66
  maxSubscriptions: 0,
86
67
  onerror: logError,
87
68
  }), { onerror: logError });
@@ -102,20 +83,14 @@ export async function serveHttp(factory, env = process.env) {
102
83
  res.writeHead(401, { "www-authenticate": "Bearer" }).end();
103
84
  }
104
85
  else if (inFlight >= maxInFlight) {
105
- // Backpressure: each in-flight request replays tools and may spend the
106
- // operator's Jev key; shed load instead of queueing it.
107
86
  res.writeHead(429, { "retry-after": "1" }).end();
108
87
  }
109
88
  else {
110
89
  inFlight++;
111
- // The token never travels past auth: rewrite the authenticated URL so
112
- // the SDK's Request (and any diagnostics built from it) sees /mcp only.
113
90
  if (fromPath !== undefined)
114
91
  req.url = "/mcp";
115
92
  void mcp(req, res)
116
93
  .catch((error) => {
117
- // toNodeHandler reports its own failures through onerror; a promise
118
- // rejection here must not become an unhandled one that kills Node.
119
94
  console.error(`[verdict-mcp] http: ${error?.message ?? error}`);
120
95
  res.destroy();
121
96
  })
@@ -145,28 +120,20 @@ export async function serveHttp(factory, env = process.env) {
145
120
  reject(error);
146
121
  }
147
122
  });
148
- // Errors after startup (for example EMFILE) must be logged, not thrown as an
149
- // unhandled 'error' event that takes the process down.
150
123
  server.on("error", logError);
151
124
  const { port: bound, address: boundAddress } = server.address();
152
- // "localhost" must actually resolve to loopback; a poisoned resolver must not
153
- // silently turn a loopback bind into a public one.
154
125
  if (onLoopback && boundAddress !== "127.0.0.1" && boundAddress !== "::1" && boundAddress !== "::ffff:127.0.0.1") {
155
126
  server.close();
156
127
  throw new Error(`HOST ${host} resolved to non-loopback ${boundAddress}; refusing to serve`);
157
128
  }
158
129
  let shuttingDown = false;
159
130
  const shutdown = () => {
160
- // A second signal means the operator is done waiting: drop the remaining
161
- // connections instead of extending the grace period.
162
131
  if (shuttingDown) {
163
132
  server.closeAllConnections();
164
133
  process.exit(1);
165
134
  }
166
135
  shuttingDown = true;
167
136
  server.close(() => process.exit(0));
168
- // server.close() closes idle sockets but waits forever for an active
169
- // request. Give in-flight work a bounded grace period, then force it down.
170
137
  const force = setTimeout(() => {
171
138
  server.closeAllConnections();
172
139
  process.exit(0);
package/dist/http.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,4EAA4E;AAC5E,OAAO,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MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,YAAY,GAAG,IAAI,CAAC;QACpB,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,CAAC,mBAAmB,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,EAAE,KAAK,CAAC,CAAC;QACV,KAAK,CAAC,KAAK,EAAE,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const MAX_IMAGES = 8;
2
+ export declare const MAX_IMAGE_BYTES: number;
3
+ export declare const MAX_TOTAL_IMAGE_BYTES: number;
4
+ export declare const MAX_IMAGE_REF_CHARS: number;
5
+ export declare class ImageInputError extends Error {
6
+ }
7
+ export interface ImageSource {
8
+ readFilePaths: boolean;
9
+ }
10
+ export declare function loadImages(refs: readonly string[] | undefined, source: ImageSource): Promise<string[]>;
package/dist/images.js ADDED
@@ -0,0 +1,80 @@
1
+ import { constants } from "node:fs";
2
+ import { open } from "node:fs/promises";
3
+ import { isAbsolute } from "node:path";
4
+ export const MAX_IMAGES = 8;
5
+ export const MAX_IMAGE_BYTES = 5 * 1024 * 1024;
6
+ export const MAX_TOTAL_IMAGE_BYTES = 20 * 1024 * 1024;
7
+ export const MAX_IMAGE_REF_CHARS = Math.ceil(MAX_IMAGE_BYTES / 3) * 4 + 64;
8
+ const MIME_TYPES = { png: "image/png", jpeg: "image/jpeg", webp: "image/webp" };
9
+ const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
10
+ const DATA_URL = /^data:(image\/(?:png|jpeg|webp));base64,([A-Za-z0-9+/]+={0,2})$/;
11
+ export class ImageInputError extends Error {
12
+ }
13
+ function formatOf(bytes) {
14
+ if (bytes.length >= PNG_SIGNATURE.length && PNG_SIGNATURE.every((byte, i) => bytes[i] === byte))
15
+ return "png";
16
+ if (bytes.length >= 3 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[2] === 0xff)
17
+ return "jpeg";
18
+ if (bytes.length >= 12 && bytes.toString("latin1", 0, 4) === "RIFF" && bytes.toString("latin1", 8, 12) === "WEBP")
19
+ return "webp";
20
+ return null;
21
+ }
22
+ function decodeDataUrl(url, index) {
23
+ const match = DATA_URL.exec(url);
24
+ if (!match)
25
+ throw new ImageInputError(`images[${index}] must be a base64 PNG, JPEG or WebP data URL`);
26
+ const bytes = Buffer.from(match[2], "base64");
27
+ const format = formatOf(bytes);
28
+ if (format === null || MIME_TYPES[format] !== match[1]) {
29
+ throw new ImageInputError(`images[${index}] does not hold the ${match[1]} image its data URL declares`);
30
+ }
31
+ return { bytes, format };
32
+ }
33
+ async function readImageFile(path, index) {
34
+ if (!isAbsolute(path))
35
+ throw new ImageInputError(`images[${index}] must be an absolute file path or a data URL`);
36
+ const handle = await open(path, constants.O_RDONLY | constants.O_NONBLOCK).catch(() => {
37
+ throw new ImageInputError(`images[${index}] could not be opened`);
38
+ });
39
+ try {
40
+ const info = await handle.stat();
41
+ if (!info.isFile())
42
+ throw new ImageInputError(`images[${index}] is not a regular file`);
43
+ if (info.size > MAX_IMAGE_BYTES)
44
+ throw tooLarge(index);
45
+ const bytes = await handle.readFile();
46
+ const format = formatOf(bytes);
47
+ if (format === null)
48
+ throw new ImageInputError(`images[${index}] is not a PNG, JPEG or WebP image`);
49
+ return { bytes, format };
50
+ }
51
+ finally {
52
+ await handle.close();
53
+ }
54
+ }
55
+ function tooLarge(index) {
56
+ return new ImageInputError(`images[${index}] is over ${MAX_IMAGE_BYTES / 1024 / 1024} MiB`);
57
+ }
58
+ export async function loadImages(refs, source) {
59
+ if (!refs?.length)
60
+ return [];
61
+ if (refs.length > MAX_IMAGES)
62
+ throw new ImageInputError(`At most ${MAX_IMAGES} images are allowed per call`);
63
+ const urls = [];
64
+ let total = 0;
65
+ for (const [index, ref] of refs.entries()) {
66
+ if (!ref.startsWith("data:") && !source.readFilePaths) {
67
+ throw new ImageInputError(`images[${index}] must be a data URL; verdict-mcp reads image files only when it runs over stdio`);
68
+ }
69
+ const { bytes, format } = ref.startsWith("data:") ? decodeDataUrl(ref, index) : await readImageFile(ref, index);
70
+ if (bytes.length > MAX_IMAGE_BYTES)
71
+ throw tooLarge(index);
72
+ total += bytes.length;
73
+ if (total > MAX_TOTAL_IMAGE_BYTES) {
74
+ throw new ImageInputError(`The images add up to over ${MAX_TOTAL_IMAGE_BYTES / 1024 / 1024} MiB`);
75
+ }
76
+ urls.push(`data:${MIME_TYPES[format]};base64,${bytes.toString("base64")}`);
77
+ }
78
+ return urls;
79
+ }
80
+ //# sourceMappingURL=images.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"images.js","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC;AAC5B,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC/C,MAAM,CAAC,M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C;QAChH,IAAI,KAAK,CAAC,MAAM,GAAG,eAAe;YAAE,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC1D,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC;QACtB,IAAI,KAAK,GAAG,qBAAqB,EAAE,CAAC;YAClC,MAAM,IAAI,eAAe,CAAC,6BAA6B,qBAAqB,GAAG,IAAI,GAAG,IAAI,MAAM,CAAC,CAAC;QACpG,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,QAAQ,UAAU,CAAC,MAAM,CAAC,WAAW,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,4 @@
1
1
  #!/usr/bin/env node
2
- // verdict-mcp CLI: boots the MCP server over stdio (default) or stateless HTTP.
3
- //
4
- // This entry is the `verdict-mcp` bin; running it starts a transport. It is NOT
5
- // the package's import entry: `exports` maps the root import to
6
- // dist/server.js, which exposes `createServer()` without booting anything,
7
- // so importing the package from another process never opens stdio or a
8
- // listener.
9
2
  import { createRequire } from "node:module";
10
3
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
11
4
  import { createServer, MODEL } from "./server.js";
@@ -43,11 +36,11 @@ else if (argv.includes("--help") || argv.includes("-h")) {
43
36
  }
44
37
  else if (argv.includes("--http") || process.env.VERDICT_MCP_TRANSPORT === "http") {
45
38
  const { serveHttp } = await import("./http.js");
46
- const { url } = await serveHttp(createServer);
39
+ const { url } = await serveHttp(() => createServer());
47
40
  console.error(`[verdict-mcp] ready — model ${MODEL}, stateless HTTP at ${url}`);
48
41
  }
49
42
  else {
50
- serveStdio(createServer);
43
+ serveStdio(() => createServer({ readImageFiles: true }));
51
44
  console.error(`[verdict-mcp] ready — model ${MODEL}`);
52
45
  }
53
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","s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ACtD,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,uBAAuB,GAAG,EAAE,CAAC,CAAC;AAClF,CAAC;KAAM,CAAC;IACN,UAAU,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;AACxD,CAAC"}
package/dist/lib.d.ts CHANGED
@@ -1,52 +1,25 @@
1
- /** Max candidates in one verdict_find call. Jev Choice supports up to 255 options. */
2
1
  export declare const MAX_CANDIDATES = 250;
3
- /** Default per-candidate text cap (characters) to keep request size bounded. */
4
2
  export declare const MAX_CANDIDATE_CHARS = 2000;
5
- export declare const PROBABILITY_SUM_TOLERANCE: number;
6
- /**
7
- * A JSON object on the wire: present, non-null, and not an array. Shared by the
8
- * transport boundary (provider payloads) and the tool boundary (the `answers`
9
- * envelope), so both agree on what counts as a record.
10
- */
11
3
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
12
- /**
13
- * Sanitize a caller-supplied id into a safe Choice option key.
14
- * Keeps alphanumerics, underscore, dash and dot; collapses the rest.
15
- */
16
4
  export declare function sanitizeId(id: string): string;
17
5
  export type Identifiable = {
18
6
  id?: string;
19
7
  [key: string]: unknown;
20
8
  };
21
- /** Ensure ids exist, are safe, and are unique; returns the id actually used per candidate. */
22
9
  export declare function ensureUniqueIds<T extends Identifiable>(items: T[], fallbackPrefix: string): {
23
10
  items: Array<T & {
24
11
  id: string;
25
12
  }>;
26
13
  renamed: Map<string, string>;
27
14
  };
28
- /** Truncate long text with an explicit marker so the model knows it is partial. */
29
15
  export declare function truncate(text: string, maxChars: number): string;
30
- /** Map a verdict_verify relation answer to a verdict label (citation-check cookbook). */
31
16
  export declare const RELATION_TO_VERDICT: Record<string, string>;
32
- /**
33
- * verdict_verify decomposition (split a judgment into questions, combine in code): besides
34
- * the relation, each claim gets "does the evidence report on this claim's own subject?". A contradiction stands only
35
- * at or above this probability; below it the evidence is about something else and says nothing about the claim.
36
- */
37
17
  export declare const DEFAULT_SUBJECT_AT = 0.5;
38
18
  export declare const SUBJECT_CRITERIA: {
39
19
  true: string;
40
20
  false: string;
41
21
  };
42
- /** Does this verdict stand on its own, or should a human confirm it? */
43
22
  export declare function verifyAction(confidence: number, autoAccept: number): "auto" | "review";
44
- /**
45
- * Screen recommendation from probabilities.
46
- * injection: probability the text contains instructions aimed at an AI agent.
47
- * relevance: probability the text is useful for the stated purpose (optional).
48
- * substance: probability the text has substantive readable content (optional).
49
- */
50
23
  export declare function screenRecommendation(input: {
51
24
  injection: number;
52
25
  relevance?: number;
@@ -57,155 +30,74 @@ export declare function screenRecommendation(input: {
57
30
  action: "pass" | "review" | "block" | "skip";
58
31
  reason: string;
59
32
  };
60
- /** Turn the exists Noul into a document-level verdict (semantic-find cookbook thresholds). */
61
33
  export declare function existsVerdict(exists: number, found?: number, absent?: number): string;
62
- /** Rank candidate ids by Choice probability, descending. Ties keep caller order. */
63
34
  export declare function rankCandidates<T extends {
64
35
  id: string;
65
36
  }>(candidates: T[], probabilities: Record<string, number>): Array<T & {
66
37
  probability: number;
67
38
  }>;
68
- /** Max classes per verdict_classify call, bounded by the Choice option limit. */
69
39
  export declare const MAX_CLASSES = 250;
70
- /** Max items per verdict_classify call; each becomes one Choice question in one request. */
71
40
  export declare const MAX_ITEMS = 64;
72
- /** Item text cap; classification works on bounded excerpts, not whole documents. */
73
41
  export declare const MAX_ITEM_CHARS = 2000;
74
- /** Winner-to-runner-up gap; a lone probability has no runner-up, so its margin is 0. */
75
42
  export declare function marginOf(probabilities: Record<string, number> | undefined | null): number;
76
- /**
77
- * Auto-accept requires BOTH a high top probability and a clear margin, per the
78
- * conservative thresholds recommended after classification spike testing.
79
- */
80
43
  export declare function classificationDecision(topProbability: number, margin: number, autoAccept: number, minimumMargin: number): "auto" | "review";
81
- /** Max candidates per verdict_decide call. */
82
44
  export declare const MAX_CANDIDATES_DECIDE = 6;
83
- /** Max requirements per verdict_decide call. */
84
45
  export declare const MAX_REQUIREMENTS = 3;
85
- /** Escape-hatch options appended to the Choice criteria so the model can decline to rank. */
86
46
  export declare const DECIDE_ESCAPE_HATCHES: Record<string, string>;
87
- /**
88
- * A requirement check contradicts the recommended candidate when it returns
89
- * "contradicted" for that candidate. Independent questions may disagree with
90
- * the recommendation; surface the disagreement, do not average it away.
91
- */
92
47
  export declare function contradictsRecommendation(checks: Array<{
93
48
  candidate: string;
94
49
  requirement: number;
95
50
  answer: string;
96
51
  }>, recommended: string): number[];
97
- /** Max candidates for verdict_rerank, bounded by the Choice option limit. */
98
52
  export declare const MAX_RERANK_CANDIDATES = 250;
99
- /** Aggregate candidate-text budget for verdict_rerank (characters, across all candidates). */
100
53
  export declare const MAX_RERANK_TOTAL_CHARS = 100000;
101
- /** Max propositions for verdict_noul (independent Noul questions). */
102
54
  export declare const MAX_PROPOSITIONS = 64;
103
- /** Max characters per verdict_noul proposition. */
104
55
  export declare const MAX_PROPOSITION_CHARS = 2000;
105
- /** Aggregate proposition plus context budget for verdict_noul (characters). */
106
56
  export declare const MAX_NOUL_TOTAL_CHARS = 150000;
107
- /** Max aspects for verdict_compare (independent per-aspect Choices). */
108
57
  export declare const MAX_COMPARE_ASPECTS = 10;
109
- /** Max fields for verdict_extract per call. */
110
58
  export declare const MAX_EXTRACT_FIELDS = 32;
111
- /** Max records per verdict_audit call, so one request stays bounded. */
112
59
  export declare const MAX_AUDIT_RECORDS = 32;
113
- /** Per-record request cap (characters) in verdict_audit; requests are instructions, not documents. */
114
60
  export declare const MAX_AUDIT_REQUEST_CHARS = 500;
115
- /** Per-record value cap (characters) in verdict_audit; values are extracted atoms, not documents. */
116
61
  export declare const MAX_AUDIT_VALUE_CHARS = 2000;
117
- /** Max regex candidates per field before the set is flagged truncated. */
118
62
  export declare const MAX_EXTRACT_CANDIDATES = 20;
119
- /** A single regex match longer than this is skipped and flagged, never silently truncated. */
120
63
  export declare const MAX_EXTRACT_CANDIDATE_CHARS = 2000;
121
- /** Aggregate candidate-preview budget for verdict_extract (characters, across all fields). */
122
64
  export declare const MAX_EXTRACT_TOTAL_CHARS = 50000;
123
- /** Hard per-field deadline for caller-supplied regex execution in a worker. */
124
65
  export declare const REGEX_TIMEOUT_MS = 1000;
125
- /** The three pairwise relations verdict_compare judges overall. */
126
66
  export declare const COMPARE_RELATIONS: Record<string, string>;
127
- /**
128
- * Per-aspect wording of the same three relations. At aspect granularity the
129
- * third outcome usually means one or both passages do not address the aspect,
130
- * so the criterion says so explicitly instead of relying on the label alone.
131
- */
132
67
  export declare const ASPECT_RELATIONS: Record<string, string>;
133
- /**
134
- * Rerank candidates by per-candidate relevance scores aligned by index,
135
- * descending. Scores are validated by the caller before this runs; the 0
136
- * fallback only guards an internal wiring mistake, never a model answer.
137
- */
138
68
  export declare function rerankByScore<T extends object>(candidates: T[], scores: number[]): Array<T & {
139
69
  relevance: number;
140
70
  }>;
141
- /** Max completion claims per verdict_gate call; each claim adds one Choice question. */
142
71
  export declare const MAX_GATE_CLAIMS = 16;
143
- /** Max evidence items per verdict_gate call, so one request stays bounded. */
144
72
  export declare const MAX_GATE_EVIDENCE_ITEMS = 16;
145
- /** Aggregate evidence budget (characters) per verdict_gate call, before per-item truncation. */
146
73
  export declare const MAX_GATE_EVIDENCE_CHARS = 200000;
147
- /** Per-document cap (characters) for request, diff, tests, and evidence texts. */
148
74
  export declare const MAX_REVIEW_DOC_CHARS = 50000;
149
- /** Max files in one per-file review (verdict_review / verdict_gate files mode). */
150
75
  export declare const MAX_REVIEW_FILES = 16;
151
- /** Combined-state budget (characters): request + tests + all file diffs for one per-file review. */
152
76
  export declare const MAX_REVIEW_FILES_TOTAL_CHARS = 200000;
153
- /** Per-file path cap (characters) in per-file review; paths are identifiers, not documents. */
154
77
  export declare const MAX_REVIEW_FILE_PATH_CHARS = 500;
155
- /** Per-claim cap (characters) in verdict_gate; claims are bounded assertions. */
156
78
  export declare const MAX_CLAIM_CHARS = 2000;
157
- /**
158
- * Tolerance for checking a score answer's reported score against its own
159
- * distribution's expected value: |score - sum(i * p_i)| must stay within
160
- * this for the answer to count. With two-decimal reporting, the score itself
161
- * can drift by 0.005 from the exact mean, and each of the three
162
- * distribution probabilities can drift by 0.005, contributing up to
163
- * 0.005 * (0 + 1 + 2) = 0.015 more, so 0.02 covers the full rounding
164
- * envelope (0.005 + 0.015); the 1e-12 mirrors PROBABILITY_SUM_TOLERANCE's
165
- * float guard. This is a validation choice of this package, not an upstream
166
- * guarantee: a conforming provider may report an exactly consistent score,
167
- * and any drift beyond this is treated as a contradictory answer.
168
- */
169
- export declare const SCORE_MEAN_TOLERANCE: number;
170
- /** Default composite floor: auto requires the weighted composite at or above this. */
171
79
  export declare const DEFAULT_COMPOSITE_FLOOR = 0.7;
172
- /**
173
- * Review rubric weights. Correctness and spec match contribute directly;
174
- * test gap and blast radius are inverted first, so a high gap or wide radius
175
- * lowers the composite.
176
- */
177
80
  export declare const REVIEW_WEIGHTS: {
178
81
  readonly correctness: 0.4;
179
82
  readonly spec_match: 0.3;
180
83
  readonly test_gap: 0.15;
181
84
  readonly blast_radius: 0.15;
182
85
  };
183
- /** The three claim verdicts verdict_gate checks, mirroring verdict_verify's evidence relation. */
184
86
  export declare const VERIFY_CLAIM_CRITERIA: Record<string, string>;
185
87
  export type PolicyAction = "auto" | "review" | "escalate";
186
88
  export type ClaimVerdict = "verified" | "contradicted" | "unsupported";
187
- /** Policy thresholds must satisfy 0 <= review_at <= auto_accept <= 1. */
188
89
  export declare function validatePolicyThresholds(autoAccept: number, reviewAt: number): void;
189
- /** Fill an omitted review_at so a lone low auto_accept cannot invert the pair. */
190
90
  export declare function resolvePolicyThresholds(autoAccept?: number, reviewAt?: number): {
191
91
  autoAccept: number;
192
92
  reviewAt: number;
193
93
  };
194
- /** Truncated input is incomplete context; it never permits auto, only stronger actions. */
195
94
  export declare function requireCompleteContext(action: PolicyAction, truncated: boolean): PolicyAction;
196
- /** Weighted 0..1 composite from 0..2 rubric scores, inverting test gap and blast radius. */
197
95
  export declare function reviewComposite(scores: {
198
96
  correctness: number;
199
97
  specMatch: number;
200
98
  testGap: number;
201
99
  blastRadius: number;
202
100
  }): number;
203
- /**
204
- * Patch-review action. Escalates when score confidence or safe_to_apply is
205
- * unknown or below review_at; auto only when safe_to_apply and min confidence
206
- * reach auto_accept and the composite clears composite_floor; otherwise review.
207
- * Unknown confidence is escalate, never a value that can satisfy a threshold.
208
- */
209
101
  export declare function reviewAction(input: {
210
102
  composite: number;
211
103
  safeToApply: number;
@@ -214,13 +106,7 @@ export declare function reviewAction(input: {
214
106
  reviewAt: number;
215
107
  compositeFloor: number;
216
108
  }): PolicyAction;
217
- /**
218
- * Per-claim action: unknown or low confidence and confident contradictions
219
- * escalate; only confident verification is auto. Unknown confidence can never
220
- * satisfy a threshold, even a zero one.
221
- */
222
109
  export declare function claimAction(verdict: ClaimVerdict, confidence: number | null, autoAccept: number, reviewAt: number): PolicyAction;
223
- /** The most severe action wins; a gate is only as strong as its weakest judgment. */
224
110
  export declare function worstAction(actions: PolicyAction[]): PolicyAction;
225
111
  export type ReviewEvidenceInput = string | {
226
112
  id?: string;
@@ -229,26 +115,18 @@ export type ReviewEvidenceInput = string | {
229
115
  id?: string;
230
116
  text: string;
231
117
  }>;
232
- /** Normalize evidence to {id,text} items with unique ids, same shape as verdict_verify. */
233
118
  export declare function normalizeEvidence(raw: ReviewEvidenceInput): Array<{
234
119
  id: string;
235
120
  text: string;
236
121
  }>;
237
- /** True when at least one evidence item carries non-whitespace text. */
238
122
  export declare function hasNonEmptyEvidence(items: Array<{
239
123
  id: string;
240
124
  text: string;
241
125
  }>): boolean;
242
- /** Regex result shape: candidate substrings plus how the universe was capped. */
243
126
  export interface RegexResult {
244
127
  candidates: string[];
245
128
  truncated: boolean;
246
129
  tooLong: number;
247
130
  error: string | null;
248
131
  }
249
- /**
250
- * Run a regex in an isolated worker so hostile patterns cannot hang the server.
251
- * An abort signal (the MCP request's cancellation) terminates the worker and
252
- * settles immediately instead of burning CPU on a request nobody awaits.
253
- */
254
132
  export declare function runRegex(document: string, pattern: string, flags: string, signal?: AbortSignal): Promise<RegexResult>;