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:
Gustavo
2026-08-24 16:49:22 -03:00
co-authored by Claude Sonnet 5
parent db7a261a10
commit 00a42db269
6 changed files with 87 additions and 11 deletions
+2 -2
View File
@@ -36,7 +36,7 @@ WITH ultima_interacao AS (
GROUP BY tu.tickets_id
), chamados_base AS (
SELECT
t.id, t.name AS titulo, t.status,
t.id, t.name AS titulo, t.content AS descricao, t.status,
CASE t.status WHEN 1 THEN 'Novo' WHEN 2 THEN 'Em atendimento' WHEN 3 THEN 'Planejado' WHEN 4 THEN 'Pendente' ELSE CONCAT('Status ', t.status) END AS status_nome,
t.date AS aberto_em, t.date_mod AS modificado_em, t.time_to_resolve AS sla_resolver_ate,
t.priority, t.urgency, t.impact,
@@ -63,7 +63,7 @@ WITH ultima_interacao AS (
AND COALESCE(c.completename, c.name, '') NOT LIKE 'INFRA%'
), chamados_ranked AS (
SELECT
id, titulo, status, status_nome, aberto_em, modificado_em, ultima_interacao_em,
id, titulo, descricao, status, status_nome, aberto_em, modificado_em, ultima_interacao_em,
dias_aberto, dias_sem_interacao, sla_resolver_ate, horas_ate_sla, sla_vencido, sla_em_risco,
priority AS prioridade, urgency AS urgencia, impact AS impacto,
entidade, categoria, tecnico_atribuido, sem_tecnico, link_glpi,