const { test } = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const root = path.join(__dirname, '..'); function read(relativePath) { return fs.readFileSync(path.join(root, relativePath), 'utf8'); } test('clinical assistant starter prompts are Redis or indexed-source backed', () => { const route = read('src/routes/clinicalAssistant.js'); const pool = read('src/utils/clinicalPromptPool.js'); assert.doesNotMatch(route, /EXAMPLE_CANDIDATES|TOPIC_SUGGESTIONS|topic_suggestions|buildSuggestionAnswer/); assert.match(route, /createClinicalPromptPool\(\{[\s\S]*redisCache: redisCache/); assert.match(pool, /opts\.redisCache\.getJson\(redisKey\)/); assert.match(pool, /opts\.redisCache\.setJson\(redisKey, payload, ttlSeconds\)/); assert.match(pool, /CLINICAL_ASSISTANT_PROMPT_POOL_TARGET, 200/); assert.match(pool, /var examples = await fallbackIndexedExamples\(\)/); }); test('clinical assistant prompt forbids relabeling other sources as named sources', () => { const answer = read('src/utils/clinicalAnswer.js'); assert.match(answer, /If the user names a specific source, textbook, guideline, or table/); assert.match(answer, /do not claim that another source is from the named source/); assert.match(answer, /If the named source is absent from the retrieved sources, say that explicitly/); }); test('clinical assistant prompt requires bracketed citations in table source columns', () => { const answer = read('src/utils/clinicalAnswer.js'); assert.match(answer, /Source, Source\(s\), Citation, or Citation\(s\) column/); assert.match(answer, /must use bracketed citation tokens like \[1\] or \[1, 3\]/); assert.match(answer, /never bare numbers like 1 or 1, 3/); });