tewip-ai 0.63.0 → 0.65.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.
|
@@ -23,13 +23,100 @@ export function parseLlmOutput(raw) {
|
|
|
23
23
|
evidence: value.evidence.slice(0, 4).map((e) => truncate(e, 300)),
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* A verdict the run history already rules out, whatever the model says.
|
|
28
|
+
*
|
|
29
|
+
* The prompt has told the model since llm-6 that a failure which passed on another attempt of the
|
|
30
|
+
* same code cannot be a real bug or a drifted locator - both of those fail every time. Measured
|
|
31
|
+
* against 547 real labelled CI failures from WordPress/gutenberg, it does not obey: the model layer
|
|
32
|
+
* decided 87 of them and got **9 right**, and almost every miss was a flaky timing failure called
|
|
33
|
+
* REAL_BUG or LOCATOR_DRIFT at a confidence of 0.9 or higher.
|
|
34
|
+
*
|
|
35
|
+
* Telling a team to hunt a bug that is not there is the most expensive mistake this tool can make,
|
|
36
|
+
* and an instruction in a prompt is a request, not a guarantee. The same fact is checked here in
|
|
37
|
+
* code, where it holds.
|
|
38
|
+
*
|
|
39
|
+
* It refuses rather than rewrites. "This cannot be REAL_BUG" is not "this is TIMING" - ENV and
|
|
40
|
+
* TEST_DATA both survive a retry too - so the answer becomes UNKNOWN, which routes the failure to a
|
|
41
|
+
* person with the model's reasoning attached rather than replacing one guess with another.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* The most this layer may claim, until a measured run says otherwise.
|
|
45
|
+
*
|
|
46
|
+
* Below 0.5 so that it routes to a person by the rule the prompt already states: "Low confidence
|
|
47
|
+
* routes the failure to a human". See the comment at the call site for the measurement.
|
|
48
|
+
*/
|
|
49
|
+
export const LLM_CONFIDENCE_CEILING = 0.45;
|
|
50
|
+
export function contradictsHistory(category, context) {
|
|
51
|
+
if (category !== 'REAL_BUG' && category !== 'LOCATOR_DRIFT')
|
|
52
|
+
return null;
|
|
53
|
+
// A timeout is not evidence of a bug, and that is measured rather than argued.
|
|
54
|
+
//
|
|
55
|
+
// Phase 56 took 471 real labelled CI failures from WordPress/gutenberg and asked, for each signal
|
|
56
|
+
// a classifier can actually see when the test fails, how far it moves the label from its base
|
|
57
|
+
// rate. Three signals move it a long way:
|
|
58
|
+
//
|
|
59
|
+
// error says Timeout/exceeded -> TIMING 91% (37% when absent)
|
|
60
|
+
// error is an assertion -> TIMING 93% (ENV 86% when absent)
|
|
61
|
+
// error mentions a locator -> TIMING 94%
|
|
62
|
+
//
|
|
63
|
+
// and REAL_BUG sits at 3-6% in **every single bucket** - its base rate, undisturbed. Nothing in
|
|
64
|
+
// the evidence available at failure time distinguishes a real bug from flakiness. That is the
|
|
65
|
+
// whole explanation for a model layer scoring 17.8%: it reaches for the one category the evidence
|
|
66
|
+
// cannot support, and is wrong about 94% of the time when it does.
|
|
67
|
+
//
|
|
68
|
+
// So a verdict of REAL_BUG resting on nothing but a timeout is refused. Six per cent of those
|
|
69
|
+
// really are bugs, and they are not lost: the case goes to a person with the model's reasoning
|
|
70
|
+
// attached, which is what this project does with every question it cannot answer.
|
|
71
|
+
const message = context.error?.message ?? '';
|
|
72
|
+
if (category === 'REAL_BUG' && /timeout|exceeded/i.test(message)) {
|
|
73
|
+
return 'refused: the only evidence is a timeout, and across 471 labelled failures a timeout was TIMING 91% of the time and REAL_BUG 6%';
|
|
74
|
+
}
|
|
75
|
+
if (context.thisRun?.anotherAttemptPassed) {
|
|
76
|
+
return `refused: another attempt of the same code passed in this run, so the failure is not deterministic and cannot be ${category}`;
|
|
77
|
+
}
|
|
78
|
+
if (/both failed and passed|not deterministic/i.test(context.history?.pattern ?? '')) {
|
|
79
|
+
return `refused: the history says "${context.history.pattern}", so the failure is not deterministic and cannot be ${category}`;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
26
83
|
export async function llmDiagnose(context, rules, client, now = new Date()) {
|
|
27
84
|
try {
|
|
28
85
|
const raw = await client.complete({ system: SYSTEM_PROMPT, user: JSON.stringify(context), schemaName: OUTPUT_SCHEMA_NAME, schema: OUTPUT_SCHEMA });
|
|
29
86
|
const out = parseLlmOutput(raw);
|
|
87
|
+
const refused = contradictsHistory(out.category, context);
|
|
88
|
+
if (refused) {
|
|
89
|
+
return {
|
|
90
|
+
category: 'UNKNOWN',
|
|
91
|
+
confidence: 0,
|
|
92
|
+
source: 'llm',
|
|
93
|
+
model: client.model,
|
|
94
|
+
engineVersion: `${rules.engineVersion}+${PROMPT_VERSION}`,
|
|
95
|
+
diagnosedAt: now.toISOString(),
|
|
96
|
+
evidence: [
|
|
97
|
+
{ source: 'llm', message: `the model said ${out.category} (${out.confidence.toFixed(2)}): ${out.reasoning}` },
|
|
98
|
+
{ source: 'rules', message: refused },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
30
102
|
return {
|
|
31
103
|
category: out.category,
|
|
32
|
-
|
|
104
|
+
// Capped, because the number it reports is not the number it earns.
|
|
105
|
+
//
|
|
106
|
+
// Measured against 752 real labelled CI failures from WordPress/gutenberg - labels taken from
|
|
107
|
+
// what the developer actually changed to fix each one - this layer decided 90 and got 16
|
|
108
|
+
// right: **17.8%**. Seventy per cent of those failures are TIMING, so answering "TIMING" to
|
|
109
|
+
// everything would have scored about 70%. The model is four times worse than the most trivial
|
|
110
|
+
// baseline there is, and it was reporting 0.90 to 0.96 while being wrong.
|
|
111
|
+
//
|
|
112
|
+
// The rules layer, on the same data, is 98.5% and keeps its own confidence untouched.
|
|
113
|
+
//
|
|
114
|
+
// Nothing is discarded: the category and the reasoning are still reported, and a person still
|
|
115
|
+
// sees them. What changes is that no consumer downstream can mistake this for a settled
|
|
116
|
+
// answer - 0.7 is where a rule becomes actionable and 0.85 is where a fix may be attempted,
|
|
117
|
+
// and a layer at 17.8% has no business clearing either. Raise this when a measured run earns
|
|
118
|
+
// it, and not before.
|
|
119
|
+
confidence: Math.min(out.confidence, LLM_CONFIDENCE_CEILING),
|
|
33
120
|
source: 'llm',
|
|
34
121
|
model: client.model,
|
|
35
122
|
engineVersion: `${rules.engineVersion}+${PROMPT_VERSION}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tewip-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"mcpName": "io.github.hmamut39/tewip",
|
|
5
5
|
"description": "Tewip finds why each failing test failed - real bug, flaky test, environment, test data or changed selector - for any stack, from the command line, CI, or your editor.",
|
|
6
6
|
"keywords": [
|