@pymodel/verdict-mcp 0.0.0-stage → 0.2.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/dist/lib.d.ts ADDED
@@ -0,0 +1,254 @@
1
+ /** Max candidates in one verdict_find call. Jev Choice supports up to 255 options. */
2
+ export declare const MAX_CANDIDATES = 250;
3
+ /** Default per-candidate text cap (characters) to keep request size bounded. */
4
+ 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
+ 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
+ export declare function sanitizeId(id: string): string;
17
+ export type Identifiable = {
18
+ id?: string;
19
+ [key: string]: unknown;
20
+ };
21
+ /** Ensure ids exist, are safe, and are unique; returns the id actually used per candidate. */
22
+ export declare function ensureUniqueIds<T extends Identifiable>(items: T[], fallbackPrefix: string): {
23
+ items: Array<T & {
24
+ id: string;
25
+ }>;
26
+ renamed: Map<string, string>;
27
+ };
28
+ /** Truncate long text with an explicit marker so the model knows it is partial. */
29
+ export declare function truncate(text: string, maxChars: number): string;
30
+ /** Map a verdict_verify relation answer to a verdict label (citation-check cookbook). */
31
+ 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
+ export declare const DEFAULT_SUBJECT_AT = 0.5;
38
+ export declare const SUBJECT_CRITERIA: {
39
+ true: string;
40
+ false: string;
41
+ };
42
+ /** Does this verdict stand on its own, or should a human confirm it? */
43
+ 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
+ export declare function screenRecommendation(input: {
51
+ injection: number;
52
+ relevance?: number;
53
+ substance?: number;
54
+ blockAt: number;
55
+ reviewAt: number;
56
+ }): {
57
+ action: "pass" | "review" | "block" | "skip";
58
+ reason: string;
59
+ };
60
+ /** Turn the exists Noul into a document-level verdict (semantic-find cookbook thresholds). */
61
+ export declare function existsVerdict(exists: number, found?: number, absent?: number): string;
62
+ /** Rank candidate ids by Choice probability, descending. Ties keep caller order. */
63
+ export declare function rankCandidates<T extends {
64
+ id: string;
65
+ }>(candidates: T[], probabilities: Record<string, number>): Array<T & {
66
+ probability: number;
67
+ }>;
68
+ /** Max classes per verdict_classify call, bounded by the Choice option limit. */
69
+ export declare const MAX_CLASSES = 250;
70
+ /** Max items per verdict_classify call; each becomes one Choice question in one request. */
71
+ export declare const MAX_ITEMS = 64;
72
+ /** Item text cap; classification works on bounded excerpts, not whole documents. */
73
+ 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
+ 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
+ export declare function classificationDecision(topProbability: number, margin: number, autoAccept: number, minimumMargin: number): "auto" | "review";
81
+ /** Max candidates per verdict_decide call. */
82
+ export declare const MAX_CANDIDATES_DECIDE = 6;
83
+ /** Max requirements per verdict_decide call. */
84
+ export declare const MAX_REQUIREMENTS = 3;
85
+ /** Escape-hatch options appended to the Choice criteria so the model can decline to rank. */
86
+ 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
+ export declare function contradictsRecommendation(checks: Array<{
93
+ candidate: string;
94
+ requirement: number;
95
+ answer: string;
96
+ }>, recommended: string): number[];
97
+ /** Max candidates for verdict_rerank, bounded by the Choice option limit. */
98
+ export declare const MAX_RERANK_CANDIDATES = 250;
99
+ /** Aggregate candidate-text budget for verdict_rerank (characters, across all candidates). */
100
+ export declare const MAX_RERANK_TOTAL_CHARS = 100000;
101
+ /** Max propositions for verdict_noul (independent Noul questions). */
102
+ export declare const MAX_PROPOSITIONS = 64;
103
+ /** Max characters per verdict_noul proposition. */
104
+ export declare const MAX_PROPOSITION_CHARS = 2000;
105
+ /** Aggregate proposition plus context budget for verdict_noul (characters). */
106
+ export declare const MAX_NOUL_TOTAL_CHARS = 150000;
107
+ /** Max aspects for verdict_compare (independent per-aspect Choices). */
108
+ export declare const MAX_COMPARE_ASPECTS = 10;
109
+ /** Max fields for verdict_extract per call. */
110
+ export declare const MAX_EXTRACT_FIELDS = 32;
111
+ /** Max records per verdict_audit call, so one request stays bounded. */
112
+ export declare const MAX_AUDIT_RECORDS = 32;
113
+ /** Per-record request cap (characters) in verdict_audit; requests are instructions, not documents. */
114
+ export declare const MAX_AUDIT_REQUEST_CHARS = 500;
115
+ /** Per-record value cap (characters) in verdict_audit; values are extracted atoms, not documents. */
116
+ export declare const MAX_AUDIT_VALUE_CHARS = 2000;
117
+ /** Max regex candidates per field before the set is flagged truncated. */
118
+ export declare const MAX_EXTRACT_CANDIDATES = 20;
119
+ /** A single regex match longer than this is skipped and flagged, never silently truncated. */
120
+ export declare const MAX_EXTRACT_CANDIDATE_CHARS = 2000;
121
+ /** Aggregate candidate-preview budget for verdict_extract (characters, across all fields). */
122
+ export declare const MAX_EXTRACT_TOTAL_CHARS = 50000;
123
+ /** Hard per-field deadline for caller-supplied regex execution in a worker. */
124
+ export declare const REGEX_TIMEOUT_MS = 1000;
125
+ /** The three pairwise relations verdict_compare judges overall. */
126
+ 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
+ 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
+ export declare function rerankByScore<T extends object>(candidates: T[], scores: number[]): Array<T & {
139
+ relevance: number;
140
+ }>;
141
+ /** Max completion claims per verdict_gate call; each claim adds one Choice question. */
142
+ export declare const MAX_GATE_CLAIMS = 16;
143
+ /** Max evidence items per verdict_gate call, so one request stays bounded. */
144
+ export declare const MAX_GATE_EVIDENCE_ITEMS = 16;
145
+ /** Aggregate evidence budget (characters) per verdict_gate call, before per-item truncation. */
146
+ export declare const MAX_GATE_EVIDENCE_CHARS = 200000;
147
+ /** Per-document cap (characters) for request, diff, tests, and evidence texts. */
148
+ export declare const MAX_REVIEW_DOC_CHARS = 50000;
149
+ /** Max files in one per-file review (verdict_review / verdict_gate files mode). */
150
+ export declare const MAX_REVIEW_FILES = 16;
151
+ /** Combined-state budget (characters): request + tests + all file diffs for one per-file review. */
152
+ 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
+ export declare const MAX_REVIEW_FILE_PATH_CHARS = 500;
155
+ /** Per-claim cap (characters) in verdict_gate; claims are bounded assertions. */
156
+ 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
+ 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
+ export declare const REVIEW_WEIGHTS: {
178
+ readonly correctness: 0.4;
179
+ readonly spec_match: 0.3;
180
+ readonly test_gap: 0.15;
181
+ readonly blast_radius: 0.15;
182
+ };
183
+ /** The three claim verdicts verdict_gate checks, mirroring verdict_verify's evidence relation. */
184
+ export declare const VERIFY_CLAIM_CRITERIA: Record<string, string>;
185
+ export type PolicyAction = "auto" | "review" | "escalate";
186
+ export type ClaimVerdict = "verified" | "contradicted" | "unsupported";
187
+ /** Policy thresholds must satisfy 0 <= review_at <= auto_accept <= 1. */
188
+ 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
+ export declare function resolvePolicyThresholds(autoAccept?: number, reviewAt?: number): {
191
+ autoAccept: number;
192
+ reviewAt: number;
193
+ };
194
+ /** Truncated input is incomplete context; it never permits auto, only stronger actions. */
195
+ 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
+ export declare function reviewComposite(scores: {
198
+ correctness: number;
199
+ specMatch: number;
200
+ testGap: number;
201
+ blastRadius: number;
202
+ }): 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
+ export declare function reviewAction(input: {
210
+ composite: number;
211
+ safeToApply: number;
212
+ minConfidence: number | null;
213
+ autoAccept: number;
214
+ reviewAt: number;
215
+ compositeFloor: number;
216
+ }): 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
+ 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
+ export declare function worstAction(actions: PolicyAction[]): PolicyAction;
225
+ export type ReviewEvidenceInput = string | {
226
+ id?: string;
227
+ text: string;
228
+ } | Array<{
229
+ id?: string;
230
+ text: string;
231
+ }>;
232
+ /** Normalize evidence to {id,text} items with unique ids, same shape as verdict_verify. */
233
+ export declare function normalizeEvidence(raw: ReviewEvidenceInput): Array<{
234
+ id: string;
235
+ text: string;
236
+ }>;
237
+ /** True when at least one evidence item carries non-whitespace text. */
238
+ export declare function hasNonEmptyEvidence(items: Array<{
239
+ id: string;
240
+ text: string;
241
+ }>): boolean;
242
+ /** Regex result shape: candidate substrings plus how the universe was capped. */
243
+ export interface RegexResult {
244
+ candidates: string[];
245
+ truncated: boolean;
246
+ tooLong: number;
247
+ error: string | null;
248
+ }
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
+ export declare function runRegex(document: string, pattern: string, flags: string, signal?: AbortSignal): Promise<RegexResult>;
package/dist/lib.js ADDED
@@ -0,0 +1,384 @@
1
+ import { Worker } from "node:worker_threads";
2
+ /** Max candidates in one verdict_find call. Jev Choice supports up to 255 options. */
3
+ export const MAX_CANDIDATES = 250;
4
+ /** Default per-candidate text cap (characters) to keep request size bounded. */
5
+ export const MAX_CANDIDATE_CHARS = 2000;
6
+ // Float-safe tolerance for probability-sum checks: a mathematically exact
7
+ // 0.01 delta (e.g. a 0.99 sum) can compare greater than 0.01 in IEEE-754.
8
+ export const PROBABILITY_SUM_TOLERANCE = 0.01 + 1e-12;
9
+ /**
10
+ * A JSON object on the wire: present, non-null, and not an array. Shared by the
11
+ * transport boundary (provider payloads) and the tool boundary (the `answers`
12
+ * envelope), so both agree on what counts as a record.
13
+ */
14
+ export function isRecord(value) {
15
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16
+ }
17
+ /**
18
+ * Sanitize a caller-supplied id into a safe Choice option key.
19
+ * Keeps alphanumerics, underscore, dash and dot; collapses the rest.
20
+ */
21
+ export function sanitizeId(id) {
22
+ const cleaned = id.replace(/[^A-Za-z0-9_.-]+/g, "_").replace(/^_+|_+$/g, "");
23
+ return cleaned.length > 0 ? cleaned.slice(0, 64) : "";
24
+ }
25
+ /** Ensure ids exist, are safe, and are unique; returns the id actually used per candidate. */
26
+ export function ensureUniqueIds(items, fallbackPrefix) {
27
+ const used = new Set();
28
+ const renamed = new Map();
29
+ const out = items.map((item, i) => {
30
+ const raw = item.id ?? "";
31
+ const base = sanitizeId(raw) || `${fallbackPrefix}${i}`;
32
+ let id = base;
33
+ let n = 1;
34
+ while (used.has(id)) {
35
+ id = `${base}_${n++}`;
36
+ }
37
+ used.add(id);
38
+ if (raw && raw !== id)
39
+ renamed.set(raw, id);
40
+ return { ...item, id };
41
+ });
42
+ return { items: out, renamed };
43
+ }
44
+ /** Truncate long text with an explicit marker so the model knows it is partial. */
45
+ export function truncate(text, maxChars) {
46
+ if (text.length <= maxChars)
47
+ return text;
48
+ return text.slice(0, maxChars) + " […truncated]";
49
+ }
50
+ /** Map a verdict_verify relation answer to a verdict label (citation-check cookbook). */
51
+ export const RELATION_TO_VERDICT = {
52
+ supports: "verified",
53
+ contradicts: "contradicted",
54
+ says_nothing: "unsupported",
55
+ };
56
+ /**
57
+ * verdict_verify decomposition (split a judgment into questions, combine in code): besides
58
+ * the relation, each claim gets "does the evidence report on this claim's own subject?". A contradiction stands only
59
+ * at or above this probability; below it the evidence is about something else and says nothing about the claim.
60
+ */
61
+ export const DEFAULT_SUBJECT_AT = 0.5;
62
+ export const SUBJECT_CRITERIA = {
63
+ true: "An evidence item reports on exactly what the claim asserts (the same check, run, file, object, or number)",
64
+ false: "The evidence is silent about it, or reports only on a different check, process, run, or object",
65
+ };
66
+ /** Does this verdict stand on its own, or should a human confirm it? */
67
+ export function verifyAction(confidence, autoAccept) {
68
+ return confidence >= autoAccept ? "auto" : "review";
69
+ }
70
+ /**
71
+ * Screen recommendation from probabilities.
72
+ * injection: probability the text contains instructions aimed at an AI agent.
73
+ * relevance: probability the text is useful for the stated purpose (optional).
74
+ * substance: probability the text has substantive readable content (optional).
75
+ */
76
+ export function screenRecommendation(input) {
77
+ const { injection, relevance, substance, blockAt, reviewAt } = input;
78
+ if (injection >= blockAt)
79
+ return { action: "block", reason: `injection probability ${injection.toFixed(2)} >= block threshold ${blockAt}` };
80
+ if (injection >= reviewAt)
81
+ return { action: "review", reason: `injection probability ${injection.toFixed(2)} >= review threshold ${reviewAt}` };
82
+ if (substance !== undefined && substance < 0.3)
83
+ return { action: "skip", reason: `little substantive content (substance ${substance.toFixed(2)})` };
84
+ if (relevance !== undefined && relevance < 0.3)
85
+ return { action: "skip", reason: `not relevant to the stated purpose (relevance ${relevance.toFixed(2)})` };
86
+ return { action: "pass", reason: "no signals above thresholds" };
87
+ }
88
+ /** Turn the exists Noul into a document-level verdict (semantic-find cookbook thresholds). */
89
+ export function existsVerdict(exists, found = 0.7, absent = 0.35) {
90
+ if (exists >= found)
91
+ return "answered";
92
+ return exists < absent ? "absent" : "partial";
93
+ }
94
+ /** Rank candidate ids by Choice probability, descending. Ties keep caller order. */
95
+ export function rankCandidates(candidates, probabilities) {
96
+ return candidates
97
+ .map((candidate, index) => ({ candidate: { ...candidate, probability: probabilities[candidate.id] ?? 0 }, index }))
98
+ .sort((a, b) => b.candidate.probability - a.candidate.probability || a.index - b.index)
99
+ .map(({ candidate }) => candidate);
100
+ }
101
+ /** Max classes per verdict_classify call, bounded by the Choice option limit. */
102
+ export const MAX_CLASSES = 250;
103
+ /** Max items per verdict_classify call; each becomes one Choice question in one request. */
104
+ export const MAX_ITEMS = 64;
105
+ /** Item text cap; classification works on bounded excerpts, not whole documents. */
106
+ export const MAX_ITEM_CHARS = 2000;
107
+ /** Winner-to-runner-up gap; a lone probability has no runner-up, so its margin is 0. */
108
+ export function marginOf(probabilities) {
109
+ const ranked = Object.values(probabilities ?? {}).sort((a, b) => b - a);
110
+ if (ranked.length < 2)
111
+ return 0;
112
+ return ranked[0] - ranked[1];
113
+ }
114
+ /**
115
+ * Auto-accept requires BOTH a high top probability and a clear margin, per the
116
+ * conservative thresholds recommended after classification spike testing.
117
+ */
118
+ export function classificationDecision(topProbability, margin, autoAccept, minimumMargin) {
119
+ return topProbability >= autoAccept && margin >= minimumMargin ? "auto" : "review";
120
+ }
121
+ /** Max candidates per verdict_decide call. */
122
+ export const MAX_CANDIDATES_DECIDE = 6;
123
+ /** Max requirements per verdict_decide call. */
124
+ export const MAX_REQUIREMENTS = 3;
125
+ /** Escape-hatch options appended to the Choice criteria so the model can decline to rank. */
126
+ export const DECIDE_ESCAPE_HATCHES = {
127
+ ask_user: "A consequential user preference or requirement is missing; ask instead of inventing it",
128
+ investigate: "Gather missing technical or factual evidence before selecting a candidate",
129
+ none: "None of the supplied candidates fits the known requirements",
130
+ };
131
+ /**
132
+ * A requirement check contradicts the recommended candidate when it returns
133
+ * "contradicted" for that candidate. Independent questions may disagree with
134
+ * the recommendation; surface the disagreement, do not average it away.
135
+ */
136
+ export function contradictsRecommendation(checks, recommended) {
137
+ return checks
138
+ .filter((c) => c.candidate === recommended && c.answer === "contradicted")
139
+ .map((c) => c.requirement);
140
+ }
141
+ /** Max candidates for verdict_rerank, bounded by the Choice option limit. */
142
+ export const MAX_RERANK_CANDIDATES = 250;
143
+ /** Aggregate candidate-text budget for verdict_rerank (characters, across all candidates). */
144
+ export const MAX_RERANK_TOTAL_CHARS = 100_000;
145
+ /** Max propositions for verdict_noul (independent Noul questions). */
146
+ export const MAX_PROPOSITIONS = 64;
147
+ /** Max characters per verdict_noul proposition. */
148
+ export const MAX_PROPOSITION_CHARS = 2000;
149
+ /** Aggregate proposition plus context budget for verdict_noul (characters). */
150
+ export const MAX_NOUL_TOTAL_CHARS = 150_000;
151
+ /** Max aspects for verdict_compare (independent per-aspect Choices). */
152
+ export const MAX_COMPARE_ASPECTS = 10;
153
+ /** Max fields for verdict_extract per call. */
154
+ export const MAX_EXTRACT_FIELDS = 32;
155
+ /** Max records per verdict_audit call, so one request stays bounded. */
156
+ export const MAX_AUDIT_RECORDS = 32;
157
+ /** Per-record request cap (characters) in verdict_audit; requests are instructions, not documents. */
158
+ export const MAX_AUDIT_REQUEST_CHARS = 500;
159
+ /** Per-record value cap (characters) in verdict_audit; values are extracted atoms, not documents. */
160
+ export const MAX_AUDIT_VALUE_CHARS = 2_000;
161
+ /** Max regex candidates per field before the set is flagged truncated. */
162
+ export const MAX_EXTRACT_CANDIDATES = 20;
163
+ /** A single regex match longer than this is skipped and flagged, never silently truncated. */
164
+ export const MAX_EXTRACT_CANDIDATE_CHARS = 2_000;
165
+ /** Aggregate candidate-preview budget for verdict_extract (characters, across all fields). */
166
+ export const MAX_EXTRACT_TOTAL_CHARS = 50_000;
167
+ /** Hard per-field deadline for caller-supplied regex execution in a worker. */
168
+ export const REGEX_TIMEOUT_MS = 1_000;
169
+ /** The three pairwise relations verdict_compare judges overall. */
170
+ export const COMPARE_RELATIONS = {
171
+ same_fact: "Both passages state the same underlying fact or claim",
172
+ contradicts: "The passages state opposing facts about the same subject",
173
+ different_facts: "The passages discuss different subjects or make non-overlapping claims",
174
+ };
175
+ /**
176
+ * Per-aspect wording of the same three relations. At aspect granularity the
177
+ * third outcome usually means one or both passages do not address the aspect,
178
+ * so the criterion says so explicitly instead of relying on the label alone.
179
+ */
180
+ export const ASPECT_RELATIONS = {
181
+ same_fact: "Both passages make comparable assertions about this aspect and they agree",
182
+ contradicts: "Both passages address this aspect and their assertions conflict",
183
+ different_facts: "The passages do not both make a comparable assertion about this aspect: at least one does not address it, or their mentions do not overlap",
184
+ };
185
+ /**
186
+ * Rerank candidates by per-candidate relevance scores aligned by index,
187
+ * descending. Scores are validated by the caller before this runs; the 0
188
+ * fallback only guards an internal wiring mistake, never a model answer.
189
+ */
190
+ export function rerankByScore(candidates, scores) {
191
+ return candidates
192
+ .map((c, i) => ({ ...c, relevance: scores[i] ?? 0 }))
193
+ .sort((a, b) => b.relevance - a.relevance);
194
+ }
195
+ // ─────────────────────────────────────────────────────────────────────────────
196
+ // Patch review and completion gate (verdict_review / verdict_gate)
197
+ // Thresholds are parameters and arithmetic stays here.
198
+ // ─────────────────────────────────────────────────────────────────────────────
199
+ /** Max completion claims per verdict_gate call; each claim adds one Choice question. */
200
+ export const MAX_GATE_CLAIMS = 16;
201
+ /** Max evidence items per verdict_gate call, so one request stays bounded. */
202
+ export const MAX_GATE_EVIDENCE_ITEMS = 16;
203
+ /** Aggregate evidence budget (characters) per verdict_gate call, before per-item truncation. */
204
+ export const MAX_GATE_EVIDENCE_CHARS = 200_000;
205
+ /** Per-document cap (characters) for request, diff, tests, and evidence texts. */
206
+ export const MAX_REVIEW_DOC_CHARS = 50_000;
207
+ /** Max files in one per-file review (verdict_review / verdict_gate files mode). */
208
+ export const MAX_REVIEW_FILES = 16;
209
+ /** Combined-state budget (characters): request + tests + all file diffs for one per-file review. */
210
+ export const MAX_REVIEW_FILES_TOTAL_CHARS = 200_000;
211
+ /** Per-file path cap (characters) in per-file review; paths are identifiers, not documents. */
212
+ export const MAX_REVIEW_FILE_PATH_CHARS = 500;
213
+ /** Per-claim cap (characters) in verdict_gate; claims are bounded assertions. */
214
+ export const MAX_CLAIM_CHARS = 2_000;
215
+ /**
216
+ * Tolerance for checking a score answer's reported score against its own
217
+ * distribution's expected value: |score - sum(i * p_i)| must stay within
218
+ * this for the answer to count. With two-decimal reporting, the score itself
219
+ * can drift by 0.005 from the exact mean, and each of the three
220
+ * distribution probabilities can drift by 0.005, contributing up to
221
+ * 0.005 * (0 + 1 + 2) = 0.015 more, so 0.02 covers the full rounding
222
+ * envelope (0.005 + 0.015); the 1e-12 mirrors PROBABILITY_SUM_TOLERANCE's
223
+ * float guard. This is a validation choice of this package, not an upstream
224
+ * guarantee: a conforming provider may report an exactly consistent score,
225
+ * and any drift beyond this is treated as a contradictory answer.
226
+ */
227
+ export const SCORE_MEAN_TOLERANCE = 0.02 + 1e-12;
228
+ /** Default composite floor: auto requires the weighted composite at or above this. */
229
+ export const DEFAULT_COMPOSITE_FLOOR = 0.7;
230
+ /**
231
+ * Review rubric weights. Correctness and spec match contribute directly;
232
+ * test gap and blast radius are inverted first, so a high gap or wide radius
233
+ * lowers the composite.
234
+ */
235
+ export const REVIEW_WEIGHTS = {
236
+ correctness: 0.4,
237
+ spec_match: 0.3,
238
+ test_gap: 0.15,
239
+ blast_radius: 0.15,
240
+ };
241
+ /** The three claim verdicts verdict_gate checks, mirroring verdict_verify's evidence relation. */
242
+ export const VERIFY_CLAIM_CRITERIA = {
243
+ verified: "The evidence clearly supports the claim",
244
+ contradicted: "The evidence contradicts the claim",
245
+ unsupported: "The evidence neither supports nor contradicts the claim",
246
+ };
247
+ /** Policy thresholds must satisfy 0 <= review_at <= auto_accept <= 1. */
248
+ export function validatePolicyThresholds(autoAccept, reviewAt) {
249
+ if (!Number.isFinite(autoAccept) ||
250
+ !Number.isFinite(reviewAt) ||
251
+ autoAccept < 0 ||
252
+ autoAccept > 1 ||
253
+ reviewAt < 0 ||
254
+ reviewAt > 1 ||
255
+ reviewAt > autoAccept) {
256
+ throw new Error("Thresholds must satisfy 0 <= review_at <= auto_accept <= 1.");
257
+ }
258
+ }
259
+ /** Fill an omitted review_at so a lone low auto_accept cannot invert the pair. */
260
+ export function resolvePolicyThresholds(autoAccept = 0.8, reviewAt) {
261
+ const resolved = reviewAt ?? Math.min(0.5, autoAccept);
262
+ validatePolicyThresholds(autoAccept, resolved);
263
+ return { autoAccept, reviewAt: resolved };
264
+ }
265
+ /** Truncated input is incomplete context; it never permits auto, only stronger actions. */
266
+ export function requireCompleteContext(action, truncated) {
267
+ return truncated && action === "auto" ? "review" : action;
268
+ }
269
+ /** Weighted 0..1 composite from 0..2 rubric scores, inverting test gap and blast radius. */
270
+ export function reviewComposite(scores) {
271
+ const clamp01 = (v) => Math.min(1, Math.max(0, v));
272
+ const clamp02 = (v) => Math.min(2, Math.max(0, v));
273
+ const correctness = clamp01(clamp02(scores.correctness) / 2);
274
+ const specMatch = clamp01(clamp02(scores.specMatch) / 2);
275
+ const tests = clamp01(1 - clamp02(scores.testGap) / 2);
276
+ const blast = clamp01(1 - clamp02(scores.blastRadius) / 2);
277
+ return (REVIEW_WEIGHTS.correctness * correctness +
278
+ REVIEW_WEIGHTS.spec_match * specMatch +
279
+ REVIEW_WEIGHTS.test_gap * tests +
280
+ REVIEW_WEIGHTS.blast_radius * blast);
281
+ }
282
+ /**
283
+ * Patch-review action. Escalates when score confidence or safe_to_apply is
284
+ * unknown or below review_at; auto only when safe_to_apply and min confidence
285
+ * reach auto_accept and the composite clears composite_floor; otherwise review.
286
+ * Unknown confidence is escalate, never a value that can satisfy a threshold.
287
+ */
288
+ export function reviewAction(input) {
289
+ if (input.minConfidence === null || input.minConfidence < input.reviewAt || input.safeToApply < input.reviewAt)
290
+ return "escalate";
291
+ if (input.safeToApply >= input.autoAccept &&
292
+ input.composite >= input.compositeFloor &&
293
+ input.minConfidence >= input.autoAccept) {
294
+ return "auto";
295
+ }
296
+ return "review";
297
+ }
298
+ /**
299
+ * Per-claim action: unknown or low confidence and confident contradictions
300
+ * escalate; only confident verification is auto. Unknown confidence can never
301
+ * satisfy a threshold, even a zero one.
302
+ */
303
+ export function claimAction(verdict, confidence, autoAccept, reviewAt) {
304
+ if (confidence === null || confidence < reviewAt)
305
+ return "escalate";
306
+ if (verdict === "contradicted" && confidence >= autoAccept)
307
+ return "escalate";
308
+ return verdict === "verified" && confidence >= autoAccept ? "auto" : "review";
309
+ }
310
+ /** The most severe action wins; a gate is only as strong as its weakest judgment. */
311
+ export function worstAction(actions) {
312
+ if (actions.includes("escalate"))
313
+ return "escalate";
314
+ if (actions.includes("review"))
315
+ return "review";
316
+ return "auto";
317
+ }
318
+ /** Normalize evidence to {id,text} items with unique ids, same shape as verdict_verify. */
319
+ export function normalizeEvidence(raw) {
320
+ const items = typeof raw === "string" ? [{ id: "evidence", text: raw }] : Array.isArray(raw) ? raw : [raw];
321
+ return ensureUniqueIds(items, "evidence").items;
322
+ }
323
+ /** True when at least one evidence item carries non-whitespace text. */
324
+ export function hasNonEmptyEvidence(items) {
325
+ return items.some((item) => item.text.trim().length > 0);
326
+ }
327
+ const REGEX_WORKER_SOURCE = `
328
+ import { parentPort, workerData } from "node:worker_threads";
329
+ const { document, pattern, flags, maxCandidates, maxCandidateChars } = workerData;
330
+ try {
331
+ const re = new RegExp(pattern, flags);
332
+ const seen = new Set();
333
+ const candidates = [];
334
+ let truncated = false;
335
+ let tooLong = 0;
336
+ for (const match of document.matchAll(re)) {
337
+ const value = match[0];
338
+ if (value.length === 0 || seen.has(value)) continue;
339
+ seen.add(value);
340
+ if (value.length > maxCandidateChars) { tooLong += 1; continue; }
341
+ if (candidates.length >= maxCandidates) { truncated = true; break; }
342
+ candidates.push(value);
343
+ }
344
+ parentPort.postMessage({ candidates, truncated, tooLong });
345
+ } catch (error) {
346
+ parentPort.postMessage({ candidates: [], truncated: false, tooLong: 0, error: String(error && error.message ? error.message : error) });
347
+ }
348
+ `;
349
+ /**
350
+ * Run a regex in an isolated worker so hostile patterns cannot hang the server.
351
+ * An abort signal (the MCP request's cancellation) terminates the worker and
352
+ * settles immediately instead of burning CPU on a request nobody awaits.
353
+ */
354
+ export function runRegex(document, pattern, flags, signal) {
355
+ return new Promise((resolve) => {
356
+ let settled = false;
357
+ const worker = new Worker(REGEX_WORKER_SOURCE, {
358
+ eval: true,
359
+ workerData: { document, pattern, flags, maxCandidates: MAX_EXTRACT_CANDIDATES, maxCandidateChars: MAX_EXTRACT_CANDIDATE_CHARS },
360
+ });
361
+ const finish = (value) => {
362
+ if (settled)
363
+ return;
364
+ settled = true;
365
+ clearTimeout(timer);
366
+ signal?.removeEventListener("abort", onAbort);
367
+ void worker.terminate();
368
+ resolve(value);
369
+ };
370
+ const timer = setTimeout(() => finish({
371
+ candidates: [],
372
+ truncated: false,
373
+ tooLong: 0,
374
+ error: `regex timed out after ${REGEX_TIMEOUT_MS}ms; simplify the pattern`,
375
+ }), REGEX_TIMEOUT_MS);
376
+ const onAbort = () => finish({ candidates: [], truncated: false, tooLong: 0, error: "request aborted" });
377
+ signal?.addEventListener("abort", onAbort, { once: true });
378
+ if (signal?.aborted)
379
+ onAbort();
380
+ worker.on("message", (message) => finish({ error: null, ...message }));
381
+ worker.on("error", (error) => finish({ candidates: [], truncated: false, tooLong: 0, error: error.message }));
382
+ });
383
+ }
384
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,sFAAsF;AACtF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,0EAA0E;AAC1E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,KAAK,CAAC;AAEtD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,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