import test from 'node:test'; import assert from 'node:assert/strict'; import { IntentClassifier } from '../src/relay/intent-classifier.js'; test('IntentClassifier — Fallback heurístico deve identificar rodadas da grill-me', async () => { const classifier = new IntentClassifier({ apiUrl: 'http://invalid-endpoint:9999', timeoutMs: 100 }); const text = ` Qual estratégia prefere para a carga? 1a) Fazer deploy com imagem local ARM64 1b) Usar Docker Hub com pull secrets tudo padrão para seguir com a recomendada. `; const result = await classifier.classify(text, 'SREOracle'); assert.equal(result.intent, 'INTENT_INTERACTIVE_GRILL_ME'); assert.equal(result.requiresHumanInput, true); assert.ok(result.options.includes('1a')); assert.ok(result.options.includes('1b')); assert.ok(result.options.includes('tudo padrão')); }); test('IntentClassifier — Fallback heurístico deve identificar Gate de Aprovação (Regra 0)', async () => { const classifier = new IntentClassifier({ apiUrl: 'http://invalid-endpoint:9999', timeoutMs: 100 }); const text = 'Gate de segurança: recurso aguardando aprovação humana para seguir com o merge do PR #42.'; const result = await classifier.classify(text, 'Builder'); assert.equal(result.intent, 'INTENT_GATE_APPROVAL'); assert.equal(result.requiresHumanInput, true); assert.ok(result.options.includes('Aprovar e Prosseguir')); }); test('IntentClassifier — Fallback heurístico deve identificar Erro Crítico (CrashLoopBackOff)', async () => { const classifier = new IntentClassifier({ apiUrl: 'http://invalid-endpoint:9999', timeoutMs: 100 }); const text = 'exec /usr/local/bin/docker-entrypoint.sh: exec format error. Pod maestri-remote em CrashLoopBackOff.'; const result = await classifier.classify(text, 'SREOracle'); assert.equal(result.intent, 'INTENT_BLOCKING_ERROR'); assert.equal(result.requiresHumanInput, false); });