trivial turn patch

This commit is contained in:
Storme-bit
2026-08-17 06:23:00 -07:00
parent 7e8aead917
commit ff1c0ab215
5 changed files with 119 additions and 19 deletions
+42
View File
@@ -0,0 +1,42 @@
// Trivial-turn guard — tests the REAL isTrivialTurn from @nexusai/shared, which
// gates whether a turn skips retrieval + entity extraction. The critical property
// is high precision: greetings/pleasantries are caught, but real short queries
// must NOT be (a false positive would suppress retrieval on a genuine question).
const { test } = require('node:test');
const assert = require('node:assert');
const { isTrivialTurn } = require('@nexusai/shared');
test('plain greetings and pleasantries are trivial', () => {
for (const m of ['good morning', 'Good morning!', 'hello', 'hey there', 'hi',
'thanks', 'thank you so much', 'bye', 'ok', 'sounds good',
'just dropping in', 'just checking in', 'cheers']) {
assert.strictEqual(isTrivialTurn(m), true, `"${m}" should be trivial`);
}
});
test('trailing filler collapses to a base greeting', () => {
assert.strictEqual(isTrivialTurn('good morning again'), true);
assert.strictEqual(isTrivialTurn('thanks everyone'), true);
assert.strictEqual(isTrivialTurn('hello there'), true);
});
test('empty or punctuation-only input is trivial', () => {
assert.strictEqual(isTrivialTurn(''), true);
assert.strictEqual(isTrivialTurn(' '), true);
assert.strictEqual(isTrivialTurn('!!!'), true);
assert.strictEqual(isTrivialTurn(null), true);
});
test('real queries are NOT trivial — even short ones (the precision guarantee)', () => {
for (const m of ['what is the capital of France', 'France capital', 'capital of France?',
'how do I configure Qdrant', 'One Piece', 'help me debug this',
'what did we decide about the schema', 'morning routine ideas']) {
assert.strictEqual(isTrivialTurn(m), false, `"${m}" should be substantive`);
}
});
test('a greeting prefix does not make a substantive message trivial', () => {
// "good morning, can you help with X" carries a real request — must not be skipped
assert.strictEqual(isTrivialTurn('good morning, can you help me with the migration'), false);
assert.strictEqual(isTrivialTurn('hey, what is the One Piece'), false);
});