fix(v2): AI_FALLBACK replaces the ACTIONABLE_NOW-with-confidence-0 lie, normalize null-like strings
Fallback (ai_disabled, ai_error, invalid_json, ai_max_candidates_cap -- any candidate the AI never actually analyzed) now produces classification 'AI_FALLBACK', an explicit technical state that is never part of the 11-class enum sent to OpenAI (the AI itself can never legitimately return it). Previously it silently claimed ACTIONABLE_NOW with confidence 0, which made unanalyzed tickets indistinguishable from genuinely confirmed ones at the classification-label level. Also normalizes blocker_type/waiting_for when the model returns the literal string "null"/"none"/"n/a"/"" instead of JSON null -- done once, in the validation layer (logic/classification.js), not scattered around the workflow. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
db7a261a10
commit
00a42db269
@@ -52,3 +52,26 @@ test('todas as classes do dominio sao aceitas', () => {
|
||||
assert.equal(result.valid, true, `classe ${classification} deveria ser valida`);
|
||||
}
|
||||
});
|
||||
|
||||
test('AI_FALLBACK nao esta no dominio de classes que a IA pode retornar', () => {
|
||||
assert.ok(!VALID_CLASSIFICATIONS.includes('AI_FALLBACK'));
|
||||
});
|
||||
|
||||
test('blocker_type/waiting_for como string "null" sao normalizados para null de verdade', () => {
|
||||
const result = validateAiClassification(validRaw({ blocker_type: 'null', waiting_for: 'None' }));
|
||||
assert.equal(result.valid, true);
|
||||
assert.equal(result.data.blocker_type, null);
|
||||
assert.equal(result.data.waiting_for, null);
|
||||
});
|
||||
|
||||
test('blocker_type/waiting_for como "n/a" ou string vazia tambem viram null', () => {
|
||||
const result = validateAiClassification(validRaw({ blocker_type: 'N/A', waiting_for: '' }));
|
||||
assert.equal(result.data.blocker_type, null);
|
||||
assert.equal(result.data.waiting_for, null);
|
||||
});
|
||||
|
||||
test('blocker_type/waiting_for com valor real nao sao afetados pela normalizacao', () => {
|
||||
const result = validateAiClassification(validRaw({ blocker_type: 'fornecedor', waiting_for: 'Patricia' }));
|
||||
assert.equal(result.data.blocker_type, 'fornecedor');
|
||||
assert.equal(result.data.waiting_for, 'Patricia');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user