@lcv-ideas-software/cross-review 4.0.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/CHANGELOG.md +2568 -0
- package/LICENSE +201 -0
- package/NOTICE +26 -0
- package/README.md +208 -0
- package/SECURITY.md +52 -0
- package/dist/scripts/api-streaming-smoke.d.ts +1 -0
- package/dist/scripts/api-streaming-smoke.js +78 -0
- package/dist/scripts/api-streaming-smoke.js.map +1 -0
- package/dist/scripts/runtime-default-smoke.d.ts +1 -0
- package/dist/scripts/runtime-default-smoke.js +88 -0
- package/dist/scripts/runtime-default-smoke.js.map +1 -0
- package/dist/scripts/runtime-smoke.d.ts +1 -0
- package/dist/scripts/runtime-smoke.js +148 -0
- package/dist/scripts/runtime-smoke.js.map +1 -0
- package/dist/scripts/smoke.d.ts +1 -0
- package/dist/scripts/smoke.js +6156 -0
- package/dist/scripts/smoke.js.map +1 -0
- package/dist/src/core/cache-manifest.d.ts +22 -0
- package/dist/src/core/cache-manifest.js +133 -0
- package/dist/src/core/cache-manifest.js.map +1 -0
- package/dist/src/core/caller-tokens.d.ts +32 -0
- package/dist/src/core/caller-tokens.js +240 -0
- package/dist/src/core/caller-tokens.js.map +1 -0
- package/dist/src/core/config.d.ts +9 -0
- package/dist/src/core/config.js +643 -0
- package/dist/src/core/config.js.map +1 -0
- package/dist/src/core/convergence.d.ts +5 -0
- package/dist/src/core/convergence.js +186 -0
- package/dist/src/core/convergence.js.map +1 -0
- package/dist/src/core/cost.d.ts +59 -0
- package/dist/src/core/cost.js +359 -0
- package/dist/src/core/cost.js.map +1 -0
- package/dist/src/core/file-config.d.ts +316 -0
- package/dist/src/core/file-config.js +490 -0
- package/dist/src/core/file-config.js.map +1 -0
- package/dist/src/core/orchestrator.d.ts +199 -0
- package/dist/src/core/orchestrator.js +3430 -0
- package/dist/src/core/orchestrator.js.map +1 -0
- package/dist/src/core/prompt-parts.d.ts +58 -0
- package/dist/src/core/prompt-parts.js +122 -0
- package/dist/src/core/prompt-parts.js.map +1 -0
- package/dist/src/core/relator-lottery.d.ts +23 -0
- package/dist/src/core/relator-lottery.js +112 -0
- package/dist/src/core/relator-lottery.js.map +1 -0
- package/dist/src/core/reports.d.ts +2 -0
- package/dist/src/core/reports.js +82 -0
- package/dist/src/core/reports.js.map +1 -0
- package/dist/src/core/session-store.d.ts +149 -0
- package/dist/src/core/session-store.js +1923 -0
- package/dist/src/core/session-store.js.map +1 -0
- package/dist/src/core/status.d.ts +61 -0
- package/dist/src/core/status.js +249 -0
- package/dist/src/core/status.js.map +1 -0
- package/dist/src/core/timeouts.d.ts +2 -0
- package/dist/src/core/timeouts.js +3 -0
- package/dist/src/core/timeouts.js.map +1 -0
- package/dist/src/core/types.d.ts +604 -0
- package/dist/src/core/types.js +36 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/dashboard/server.d.ts +2 -0
- package/dist/src/dashboard/server.js +339 -0
- package/dist/src/dashboard/server.js.map +1 -0
- package/dist/src/mcp/server.d.ts +54 -0
- package/dist/src/mcp/server.js +1584 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/observability/logger.d.ts +9 -0
- package/dist/src/observability/logger.js +24 -0
- package/dist/src/observability/logger.js.map +1 -0
- package/dist/src/peers/anthropic.d.ts +14 -0
- package/dist/src/peers/anthropic.js +290 -0
- package/dist/src/peers/anthropic.js.map +1 -0
- package/dist/src/peers/base.d.ts +72 -0
- package/dist/src/peers/base.js +416 -0
- package/dist/src/peers/base.js.map +1 -0
- package/dist/src/peers/deepseek.d.ts +12 -0
- package/dist/src/peers/deepseek.js +246 -0
- package/dist/src/peers/deepseek.js.map +1 -0
- package/dist/src/peers/errors.d.ts +2 -0
- package/dist/src/peers/errors.js +185 -0
- package/dist/src/peers/errors.js.map +1 -0
- package/dist/src/peers/gemini.d.ts +13 -0
- package/dist/src/peers/gemini.js +215 -0
- package/dist/src/peers/gemini.js.map +1 -0
- package/dist/src/peers/grok.d.ts +17 -0
- package/dist/src/peers/grok.js +346 -0
- package/dist/src/peers/grok.js.map +1 -0
- package/dist/src/peers/model-selection.d.ts +4 -0
- package/dist/src/peers/model-selection.js +260 -0
- package/dist/src/peers/model-selection.js.map +1 -0
- package/dist/src/peers/openai.d.ts +14 -0
- package/dist/src/peers/openai.js +299 -0
- package/dist/src/peers/openai.js.map +1 -0
- package/dist/src/peers/perplexity.d.ts +18 -0
- package/dist/src/peers/perplexity.js +375 -0
- package/dist/src/peers/perplexity.js.map +1 -0
- package/dist/src/peers/registry.d.ts +3 -0
- package/dist/src/peers/registry.js +77 -0
- package/dist/src/peers/registry.js.map +1 -0
- package/dist/src/peers/retry.d.ts +2 -0
- package/dist/src/peers/retry.js +36 -0
- package/dist/src/peers/retry.js.map +1 -0
- package/dist/src/peers/stub.d.ts +13 -0
- package/dist/src/peers/stub.js +344 -0
- package/dist/src/peers/stub.js.map +1 -0
- package/dist/src/peers/text.d.ts +18 -0
- package/dist/src/peers/text.js +39 -0
- package/dist/src/peers/text.js.map +1 -0
- package/dist/src/security/redact.d.ts +2 -0
- package/dist/src/security/redact.js +128 -0
- package/dist/src/security/redact.js.map +1 -0
- package/docs/api-keys.md +34 -0
- package/docs/architecture.md +118 -0
- package/docs/caching.md +135 -0
- package/docs/costs.md +40 -0
- package/docs/evidence-preflight.md +88 -0
- package/docs/github-security-baseline.md +32 -0
- package/docs/model-selection.md +105 -0
- package/docs/reports/cross-review-v2-api-capability-smoke-2026-04-30.md +354 -0
- package/docs/reports/cross-review-v2-format-recovery-findings-2026-04-28.md +223 -0
- package/docs/reports/cross-review-v2-official-provider-docs-refresh-2026-05-05.md +60 -0
- package/docs/reports/cross-review-v2-token-streaming-smoke-2026-04-30.md +119 -0
- package/package.json +88 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
import { estimateCost } from "../core/cost.js";
|
|
2
|
+
import { decisionQualityFromStatus, parsePeerStatus } from "../core/status.js";
|
|
3
|
+
import { redact } from "../security/redact.js";
|
|
4
|
+
// v2.4.0 / audit closure (P2.9): defensive cap on accumulated streaming
|
|
5
|
+
// text per peer call. Pre-v2.4.0 every adapter used `text += delta`
|
|
6
|
+
// without bound, so a hostile or buggy peer could OOM the orchestrator
|
|
7
|
+
// by emitting unbounded tokens. The cap is per-call (not per-session)
|
|
8
|
+
// and very generous — 16 MiB is roughly 4M tokens, well above any
|
|
9
|
+
// legitimate response. When the cap is exceeded the helper throws a
|
|
10
|
+
// retryable error so the retry loop can shorten the prompt instead of
|
|
11
|
+
// crashing the process.
|
|
12
|
+
export const STREAM_TEXT_MAX_BYTES = 16 * 1024 * 1024;
|
|
13
|
+
export class StreamBufferOverflowError extends Error {
|
|
14
|
+
constructor(peer, bytes) {
|
|
15
|
+
super(`${peer} streaming response exceeded ${STREAM_TEXT_MAX_BYTES} bytes (got ${bytes}); aborting to protect the orchestrator from OOM.`);
|
|
16
|
+
this.name = "StreamBufferOverflowError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// v2.4.0 cross-review R2 (codex): byte-budget pre-check BEFORE
|
|
20
|
+
// concatenation. Pre-R2 the helper computed `combined = buffer + delta`
|
|
21
|
+
// first and only THEN tested the byte length, so a hostile peer could
|
|
22
|
+
// allocate a multi-GB string before triggering the throw — the very OOM
|
|
23
|
+
// we are trying to prevent. R2 measures the buffer + delta byte counts
|
|
24
|
+
// separately (no allocation beyond the strings already in hand) and
|
|
25
|
+
// throws BEFORE the concatenation is materialized.
|
|
26
|
+
// v2.4.0 cross-review R3 (gemini): O(1) per-append byte accounting.
|
|
27
|
+
// R2 closed Codex's pre-allocation concern by measuring bytes BEFORE
|
|
28
|
+
// concatenation, but Gemini caught the resulting O(N^2) regression —
|
|
29
|
+
// `Buffer.byteLength(buffer, "utf8")` rescans the entire accumulated
|
|
30
|
+
// string on every delta, so a 16 MiB stream emitted in 100-byte chunks
|
|
31
|
+
// pays 16 MiB x 160 000 chunks ~= 2.5 TB of scanning before the cap is
|
|
32
|
+
// reached, which DoS-locks the event loop. R3 introduces a stateful
|
|
33
|
+
// `StreamBuffer` class that maintains a running byte counter — each
|
|
34
|
+
// append measures only the delta (O(deltaLength)) and increments the
|
|
35
|
+
// counter, never re-scanning the accumulated text. Adapters use the
|
|
36
|
+
// class form; the legacy free-function is kept as a stateless shim.
|
|
37
|
+
export class StreamBuffer {
|
|
38
|
+
peer;
|
|
39
|
+
buffer = "";
|
|
40
|
+
bytes = 0;
|
|
41
|
+
constructor(peer) {
|
|
42
|
+
this.peer = peer;
|
|
43
|
+
}
|
|
44
|
+
// Append a delta. Throws StreamBufferOverflowError BEFORE any
|
|
45
|
+
// concatenation if the projected size would exceed the cap.
|
|
46
|
+
// Time complexity: O(delta.length) — independent of accumulated size.
|
|
47
|
+
append(delta) {
|
|
48
|
+
if (!delta)
|
|
49
|
+
return this.buffer;
|
|
50
|
+
const deltaBytes = Buffer.byteLength(delta, "utf8");
|
|
51
|
+
const projected = this.bytes + deltaBytes;
|
|
52
|
+
if (projected > STREAM_TEXT_MAX_BYTES) {
|
|
53
|
+
throw new StreamBufferOverflowError(this.peer, projected);
|
|
54
|
+
}
|
|
55
|
+
this.buffer += delta;
|
|
56
|
+
this.bytes = projected;
|
|
57
|
+
return this.buffer;
|
|
58
|
+
}
|
|
59
|
+
text() {
|
|
60
|
+
return this.buffer;
|
|
61
|
+
}
|
|
62
|
+
byteLength() {
|
|
63
|
+
return this.bytes;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Legacy free-function shim. Stateless callers (tests, edge cases) may
|
|
67
|
+
// still use it; production adapters MUST use StreamBuffer for O(1)
|
|
68
|
+
// amortized cost.
|
|
69
|
+
export function appendStreamText(peer, buffer, delta) {
|
|
70
|
+
if (!delta)
|
|
71
|
+
return buffer;
|
|
72
|
+
const projected = Buffer.byteLength(buffer, "utf8") + Buffer.byteLength(delta, "utf8");
|
|
73
|
+
if (projected > STREAM_TEXT_MAX_BYTES) {
|
|
74
|
+
throw new StreamBufferOverflowError(peer, projected);
|
|
75
|
+
}
|
|
76
|
+
return buffer + delta;
|
|
77
|
+
}
|
|
78
|
+
// v2.6.0 (Codex+Gemini audit, 2026-05-03): coalesce streaming token
|
|
79
|
+
// deltas before emit. Empirical measurement of 253 historical sessions
|
|
80
|
+
// surfaced 96 282 of 98 664 events (97.6%) as `peer.token.delta` —
|
|
81
|
+
// dominant noise in events.ndjson. Each provider chunk used to fire a
|
|
82
|
+
// dedicated event; a single response could produce 50-200 events. We
|
|
83
|
+
// now buffer deltas and flush a coalesced delta either when the buffer
|
|
84
|
+
// crosses a char-count threshold (synchronous) OR when a setTimeout
|
|
85
|
+
// for the configured ms threshold fires (covers stream stalls — Gemini
|
|
86
|
+
// R1 catch). Total emitted chars are preserved; the difference is
|
|
87
|
+
// event granularity, not content.
|
|
88
|
+
//
|
|
89
|
+
// Verbose escape hatch: `CROSS_REVIEW_TOKEN_DELTA_VERBOSE=1` makes
|
|
90
|
+
// every chunk emit immediately (legacy v2.5.x behavior) for operators
|
|
91
|
+
// who want chunk-level observability.
|
|
92
|
+
export class TokenEventBuffer {
|
|
93
|
+
flushDelta;
|
|
94
|
+
emitCompleted;
|
|
95
|
+
charsThreshold;
|
|
96
|
+
msThreshold;
|
|
97
|
+
verbose;
|
|
98
|
+
buffered = "";
|
|
99
|
+
flushTimer = null;
|
|
100
|
+
completed = false;
|
|
101
|
+
constructor(flushDelta, emitCompleted, charsThreshold, msThreshold, verbose) {
|
|
102
|
+
this.flushDelta = flushDelta;
|
|
103
|
+
this.emitCompleted = emitCompleted;
|
|
104
|
+
this.charsThreshold = charsThreshold;
|
|
105
|
+
this.msThreshold = msThreshold;
|
|
106
|
+
this.verbose = verbose;
|
|
107
|
+
}
|
|
108
|
+
append(delta) {
|
|
109
|
+
if (!delta || this.completed)
|
|
110
|
+
return;
|
|
111
|
+
if (this.verbose) {
|
|
112
|
+
this.flushDelta(delta);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this.buffered += delta;
|
|
116
|
+
if (this.buffered.length >= this.charsThreshold) {
|
|
117
|
+
this.flushPending();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// v2.6.0 R1 fix (Gemini): setTimeout covers stream stalls. If a
|
|
121
|
+
// chunk arrives but no further chunks for `msThreshold` ms (network
|
|
122
|
+
// pause, slow LLM), the timer ensures the buffered delta still
|
|
123
|
+
// emits without waiting for `complete()` or the next chunk.
|
|
124
|
+
if (!this.flushTimer) {
|
|
125
|
+
this.flushTimer = setTimeout(() => {
|
|
126
|
+
this.flushTimer = null;
|
|
127
|
+
this.flushPending();
|
|
128
|
+
}, this.msThreshold);
|
|
129
|
+
// Don't keep the event loop alive just for this timer.
|
|
130
|
+
this.flushTimer.unref?.();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
flushPending() {
|
|
134
|
+
if (this.flushTimer) {
|
|
135
|
+
clearTimeout(this.flushTimer);
|
|
136
|
+
this.flushTimer = null;
|
|
137
|
+
}
|
|
138
|
+
if (!this.buffered)
|
|
139
|
+
return;
|
|
140
|
+
const pending = this.buffered;
|
|
141
|
+
this.buffered = "";
|
|
142
|
+
this.flushDelta(pending);
|
|
143
|
+
}
|
|
144
|
+
// v2.6.0 R1 fix (Codex): try/finally guarantees emitCompleted fires
|
|
145
|
+
// even if the final flushDelta throws. Marks completed so any
|
|
146
|
+
// late-arriving append (e.g. from a delayed event handler) is a no-op
|
|
147
|
+
// rather than re-emitting after completion.
|
|
148
|
+
complete(chars) {
|
|
149
|
+
if (this.completed)
|
|
150
|
+
return;
|
|
151
|
+
this.completed = true;
|
|
152
|
+
try {
|
|
153
|
+
this.flushPending();
|
|
154
|
+
}
|
|
155
|
+
finally {
|
|
156
|
+
this.emitCompleted(chars);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export class BasePeerAdapter {
|
|
161
|
+
config;
|
|
162
|
+
constructor(config) {
|
|
163
|
+
this.config = config;
|
|
164
|
+
}
|
|
165
|
+
modelMatches(reported) {
|
|
166
|
+
if (!reported)
|
|
167
|
+
return undefined;
|
|
168
|
+
const requestedModel = this.normalizeModelId(this.model);
|
|
169
|
+
const reportedModel = this.normalizeModelId(reported);
|
|
170
|
+
if (reportedModel === requestedModel)
|
|
171
|
+
return true;
|
|
172
|
+
// A concrete dated id of the requested base id is a match:
|
|
173
|
+
// `gpt-5.5` → `gpt-5.5-2026-04-23`.
|
|
174
|
+
if (reportedModel.startsWith(`${requestedModel}-`))
|
|
175
|
+
return true;
|
|
176
|
+
// v3.7.4: a `-latest` alias resolves provider-side to a concrete
|
|
177
|
+
// dated id that reports the model FAMILY, not the literal alias
|
|
178
|
+
// string — xAI returns `grok-4-0709` for the pinned `grok-4-latest`.
|
|
179
|
+
// That is the alias resolving, NOT a silent downgrade. Strip the
|
|
180
|
+
// `-latest` suffix to the family stem and match the reported id
|
|
181
|
+
// against the stem: `grok-4-latest` → stem `grok-4` → `grok-4-0709`
|
|
182
|
+
// matches. A genuine cross-family downgrade (e.g. `grok-3-*` for a
|
|
183
|
+
// `grok-4-latest` pin) does not start with the stem, so it is still
|
|
184
|
+
// flagged as `silent_model_downgrade` — the no-downgrade protection
|
|
185
|
+
// is preserved.
|
|
186
|
+
if (requestedModel.endsWith("-latest")) {
|
|
187
|
+
const familyStem = requestedModel.slice(0, -"-latest".length);
|
|
188
|
+
return reportedModel === familyStem || reportedModel.startsWith(`${familyStem}-`);
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
normalizeModelId(model) {
|
|
193
|
+
return model.trim().replace(/^models\//i, "");
|
|
194
|
+
}
|
|
195
|
+
shouldStreamTokens(context) {
|
|
196
|
+
return Boolean(context.stream_tokens && this.config.streaming.tokens);
|
|
197
|
+
}
|
|
198
|
+
emitTokenDelta(context, params) {
|
|
199
|
+
if (!this.shouldStreamTokens(context) || !params.delta)
|
|
200
|
+
return;
|
|
201
|
+
const data = {
|
|
202
|
+
phase: params.phase,
|
|
203
|
+
provider: this.provider,
|
|
204
|
+
model: this.model,
|
|
205
|
+
source: params.source ?? "text",
|
|
206
|
+
chars: params.delta.length,
|
|
207
|
+
};
|
|
208
|
+
if (this.config.streaming.include_text) {
|
|
209
|
+
data.delta = redact(params.delta);
|
|
210
|
+
}
|
|
211
|
+
context.emit({
|
|
212
|
+
type: "peer.token.delta",
|
|
213
|
+
session_id: context.session_id,
|
|
214
|
+
round: context.round,
|
|
215
|
+
peer: this.id,
|
|
216
|
+
message: `${this.id} streamed ${params.delta.length} chars.`,
|
|
217
|
+
data,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
emitTokenCompleted(context, params) {
|
|
221
|
+
if (!this.shouldStreamTokens(context))
|
|
222
|
+
return;
|
|
223
|
+
context.emit({
|
|
224
|
+
type: "peer.token.completed",
|
|
225
|
+
session_id: context.session_id,
|
|
226
|
+
round: context.round,
|
|
227
|
+
peer: this.id,
|
|
228
|
+
message: `${this.id} completed token streaming.`,
|
|
229
|
+
data: {
|
|
230
|
+
phase: params.phase,
|
|
231
|
+
provider: this.provider,
|
|
232
|
+
model: this.model,
|
|
233
|
+
chars: params.chars,
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// v2.6.0: build a per-call TokenEventBuffer that coalesces token
|
|
238
|
+
// deltas before emit. Each adapter call should construct the buffer
|
|
239
|
+
// once at the start of streaming, append every chunk, and call
|
|
240
|
+
// complete() at the end. The buffer respects shouldStreamTokens (no-
|
|
241
|
+
// op when streaming is disabled) and the verbose escape hatch.
|
|
242
|
+
createTokenEventBuffer(context, phase, source = "text") {
|
|
243
|
+
const flushDelta = (delta) => this.emitTokenDelta(context, { phase, delta, source });
|
|
244
|
+
const emitCompleted = (chars) => this.emitTokenCompleted(context, { phase, chars });
|
|
245
|
+
// v2.6.0 R1 (Gemini catch): renamed to charsThreshold for clarity
|
|
246
|
+
// (we measure UTF-16 code units, not UTF-8 bytes). The legacy env
|
|
247
|
+
// var name is preserved for op compatibility but read into the
|
|
248
|
+
// semantically correct field. A new alias env var is also accepted.
|
|
249
|
+
// v3.6.0 (B2, logs+sessions study): default raised 1024 -> 16384.
|
|
250
|
+
// The 169-session corpus showed token.delta events were 79.5% of all
|
|
251
|
+
// 42541 persisted events even with the operator's config.json at
|
|
252
|
+
// 4096 — session_doctor flagged this directly. A 16384 default cuts
|
|
253
|
+
// delta-event volume ~16x vs the old 1024 default (~4x vs 4096)
|
|
254
|
+
// while keeping streaming responsive. Operators who want
|
|
255
|
+
// fine-grained streaming lower it via CROSS_REVIEW_TOKEN_DELTA_CHARS_THRESHOLD.
|
|
256
|
+
const charsThreshold = Math.max(1, Number.parseInt(process.env.CROSS_REVIEW_TOKEN_DELTA_CHARS_THRESHOLD ??
|
|
257
|
+
process.env.CROSS_REVIEW_TOKEN_DELTA_BYTES_THRESHOLD ??
|
|
258
|
+
"", 10) || 16384);
|
|
259
|
+
const msThreshold = Math.max(1, Number.parseInt(process.env.CROSS_REVIEW_TOKEN_DELTA_MS_THRESHOLD ?? "", 10) || 250);
|
|
260
|
+
const verbose = process.env.CROSS_REVIEW_TOKEN_DELTA_VERBOSE === "1";
|
|
261
|
+
return new TokenEventBuffer(flushDelta, emitCompleted, charsThreshold, msThreshold, verbose);
|
|
262
|
+
}
|
|
263
|
+
resultFromText(params) {
|
|
264
|
+
const parsed = parsePeerStatus(params.text);
|
|
265
|
+
const modelMatch = this.modelMatches(params.modelReported);
|
|
266
|
+
const extra = params.extraParserWarnings ?? [];
|
|
267
|
+
const baseWarnings = [...parsed.parser_warnings, ...extra];
|
|
268
|
+
const parserWarnings = modelMatch === false
|
|
269
|
+
? [
|
|
270
|
+
...baseWarnings,
|
|
271
|
+
`reported model ${params.modelReported} did not match requested model ${this.model}`,
|
|
272
|
+
]
|
|
273
|
+
: baseWarnings;
|
|
274
|
+
return {
|
|
275
|
+
peer: this.id,
|
|
276
|
+
provider: this.provider,
|
|
277
|
+
model: this.model,
|
|
278
|
+
model_reported: params.modelReported,
|
|
279
|
+
model_match: modelMatch,
|
|
280
|
+
status: modelMatch === false ? null : parsed.status,
|
|
281
|
+
structured: parsed.structured,
|
|
282
|
+
text: params.text,
|
|
283
|
+
raw: params.raw,
|
|
284
|
+
usage: params.usage,
|
|
285
|
+
cost: estimateCost(this.config, this.id, params.usage),
|
|
286
|
+
latency_ms: Date.now() - params.started,
|
|
287
|
+
attempts: params.attempts,
|
|
288
|
+
parser_warnings: parserWarnings,
|
|
289
|
+
decision_quality: modelMatch === false ? "failed" : decisionQualityFromStatus(parsed.status, parserWarnings),
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
generationFromText(params) {
|
|
293
|
+
const modelMatch = this.modelMatches(params.modelReported);
|
|
294
|
+
const extra = params.extraParserWarnings ?? [];
|
|
295
|
+
return {
|
|
296
|
+
peer: this.id,
|
|
297
|
+
provider: this.provider,
|
|
298
|
+
model: this.model,
|
|
299
|
+
model_reported: params.modelReported,
|
|
300
|
+
model_match: modelMatch,
|
|
301
|
+
text: params.text,
|
|
302
|
+
raw: params.raw,
|
|
303
|
+
usage: params.usage,
|
|
304
|
+
cost: estimateCost(this.config, this.id, params.usage),
|
|
305
|
+
latency_ms: Date.now() - params.started,
|
|
306
|
+
attempts: params.attempts,
|
|
307
|
+
parser_warnings: extra.length > 0 ? extra : undefined,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
systemPrompt(context) {
|
|
311
|
+
return [
|
|
312
|
+
"You are a peer reviewer in cross-review.",
|
|
313
|
+
"Your job is to review the caller's work rigorously and independently.",
|
|
314
|
+
"Do not rubber-stamp. Do not invent evidence.",
|
|
315
|
+
"Unanimity is required: READY only when no blocking issue remains.",
|
|
316
|
+
`Session: ${context.session_id}`,
|
|
317
|
+
`Round: ${context.round}`,
|
|
318
|
+
"Original task:",
|
|
319
|
+
context.task,
|
|
320
|
+
].join("\n\n");
|
|
321
|
+
}
|
|
322
|
+
// v2.9.0: default judge implementation. Builds a tightly-scoped prompt
|
|
323
|
+
// that gives the LLM ONLY the ask + draft (no session history per
|
|
324
|
+
// design) and asks for a structured boolean satisfied + confidence +
|
|
325
|
+
// rationale. Routes through this.generate() so cost/usage/latency are
|
|
326
|
+
// accounted by the same FinOps path as generations. Provider adapters
|
|
327
|
+
// can override if they want to use structured-output APIs (e.g. OpenAI
|
|
328
|
+
// structured outputs, Gemini json mode) for stricter parsing.
|
|
329
|
+
async judgeEvidenceAsk(ask, draft, context) {
|
|
330
|
+
const prompt = this.buildJudgePrompt(ask, draft);
|
|
331
|
+
const generation = await this.generate(prompt, context);
|
|
332
|
+
return this.parseJudgeResponse(generation, draft.length);
|
|
333
|
+
}
|
|
334
|
+
buildJudgePrompt(ask, draft) {
|
|
335
|
+
return [
|
|
336
|
+
"# Evidence Ask Judgment",
|
|
337
|
+
"",
|
|
338
|
+
"You are a judge. The caller has revised a draft and wants to know whether the revision SATISFIES one specific evidence ask raised by a peer in a prior round.",
|
|
339
|
+
"Your job is single-question: does the draft below answer the ask?",
|
|
340
|
+
"Do NOT review the draft for other issues. Do NOT propose new asks. Do NOT rubber-stamp.",
|
|
341
|
+
"",
|
|
342
|
+
"## Ask (verbatim peer caller_request)",
|
|
343
|
+
ask,
|
|
344
|
+
"",
|
|
345
|
+
"## Draft (the proposed revised solution)",
|
|
346
|
+
draft,
|
|
347
|
+
"",
|
|
348
|
+
"## Output format (REQUIRED — JSON object, exactly these keys)",
|
|
349
|
+
'{ "satisfied": <true|false>, "confidence": "<verified|inferred|unknown>", "rationale": "<one or two sentences>" }',
|
|
350
|
+
"",
|
|
351
|
+
"Rules:",
|
|
352
|
+
'- "satisfied": true ONLY if the draft contains concrete evidence that answers the ask (file:line, grep output, diff, MD5, log line, etc.).',
|
|
353
|
+
'- "confidence": "verified" ONLY if you traced the evidence in the draft itself; "inferred" if plausible but you could not directly trace it; "unknown" if you cannot tell.',
|
|
354
|
+
"- The runtime promotes the ask to addressed only when satisfied=true AND confidence=verified. Anything else leaves the ask open.",
|
|
355
|
+
'- "rationale": brief, verbatim citation if possible (e.g. "Draft includes the literal `git diff --stat` output requested by the ask").',
|
|
356
|
+
].join("\n");
|
|
357
|
+
}
|
|
358
|
+
parseJudgeResponse(generation, draftLength) {
|
|
359
|
+
void draftLength;
|
|
360
|
+
const parserWarnings = [];
|
|
361
|
+
let satisfied = false;
|
|
362
|
+
let confidence = "unknown";
|
|
363
|
+
let rationale = "";
|
|
364
|
+
try {
|
|
365
|
+
const trimmed = generation.text.trim();
|
|
366
|
+
// Tolerate fenced ```json blocks and stray prose around the JSON.
|
|
367
|
+
const jsonStart = trimmed.indexOf("{");
|
|
368
|
+
const jsonEnd = trimmed.lastIndexOf("}");
|
|
369
|
+
if (jsonStart < 0 || jsonEnd < jsonStart) {
|
|
370
|
+
parserWarnings.push("judge_response_missing_json_object");
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
const payload = JSON.parse(trimmed.slice(jsonStart, jsonEnd + 1));
|
|
374
|
+
if (typeof payload.satisfied === "boolean") {
|
|
375
|
+
satisfied = payload.satisfied;
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
parserWarnings.push("judge_response_satisfied_not_boolean");
|
|
379
|
+
}
|
|
380
|
+
if (payload.confidence === "verified" ||
|
|
381
|
+
payload.confidence === "inferred" ||
|
|
382
|
+
payload.confidence === "unknown") {
|
|
383
|
+
confidence = payload.confidence;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
parserWarnings.push("judge_response_confidence_unrecognized");
|
|
387
|
+
}
|
|
388
|
+
if (typeof payload.rationale === "string") {
|
|
389
|
+
rationale = payload.rationale.trim().slice(0, 800);
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
parserWarnings.push("judge_response_rationale_missing");
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
catch (err) {
|
|
397
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
398
|
+
parserWarnings.push(`judge_response_parse_failed:${message}`);
|
|
399
|
+
}
|
|
400
|
+
return {
|
|
401
|
+
peer: this.id,
|
|
402
|
+
provider: this.provider,
|
|
403
|
+
model: this.model,
|
|
404
|
+
satisfied,
|
|
405
|
+
confidence,
|
|
406
|
+
rationale,
|
|
407
|
+
raw: generation.raw,
|
|
408
|
+
usage: generation.usage,
|
|
409
|
+
cost: generation.cost,
|
|
410
|
+
latency_ms: generation.latency_ms,
|
|
411
|
+
attempts: generation.attempts,
|
|
412
|
+
parser_warnings: parserWarnings,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/peers/base.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,wEAAwE;AACxE,oEAAoE;AACpE,uEAAuE;AACvE,sEAAsE;AACtE,kEAAkE;AAClE,oEAAoE;AACpE,sEAAsE;AACtE,wBAAwB;AACxB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAClD,YAAY,IAAY,EAAE,KAAa;QACrC,KAAK,CACH,GAAG,IAAI,gCAAgC,qBAAqB,eAAe,KAAK,mDAAmD,CACpI,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED,+DAA+D;AAC/D,wEAAwE;AACxE,sEAAsE;AACtE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,mDAAmD;AACnD,oEAAoE;AACpE,qEAAqE;AACrE,qEAAqE;AACrE,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,oEAAoE;AACpE,oEAAoE;AAC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eResult, PeerResult } from "../core/types.js";
|
|
2
|
+
import { BasePeerAdapter } from "./base.js";
|
|
3
|
+
export declare class DeepSeekAdapter extends BasePeerAdapter implements PeerAdapter {
|
|
4
|
+
id: PeerId;
|
|
5
|
+
provider: string;
|
|
6
|
+
model: string;
|
|
7
|
+
constructor(config: AppConfig, modelOverride?: string);
|
|
8
|
+
private client;
|
|
9
|
+
probe(): Promise<PeerProbeResult>;
|
|
10
|
+
call(prompt: string, context: PeerCallContext): Promise<PeerResult>;
|
|
11
|
+
generate(prompt: string, context: PeerCallContext): Promise<GenerationResult>;
|
|
12
|
+
}
|