- Real bug found by code review while implementing this cycle: "Code - Reusar Classificacao em Cache" always hardcoded is_fallback: false when reconstructing a classification from memory, even when the cached classification was itself AI_FALLBACK. On a cache hit for a previously fallback-classified ticket, this would have let it skip applyFallbackPolicy's exclusion entirely (the policy checks aiClassification.is_fallback first). Fixed to derive is_fallback from the cached ai_classification value. - select-top10.node.js now carries `resolucao` (ia | cache | fallback_cap) through to the scored item, previously dropped -- needed to tell cache hits apart from real AI calls in observability. - Code - Comparar Legacy x V2 now computes the full observability summary (candidate_count, cache_hits/misses, ai_requested/success/errors, ai_fallback_count and by-reason breakdown, classification_counts, insufficient_context_count, actionable_real_count, critical_override_count, top10_count, blocked_count, coordination_count) and the data-quality review (buildDataQualityReview over INSUFFICIENT_CONTEXT tickets), both stored in the shadow_runs `summary` JSON column -- no new Data Table needed. - Removed the debug webhook entirely (Debug - Ver Painel, Data Table - Buscar Shadow Runs Recentes debug branch, Code - Montar Painel Debug, Debug - Responder) and the now-unused debug-panel.node.js driver. Workflow went from 37 to 33 nodes. Debugging goes through n8n execution data, the Data Tables, and the shadow diff instead, as requested. - Fixed glpi_base_url: was still V1's own placeholder (https://glpi.suaempresa.com.br, never a real value, not report anonymization) -- confirmed the real domain (https://glpi.gtigrupo.com.br) from the live, active GLPI x WhatsApp workflow's own GLPI API config in the same n8n instance. SQL still only ever receives it through {GLPI_BASE_URL} substitution from the Config node, never hardcoded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
// @requires fallback.js
|
|
return $input.all().map((item) => {
|
|
const data = item.json;
|
|
if (data.resolucao === 'cache' && data.memory) {
|
|
const m = data.memory;
|
|
const isFallback = m.ai_classification === 'AI_FALLBACK';
|
|
return {
|
|
json: {
|
|
...data,
|
|
aiClassification: {
|
|
classification: m.ai_classification,
|
|
actionable_today: m.ai_classification === 'ACTIONABLE_NOW' || m.ai_classification === 'UNASSIGNED_ACTIONABLE',
|
|
confidence: Number(m.ai_confidence || 0),
|
|
blocker_type: m.blocker_type || null,
|
|
waiting_for: m.waiting_for || null,
|
|
next_action: m.next_action || 'Revisar chamado',
|
|
suggested_action_type: 'technical_action',
|
|
business_risk: 'medium',
|
|
reason: m.last_ai_reason || 'Classificacao reaproveitada do cache.',
|
|
evidence: [],
|
|
// Precisa refletir de verdade o que foi cacheado -- um AI_FALLBACK cacheado
|
|
// continua sendo fallback (senao a politica de elegibilidade em cooldown.js
|
|
// nao aplicaria a exclusao/override certos numa segunda execucao com cache).
|
|
is_fallback: isFallback,
|
|
fallback_reason: isFallback ? 'cached_ai_fallback' : null,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
return { json: { ...data, aiClassification: buildFallbackClassification('ai_max_candidates_cap') } };
|
|
});
|