circle-ir-ai 2.35.0 → 2.37.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 +176 -0
- package/dist/cache/backend.d.ts +39 -7
- package/dist/cache/backend.d.ts.map +1 -1
- package/dist/cache/backend.js +18 -6
- package/dist/cache/backend.js.map +1 -1
- package/dist/cache/backends/index.d.ts +12 -7
- package/dist/cache/backends/index.d.ts.map +1 -1
- package/dist/cache/backends/index.js +12 -7
- package/dist/cache/backends/index.js.map +1 -1
- package/dist/cache/backends/layout.d.ts +13 -4
- package/dist/cache/backends/layout.d.ts.map +1 -1
- package/dist/cache/backends/layout.js +20 -5
- package/dist/cache/backends/layout.js.map +1 -1
- package/dist/cache/backends/local-fs.d.ts +9 -5
- package/dist/cache/backends/local-fs.d.ts.map +1 -1
- package/dist/cache/backends/local-fs.js +9 -5
- package/dist/cache/backends/local-fs.js.map +1 -1
- package/dist/cache/backends/r2.d.ts +14 -9
- package/dist/cache/backends/r2.d.ts.map +1 -1
- package/dist/cache/backends/r2.js +14 -9
- package/dist/cache/backends/r2.js.map +1 -1
- package/dist/cache/classification-cache.d.ts +22 -4
- package/dist/cache/classification-cache.d.ts.map +1 -1
- package/dist/cache/classification-cache.js +32 -4
- package/dist/cache/classification-cache.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/ax-client.d.ts +24 -0
- package/dist/llm/ax-client.d.ts.map +1 -1
- package/dist/llm/ax-client.js +25 -0
- package/dist/llm/ax-client.js.map +1 -1
- package/dist/llm/discovery.d.ts +25 -0
- package/dist/llm/discovery.d.ts.map +1 -1
- package/dist/llm/discovery.js +13 -1
- package/dist/llm/discovery.js.map +1 -1
- package/dist/llm/index.d.ts +1 -0
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +2 -0
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/llm-error-counter.d.ts +71 -0
- package/dist/llm/llm-error-counter.d.ts.map +1 -0
- package/dist/llm/llm-error-counter.js +109 -0
- package/dist/llm/llm-error-counter.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM error counter (cognium-ai#191)
|
|
3
|
+
*
|
|
4
|
+
* Process-wide singleton that tracks aggregate LLM discovery/verification
|
|
5
|
+
* failures by categorical `kind`. Populated by callers whose outer catch
|
|
6
|
+
* blocks previously swallowed transport errors into a "not vulnerable"
|
|
7
|
+
* result shape (e.g. `discovery.ts:524-531`).
|
|
8
|
+
*
|
|
9
|
+
* Two consumers:
|
|
10
|
+
*
|
|
11
|
+
* 1. Benchmark runners (`benchmarks/runners/run-cwe-bench-java.ts` +
|
|
12
|
+
* cousins) read `snapshot()` at end-of-run to decide whether to emit
|
|
13
|
+
* a "high LLM failure rate" banner. Without this, a total-outage run
|
|
14
|
+
* is indistinguishable from a real static-only baseline in the score
|
|
15
|
+
* output — which was the root cause of the identical 65/120 seen on
|
|
16
|
+
* `zai-org/glm-5.2` and `minimax/minimax-m3` in the 2026-07-02/03
|
|
17
|
+
* Novita sweeps.
|
|
18
|
+
*
|
|
19
|
+
* 2. The first `increment()` call also mirrors a single stderr warning
|
|
20
|
+
* so operators running a plain `cognium-ai scan --llm` notice the
|
|
21
|
+
* failure without needing to open the JSONL log. Subsequent calls
|
|
22
|
+
* are silent (avoids stderr flooding on a persistent outage).
|
|
23
|
+
*
|
|
24
|
+
* Categorization reuses `LLMErrorCategory` from `call-logger.ts`. Callers
|
|
25
|
+
* that don't have a categorical reason pass `'unknown'`.
|
|
26
|
+
*
|
|
27
|
+
* Related:
|
|
28
|
+
* - cognium-ai#189 (circle-ir-ai 2.36.0) — cache Round 3 model-in-path.
|
|
29
|
+
* Complementary: #189 makes cache-collision regressions loud; this
|
|
30
|
+
* module makes LLM-call failures loud.
|
|
31
|
+
* - cognium-ai#87 — per-attempt JSONL logging. Attempt-level failures
|
|
32
|
+
* still land in the log; this counter is the aggregate signal.
|
|
33
|
+
* - The existing JSONL `errorCategory` field on `kind:'call'` rows is
|
|
34
|
+
* the source-of-truth for offline analysis. This counter is a live
|
|
35
|
+
* process-local mirror sized for immediate benchmark-runner use.
|
|
36
|
+
*/
|
|
37
|
+
const ALL_KINDS = [
|
|
38
|
+
'empty_response',
|
|
39
|
+
'parse_error',
|
|
40
|
+
'timeout',
|
|
41
|
+
'http_error',
|
|
42
|
+
'rate_limited',
|
|
43
|
+
'connection_error',
|
|
44
|
+
'transient_server_error',
|
|
45
|
+
'unknown',
|
|
46
|
+
];
|
|
47
|
+
class LLMErrorCounter {
|
|
48
|
+
counts = new Map();
|
|
49
|
+
warned = false;
|
|
50
|
+
/**
|
|
51
|
+
* Record one LLM-call failure. First call also mirrors a single
|
|
52
|
+
* stderr line so operators notice a broken model config on a bare
|
|
53
|
+
* `cognium-ai scan --llm` invocation. Subsequent failures are silent.
|
|
54
|
+
*/
|
|
55
|
+
increment(kind, sampleMessage) {
|
|
56
|
+
this.counts.set(kind, (this.counts.get(kind) ?? 0) + 1);
|
|
57
|
+
if (!this.warned) {
|
|
58
|
+
this.warned = true;
|
|
59
|
+
const suffix = sampleMessage ? `: ${trim(sampleMessage)}` : '';
|
|
60
|
+
try {
|
|
61
|
+
process.stderr.write(`[llm] first discovery-stage LLM error (${kind})${suffix}\n` +
|
|
62
|
+
`[llm] subsequent errors are aggregated silently; see LLM_LOG_JSONL for per-call detail\n`);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// swallow — logging failure must not affect analysis
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Return a stable point-in-time snapshot keyed by every known kind so
|
|
71
|
+
* downstream printers can format a fixed-width breakdown without
|
|
72
|
+
* probing for undefined keys. Zero-value kinds are included.
|
|
73
|
+
*/
|
|
74
|
+
snapshot() {
|
|
75
|
+
const out = {};
|
|
76
|
+
for (const k of ALL_KINDS) {
|
|
77
|
+
out[k] = this.counts.get(k) ?? 0;
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/** Total across all kinds. Cheap; recomputed on each call. */
|
|
82
|
+
total() {
|
|
83
|
+
let sum = 0;
|
|
84
|
+
for (const n of this.counts.values())
|
|
85
|
+
sum += n;
|
|
86
|
+
return sum;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Test-only: clear counts + reset the first-warning latch. Also called
|
|
90
|
+
* by benchmark harnesses that want per-repo counters rather than a
|
|
91
|
+
* process-wide roll-up.
|
|
92
|
+
*/
|
|
93
|
+
reset() {
|
|
94
|
+
this.counts.clear();
|
|
95
|
+
this.warned = false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Process-wide singleton. Callers use this directly rather than passing
|
|
100
|
+
* the counter through discovery/verification APIs — every LLM call path
|
|
101
|
+
* currently shares one client anyway, and a live singleton matches the
|
|
102
|
+
* existing `llmCallLogger` pattern.
|
|
103
|
+
*/
|
|
104
|
+
export const llmErrorCounter = new LLMErrorCounter();
|
|
105
|
+
/** Trim a message for the first-error stderr line. */
|
|
106
|
+
function trim(s, max = 200) {
|
|
107
|
+
return s.length > max ? s.slice(0, max) + '…' : s;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=llm-error-counter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-error-counter.js","sourceRoot":"","sources":["../../src/llm/llm-error-counter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,MAAM,SAAS,GAAkC;IAC/C,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,YAAY;IACZ,cAAc;IACd,kBAAkB;IAClB,wBAAwB;IACxB,SAAS;CACV,CAAC;AAEF,MAAM,eAAe;IACX,MAAM,GAAG,IA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